hi any help on this?
Printable View
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!