Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / COD only above certain order amount?

COD only above certain order amount?

Locked

Views: 8,746

Results 1 to 20 of 52
This thread is locked. New replies are disabled.
7 Jun 2007, 6:20 AM
#1
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

COD only above certain order amount?

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

8 Jun 2007, 1:21 PM
#2
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

no quick fix or tweak?

8 Jun 2007, 4:09 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD only above certain order amount?

You would need to customize the cod.php and change the $this->enable so that it is only true when the Total >= $XXX.XX ...

14 Jun 2007, 1:45 PM
#4
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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....

14 Jun 2007, 2:47 PM
#5
econcepts avatar

econcepts

Totally Zenned

Join Date:
Dec 2005
Posts:
1,505
Plugin Contributions:
2

Re: COD only above certain order amount?

You want to try something more like this:

	  if (zen_get_shipping_enabled($this->code) and $total_cart >= 100) {
        $this->enabled = ((MODULE_SHIPPING_COD_STATUS == 'True') ? true : false);
		}

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.

14 Jun 2007, 4:08 PM
#6
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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;
}
}
}


14 Jun 2007, 4:27 PM
#7
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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

14 Jun 2007, 5:35 PM
#8
econcepts avatar

econcepts

Totally Zenned

Join Date:
Dec 2005
Posts:
1,505
Plugin Contributions:
2

Re: COD only above certain order amount?

ronwong:

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).

15 Jun 2007, 11:00 AM
#9
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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);
}

15 Jun 2007, 11:27 AM
#10
econcepts avatar

econcepts

Totally Zenned

Join Date:
Dec 2005
Posts:
1,505
Plugin Contributions:
2

Re: COD only above certain order amount?

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.

15 Jun 2007, 1:21 PM
#11
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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'); } } ?>
15 Jun 2007, 3:35 PM
#12
econcepts avatar

econcepts

Totally Zenned

Join Date:
Dec 2005
Posts:
1,505
Plugin Contributions:
2

Re: COD only above certain order amount?

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'); } } ?>
15 Jun 2007, 3:56 PM
#13
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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');
}

}
?>

15 Jun 2007, 4:34 PM
#14
econcepts avatar

econcepts

Totally Zenned

Join Date:
Dec 2005
Posts:
1,505
Plugin Contributions:
2

Re: COD only above certain order amount?

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.

16 Jun 2007, 5:01 AM
#15
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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.

16 Jun 2007, 11:01 AM
#16
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

I cant get it right....
econcepts ... if I could get your kind help again.

16 Jun 2007, 4:19 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD only above certain order amount?

A better way to do this so it can run in both the Catalog and Admin is to find the section that starts with:

    function update_status() {
      global $order, $db;

Then change the following from:

    function update_status() {
      global $order, $db;

to read:

    function update_status() {
      global $order, $db;
      global $cart;

Then change this from:

// disable the module if the order only contains virtual products
      if ($this->enabled == true) {
        if ($order->content_type != 'physical') {
          $this->enabled = false;
        }
      }
    }

to read:

// 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:

16 Jun 2007, 4:50 PM
#18
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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?

16 Jun 2007, 10:55 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: COD only above certain order amount?

Go to your Admin and hit the Modules ... Payments ... notice the error messages? :eek:

17 Jun 2007, 6:13 AM
#20
ronwong avatar

ronwong

Zen Follower

Join Date:
Jan 2006
Posts:
223
Plugin Contributions:
0

Re: COD only above certain order amount?

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;
}