View Single Post
  #1  
Old 11-23-2006, 01:52 PM
  ShishaPipeUK's Avatar 
ShishaPipeUK ShishaPipeUK is offline
 

Senior Member
  
Join Date: Jul 2005
Location: London, England.
Posts: 118
 

Lightbulb Notify me when the product's information, price and stock level is changed

Notify me when the product's information, price and stock level is changed

You can see this in action at http://www.theshisha.com/shopcart/product.php?productid=16139&cat=0&page=1

This modification is for x-cart 4.1.3 version
I have posted this modification so that x-cart forum members can contribute to the code and hopefully make any improvements to the modification and post them in this thread.

Now about the modification:

CUSTOMER:

1. When customer is on "Product Details" page, s/he will see a new form:
------
Notify my when the product's information is changed: < "Enter the email here..." text field >
<"Submit" button>
------

The form will look similar for both logged and not logged customer. The only exception will be that the email from the user' profile will be pre-filled in the text-field, however, can be changed to another address, if needed.

2. After clicking "Submit", the script will create a special record in the database, containing the productID, current description, price, quantity in stock and specified email address (a new table will be created for this purpose).

ADMIN:

When changing the product details (submitting "Product Modify" form, or using "Products import" facility), the script will look if there are any email addresses, associated with the current productID.

If yes, it will look for the differences in one of the following fields:
- Short/Long description;
- Price;
- Quantity in stock (from 0 to a bigger value).

I.e., it will compare the date, was stored when customer submitted a new form and the currently submitted by the admin data.

If any of described changes have taken place, a special "Product information has changed" email will be sent to all the email addresses, associated with current product.

The email will contain the text, saying that the information about the product has changed (language variable, which the admin can change in "Languages" section) and the link to "Product Details" page. updated product's information.

Also, the information, saved about the product initially (in new table) will be updated with the new product's information (will allow to catch the next changes for the product).

Also with the email your customer receives, you have the option to unsubscribe to the product notify me.

This modification requires five original xcart 4.1.3 files to be changed:
init.php
product.php
include/import_products.php
include/product_modify.php
skin1/customer/main/product.tpl

Four new x-cart files
changed_product_notify.php
skin1/mail/productinfo_has_changed.tpl
skin1/mail/productinfo_has_changed_subj.tpl
skin1/mail/html/productinfo_has_changed.tpl

And a change to the SQL file which is below.

Apply the SQL changes (Open the Patch/Upgrade page in admin area and select the patch.sql from the archive for the "Apply SQL patch" section).

Code:
UPDATE xcart_config SET value='1164025634' WHERE name='data_cache_expiration'; UPDATE xcart_config SET value='19' WHERE name='survey_sending_remainder'; CREATE TABLE xcart_email_for_changed_products (productid int(11) NOT NULL default '0',email varchar(128) NOT NULL default '',descr text NOT NULL default '',fulldescr text NOT NULL default '',price decimal(12,2) NOT NULL default '0.00',avail int(11) NOT NULL default '0',PRIMARY KEY (productid,email)) TYPE=MyISAM; INSERT INTO xcart_languages SET code='US', name='eml_productinfo_has_changed', value='The product description, price, or quantity has changed with regard to this product.<br><br>Please go to the product for more details.', topic='E-Mail'; INSERT INTO xcart_languages SET code='US', name='eml_productinfo_has_changed_subj', value='Product information has changed', topic='E-Mail'; INSERT INTO xcart_languages SET code='US', name='lbl_notify_about_changed_product', value='Notify me when the product's information is changed', topic='Labels'; INSERT INTO xcart_languages SET code='US', name='lbl_notify_me', value='Notify me if any changes are made to the above product', topic='Labels'; INSERT INTO xcart_languages SET code='US', name='productinfo_has_changed_subj', value='Product information has changed', topic='Labels'; INSERT INTO xcart_languages SET code='US', name='txt_unsubscribe_message', value='You have unsubscribed to the email notification about product changes.', topic='Text';

Upload the Four new x-cart files

changed_product_notify.php - This new file goes in the root of your x-cart, same area as where the home.php file is.

Code:
<?php if($mode == "unsubscribe"){ require "./auth.php" ; db_query("DELETE FROM $sql_tbl[email_for_changed_products] WHERE productid='$productid' AND email='$email'"); echo($message); exit; } if ($mode == "changed_product_notify" && !empty($notify_email)){ $is_notified = func_query_first("SELECT productid FROM $sql_tbl[email_for_changed_products] WHERE productid='$productid' AND email='$notify_email'"); if ($is_notified) db_query("DELETE FROM $sql_tbl[email_for_changed_products] WHERE productid='$productid' AND email='$notify_email'"); db_query("INSERT INTO $sql_tbl[email_for_changed_products] VALUES ('$productid', '$notify_email', '$desc', '$fulldesc', '$price', '$avail')"); } if ($login) { $notify_email = func_query_first_cell("SELECT email FROM $sql_tbl[customers] WHERE login='$login'"); $smarty->assign("notify_email", $notify_email); } ?>

skin1/mail/productinfo_has_changed.tpl

Code:
{* $Id: productinfo_has_changed.tpl,v 1.0 2006/11/23 Shishapipe UK $ *} {config_load file="$skin_config"} {include file="mail/mail_header.tpl"} {$lng.eml_productinfo_has_changed} {include file="mail/signature.tpl"}

skin1/mail/productinfo_has_changed_subj.tpl

Code:
{config_load file="$skin_config"}{ $config.Company.company_name }: {$lng.eml_productinfo_has_changed_subj}

skin1/mail/html/productinfo_has_changed.tpl

Code:
{* $Id: productinfo_has_changed.tpl,v 1.0 2006/11/23 Shishapipe UK *} {config_load file="$skin_config"} {include file="mail/html/mail_header.tpl"} <P>{$lng.eml_productinfo_has_changed} <P>{$lng.product_details} <P><A href="{$http_location}/product.php?productid={$productid}" target=_new>{$http_location}/product.php?productid={$productid}</A> <P><A href="{$http_location}/changed_product_notify.php?mode=unsubscribe&email={$email}&productid={$productid}&message={$lng.txt_unsubscribe_message}" target=_new>Click HERE to Unsubscribe from this product change notify me</A> {include file="mail/html/signature.tpl"}
__________________
Apache/2.0.55 (Red Hat) & MYSQL Server: 5.0.24
PERL: 5.008005 / PHP: 4.4.4 - 4.3.1 X-CART

Shop carts at
http://www.nightscene.co.uk/shop/home.php
http://www.theshisha.net/shopcart/home.php
http://www.system-maintenance.com/maint/home.php
http://www.tabac4u.com
Reply With Quote