EmmaThePoly:
Hello, I was wondering if there would be a way to view how many points a customer has on their account by going to the 'my account' page? Is there a PHP script I can use to call the value? Thanks :)
This isn't built in.
I wanted the same thing so I created it. I can give you some basics, but keep in mind this is specific to the Tableau template.
Also keep in mind I am not a 'programmer'. I hacked this together. It has been working for a couple months with no error logs, but it could be garbage :smile:
Here is a quick run down for my site: :
- add the link to the My Account Page
on includes\templates\tableau\templates\tpl_modules_account_menu.php insert the following after line 11:
<li class="communications"><?php echo ' <a href="' . zen_href_link(FILENAME_ACCOUNT_REWARDS, '', 'SSL') . '">' . MY_ACCOUNT_REWARDS . '</a>'; ?></li>
-
In includes\languages\english\extra_definitions\account.php
Add something like the following after line 23:
define('MY_ACCOUNT_REWARDS','Rewards/Store Credit');
-
Create a file includes\templates\tableau\templates\tpl_account_rewards_default.php and put this in it:
<?php
/**
* Page Template
*
* Loaded automatically by index.php?main_page=account_rewards.<br />
* View or change Customer Account Information
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0
*
@version $Id: tpl_account_rewards_default.php 3848 2006-06-25 20:33:42Z drbyte $
* @copyright Portions Copyright 2003 osCommerce
*/
?>
<div class="centerColumn" id="accountPassword">
<h1 class="back"><?php echo HEADING_TITLE; ?></h1>
<div class="required alert forward"><?php echo FORM_REQUIRED_INFORMATION; ?></div>
<?php require($template->get_template_dir('tpl_modules_account_menu.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_account_menu.php'); ?>
<div class="account-info-wrapper">
<fieldset>
<legend><?php echo REWARD_POINT_TITLE; ?></legend>
<?php
$total_points=getCustomersRewardPoints($_SESSION['customer_id']);
if(defined(MODULE_ORDER_TOTAL_REWARD_POINTS_STATUS) && MODULE_ORDER_TOTAL_REWARD_POINTS_STATUS==true)
{
$redeem_ratio=GetRedeemRatio($_SESSION['customer_id']);
$points_value=$currencies->format($total_points*$redeem_ratio);
}
else
if(defined(MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_STATUS) && MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_STATUS==true)
{
$row=GetRewardPointDiscountRow($total_points);
$value=($row!=null?$row['discount']:0);
if(MODULE_ORDER_TOTAL_REWARD_POINTS_DISCOUNT_TYPE==0)
$points_value=$value."%";
else
$points_value=$currencies->format($value);
}
echo '<label class="inputLabel">'.REWARD_POINT_PROMPT.'</label>'.'<label class="inputLabel">'.$total_points.'</label>';
echo '<br class="clearBoth" />';
echo '<label class="inputLabel">'.REWARD_POINT_VALUE_PROMPT.'</label>'.'<label class="inputLabel">'.$points_value.'</label>';
echo '<br class="clearBoth" />';
echo '<a href="https://www.lindasdietdelites.com/pages/rewards-48.html">Rewards Info</a>';
?>
<br class="clearBoth" />
</fieldset>
</div>
</div>
-
Make sure includes/extra_datafiles/reward_points_filenames.php includes the following:
define('FILENAME_ACCOUNT_REWARDS','account_rewards');
-
Create a folder includes/modules/pages/account_rewards
-
Create a file includes/modules/pages/account_rewards/header_php.php and put this in it:
<?php
/**
* Header code file for the Account History page
*
* @package page
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0
*
@version $Id: header_php.php 3160 2006-03-11 01:37:18Z drbyte $
*/
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_ACCOUNT_REWARDS');
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2);
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_ACCOUNT_REWARDS');
?>