oh dear.... my mistake...
when posting on the board, i am a BIG of using bb code tags. there is link at the bottom of every board page for BB code and it's very helpful for me, especially when posting code.
you have a bit of a learning curve.
i have never used group pricing; the table seems part of the base ZC code; although i can not tell if you are using the following plugin:
https://www.zen-cart.com/downloads.p...=154&styleid=2
which is neither here nor there.
the only useful SESSION variable available to you is the customer_id. this refers only to a particular customer. it is a number. the group that the particular customer is in is NOT available in the SESSION variables.
i do not see customers_whole or customers_group_pricing being set as part of the user session. which explains the results you see. 0 is the same as false or not set (or something a little more specific, which is not really relevant to our conversation).
during the _construct function in the COD class, there is a global variable called $order and specifically an array called $order->customer. when i look at that array on my heavily modified test system, the group pricing variable is also not there.
what to do??
so many choices:
- we can add the group pricing variable to the SESSION.
- we can add the group pricing variable to the order class. the most elegant way would be to make it part of a new observer class. that way when you upgrade you are not modifying the core order class code.
- we can add a function in the COD class to determine the group the customer is in; and keep it all here. this involves modifying core code, but you are already doing that for this selection.
i'm sure there are other ways to skin this cat, but i'll show you option 3, and then you can figure out what you want to do.
here is modified COD class. you will need to bring this change along with you whenever you do an update.
PHP Code:
// class constructor
function __construct() {
global $order;
$this->code = 'cod';
$this->title = MODULE_PAYMENT_COD_TEXT_TITLE;
$this->description = MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
$this->sort_order = defined('MODULE_PAYMENT_COD_SORT_ORDER') ? MODULE_PAYMENT_COD_SORT_ORDER : null;
$this->enabled = (defined('MODULE_PAYMENT_COD_STATUS') && MODULE_PAYMENT_COD_STATUS == 'True');
// only allow certain groups to use COD.
$allowed_group_classes = array('1', '2', '3', '4');
if (!in_array($this->get_group_price($_SESSION['customer_id']), $allowed_group_classes)) {
$this->enabled = false;
}
if (defined('MODULE_PAYMENT_COD_ORDER_STATUS_ID') && (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 get_group_price($customer_id) {
global $db;
$query = "SELECT customers_group_pricing from " . TABLE_CUSTOMERS . " WHERE customers_id = " . (int)$customer_id;
$group_price = $db->Execute($query);
return $group_price->fields['customers_group_pricing'];
}
function update_status() {
global $order, $db;
...
good luck.
Bookmarks