I hunted through the code and possible changes for this and found a way to make this happen if the idea is only those with a shipping address with the country_id of 222 is what you want to be able to have the discount quantities ...
1 Guests would NOT see the discount quantities when added to the cart (this could be done so that they can, but I have not looked to see if that complicates things)
2 Discount quantities would initially show if the customer's default address is countries_id 222
3 When the shipping address is changed either to countries_id 222 or another country on the checkout_shipping a message will show on the checkout_payment page saying discounts available/not available
There are quite a few steps to this, so I hope not to mess up the first time listing them ...
Edit the file:
/includes/modules/pages/login/header_php.php
and add the code in RED around line 85:
Code:
$_SESSION['customer_country_id'] = $check_country->fields['entry_country_id'];
$_SESSION['customer_zone_id'] = $check_country->fields['entry_zone_id'];
// bof: set shipping country for discount quantity
$_SESSION['ship_to_customer_country_id'] = $check_country->fields['entry_country_id'];
// eof: set shipping country for discount quantity
$sql = "UPDATE " . TABLE_CUSTOMERS_INFO . "
Edit the file:
/includes/functions/functions_prices.php
and edit the code for the function zen_get_products_discount_price_qty and add the code in RED:
Code:
$display_specials_price = zen_get_products_special_price($product_id, true);
switch ($products_query->fields['products_discount_type']) {
// bof: set shipping country for discount quantity
case ($_SESSION['ship_to_customer_country_id'] != 222):
//no discount applies
$discounted_price = zen_get_products_actual_price($product_id);
break;
// eof: set shipping country for discount quantity
// none
case ($products_discounts_query->EOF):
Edit the file:
/includes/modules/pages/checkout_shipping/header_php.php
and add the code in RED:
Code:
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
// bof: set shipping country for discount quantity
$_SESSION['ship_to_customer_country_id'] = $order->delivery['country_id'];
if ($_SESSION['ship_to_customer_country_id'] !=222) {
// not company for discount
$messageStack->add_session('checkout_payment', 'DISCOUNTS NOT VALID FOR SHIPPING DESTINATION', 'caution');
} else {
$messageStack->add_session('checkout_payment', 'DISCOUNTS ARE VALID FOR SHIPPING DESTINATION', 'success');
}
// eof: set shipping country for discount quantity
// register a random ID in the session to check throughout the checkout procedure
I would then, using your templates and overrides, edit the code for:
/includes/templates/template_default/templates/tpl_modulesproducts_quantity_discounts.php
Code:
<?php
if ($disc_cnt < $columnCount) {
// bof: set shipping country for discount quantity
?>
<td align="center" colspan="<?php echo ($columnCount+1 - $disc_cnt)+1; ?>"><span class="alert">DISCOUNTS FOR UK SHIPPING ONLY </span></td>
<?php } // eof: set shipping country for discount quantity ?>
</tr>
<?php
if (zen_has_product_attributes($products_id_current)) {
?>
<tr>
In theory, this will allow Discount Quantities for ALL Products only for the UK country_id 222 ... and as the shipping address is changed in the checkout_shipping, or if the customer logs in to an account with the Primary address as the UK, it will switch it on/off ...
Bookmarks