Latest News: (loading..)
scottyb

Newsletter products, HTML email

271 posts in this topic

v1.0 was developed using only one language. A couple of people have contacted me about multiple products showing up when more than one language is being used.

 

Although I had included the $language_id variable in the sql, it's apparent that it doesn't work.

 

Until I have time to fix the language issue for v1.1, a fix for multiple languages can be simply changing $language_id to the actual number used for the desired language (i.e. '1' for english etc.).

Two occurances of the variable are around lines 31, and 45 of includes/modules/newsletter/newsletter_products.php.

 

Thanks to Teun for pointing this out.

Edited by scottyb

Share this post


Link to post
Share on other sites
v1.0 was developed using only one language. A couple of people have contacted me about multiple products showing up when more than one language is being used.

 

Although I had included the $language_id variable in the sql, it's apparent that it doesn't work.

 

Until I have time to fix the language issue for v1.1, a fix for multiple languages can be simply changing $language_id to the actual number used for the desired language (i.e. '1' for english etc.).

Two occurances of the variable are around lines 31, and 45 of includes/modules/newsletter/newsletter_products.php.

 

There was also a change neaded around line 112 of includes/modules/newsletter/newsletter_products.php. to prevent the module selecting 2 pictures/texts for each product in my bilingual shop.

change:

 

$images_query = tep_db_query("select p.products_id, pd.products_name, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and p.products_id in(" . $this->products . ")");

}

 

to:

 

$images_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '1' and pd.products_id = p.products_id and p.products_id in(" . $this->products . ")");

}

 

Where '1' is the number for the desired language. It now works perfectly for me.

Share this post


Link to post
Share on other sites

Hi scottyb,

 

what am i doing wrong?

 

1) I altered newsletter in database

2) I copied the 2 files

admin/includes/languages/english/modules/newsletters/newsletter_products.php

and

admin/includes/modules/newsletters/newsletter_products.php

and changed the other files following your advises.

3) I created "templates" under admin/ and chmod it to 777

4) I created my own html-template, very simple, just with a little text followed by $html_content

5) I opened the newsletter administration tool, chose 2 articles, browsed to my template file and saved the newsletter.

6) however, what I get is an empty mail with only mail subject.

 

anything i forgot?

 

thanx for more information.

 

Jerome

Share this post


Link to post
Share on other sites
Hi scottyb,

 

what am i doing wrong?

 

 

... bit dump, i forgot to select "newsletter_products" as Module...

Now I get few errors, but i think i'll resolve it soon..

 

Thanx anyway

Jerome

Share this post


Link to post
Share on other sites
... bit dump, i forgot to select "newsletter_products" as Module...

Now I get few errors, but i think i'll resolve it soon..

 

Thanx anyway

Jerome

 

Did you resolve the other errors? Were they related to this contribution? If so post them so we can troubleshoot this contribution.

Share this post


Link to post
Share on other sites

Ok scottyb,

First of all, thanks for the quick reply.

 

I played around with my newsletter templates for a very long time, and I did get the module to work, which I couldn't before. But I still would like to have more control of how the products display. For instance, the products lay out in a horizontal row (I have only two test products), how do I get them to lay vertical?

 

Sending Emails. Yes, the screen lets me know the correct number of newsletters to send out, than I press send. Once I press send I see the Animated GIF that says "Please wait .. sending emails .. Please do not interrupt this process!" and than in red it reads "Finished sending emails!" But when I check my test account, no email ever comes. I don't know anything about changing the function for sending an html email. How do I go about doing this?

Share this post


Link to post
Share on other sites
Ok scottyb,

  First of all, thanks for the quick reply.

 

  I played around with my newsletter templates for a very long time, and I did get the module to work, which I couldn't before.  But I still would like to have more control of how the products display.  For instance, the products lay out in a horizontal row (I have only two test products), how do I get them to lay vertical?

 

  Sending Emails.  Yes, the screen lets me know the correct number of newsletters to send out, than I press send.  Once I press send I see the Animated GIF that says "Please wait .. sending emails ..  Please do not interrupt this process!" and than in red it reads "Finished sending emails!"  But when I check my test account, no email ever comes.  I don't know anything about changing the function for sending an html email.  How do I go about doing this?

 

Around line 107 of includes/modules/newsletters/newsletter_products.php you'll see:

 

define('COLS', 2);

 

Change the 2 to a 1 and you've got a vertical column.

 

It's tought to say why your emails aren't being sent out yet. Do you have send HTML emails enabled in your admin? If that's not the case, make sure that your $mail_query is retreiving customers on line 169 of includes/modules/newsletters/newsletter_products.php.

 

You can use:

var_dump($mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title));

to see what is happening with the actual email line.

 

Hope this helps

Share this post


Link to post
Share on other sites

I have a bigger problem than first thought. I can't send ANY emails from any section of my admin. Apparently I never have, i.e. product notifications, new customer emails or the send mail option in admin.

 

Can you point me in the right direction on how to fix this?

 

Do I have to have certain mailing rights from my web host? Can I download software to use with my site? What?

 

I'm at the point where I would like to launch my website and I can't be fully functional without the email working.

 

Thanks in advance.

Share this post


Link to post
Share on other sites
I have a bigger problem than first thought.  I  can't send ANY emails from any section of my admin.  Apparently I never have, i.e. product notifications, new customer emails or the send mail option in admin.

 

Can you point me in the right direction on how to fix this?

 

Do I have to have certain mailing rights from my web host?  Can I download software to use with my site?  What?

 

I'm at the point where I would like to launch my website and I can't be fully functional without the email working.

 

Thanks in advance.

 

Not enough info there to point you in the right direction. Send emails set to true in the admin?

Share this post


Link to post
Share on other sites
Not enough info there to point you in the right direction.  Send emails set to true in the admin?

 

 

I believe the problem with NO EMAILS is my web host. I must have some kind of restrictions. I will reply here when I find out...

Share this post


Link to post
Share on other sites

Hi Scott,

 

I have installed this contrib and I can send the email but as someone previous said the email is blank with just the subject line. I have set 'Use MIME HTML When Sending Emails' to true and also I have the correct module selected for the newsletter_products.

 

After the email has been sent I get the following errors on the page with the animated brief case.

 

Warning: Missing argument 3 for newsletter_products() in /home/mobiacc/public_html/admin/includes/modules/newsletters/newsletter_products.php on line 16

 

Warning: Missing argument 4 for newsletter_products() in /home/mobiacc/public_html/admin/includes/modules/newsletters/newsletter_products.php on line 16

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mobiacc/public_html/admin/includes/functions/database.php on line 99

 

Line 16 is this

 

	function newsletter_products($title, $content, $products, $template) {

 

As for the database.php error I am presuming the errors above are causing this and there is no problem with that file.

 

Also when I created the newsletter, lock it and then try to edit the newsletter I get these errors

 

Warning: reset(): Passed variable is not an array or object in /home/mobiacc/public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home/mobiacc/public_html/admin/includes/classes/object_info.php on line 18

 

The basic templates I created for the test newsletter is this

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
$html_content
</body>
</html>

 

Any help on sorting out these problems would be appreciated as I think this contrib has so much scope. :thumbsup:

 

Thanks

 

Mark

Edited by mark27uk3

Share this post


Link to post
Share on other sites

Mark,

 

It looks like the problem is that somewhere along the line, the module is not saving the products and template to the db. When you preview the newsletter before you send it, you should see the newsletter displayed on the screen.

 

Around line 279: $module = new newsletter_products($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template);

 

Basically, the 3 & 4 parameter error is telling you that $nInfo->products and $nInfo->template are not being passed to the module.

 

It looks like the root of you problem comes from this error when trying to save the products:

 

QUOTE

Warning: reset(): Passed variable is not an array or object in /home/mobiacc/public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home/mobiacc/public_html/admin/includes/classes/object_info.php on line 18

 

Double check to make sure that the product values and template are being saved to the db. Your template is fine, the email was blank because of the missing argument failures.

 

Hope this helps, I've been to busy to make any updates to this module, but hopefully it's helping some people out.

 

Scott

Share this post


Link to post
Share on other sites

Hi Scott,

 

Thanks for the reply.

 

All fields in the database are populated except for the content field.

 

Does this mean anything to you?

 

Mark

Share this post


Link to post
Share on other sites
Hi Scott,

 

Thanks for the reply.

 

All fields in the database are populated except for the content field.

 

Does this mean anything to you?

 

Mark

 

So then it looks like it isn't putting the information into the object_info class.

 

Do you have this around line 163?

 

$parameters = array('title' => '',

'content' => '',

'module' => '',

'products' => '',

'template' => '');

 

Have you tried it with some content? I'm pretty sure I tested it without a message, but give that a whirl.

Share this post


Link to post
Share on other sites

Hi Scott,

 

Dont ask me wot I did but it now works - sweet!

 

The next task for me to do is add the price, special price and a short description of the product.

 

I am also going to change the table layout so that the product image is on the left and the product name and price etc is on the right of the image.

 

Any pointers or tips would be welcomed.

 

Thanks

 

Mark

Share this post


Link to post
Share on other sites
Hi Scott,

 

Dont ask me wot I did but it now works - sweet!

 

The next task for me to do is add the price, special price and a short description of the product.

 

I am also going to change the table layout so that the product image is on the left and the product name and price etc is on the right of the image.

 

Any pointers or tips would be welcomed.

 

Thanks

 

Mark

 

Good to hear. The whole point of this contribution is to be bare bones. Making it this way makes it easier to add other stuff. Check out specials queries in osc, find out what the sql is, then add it to includes/modules/newsletter/newsletter_products.php right near the top. That way, if a product is already on sale, you don't have to replicate the sale within this contribution.

Share this post


Link to post
Share on other sites
Good to hear. The whole point of this contribution is to be bare bones. Making it this way makes it easier to add other stuff. Check out specials queries in osc, find out what the sql is, then add it to includes/modules/newsletter/newsletter_products.php right near the top. That way, if a product is already on sale, you don't have to replicate the sale within this contribution.

 

scottyb - I think this is a fantastic contribution that seems to get less attention that it deserves. This module makes it easy for a shop to send newsletters to their customer base without the need for a graphic/web designer which is great.

To add extra value to the recipient I have added the product name, short product info, and (net) price to the message, however attempting to add tax and currency has been fruitless so far with this error:

 

Fatal error: Call to a member function on a non-object in ../admin/includes/modules/newsletters/newsletter_products.php

 

Any ideas?

Share this post


Link to post
Share on other sites
scottyb - I think this is a fantastic contribution that seems to get less attention that it deserves. This module makes it easy for a shop to send newsletters to their customer base without the need for a graphic/web designer which is great.

To add extra value to the recipient I have added the product name, short product info, and (net) price to the message, however attempting to add tax and currency has been fruitless so far with this error:

 

Fatal error: Call to a member function on a non-object in ../admin/includes/modules/newsletters/newsletter_products.php

 

Any ideas?

 

Thanks superstyling! If I ever get some time I'm going to come out with v2.0 that will fix a couple of issues that others and myself have spotted.

 

Without knowing what you have tried so far, you should be using the currencies class which is called in application_top.php. So it would be something like $currencies->display_price($price_value, $tax_value, $quantity); to get the price w/tax. All of those variables are something that should happen from within the newsletters.php file (quantity defaults to 1 if not supplied). The error noted above would make it seem like you are trying to use something that has not actually been defined within the currencies class?

Share this post


Link to post
Share on other sites

Hi scottyb,

 

Do me a favour and have a look at this bit of code I have put in my newsletter_products module

 

<td class="main">' . tep_flatten_product_description($images['products_description']) . '<br>'<a href=" . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . "&products_id=" . $bundle_data['products_id'])) .>" . tep_image_button('button_details.gif', IMAGE_BUTTON_DETAILS) . "</a></td></tr>';

 

I am getting Parse error: parse error, unexpected T_STRING and can not see for the life of me where the problem is.

 

I am adding loads of the things to this great contrib like short description of products, price, specials price etc etc and my eyes are starting to go googly right about now lol

 

Thanks

 

Mark

Share this post


Link to post
Share on other sites
Hi scottyb,

 

Do me a favour and have a look at this bit of code I have put in my newsletter_products module

 

<td class="main">' . tep_flatten_product_description($images['products_description']) . '<br>'<a href=" . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . "&products_id=" . $bundle_data['products_id'])) .>" . tep_image_button('button_details.gif', IMAGE_BUTTON_DETAILS) . "</a></td></tr>';

 

I am getting Parse error: parse error, unexpected T_STRING and can not see for the life of me where the problem is.

 

I am adding loads of the things to this great contrib like short description of products, price, specials price etc etc and my eyes are starting to go googly right about now lol

 

Thanks

 

Mark

 

you have an extra ' after the <br>

Share this post


Link to post
Share on other sites
Thanks superstyling! If I ever get some time I'm going to come out with v2.0 that will fix a couple of issues that others and myself have spotted.

 

Without knowing what you have tried so far, you should be using the currencies class which is called in application_top.php. So it would be something like $currencies->display_price($price_value, $tax_value, $quantity); to get the price w/tax. All of those variables are something that should happen from within the newsletters.php file (quantity defaults to 1 if not supplied). The error noted above would make it seem like you are trying to use something that has not actually been defined within the currencies class?

 

Thanks for you reply scottyb - I was trying to use $currencies->display_price($price_value, $tax_value, $quantity); in the module. You say these variables should happen from within the newsletter.php file, and I am unsure how/where to go.

I have not edited the newsletter.php file. What I have done to the $images_query in the newsletter_products.php file is simple as below:

 

	function html_content() {
	//create HTML string containing links & pics
	define('COLS', 1);
	$width = intval(25/COLS);
	$html_content = '<table border="0" width="100%" height="100%" cellpadding="2" cellspacing="3"><tr><td colspan="2" align="left" class="content">' . $this->content . '</td></tr><tr><td colspan="2">' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td></tr><tr>';
	$col = 0;
	if ($this->products != ''){
	$images_query = tep_db_query("select p.products_id, pd.products_name, pd.products_intro, pd.products_description, p.products_price, p.products_tax_class_id, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and p.products_id in(" . $this->products . ")");

}
	while($images = tep_db_fetch_array($images_query)){
		if($col > COLS-1){
			$html_content .= '</tr><tr><td class="content" align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $images['products_id']) . '"  class="content">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $images['products_image'], $images['products_name'], LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></td>
<td valign="top"><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>' . $images['products_name'] . '</b></font><br><font size="3" color="#663366" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">' . $images['products_intro'] . '</font><br><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">' . $images['products_description'] . $images['products_price'] . '<font></td>';
			$col = 0;
		}else{
			$html_content .= '<td class="content" align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $images['products_id']) . '"  class="content">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $images['products_image'], $images['products_name'], LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></td>
<td valign="top"><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>' . $images['products_name'] . '</b></font><br><font size="3" color="#663366" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">' . $images['products_intro'] . '</font><br><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">' . $images['products_description'] . $images['products_price'] . '<font></td>';
		}
		$col++;
	}
	$html_content .= '</tr></table>';

 

Mark, you mentioned adding specials price - if you have this sorted, perhaps you can help out with that?

Share this post


Link to post
Share on other sites

Hi,

 

I seem to be struggling a bit with getting the price to display, every time I try to use $currencies->display_price I get an undefined function error.

 

The only way I can get the price to display is this way

 

' . $images['products_price'] . '

 

Obviously this price is not formatted correctly and ends up looking like ?49.0000.

 

superstyling have you managed to get the price to display correctly?

 

Thanks

 

Mark

Share this post


Link to post
Share on other sites
Hi,

 

I seem to be struggling a bit with getting the price to display, every time I try to use $currencies->display_price I get an undefined function error.

 

The only way I can get the price to display is this way

 

' . $images['products_price'] . '

 

Obviously this price is not formatted correctly and ends up looking like ?49.0000.

 

superstyling have you managed to get the price to display correctly?

 

Thanks

 

Mark

 

Mark - I have the same issue. The only way I got to 2 decimal places was by aletering the database:

 

ALTER TABLE `products` CHANGE `products_price` `products_price` DECIMAL( 15, 2 ) DEFAULT '0.00' NOT NULL

 

but this does not help when adding tax (say 17.5%) an alternate way to the currencies class:

. $images['products_price']*1.175 .

and anyway, it may have an unwanted effect on other parts of OSC.

 

scottb mentioned using something like $currencies->display_price($price_value, $tax_value, $quantity); to get the price w/tax and that all of those variables are something that should happen from within the newsletters.php file. If we can get this to work, you will have 2 decimal places -- need some help though.

Share this post


Link to post
Share on other sites

Whoa, that's what I get when I try to reply in the am before coffee.

 

So when I said that whole $currencies->display_price($price_value, $tax_value, $quantity); thing I was looking at the application_top.php from the catalog, not the admin.

 

Anyways, in order to use this, you're going to need to add

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

to the top of your newsletters.php file. Then add the $currencies->display_price($images['products_price'], $images['products_tax']).

 

That should work (without having to alter your DB).

Edited by scottyb

Share this post


Link to post
Share on other sites

Hi Scott,

 

Sorry to be such a pain the butt with such a relatively simple thing but I still get

 

Fatal error: Call to a member function on a non-object

 

when adding what you said above.

 

Mark

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now