How do I do this? Say, If your order is above $100, then you can pay by COD, else it wont appear, so you can only pay by other methods?
I am using 1.36
Printable View
How do I do this? Say, If your order is above $100, then you can pay by COD, else it wont appear, so you can only pay by other methods?
I am using 1.36
no quick fix or tweak?
You would need to customize the cod.php and change the $this->enable so that it is only true when the Total >= $XXX.XX ...
Hi, I know nuts on php...
which line should I edit?
would the following additional code work?
-------------------------------------------------
// additonal code
if Total >= $100.00 {
$this->enabled = false;
-------------------------------------------------
Pls assist....
You want to try something more like this:
I don't have the "exact" CONSTANT in front of me for the COD shipping part, but you get the idea. You'll want to replace that with the proper one.PHP Code:
if (zen_get_shipping_enabled($this->code) and $total_cart >= 100) {
$this->enabled = ((MODULE_SHIPPING_COD_STATUS == 'True') ? true : false);
}
did I miss something?? the COD is still shown?
my code
-----------------------------------
// turn off COD for low value
if (zen_get_shipping_enabled($this->code) and $total_cart >= 50) {
$this->enabled = ((MODULE_SHIPPING_COD_STATUS == 'True') ? true : false);
}
// turn off COD for table
if (substr_count($_SESSION['shipping']['id'], 'table') == 1) {
$this->enabled = false;
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
}
-----------------------------------
Hi, what is this MODULE_SHIPPING_COD_STATUS?
Does not appear any where else in any other file.... I am using 1.36, if that matters
That is probably why it isn't working for you. That was just a DEMO variable I used to represent the actual one (which would be in the module you are trying to edit). I do not have that module in front of me so I don't know the exact terminology.
"MODULE_SHIPPING_COD_STATUS" is the Constant that refers back to the language file for that module (cod).
To make it work, you should replace that with the proper constant value (found in that shipping module you are trying to edit).
Hi, this does not work either
------------------------
// turn off COD for low value
if (zen_get_shipping_enabled($this->code) and $total_cart >= 50) {
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
}
-----------------------
I'd have to actually see the page of code you are trying to alter to tell you where to place it and to find out if that code is the exact code you need.
It is the "style" you want to follow though. I used it on a few sites (for shipping etc..) and it worked fine. Again, though, those are different modules.
The following is the standard cod.php file that came with the installation,
'// turn off COD for table' and '// turn off COD for low value' is what I tried to add, both does not work
I really appreciate your help...
--------------------------
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: cod.php 1105 2005-04-04 22:05:35Z birdbrain $
//
class cod {
var $code, $title, $description, $enabled;
// class constructor
function cod() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_COD_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_COD_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_COD_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
// turn off COD for table
if (substr_count($_SESSION['shipping']['id'], 'table') == 1) {
$this->enabled = false;
}
// turn off COD for low value
if (zen_get_shipping_enabled($this->code) and $total_cart >= 50) {
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
}
function javascript_validation() {
return false;
}
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
return false;
}
function before_process() {
return false;
}
function after_process() {
return false;
}
function get_error() {
return false;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
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 ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', 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 of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '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()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER');
}
}
?>
You want it to look like this. As I mentioned in the previous post, the information I sent you was for example only to get you moving in the right direction. You had the wrong variable and did not specify the order total to run your figures against on the page.
--------------------------
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: cod.php 1105 2005-04-04 22:05:35Z birdbrain $
//
class cod {
var $code, $title, $description, $enabled;
// class constructor
function cod() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_COD_SORT_ORDER;
//$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
$total_cart = $_SESSION['cart']->show_total();
if ($total_cart >= 50) {
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
}
if ((int)MODULE_PAYMENT_COD_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_COD_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
// turn off COD for table
if (substr_count($_SESSION['shipping']['id'], 'table') == 1) {
$this->enabled = false;
}
// turn off COD for low value
if (zen_get_shipping_enabled($this->code) and $total_cart >= 50) {
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
}
function javascript_validation() {
return false;
}
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
return false;
}
function before_process() {
return false;
}
function after_process() {
return false;
}
function get_error() {
return false;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
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 ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', 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 of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '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()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER');
}
}
?>
I understand, and I thank you again. I was trying to experiement with it with no knowledge of php. Anyway, it still dont work, this is the full file again. The Cash on Delivery button is still there to click nomatter the total amount is $10 or $100....
------------------------------
?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: cod.php 1105 2005-04-04 22:05:35Z birdbrain $
//
class cod {
var $code, $title, $description, $enabled;
// class constructor
function cod() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_COD_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
//$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
$total_cart = $_SESSION['cart']->show_total();
if ($total_cart >= 50) {
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
}
if ((int)MODULE_PAYMENT_COD_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_COD_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
}
function javascript_validation() {
return false;
}
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
return false;
}
function before_process() {
return false;
}
function after_process() {
return false;
}
function get_error() {
return false;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
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 ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', 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 of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '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()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER');
}
}
?>
You must either be doing something wrong, a setting somewhere in the cart is incorrect, or the session variable is not pulling correctly.
I have that exact code working (for $50 and over to get COD otherwise they do not get that option) on my zen test site without a hitch:
:smile:
EDIT:
In fact, after I just submitted this post I saw your mistake so I am editing it here.
You have the following code:
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
(the above line should NOT be in here).
//$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
$total_cart = $_SESSION['cart']->show_total();
if ($total_cart >= 50) {
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
}
That is incorrect.
You left in the bold variable I show above and in fact, if you look at the code I sent, or copied directly, you'll see I commented that line out with a "//" in front.
You need to remove that line in bold above and it should work just fine.
good grief! You are absolute right! I got it working!
This is a first step. I am actually looking for a more complex setup, I will be trying to play with the codes before I ask for your kind help:
This is the pseudo code:
COD availbale if:
delivery is 'self collect' (all case)
else
availbale if order above $50 only for other delivery methods
---------------------------------------------
My settings"
-Shipping available: Local Van delivery($10), Post(pay stamp), Self collect(free), Free Shipping(free)
-PAyment: Credit card, COD, Check.MO, Bank Transfer
-Free delivery if total order > $30
-Free deliver if chosen leave the option with us to send down by post or van.
I want to limit COD option to orders above $50 because COD obviously means we have to send van down for delivery, so we want to discourange that for small orders ($30-50).
I have done this with your code!
But If people choose self collect, they should have the option to COD even if its $5 total order. Currently these group will not have COD option with this new code.
I am running this site in Singapore, which is a damn small place, so we have local delivery as a very big part of consideration, and COD too.
I cant get it right....
econcepts ... if I could get your kind help again.
A better way to do this so it can run in both the Catalog and Admin is to find the section that starts with:
Then change the following from:PHP Code:
function update_status() {
global $order, $db;
to read:PHP Code:
function update_status() {
global $order, $db;
Then change this from:PHP Code:
function update_status() {
global $order, $db;
global $cart;
to read:PHP Code:
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
}
PHP Code:
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
// disable if total is < 50
if ($_SESSION['cart']->show_total() < 50) {
$this->enabled = false;
}
}
Now this does not break in the Admin and will disable COD if the total is < 50 ... :smile:
Hi Linda, what does it mean when you say break in admin?
After my last post, I actually figured out the quote for my exact requirement
On top of what econcept last gave me, I added the following just before the virtual product lines:
----------------------------------------------------------------
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == true) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'vandelivery') == true) {
$this->enabled = true;
}
-----------------------------------------------------
Earlier I did not managed to get it to work as I had '== 1' instead of '==true', some servers like mine dont like that and does not work.
I want to understand the new codes you suggested. What is the complications I will get if I am doing what I am doing now?
Go to your Admin and hit the Modules ... Payments ... notice the error messages? :eek:
oh yeah, shucks.
It also appear when I open some of the orders with COD..
I will change to your code and try it out.
But how do I also incorporate the other 2 conditions? Would they work with no modification?
------------------------------------
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == true) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'vandelivery') == true) {
$this->enabled = true;
}
------------------------------------
I get this when I try to check out with the new code...
PHP Parse error: parse error in C:\Program Files\Ensim\Sitedata\onlineshop\Inetpub\wwwroot\includes\modules\payment\cod.php on line 150
I did on a clean file and it worked on the basic >50 condition.
But can I also incorporate the other 2 conditions? vandelivery and storepickup?
Hi Linda, your code has problem as well, with a clean cod.php file and your additional codes, its ok on the customer side checkout. It is also ok in admin when I click modules-payment. But when I open the admin-customers-orders, and click to open each order, orders with COD as payment will not open, and there is a line:
PHP Fatal error: Call to a member function on a non-object in C:\Program Files\Ensim\Sitedata\onlineshop\Inetpub\wwwroot\includes\modules\payment\cod.php on line 74
line 74 refers to this line:
if ($_SESSION['cart']->show_total() < 50) {
I have taken out all other codes regarding the other conditions. so its down to the baisc total>50 codes only.
Any idea?
Where exactly are you when you see this error?
I am trying to reproduce it ... :unsure:
hi,
ok, clean unmodified file, then put in your code in cod.php, no other conditions yet. So orders above 50, COD will show, below, COD will not show. I log in as a regular registered customer and tried all the combination of shipping and payment. Works fine.
Now I log into admin.
Modules -> Payment. No error. Your code solved the problem over econcepts original code. Great.
Now the error:
Do a check out transaction with a dummy customer. You can try 2 transaction to compare. One use COD, another use say bank transfer. Both have to be above $50 so that COD is shown?
Log back into admin.
Customers -> Orders
So your new 2 transaction is listed. say 1001 and 1002.
We usually click on the transaction to open it up to see the details, and also to update status etc.
But if the transaction is a COD transaction, it wont show the details, it will show:
PHP Fatal error: Call to a member function on a non-object in C:\Program Files\Ensim\Sitedata\onlineshop\Inetpub\wwwroot\in cludes\modules\payment\cod.php on line 74
and nothing else. I dont believe I did any other customization of any sort.
Odd ... mine is working fine ...
What version Zen Cart are you running?
Make sure that you added that global $cart; at the start of the function as indicated in my changes ... or you will get errors ...
But I just tried this on another installation and still no errors ...
I am on 1.36...
that is very strange.....
I dont think posting the whole cod.php file here will help. Looking at the situation, ie the error on that line occurs when I open a COD transaction in customers-> orders, would it be easier if I troubleshoot what is called when I open an order?
When I mean open an order, I mean click on the particular transaction, it will then be highlighted, the arrow on it, then click again to open the details... all the COD transaction does not work...
Do you have any kind of add-ons or something in the Admin?
I am at wits end. I post my cod file, maybe I am really missing a bracket here or a word there. Red ones are the one I added according to your post. Blue ones are what I will want to add when the red works....
PHP Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: cod.php 1105 2005-04-04 22:05:35Z birdbrain $
//
class cod {
var $code, $title, $description, $enabled;
// class constructor
function cod() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_COD_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_COD_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_COD_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order, $db;
global $cart;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
// disable if total is < 50
if ($_SESSION['cart']->show_total() < 50) {
$this->enabled = false;
}
// turn off COD for post
//if (substr_count($_SESSION['shipping']['id'], 'table') == true) {
//$this->enabled = false;
//}
// turn on COD for storepickup
//if (substr_count($_SESSION['shipping']['id'], 'storepickup') == true) {
//$this->enabled = true;
//}
// turn on COD for delivery
//if (substr_count($_SESSION['shipping']['id'], 'flat') == true) {
//$this->enabled = true;
//}
}
function javascript_validation() {
return false;
}
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
return false;
}
function before_process() {
return false;
}
function after_process() {
return false;
}
function get_error() {
return false;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
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 ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', 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 of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '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()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER');
}
}
?>
sorry, the red and blue highlights does not seem to come out when I put the codes in php brackets.....
NOTE: All of those == true should be an == 1 or == 2 as you are looking for a count ...
Next ... rename cod.php to cod.php_HIDE on your server ...
Now load the original file ... can you use COD?
ok, wait, let me get in a totally clean file again.
Hi Linda,
I did a clean downloaded cod.php, only put in your codes. Test, ok all seems to work like you said.
I guess I messed up along the way.
This has solved part of my requirement.
But the other conditions that I need, how to I incorporate it?
I think you get my idea of the requirement. postal delivery cannot COD for all value, and van delivery/self collect must allow COD for all value..
If I change the ==true to ==1, will it work?
PHP Code:
// turn off COD for post
//if (substr_count($_SESSION['shipping']['id'], 'table') == true) {
//$this->enabled = false;
//}
// turn on COD for storepickup
//if (substr_count($_SESSION['shipping']['id'], 'storepickup') == true) {
//$this->enabled = true;
//}
// turn on COD for delivery
//if (substr_count($_SESSION['shipping']['id'], 'flat') == true) {
//$this->enabled = true;
//}
table == 2
usps == 1
ups == 1
This is count how many times that appears in the id ...
table_table is 2
ups_Express is 1
Hi Linda,
THe <50 worked
Then I added the codes
table works, as COD is not shown when table is choosen and order above $50.PHP Code:
// turn off COD for post
if (substr_count($_SESSION['shipping']['id'], 'table') == 2) {
$this->enabled = false;
}
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == 1) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'flat') == 1) {
$this->enabled = true;
}
But the other 2 does not work.
I 'derived' the '$this->enabled = true' from the table code. But it does not seem to work. Does it not work this way?
For storepickup and flat, COD option should always be on no matter what amount or what type of delivery.....
I believe flat and storepickup are both 2 also ...
Not working....
if I put
I getPHP Code:
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
// disable if total is < 50
if ($_SESSION['cart']->show_total() < 50) {
$this->enabled = false;
}
}
// turn off COD for post
if (substr_count($_SESSION['shipping']['id'], 'table') == 2) {
$this->enabled = false;
}
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == 2) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'flat') == 2) {
$this->enabled = true;
}
}
error on line 88, which is the line if ($_SESSION['cart']->show_total() < 50) {
If I put
I getPHP Code:
// turn off COD for post
if (substr_count($_SESSION['shipping']['id'], 'table') == 2) {
$this->enabled = false;
}
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == 2) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'flat') == 2) {
$this->enabled = true;
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
// disable if total is < 50
if ($_SESSION['cart']->show_total() < 50) {
$this->enabled = false;
}
PHP Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in C:\Program Files\Ensim\Sitedata\onlineshop\Inetpub\wwwroot\includes\modules\payment\cod.php on line 79
So I dont think its just stacking up the conditions... they seem to affect one another...
The customer side/shop front works fine/great. But the admin side does not work. I cant open all the COD transactions in customer-> orders...
the final code I am using now is:
PHP Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: cod.php 1105 2005-04-04 22:05:35Z birdbrain $
//
class cod {
var $code, $title, $description, $enabled;
// class constructor
function cod() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_COD_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_COD_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_COD_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order, $db;
global $cart;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
// disable if total is < 50
if ($_SESSION['cart']->show_total() < 50) {
$this->enabled = false;
}
// turn off COD for post
if (substr_count($_SESSION['shipping']['id'], 'table') == 2) {
$this->enabled = false;
}
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == 2) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'flat') == 2) {
$this->enabled = true;
}
}
function javascript_validation() {
return false;
}
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
return false;
}
function before_process() {
return false;
}
function after_process() {
return false;
}
function get_error() {
return false;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
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 ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', 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 of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '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()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER');
}
}
?>
any kind soul can help on this?
hi any help on this?
Currently the procedure sucks for me, as I need to keep 2 copies of COD.php, and use the modified one so that the customer get the correct conditions when checking out, then I have to upload the default cod quickly and update all my COD transactions, before uploading the modified one again. So there is a 'downtime' where cod is available for the wrong conditions if a customer checks out in that few minutes. Not the way to go....its just some codes somewhere..
any help on this? Or is there a better way to do this?
What I am seeing here is you turn off the COD when < 50 ... but then you change that setting based on the shipping ...
What exactly do you want to happen here as your first check gets overridden later by the second set of checks ...
On the code for the Admin orders to work, change the code slightly:
PHP Code:
if (IS_ADMIN_FLAG) {
$skip_it = true;
} else {
$skip_it = false;
}
if ($skip_it == false) {
// disable if total is < 50
if ($_SESSION['cart']->show_total() < 50) {
$this->enabled = false;
}
// turn off COD for post
if (substr_count($_SESSION['shipping']['id'], 'table') == 2) {
$this->enabled = false;
}
// turn on COD for storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') == 2) {
$this->enabled = true;
}
// turn on COD for delivery
if (substr_count($_SESSION['shipping']['id'], 'flat') == 2) {
$this->enabled = true;
}
} // $skip-it
Apparently, I want all the conditions to be fulfilled. I understand pseudo code, and a bit of vb, but nuts about php, that is why I cant read or see what is happening. If the 2nd condition overrides the first and such, then its not cool, but in any case, I tested the functionality on the cart itself and it seems to fulfill all the combination required at this time. So I guess I can leave it as it is although it is not the best codes.
Thanks a mil ajeh. I wonder why I am the only one requiring hacking at the cod codes... maybe most sides dont use COD that much.
I've solved here:
"assegnato" is shipping option made by me, and I exclude cod for this shipping option.PHP Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: cod.php 1105 2005-04-04 22:05:35Z birdbrain $
//
class cod {
var $code, $title, $description, $enabled;
// class constructor
function cod() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_COD_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_COD_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_COD_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
$upper_value = 500;
if ( ($this->enabled == true) && ( $order->info['total'] > (int)$upper_value) && ( $upper_value != "" ) ) $this->enabled = false;
// escludi il contrassegno per porto assegnato
if (substr_count($_SESSION['shipping']['id'], 'assegnato') == true) {
$this->enabled = false;
}
// disable the module if the order only contains virtual products
if ($this->enabled == true) {
if ($order->content_type != 'physical') {
$this->enabled = false;
}
}
}
function javascript_validation() {
return false;
}
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
return false;
}
function before_process() {
return false;
}
function after_process() {
return false;
}
function get_error() {
return false;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
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 ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', 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 of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '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()) . "')");
}
function keys() {
return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER');
}
}
?>
This value is 1
substr_count($_SESSION['shipping']['id']
You should really use 1 and not true in the IF statement ...
By coincidence true is 1 ... but that is not what you are really asking for in the IF you are asking if the word assegnato appears in the $_SESSION['shipping']['id'] 1 time using the php function substr_count ...
I would take the time to test this properly with the value of 1 instead of the true ...
I've tested with 1 value, but the function don't work, and I don't know what's the value of assegnato shipping option. How can I see this value?
You can try an echo or die statement inside the IF when this is working and see what comes up, such as:
die('I SEE ' . substr_count($_SESSION['shipping']['id'], 'assegnato'));
I'm actually trying to establish the ability to switch off specific flat rate modules, based on the shipping_weight.
Example:
There are different methods of delivery:
1) Regular Mail
2) Registered Mail
3) Courier Service
For items less than 3lbs, I would like to offer the Regular Mail and the Registered Mail options. However, for items above 3lbs, I'd only like to offer Courier Service.
I've cloned the table module 3 times: table.php, reg_table.php and cour_table.php. I've edited the files to ensure that they are able to work side-by-side and all is working magnificently. Unfortunately, I'm not able to put the conditions in place yet.
In the cour_table.php file, I've put the following:
After the IF statement that is followed by:PHP Code:
if ($this->enabled == true) {
if ($shipping_weight < 3) {
$this->enabled = false;
}
}
// disable only when entire cart is free shipping
However, it seems $shipping_weight is not yet recognized.. I've declared $shipping_weight as a global variable for the table function, but whatever I do, $shipping_weight seems to always be 0.. What am I doing wrong?
Also, using the above catch option, I should also be able to edit the table.php and reg_table.php to check if $shipping_weight > 3, then $this->enabled should be false, right?
Appreciate your thoughts and comments!
Nobody any ideas? :((
Try that same logic on table.php to ensure that your logic works ... as you could have other errors in your cloned modules ...