Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Newsletter products, HTML email


scottyb

Recommended Posts

Hi scottyb,

 

 

I have this contribution working, but only for the table "newsletter". I have another table "maillist" where all the visitors

can subscribe to the newsletter.

The problem is that only who are subscribed from the table newsletter is receiving my newsletters. Where can I change the code to allow ALL the subscriber to receive it?

The structure is as follow:

maillist table with 4 column:

customers_firstname varchar(20)

customers_lastname varchar(20)

customers_email_address varchar(40)

customers_newsletter char(2)

 

primary key: customers_email_address

 

 

Thank you

Link to comment
Share on other sites

  • Replies 268
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

The easiest way to do this would be just to add a second query to send() function. That's where the recipients are selected. Either add the result to the $mail_query result, or just make another loop specifically for the maillist.

 

Sorry, i cannot EDIT my Post..and i don't understand why..

Just to correct the previous Post:

Where I wrote "table newsletter" I meant "table customers".

Thank you

Link to comment
Share on other sites

The easiest way to do this would be just to add a second query to send() function. That's where the recipients are selected. Either add the result to the $mail_query result, or just make another loop specifically for the maillist.

 

Thanks Scottyb!

I did change the code but the results was not what i expected. I can send the newsletter to ALL but the body message is empty.

Here is my code:

 

<?php

/*

$Id: newsletter_products.php,v 1.0 2005/07/29 scottyb Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

//newsletter products

*/

 

class newsletter_products {

 

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

$this->title = $title;

$this->content = $content;

$this->products = $products;

$this->template = $template;

}

 

function choose_products() {

global $HTTP_GET_VARS, $languages_id;

 

if($HTTP_GET_VARS['nID']){

$newsletter_products_query = tep_db_query("select products from " . TABLE_NEWSLETTERS . " where newsletters_id ='" . $HTTP_GET_VARS['nID'] . "'");

$newsletter_products_string = tep_db_result($newsletter_products_query, 0, $newsletter_products_query['products']);

}

 

$current_products_query = "select pd.products_id, pd.products_name, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '" . $languages_id . "' and pd.products_id = p.products_id and p.products_status = '1'";

if($newsletter_products_string) $current_products_query .= " and pd.products_id in(" . $newsletter_products_string . ")";

$current_products_query .= " order by pd.products_name";

 

$current_products_array = array();

$current_products_query = tep_db_query($current_products_query);

 

if($newsletter_products_string){

while ($current_products = tep_db_fetch_array($current_products_query)){

$current_products_array[] = array('id' => $current_products['products_id'],

'text' => $current_products['products_name'] . ' - ' . $current_products['products_model']);

}

}

 

$products_query = "select pd.products_id, pd.products_name, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '" . $languages_id . "' and pd.products_id = p.products_id and p.products_status = '1'";

if($newsletter_products_string) $products_query .= " and pd.products_id not in(" . $newsletter_products_string . ")";

$products_query .= " order by pd.products_name";

 

$products_array = array();

$products_query = tep_db_query($products_query);

 

while ($products = tep_db_fetch_array($products_query)) {

$products_array[] = array('id' => $products['products_id'],

'text' => $products['products_name'] . ' - ' . $products['products_model']);

}

 

$choose_products_string = '<script language="javascript"><!--

function mover(move) {

if (move == \'remove\') {

for (x=0; x<(document.newsletter.products.length); x++) {

if (document.newsletter.products.options[x].selected) {

with(document.newsletter.elements[\'chosen[]\']) {

options[options.length] = new Option(document.newsletter.products.options[x].text,document.newsletter.products

.options[x].value);

}

document.newsletter.products.options[x] = null;

x = -1;

}

}

}

if (move == \'add\') {

for (x=0; x<(document.newsletter.elements[\'chosen[]\'].length); x++) {

if (document.newsletter.elements[\'chosen[]\'].options[x].selected) {

with(document.newsletter.products) {

options[options.length] = new Option(document.newsletter.elements[\'chosen[]\'].options[x].text,document.newsletter.elements[\'chosen[]\'].options[x].value);

}

document.newsletter.elements[\'chosen[]\'].options[x] = null;

x = -1;

}

}

}

return true;

}

 

function selectAll(FormName, SelectBox) {

temp = "document." + FormName + ".elements[\'" + SelectBox + "\']";

Source = eval(temp);

 

for (x=0; x<(Source.length); x++) {

Source.options[x].selected = "true";

}

}

//--></script>';

 

$choose_products_string .= '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n" .

' <tr>' . "\n" .

' <td align="center" class="main"><b>' . TEXT_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('products', $products_array, '', 'size="20" style="width: 32em;" multiple') . '</td>' . "\n" .

' <td align="center" class="main"> <br><br><input type="button" value="' . BUTTON_SELECT . '" style="width: 8em;" onClick="mover(\'remove\');"><br><br><input type="button" value="' . BUTTON_UNSELECT . '" style="width: 8em;" onClick="mover(\'add\');"></td>' . "\n" .

' <td align="center" class="main"><b>' . TEXT_SELECTED_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('chosen[]', $current_products_array, '', 'size="20" style="width: 25em;" multiple') . '</td>' . "\n" .

' </tr>' . "\n" .

'</table>';

 

return $choose_products_string;

}

 

function html_content() {

//create HTML string containing links & pics

define('COLS', 2);

$width = intval(100/COLS);

$html_content = '<table border="0" width="100%" height="100%" cellpadding="2" cellspacing="3"><tr><td colspan="' . COLS . '" align="center" 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, 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'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></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'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '</a></td>';

}

$col++;

}

$html_content .= '</tr></table>';

 

if(tep_not_null($this->template)){

//HTML page from template

$content = join('', file(DIR_WS_TEMPLATES . $this->template));

$content = addslashes($content);

eval ("\$content = \"$content\";");

$html_content = $content;

}

 

return $html_content;

}

 

function confirm() {

global $HTTP_GET_VARS;

 

$mail_query1 = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");

$mail_query2 = tep_db_query("select count(*) as count from " . TABLE_NEWSLETTER . " where customers_newsletter = '1'");

 

 

$mail1 = tep_db_fetch_array($mail_query1);

$mail2 = tep_db_fetch_array($mail_query2);

 

$mail['count'] = ($mail1['count'] + $mail2['count'] );

 

$confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .

' <tr>' . "\n" .

' <td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</b></font></td>' . "\n" .

' </tr>' . "\n" .

' <tr>' . "\n" .

' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .

' </tr>' . "\n" .

' <tr>' . "\n" .

' <td class="main"><b>' . $this->title . '</b></td>' . "\n" .

' </tr>' . "\n" .

' <tr>' . "\n" .

' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .

' </tr>' . "\n" .

' <tr>' . "\n" .

' <td class="main">' . $this->html_content() . '</td>' . "\n" .

' </tr>' . "\n" .

' <tr>' . "\n" .

' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .

' </tr>' . "\n" .

' <tr>' . "\n" .

' <td align="right"><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></td>' . "\n" .

' </tr>' . "\n" .

'</table>';

 

return $confirm_string;

}

 

function send($newsletter_id) {

$mail_query1 = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");

$mail_query2 = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_NEWSLETTER . " where customers_newsletter = '1'");

 

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

$mimemessage->add_text($this->content);

$mimemessage->build_message();

while ($mail = tep_db_fetch_array($mail_query1)) {

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

}

while ($mail = tep_db_fetch_array($mail_query2)) {

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

}

$newsletter_id = tep_db_prepare_input($newsletter_id);

tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");

}

}

?>

 

Thank you for your help.

Link to comment
Share on other sites

add $mimemessage->add_html($this->html_content()); after $mimemessage->add_text($text->content);

 

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

$mimemessage->add_text($this->content);

$mimemessage->build_message()

Edited by scottyb
Link to comment
Share on other sites

add $mimemessage->add_html($this->html_content()); after $mimemessage->add_text($text->content);

 

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

$mimemessage->add_text($this->content);

$mimemessage->build_message()

 

 

Hey, Scottyb!

 

You are GREAT!

It works. Thanks again for this contribution!

Link to comment
Share on other sites

  • 2 weeks later...

Hello.

My english is bad, i am spanish

I have a problem.

In the boletin of admin i see this error:

Fatal error: Cannot redeclare class newsletter_products in /home/chs/xxxxxx.com/home/html/admin/includes/languages/espanol/modules/newsletters/newsletter_products.php on line 14

the code in this file is (newsleter/newsletter_products.php) :class newsletter_products {

 

I need you

 

Thanks

Link to comment
Share on other sites

You declared "new newsletter_products" twice in your code. You can only do so once.

 

Hello.

My english is bad, i am spanish

I have a problem.

In the boletin of admin i see this error:

Fatal error: Cannot redeclare class newsletter_products in /home/chs/xxxxxx.com/home/html/admin/includes/languages/espanol/modules/newsletters/newsletter_products.php on line 14

the code in this file is (newsleter/newsletter_products.php) :class newsletter_products {

 

I need you

 

Thanks

Link to comment
Share on other sites

Hi, i try to add this contribution but i have a little problem, the price is calculate wrong, it seams to round the price to whole number (8.35€ appears as 8.00€)

 

This is my newsletter_products.php

 

///create HTML string containing links & pics
define('COLS', 1);
$width = intval(25/COLS);
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$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_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'], SMALL_IMAGE_WIDTH, SMALL_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"><b>' . $images['products_description'] .  '</b></font><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><br>' . $currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])) . '</br></b></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'], SMALL_IMAGE_WIDTH, SMALL_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"><b>' . $images['products_description'] .  '</b></font><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><br>' . $currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])) . '</br></b></font></td>';
}
$col++;
}
$html_content .= '</tr></table>';

	if(tep_not_null($this->template)){

 

 

I try to do everything as the first post say, but the only step i can do is insert

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

into newsletters.php because i get this error:

Warning: main(DIR_WS_CLASSEScurrencies.php) [function.main]: failed to open stream: No such file or directory in /web/htdocs/www.edicoesmangaline.com/home/loja/admin/newsletters.php on line 13

Fatal error: main() [function.require]: Failed opening required 'DIR_WS_CLASSEScurrencies.php' (include_path='.:/php/lib/php/') in /web/htdocs/www.edicoesmangaline.com/home/loja/admin/newsletters.php on line 13

 

Please some help me, i been 48h in this without results.

Sorry for my bad english.

Link to comment
Share on other sites

Failed opening required 'DIR_WS_CLASSEScurrencies.php'

 

Your page is either not calling the config.php file that defines DIR_WS_CLASSES or that definition has been removed. Look to make sure that these are included.

Link to comment
Share on other sites

  • 3 weeks later...
I'm using that code. The image is not appearing, it's X-ed out.

 

When I check the properties, it just links to my /images/ directory, it doesn't link to the name of the file.jpg

Thanks for a great contribution :D

 

For everyone that get the x'ed out picture when changing the $images_query can change it to this and then the picture will appear again

 

$images_query = tep_db_query("select p.products_id, p.products_image, pd.products_name, p.products_price, p.products_tax_class_id, if(s.status, s.specials_new_products_price, NULL) as specials_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.products_id = p.products_id and p.products_id in(" . $this->products . ") and pd.language_id=" . $languages_id); }

 

 

Again thanks

 

-THomas-

Link to comment
Share on other sites

Hi,

 

This is a great contribution.

Is there anyway to incorporate the send feature of the stock product_notification module into this contribution?

I'd like to be able to pick the recipients of a newsletter rather than send it to everyone.

Thanks again for the great contrib.

 

John

Link to comment
Share on other sites

  • 2 weeks later...

Hello, thanks for this great contribution.

 

Although I got one question, I've never used templates before on a oscommerce store so im not sure how it works. It doest really matter (i think) I was just wondering how to give the mail a style (for the text and such), as the .css file doesnt work on mails.

Link to comment
Share on other sites

Hello,

 

I have tried out this contribution and everything works great, except the template. I have made an easy template with the logo at the top.

I have given the folder templates 777 permissions, i have tried to use the template from my computer and from the webserver but no matter where i choose it, it isnt included in the newsletter.

 

Can you help me with this? I have checked the configure.php file and it doens't seem to be any wrong there.

 

Is there some special name the template fil should be named, or how can i include it? Since when i chooses the template i get to my locale computer.

 

Hope someone here has the solution for this problem :D

 

Best Regards

-Thomas

Link to comment
Share on other sites

Hello,

 

I have tried out this contribution and everything works great, except the template. I have made an easy template with the logo at the top.

I have given the folder templates 777 permissions, i have tried to use the template from my computer and from the webserver but no matter where i choose it, it isnt included in the newsletter.

 

Can you help me with this? I have checked the configure.php file and it doens't seem to be any wrong there.

 

Is there some special name the template fil should be named, or how can i include it? Since when i chooses the template i get to my locale computer.

 

Hope someone here has the solution for this problem :D

 

Best Regards

-Thomas

 

I think i have figured it out now, it seems that on line 128 in newsletter_products.php it says: $content = join('', file(DIR_WS_TEMPLATES . $this->template));

 

In my configure file it already is a line named that DIR_WS_TEMPLATES

sow i changed it to DIR_WS_TEMPLATES2 and then i got it to show the template.

 

But the only problem i have now is that it want save my template file when i upload it in the newsletter file.

I have to go to my mysql admin panel and insert the file myself.

 

Does someone now why it doesnt save the template file?

 

-Thomas-

Link to comment
Share on other sites

  • 3 weeks later...

Hi ! As a french user, I'll try my best english :lol:

 

This contribution is more than useful, and I manage to display the prices in the newsletter following the several advices in the topic.

 

But there is one thing left : I haven't succeded in displaying specials prices.

 

Here are the relevant code :

 

$current_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, if(s.status, s.specials_new_products_price, NULL) as specials_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.products_id = p.products_id and p.products_id in(" . $p_string . ") and pd.language_id=" . $languages_id);

 

$product_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, if(s.status, s.specials_new_products_price, NULL) as specials_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.products_id = p.products_id and p.products_id in(" . $p_string . ") and pd.language_id=" . $languages_id);

 

if ($this->products != ''){
$images_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id 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_NORMAL_IMAGES . $images['products_image'], $images['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '<br>' . $currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])) . $specials_price->$product['specials_price'] .'</a></td>';
			$html_content .= (!empty($images['specials_price'])) ? '<s>' . $images['specials_price'] . '</s>' : '';
			$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_NORMAL_IMAGES . $images['products_image'], $images['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $images['products_name'] . '<br>' . $currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])) . $specials_price->$product['specials_price'] .'</a></td>';
			$html_content .= (!empty($images['specials_price'])) ? '<s>' . $images['specials_price'] . '</s>' : '';
		}
		$col++;
	}

 

 

Thanks to those who will take time to help me !

Link to comment
Share on other sites

Hi There!

 

I'm new user of Oscommerce.

I should say I really like it! Because the default product notification newsletter is not working in some of the reasons (it's sending only the text included in the message but no pictures etc.) I was planning to try this contrib which is doing mutch more then the original one :-) I mean at least I can see the images in the preview.

My problem is that I also install the "Newsletter Groups" contrib and right after this contrib. When I try to send a newsletter is tells me "Customers receiving newsletter: 0". I don't want to say something is wrong with this contrib but I need help to solve it. I would like to use the 2 contribs together. I found it's a good Ideea to have newsletter groups.

 

Any help is appreciated!

Link to comment
Share on other sites

  • 3 weeks later...

hi,

 

1. how can i add a link to the end of the email with the email addy of the receiver!?

2. how can i embedd the pictures so i dont need to click on that warning in outlook!?

 

thank you for the reply and the nice contrib...

 

MR-M

Link to comment
Share on other sites

hi,

 

1. how can i add a link to the end of the email with the email addy of the receiver!?

2. how can i embedd the pictures so i dont need to click on that warning in outlook!?

 

thank you for the reply and the nice contrib...

 

MR-M

 

HI, first of all, sorry for my bad english :lol:

 

Next the solution :

 

1. How I've proceed :

 

at the end of the file

 

while ($mail = tep_db_fetch_array($mail_query)) {

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

$mimemessage->add_html($this->content.'<br><br><div align="center"> YOUR TEXT<br>'.'<a href="'.HTTP_SERVER.DIR_WS_CATALOG.THE NAME OF THE FILE YOU WANT THE RECEIVER TO GO.'?email='.$mail['email'].'">Stop receiving the news</a></div>');

$mimemessage->build_message();

$mimemessage->send('', $mail['email'], 'XXXX' . ' ', EMAIL_FROM, $this->title);

 

}

You are likely to replace email or $mail by the name you have in your database.

 

 

2. Just let your pictures on a folder in your web site, and in your template put a link like <img src ="http://www.mysite/images/mypicture.jpg">

 

Hope I've been useful :-"

Link to comment
Share on other sites

thank you for the reply

 

   $image_new = "images/logo.jpg";
copy($image,$image_new); 
$attachment = fread(fopen($image_new, "r"), filesize($image_new));
$mail->add_attachment("$attachment", $image_new, "image/jpeg");
$mail->send();
@unlink($iamge_new);

 

i am looking for something like the above code,

but it adds the images as a attachment... but to stop the message about unsecure blocked items in mail it needs to be embedded like if you insert images in outlook...

 

while ($mail = tep_db_fetch_array($mail_query)) {

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

$mimemessage->add_html($this->content.'<br><br><div align="center"> YOUR TEXT<br>'.'<a href="'.HTTP_SERVER.DIR_WS_CATALOG.THE NAME OF THE FILE YOU WANT THE RECEIVER TO GO.'?email='.$mail['email'].'">Stop receiving the news</a></div>');

$mimemessage->build_message();

$mimemessage->send('', $mail['email'], 'XXXX' . ' ', EMAIL_FROM, $this->title);

 

}

did not work for me ;(

 

MR-M

Edited by MR-M
Link to comment
Share on other sites

In my cas, I have the contribution Price Break installed and it would have been necessary me to adapt the code to allow the correct dispaly of the prices (price range and specials).

 

I already wrote that but I find products with the barred price systematicaly in the place of the normal price as well as the range price :

	function html_content() {
  global $currencies, $languages_id; 
	//create HTML string containing links & pics
	define('COLS', 2);
	$width = intval(100/COLS);
	$html_content = '<table border="0" width="100%" height="100%" cellpadding="2" cellspacing="3"><tr><td colspan="' . COLS . '" align="center" 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, p.products_image, p.products_quantity, p.products_tax_class_id, s.status, s.specials_new_products_price, specials_new_products_price, p.products_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.language_id = '1' and pd.products_id = p.products_id and p.products_id in(" . $this->products . ")");
	}

while($images = tep_db_fetch_array($images_query)){
$images['products_name'] = tep_get_products_name($images['products_id']);
$images['specials_new_products_price'] = tep_get_products_special_price($images['products_id']);

	if (tep_not_null($this->products['specials_new_products_price'])) {
	  $whats_new_price = '<s>' . $currencies->display_price($images['products_price'], tep_get_tax_rate($images['products_tax_class_id'])) . '</s><br>';
	  $whats_new_price .= '<span class="productSpecialPrice">' . $currencies->display_price($images['specials_new_products_price'], tep_get_tax_rate($images['products_tax_class_id'])) . '</span>';
	} else {
	  $pf->loadProduct((int)$images['products_id'], (int)$languages_id);
	  $whats_new_price = $pf->getPriceStringshort();
	}

		if($col > COLS-1){
			$html_content .= '</tr><tr><td class="content" align="center" width="' . $width . '%">' . tep_draw_separator('pixel_trans.gif', '1', '4') . '<br><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'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . tep_draw_separator('pixel_trans.gif', '1', '2') . '<br>' . $images['products_name'] . '</a><br>' .  tep_draw_separator('pixel_trans.gif', '1', '2') . '<br><span class="productNormalPrice">' . $whats_new_price . '</span><br>' . tep_draw_separator('pixel_trans.gif', '1', '6') . '</td>';
			$col = 0;
		}else{
			$html_content .= '<td class="content" align="center" width="' . $width . '%">' . tep_draw_separator('pixel_trans.gif', '1', '4') . '<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'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . tep_draw_separator('pixel_trans.gif', '1', '2') . '<br>' . $images['products_name'] . '</a><br>' .  tep_draw_separator('pixel_trans.gif', '1', '2') . '<br><span class="productNormalPrice">' . $whats_new_price . '</span><br>' . tep_draw_separator('pixel_trans.gif', '1', '6') . '</td>';
		}
		$col++;
	}
	$html_content .= '</tr></table>';

Preliminary, I have insert into admin/newsletters.php :

// include currencies class and create an instance
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

// include the price formatter for the price breaks contribution
 require(DIR_WS_CLASSES . 'PriceFormatter.php');
 $pf = new PriceFormatter;

And I added the PriceFormatter.php file into admin/includes/classes in order to obtain the "getPriceStringshort" function and into admin/includes/functions/general.php the "tep_get_products_special_price" function :

////
// Return a product's special price (returns nothing if there is no offer)
// TABLES: products
 function tep_get_products_special_price($product_id) {
$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status");
$product = tep_db_fetch_array($product_query);

return $product['specials_new_products_price'];
 }

I took as a starting point from the model offered by the file includes/modules/new_products.php.

 

So, if someone haved installed the Price Break contibution (or not) and want to give me a small blow of inch that would have come very well. :)

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

********* HOT NEW !!! *********

V1.2 by milerwan (20.05.2007):

- Prices and special prices added

- Fix for Price Break contribution with PriceFormatter.php file (with special price fix)

- French language added

- stylesheet.css added for modulable color and size prices

 

This is full package.

 

Enjoy! : )

 

Available HERE.

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

Not to be outdone by milerwan, the official Version 2.0 (that I have promised long ago) is released.

 

B.K. & Kristian (don't know his username) got a sneak peak last week - I'm hoping no news is good news.

 

This release fixes the obvious issues stated here, adds specials, adds multipart-text/html email version to help lower spam scoring. Overall, this release is more in-tune with the osCommerce standard of coding.

 

Enjoy

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...