Zen Cart Logo
Forums / General Questions / Cash on delivery max. amount

Cash on delivery max. amount

Locked

Views: 2,673

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
11 May 2006, 10:19 AM
#1
pivey avatar

pivey

Zen Follower

Join Date:
Mar 2006
Posts:
192
Plugin Contributions:
0

Cash on delivery max. amount

Hello,

I want to offer the payment option "cash on delivery" until a certain order amount
of EUR 500.00

How should I edit cod.php in this line to show up until that amount?

$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);

Dimi

11 May 2006, 1:58 PM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Cash on delivery max. amount

Don't edit that line of cod.php

Here are some suggested changes to that file that will achieve what you want:

find this section of code:

// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
immediately before it, insert this code:
// disable the module if order value exceeds admin-configured maximum limit
if (zen_not_null(MODULE_PAYMENT_COD_MAX_VALUE) && ($order->info['subtotal'] > MODULE_PAYMENT_COD_MAX_VALUE)) {
$this->enabled = false;
}

now, add this line to the list of configuration keys in the function install() down near the bottom so you can set from admin the maximum order value you want to allow COD payments for:

$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Order Value', 'MODULE_PAYMENT_COD_MAX_VALUE', '500', 'Maximum order subtotal allowed for COD payment. (Leave blank for no upper limit)', '6', '0', now())");

and in the function keys() right at the bottom, change the whole array line to this:

return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER', 'MODULE_PAYMENT_COD_MAX_VALUE');

Once you upload the modified file, you will need to remove the module and reinstall it from Admin > Modules > Payment so the new configuration key is added to the database.

11 May 2006, 2:43 PM
#3
pivey avatar

pivey

Zen Follower

Join Date:
Mar 2006
Posts:
192
Plugin Contributions:
0

Re: Cash on delivery max. amount

Hello bunyip,

that was a 2 min fix!
Thank you for your detailed step by step instructions

I buy you a beer next time you are in Greece :-)

Thanks again
Dimi