Zen Cart Disable Purchase of Products Based on Shipping Zone

Your zen cart store sells a wide variety of products. Some of these products you do not want to ship to certain zones. This Easy Help Zen Cart Tutorial swill show you how to disable the purchase of certain products based on the shipping zone of the purchaser.

In your favorite plain text editor open the includes/modules/shipping/zones.php file. This is a zen cart core file so be sure to back it up and make a note that you have changed the file for future upgrades.

Find this:


     $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => $shipping_method,
                                                     'cost' => $shipping_cost)));

Change it to:


// check cart for Zone 2
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('products_id','115');
$chk_cat += $_SESSION['cart']->in_cart_check('products_id','112');
echo '$dest_zone: ' . $dest_zone . ' $chk_cat: ' . $chk_cat . '<br />';
if ($dest_zone == 2 and $chk_cat > 0) {
  echo '<br />Products blocked in cart! ' . $chk_cat . '<br />';
} else {
      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => $shipping_method,
                                                     'cost' => $shipping_cost)));
}

      if ($this->tax_class > 0) {

Now, Zone 2 will not display if products_id 115 or 112 are in the cart.

If you need additional Products, just add another line, with the products_id:


$chk_cat += $_SESSION['cart']->in_cart_check('products_id','XXX');

Where XXX is the products_id.

If you need help with your zen cart web site please contact us for a quote.

Picaflor Azul specializes in responsive zen cart design. Contact us to convert your current zen cart to a responsive design, or to have a fantastic new custom design made just for your business.

zen cart plus picaflor azul equals success

Leave a Reply