/*************************************************\ | Customer Reward Points 1.1.0 | | | |Reward your repeat customers!! | | Fully featured, highly customizable customer | | points rewards system. | | -Each product can have it's own point value | | and you can also have a global point value for | | orders. | | -Points are auto calculated based on order | | status | | -See full feature list on our website | | | | BCS Engineering | | Copyright (c) 2004 BCS Engineering, | | Carrie L. Saunders | All rights reserved. | | See http://www.bcsengineering.com/license.shtml | | for full license | | For X-cart versions 3.4.X | \*************************************************/ NOTE: You should always make a back-up copy of your files and database before installing any modification. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INSTALLATION: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Log into your Admin interface and copy and paste the SQL queries in patch.sql into the Patch/Upgrade sql utility. (You can put them all in at once) 2. Uncompress the zip and copy all the files into their appropriate directories. 3. In include/func.php Find the function func_calculate_single and insert this code: # BCSE Points Begin $total = $total - $cart["points_discount"]; # BCSE Points End After: $total = $total-$discount; $total_shipping -= $discount; if ($total_shipping < 0) $total_shipping = 0; Find the function func_place_order and insert this code: # BCSE Begin include "bcse_points_system_order.php"; # BCSE End After (there is a very long query before this): $orderid=db_insert_id(); Finally in include/func.php find the function func_change_order_status and insert this code: # BCSE Begin include "bcse_points_system_order.php"; # BCSE End After: db_query("update $sql_tbl[orders] set status='$status'".(($advinfo)? ", details='".$info."'" : "")." where orderid='$orderid'"); 4. Add to skin1/common_templates.tpl: {* BCSE Begin *} {elseif $main eq "points_system_rates"} {include file="admin/main/bcse_points_system.tpl"} {* BCSE End *} Somewhere after the first {if} 5. Add to skin1/admin/menu.tpl: Customer Reward Points
Recommended Before {/capture} 6. Add to customer/cart.php: # BCSE Begin $cart["points_discount"]=0; $cart["points_used"]=0; # BCSE Begin After: if ($mode=="delete" && $productindex!="") { # # Delete product from cart # Also Add to cart.php: # BCSE Begin if($points['total'] <=0) $cart['points_discount']=0; # BCSE End After: require "./auth.php"; include $xcart_dir."/shipping/shipping.php"; 7. Add to skin1/customer/main/cart_totals.tpl: {* BCSE Begin *} {if $cart.points_discount gt 0}{/if}{$lng.lbl_points} {$lng.lbl_discount}:{if $cart.points_discount gt 0}{/if}
{include file="currency.tpl" value=$cart.points_discount} {include file="customer/main/alter_currency_value.tpl" alter_currency_value=$cart.points_discount} {* BCSE End *} Before: {if $cart.coupon_discount ne 0} 8. Add the following to customer/auth.php after the long list of includes: # BCSE Begin include "../include/bcse_get_points.php"; # BCSE End 9. Add lbl_points to your languages area in Admin. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INSTALL DONE! You are now done with all required install steps!!! To add more features to this mod, review the following steps and apply if you would like these optional features. They are not required for the mod to work, but may be desirable. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OPTIONAL: DISPLAY THE POINTS EARNED to the customer and to the admin in the customer's profile page do these steps: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Add the following to include/register.php: # BCSE Begin include "../include/bcse_get_points.php"; # BCSE End Before: require "../include/countries.php"; require "../include/states.php"; 2. Add the following to skin1/main/register.tpl: {* BCSE Begin *} Points Available: {$points.total} {* BCSE End *} After:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OPTIONAL: DISPLAY THE POINTS EARNED ANYWHERE ON THE SITE, do these steps: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Add the following anywhere in the templates to display customer points: {if $login} {$points.total}{/if} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OPTIONAL: DISPLAY THE POINTS EARNED PER ORDER AND USED PER ORDER, do these steps: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Add the following to include/history_order.php: # BCSE Points Begin $points_payment = func_query_first("select * from points where orderid='$orderid' and type='P'"); $smarty->assign("points_payment",$points_payment); $points_earned = func_query_first("select * from points where orderid='$orderid' and type='O'"); $smarty->assign("points_earned",$points_earned); # BCSE Points End After: if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } 2. Add the following to main/history_order.tpl:     {$lng.lbl_points_earned} {$points_earned.points} Recommended before:     {$lng.lbl_payment_method} {$order.payment_method} Also add to main/history_order.tpl: {$lng.lbl_points_applied} {$points_payment.points|abs} Recommended before: {$lng.lbl_discount} {include file="currency.tpl" value=$order.discount} 3. In your admin languages area, add lbl_points_earned and lbl_points_applied ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OPTIONAL: DISPLAY THE POINTS EARNED PER ORDER AND USED PER ORDER ON ORDER PRINT OUT, do these steps: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Add the following to skin1/mail/order_invoice.tpl: {* BCSE Begin *} {$lng.lbl_customer_rewards} ------------------------ {$lng.lbl_points_earned}: {$points_earned.points} {$lng.lbl_points_applied}: {$points_payment.points|abs} {if $usertype eq "C"}{$lng.lbl_total_points}: {$points.total}{/if} {* BCSE End *} Recommended before: {include file="mail/order_data.tpl"} 2. Add the following to include/history_order.php (if you haven't already in the above optional section): # BCSE Points Begin $points_payment = func_query_first("select * from points where orderid='$orderid' and type='P'"); $smarty->assign("points_payment",$points_payment); $points_earned = func_query_first("select * from points where orderid='$orderid' and type='O'"); $smarty->assign("points_earned",$points_earned); # BCSE Points End After: if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } 3. In your admin languages area, add lbl_customer_rewards and lbl_total_points ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OPTIONAL: DISPLAY THE POINTS EARNED PER ORDER, USED PER ORDER, AND TOTAL POINTS IN ORDER EMAILS, do these steps: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Add to any of the email templates (skin1/mail/order_notification.tpl, skin1/mail/order_customer_complete.tpt, etc) code similar to: {* BCSE Begin *} {$lng.lbl_customer_rewards} ------------------------ {$lng.lbl_points_earned}: {$points_earned.points} {$lng.lbl_points_applied}: {$points_payment.points|abs} {$lng.lbl_total_points}: {$total_points.total} {* BCSE End *} 2. In your admin languages area, add lbl_customer_rewards and lbl_total_points if you haven't already