Page 5 of 14 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 140
  1. #41
    Join Date
    Nov 2006
    Posts
    18
    Plugin Contributions
    0

    Default Re: Store Credit Module

    OK, I've done what I'm going to call an "alpha release" using the code from my live store, plus a couple of changes I realised were necessary when I put it into a fresh ZC 1.3.7 install.

    You can download and play http://staging.funtimesx.com/store_c...dule_0.0.4.zip

    (When we get this stable, I'm going to remove that link and put a proper release on the ZC page for this contrib).

    gonewild - it should fix your balance problem/SQL error, and those of you who were having problems with a file missing, I think that is fixed as well.

    If you're happy to test this, please download, follow the install/upgrade instructions and let me know what does or does not work for you. Please don't do this for a production/critical store if you're not happy to tinker - as you can see I tend to have to "come and go" a bit, so I can't be relied on to provide help asap if it goes wrong.

    Cheers,
    Kath
    (Thanks to sleeping babies!)

  2. #42
    Join Date
    Apr 2005
    Posts
    150
    Plugin Contributions
    0

    Default Re: Store Credit Module

    OK!!
    It works.
    I upgraded to your new version by simply coping the files over. It seems to work now. I made purchases both with and without credit and everything worked normally.
    Thanks for fixing it and thanks for contributing the module. We've needed this for a long time.

  3. #43
    Join Date
    Mar 2006
    Posts
    29
    Plugin Contributions
    0

    Default Re: Store Credit Module

    I downloaded it and tried it. It works great so far. I tried it with a huge balance and it subtracted everything correctly. I also tried it with 0 credit and it worked fine.

    The only thing this feature needs is to allow the purchaser the ability to not have to put in a payment type if the balance owed is $0. At the least, maybe some info that says that they will not be charged even though they need to input there card info.

    Anyone got any ideas?

    Corbett

  4. #44
    Join Date
    Nov 2006
    Posts
    18
    Plugin Contributions
    0

    Default Re: Store Credit Module

    Quote Originally Posted by cmessa View Post
    The only thing this feature needs is to allow the purchaser the ability to not have to put in a payment type if the balance owed is $0. At the least, maybe some info that says that they will not be charged even though they need to input there card info.
    It's on the "Planned Features List ". I just wanted to ensure we got a stable version out there first.

    Although I keep thinking I must be missing something and there's a way to configure ZenCart not to require payment for zero balance orders, but I haven't figured it out yet.

  5. #45
    Join Date
    Jun 2006
    Location
    My family and I live in Brighton, England
    Posts
    982
    Plugin Contributions
    0

    Default Re: Store Credit Module

    Great to see you again, Kath! I think this is an important module and I'm very glad to see it moving forward.
    I'm creating a vintage shop for a couple here in Florence. Returns are a fact of life when selling vintage clothing online but to have the option of offering store credit instead of cash... I have to say that this module is a real lifesaver!

    I'll give it another whirl and let you know how it goes.

    Thanks again! Tim

  6. #46
    Join Date
    Jun 2006
    Location
    My family and I live in Brighton, England
    Posts
    982
    Plugin Contributions
    0

    Default Re: Store Credit Module

    So far, so good! I've run it through the paces as best I could, adding store credit, placing orders... basically hitting it from all sides. So far not 1 glitch.

    I'll keep you updated.

    Thnaks again! Tim

  7. #47
    Join Date
    Apr 2006
    Posts
    12
    Plugin Contributions
    0

    Default Re: Store Credit Module

    ok, I got this working the way i want it. This is based off the original script. I have not looked at the updated one yet. I believe this will work. I am getting my credit info from a different database than the Zencart one so I had to put the original database calls back into this script and I have not tested it on my store yet, but you are welcome to give it a try if you want.

    The only changes to this is that it allows the customer to select how much credit they wish to use. If they do not put a credit amount in the Store Credit box then it will use all avaiable store credit for the purchase.

    funtimesx you may want to try this. It may need some cleaning up, but I think it will work. Or you may want to integrate it into the original script.

    Change the following files to the scripts below.

    includes/modules/orders_totals/ot_sc.php

    <?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
    */
    ?>
    <?php
    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->show_redeem_box = MODULE_ORDER_TOTAL_GV_REDEEM_BOX;
    $this->redeem_instructions = MODULE_ORDER_TOTAL_SC_INSTRUCTIONS;
    $this->credit_class = true;
    $_SESSION['cot_sc'] = $this->get_user_balance($_SESSION['customer_id']);
    if (!zen_not_null(ltrim($_SESSION['cot_sc'], ' 0')) || $_SESSION['cot_sc'] == '0') $_SESSION['cot_sc'] = '0.00';
    $this->checkbox = $this->user_prompt . '<input type="text" 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 = \'\';" />' . ($this->get_user_balance($_SESSION['customer_id']) > 0 ? '<br />' . MODULE_ORDER_TOTAL_SC_USER_BALANCE . $currencies->format($this->get_user_balance($_SESSION['customer_id'])) : '');
    $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, $currencies;
    // 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'] > $currencies->value($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;
    $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']);
    $amount = $check_query->fields['amount'];
    return $amount;
    }else{
    $amount = 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()) . "')");
    }
    }
    ?>

    include/lanquages/english/modules/order_total/ot_sc.php

    <?
    /* Start Store Credit Order Total Module */
    define('MODULE_ORDER_TOTAL_SC_TITLE', 'Store Credit');
    define('MODULE_ORDER_TOTAL_SC_HEADER', 'Store Credit');
    define('MODULE_ORDER_TOTAL_SC_DESCRIPTION','Your balance is');
    define('MODULE_ORDER_TOTAL_SC_USER_PROMPT','Enter Store Credit: ');
    define('MODULE_ORDER_TOTAL_SC_SORT_ORDER','Sort Order');
    define('MODULE_ORDER_TOTAL_SC_INSTRUCTIONS','<b><font color="red">NOTE: If you do not put an amount in the box below your entire Store Credit up to the purchase amount will be used on this purchase.</font></b>
    <br><br> Please enter the amount of store credit you would like to use for this purchase. The credit should show up on the Order Confirmation page. Please make sure to check this before "Confirming" your order.');
    define('TEXT_INVALID_REDEEM_AMOUNT','It appears that the amount you have tried to apply and your Store Credit balance do not match. Please try again.');
    define('MODULE_ORDER_TOTAL_SC_USER_BALANCE','Available Balance: ');

    /* End Store Credit Order Total Module */
    ?>

    If you have problems let us know. I will check back in the next couple of days.

  8. #48
    Join Date
    Nov 2006
    Posts
    18
    Plugin Contributions
    0

    Default Re: Store Credit Module

    Wow, that looks good.

    When I get a chance (probably not until next week), I'll look at rolling that into the code mainline.

  9. #49
    Join Date
    Mar 2006
    Posts
    29
    Plugin Contributions
    0

    Default Re: Store Credit Module

    I just tried it and I get this error

    syntax error, unexpected T_STRING in xxx/xxx/includes/modules/order_total/ot_sc.php on line 67

    I have not looked at the error, got any ideas?

  10. #50
    Join Date
    Apr 2006
    Posts
    12
    Plugin Contributions
    0

    Default Re: Store Credit Module

    Supposedly this is line 67. The only thing I saw wrong with it some how space was added between the E and N in FILENAME_CHECKOUT_PAYMENT. I am not sure this would cause this error. Normally the "parse error, unexpected T_STRING" is caused by problems with single-double quotes.

    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 this doesn't fix it. I will install this exact code on one of my non live stores when I get home and see what errors I get. I didn't have time to do it last night before I posted this. However, it does work on my store, but like I said I pull my credit data from a database other then ZC so I had to remove my code for database calls and reinsert the original calls. I have not tested to see what errors come from doing that.

 

 
Page 5 of 14 FirstFirst ... 34567 ... LastLast

Similar Threads

  1. Store credit and reward point module
    By yellow1912 in forum Addon Payment Modules
    Replies: 170
    Last Post: 19 Mar 2021, 03:17 PM
  2. Replies: 0
    Last Post: 11 Mar 2010, 04:39 AM
  3. Replies: 2
    Last Post: 24 Jun 2008, 11:07 PM
  4. Replies: 1
    Last Post: 16 Mar 2008, 12:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR