:clap: this is an awesome module, no problems installing , tested it out,
thanks :hug:
Printable View
:clap: this is an awesome module, no problems installing , tested it out,
thanks :hug:
Okay, I don't know much about php code but I know this is a small problem. I have install with no problem but in my side box the title and text are incorrect it is reading the php code. Where do I fix this? Store_credit_definitions.php seems to read correctly
the side box is reading BOX_HEADING_STORE_CREDIT and the text is reading BOX_DESC_STORE_CREDITQuote:
/* Start Store Credit Order Total Module */
define('TEXT_SC_NAME', 'Store Credit');
define('TEXT_SC_NAMES', 'Store Credits');
define('BOX_HEADING_STORE_CREDIT','Store Credit');
define('BOX_DESC_STORE_CREDIT','Your balance is ');
/* End Store Credit Order Total Module */
Thanks, I have messed with it but can't find anywhere to fix it.
This is a great module!!
Hi, I am using GSPAY payment module. The Store Credit shows up and calculates total ok during the checkout but once the checkout goes to Gspay page for CC information the store credit is lost.
Is that Gspay module issue?
just wanted to say THANK YOU!!! I have been looking for a module such as this for days ! and other than search for credit control lol not store credit I could not find anything so THANK YOU - saved a HUGE headache!!!!
Hi all
I have just tryed installing this module on my zen cart store and i get the follwoing error when try accessing the admin page
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\zen\admin\includes\languages\english\extra_definitions\store_credit_ definitions.php:1) in C:\wamp\www\zen\admin\includes\init_includes\init_templates.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\zen\admin\includes\languages\english\extra_definitions\store_credit_ definitions.php:1) in C:\wamp\www\zen\admin\includes\functions\general.php on line 34
any ideas ?
\wamp\www\zen\admin\includes\languages\english\e xtra_definitions\store_credit_definitions.php
-> Re-upload this file, or check if it leaves any blank space/line at the beginning of at the end of the file.
Hello ... there was some problmes with sql query when confirming order ... problem was that ...
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where customer_id=1' at line 1
in:
[update sc_customer set amount = amount - where customer_id=1]
..............................
strange was that i was getting that error only when i had used xtremeimpulse's change for customer can make decision to how much of credits he will use ... with original ot_sc.php it was ok ... so i confront both files and i make some changes ... final code for ot_sc.php what im using now looks as that ... and it works good ...
Quote:
?php
/**
* @package storeCredit
* @copyright Copyright 2007 Kath Chapman
* @copyright Portions Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*/
class ot_sc {
var $title, $output;
function ot_sc() {
global $currencies;
$this->code = 'ot_sc';
$this->title = MODULE_ORDER_TOTAL_SC_TITLE;
$this->header = MODULE_ORDER_TOTAL_SC_HEADER;
$this->description = MODULE_ORDER_TOTAL_SC_DESCRIPTION;
$this->user_prompt = MODULE_ORDER_TOTAL_SC_USER_PROMPT;
$this->sort_order = MODULE_ORDER_TOTAL_SC_SORT_ORDER;
$this->credit_class = true;
$_SESSION['cot_sc'] = $this->get_user_balance($_SESSION['customer_id']);
$this->checkbox = $this->user_prompt . '<input type="textfield" size="6" onchange="submitFunction()" name="cot_sc" value="' . number_format($_SESSION['cot_sc'], 2) . '" onfocus="if (this.value == \'' . number_format($_SESSION['cot_sc'], 2) . '\') this.value = \'\';" />' . ($_SESSION['cot_sc'] > 0 ? '<br />' . MODULE_ORDER_TOTAL_SC_USER_BALANCE . $currencies->format($_SESSION['cot_sc']) : '');
$this->output = array();
}
function process() {
global $order, $currencies;
if ($_SESSION['cot_sc']) {
$order_total = $this->get_order_total();
$od_amount = $this->calculate_credit($order_total);
$this->deduction = $od_amount;
$order->info['total'] = zen_round($order->info['total'] - $this->deduction, 2);
if ($od_amount > 0) {
$this->output[] = array('title' => $this->title . ':',
'text' => '-' . $currencies->format($this->deduction),
'value' => $this->deduction);
}
}
}
function clear_posts() {
unset($_SESSION['cot_sc']);
}
function selection_test() {
if ($this->get_user_balance($_SESSION['customer_id']) > 0) {
return true;
} else {
return false;
}
}
function pre_confirmation_check($order_total) {
global $order;
// clean out negative values and strip common currency symbols
$_SESSION['cot_sc'] = preg_replace('/[^0-9.%]/', '', $_SESSION['cot_sc']);
$_SESSION['cot_sc'] = abs($_SESSION['cot_sc']);
if ($_SESSION['cot_sc'] > 0) {
if (ereg('[^0-9/.]', trim($_SESSION['cot_sc']))) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_REDEEM_AMOUNT), 'SSL',true, false));
}
if ($_SESSION['cot_sc'] > $this->get_user_balance($_SESSION['customer_id'])) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_REDEEM_AMOUNT), 'SSL',true, false));
}
$od_amount = $this->calculate_credit($order_total);
if ($od_amount >= $order->info['total'] && MODULE_ORDER_TOTAL_SC_ORDER_STATUS_ID != 0) $order->info['order_status'] = MODULE_ORDER_TOTAL_SC_ORDER_STATUS_ID;
}
return $od_amount;
}
function use_credit_amount() {
if ($this->selection_test()) {
$output_string = $this->checkbox;
}
return $output_string;
}
function credit_selection() {
global $db, $currencies;
$gv_query = $db->Execute("select amount from " . TABLE_STORE_CREDIT . " where customer_id = ".$_SESSION['customer_id']);
if ($gv_query->$amount > 0 || $this->use_credit_amount()) {
$selection = array('id' => $this->code,
'module' => $this->title,
'redeem_instructions' => MODULE_ORDER_TOTAL_SC_INSTRUCTIONS,
'checkbox' => $this->use_credit_amount(),
'fields' => array(array(
'tag' => $this->code
)));
}
return $selection;
}
function apply_credit() {
global $db;
if(is_numeric($this->deduction)){
$db->execute("update " . TABLE_STORE_CREDIT . " set amount = amount - " .$this->deduction. " where customer_id=".$_SESSION['customer_id']);
}
}
function calculate_credit($amount) {
global $db, $order;
$gv_payment_amount = $_SESSION['cot_sc'];
$gv_amount = $gv_payment_amount;
$save_total_cost = $amount;
$full_cost = $save_total_cost - $gv_payment_amount;
if ($full_cost < 0) {
$full_cost = 0;
$gv_payment_amount = $save_total_cost;
}
return zen_round($gv_payment_amount,2);
}
function get_order_total() {
global $order;
$order_total = $order->info['total'];
return $order_total;
}
function collect_posts() {
}
function update_credit_account($i) {
}
function get_user_balance(){
global $db;
if(isset($_SESSION['customer_id'])){
$check_query = $db->Execute("select amount from " . TABLE_STORE_CREDIT . " where customer_id = ".$_SESSION['customer_id']);
return $check_query->fields['amount'];
}else{
return 0;
}
}
function check() {
global $db;
if (!isset($this->check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_SC_STATUS'");
$this->check = $check_query->RecordCount();
}
return $this->check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_SC_STATUS', 'MODULE_ORDER_TOTAL_SC_SORT_ORDER', 'MODULE_ORDER_TOTAL_SC_ORDER_STATUS_ID');
}
function install() {
global $db;
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_SC_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_SC_SORT_ORDER', '840', 'Sort order of display.', '6', '2', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_ORDER_TOTAL_SC_ORDER_STATUS_ID', '0', 'Set the status of orders made where GV covers full payment', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}
?>
BACKUP FIRST ! :)
A question before I install and use this...
If I edit an order and the total changes will it then change the store credit?
Jacque
I answered my own question. No, it will not update the credit after you edit an order.
Any ideas on how to get it to do so?
Is as simple as adding a line to extra_datafiles\store_credit_filenames.php and changing TABLE_STORE_CREDIT in order_total\ot_sc.php (code below is what I'm referring to)
To a different field in a separate table?Code:function get_user_balance(){
global $db;
if(isset($_SESSION['customer_id'])){
$check_query = $db->Execute("select amount from " . TABLE_STORE_CREDIT . " where customer_id = ".$_SESSION['customer_id']);
return $check_query->fields['amount'];
}else{
return 0;
}
}