Is there any way I can make certain customer groups have cod as an option, while ordinary customers don't?
I've found the invoice add on (haven't installed it yet, though), but it would be great to have one for cod aswell. :)
Is there any way I can make certain customer groups have cod as an option, while ordinary customers don't?
I've found the invoice add on (haven't installed it yet, though), but it would be great to have one for cod aswell. :)
I don't believe this is available without some coding but I may be wrong and someone may have done it before. it isn't a major change. You need to edit :
modules/payment/cod.php
and insert some of the code from swguys invoice mod.
the function you are going to alter is :
And of the top of my head you are going to change it to:Code: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; } } }
When I say ' off the top of my head' I mean Ihaven't checked this in any way, shape or formCode: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(); } $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'"); if ($this->enabled == true) { $check_flag_group = false; $check = $db->Execute("select group_name from " . TABLE_GROUP_PRICING . " where group_id = '" . $group_query->fields['customers_group_pricing'] . "'"); if ($check->RecordCount() == 1) { $invoice_prefix = "invoice"; $check_prefix = substr($check->fields['group_name'], 0, strlen($invoice_prefix)); if (strcasecmp($check_prefix, $invoice_prefix) == 0) { $check_flag_group = true; } } if ($check_flag == false || $check_flag_group == 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; } } }![]()
Last edited by niccol; 12 Jul 2010 at 08:31 AM. Reason: cut and paste error
Nick
iszent.com
Thanks! :)
How do I link this code to the actual group? Let's say I called the group "COD" for the sake of simplicity. I suppose I would right "COD" in the code somewhere, but where..? *ponders*
Update:
I tried replacing "invoice" with "COD", in $invoice_prefix =, but no luck so far... :)
My understanding is that:
If you leave the code as it is then any group whose group name starts with 'invoice' will be able to use this payment type.
So you need to name your group appropriately.
If you change the prefix to 'COD' any group whose group name starts with COD should be able to use this payment type.
What is the name of the group that you are trying to enable?
Nick
iszent.com
I think that you are misunderstanding. You need to create a group in admin first. Then you add individual customers to that group. If you have done that then what is the name of that group?
Nick
iszent.com
My apologies. When I said 'off the top of my head' earlier it meant that I wasn't testing it. Below is a tested version of that function:
Your group should be called 'COD' or you can change that in the code.Code: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; } } $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'"); $check_flag_group = false; $check = $db->Execute("select group_name from " . TABLE_GROUP_PRICING . " where group_id = '" . $group_query->fields['customers_group_pricing'] . "'"); if ($check->RecordCount() == 1) { $invoice_prefix = "COD"; $check_prefix = substr($check->fields['group_name'], 0, strlen($invoice_prefix)); if (strcasecmp($check_prefix, $invoice_prefix) == 0) { $check_flag_group = true; } } if ($check_flag_group == 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; } } }
Nick
iszent.com
Yay!!! It works!! Thank you!! :)