Forums / Built-in Shipping and Payment Modules / Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Started by gsh68 on 29 Sep 2012, 4:42 PM · Views: 2,922

Results 1 to 12 of 12
29 Sep 2012, 4:42 PM
#1
gsh68 avatar

gsh68

Zen Follower

Join Date:
Mar 2011
Posts:
103
Plugin Contributions:
0

Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Store is UK based.

I have 2 products which due to their size and/or weight cannot ship internationally by standard Royal Mail services and so I must get courier quotes for those items. Technically they could ship by RM or Parcelforce however the cost would be extremely high and would lose me customers. Providing third party courier quotes is the preferred option.

When customers from Europe select one of these products, the shipping rates shown states
Available Shipping Methods Zone Rates (Shipping rate cannot be determined at this time - please contact for a shipping quote) Rates £0.00
This is as expected (I edited the files so this message would show).
However, they can still continue the checkout process and pay, using both Paypal Express and the regular checkout.
This of course causes confusion and upset customers when I contact them for additional funds.

Is there a way that I can ensure that international customers cannot complete checkout when these two products are in the cart so they must contact me for a quote?
(I have been contemplating the Ceon Advanced Shipping module however I don't know if that module can do this either)

I am using Zone Rates for shipping, Calculation Method Weight
Zone 1 - GB
Zone 2 - Europe
I have set my Zone Table weights for Zone 2 so that these products are heavier than any designated weight/charge.

I offer free shipping on items of £20 and over in the UK. Both these products are over £20
admin/modules/order total/shipping/
Free Shipping For Orders Over £19.99
Provide Free Shipping For Orders Made national

I previously used Request International Quote modules but as the majority of my products can ship by regular mail this is really not required and puts international customers of small items off. The modules are still installed but disabled.

Any help would be most appreciated.

29 Sep 2012, 7:01 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

As far as disabling a particular shipping module, regardless of products ...

With all shipping and payment modules, you can set up a Zone Definition and use that as a restriction tool to allow any particular module to only work if the customer is inside that zone.

So, if you go to Admin->Locations/Taxes->Zone Definitions, and create a zone there (create the zone, then click the Details button and assign countries and/or states/provinces/etc associated with that specific country for which you want the module to work), and then go into your shipping module and set the Shipping Zone pulldown to use that defined zone, then that shipping module will only work if the customer's shipping address falls inside that zone definition's defined region.
If their address falls outside that region, then that shipping module won't give any quotes back at all, and thus they won't see a "0.00" option such as you mentioned, thus minimizing the confusion you were talking about.

Caution: don't confuse the word "zone" as used inside the module with how it's used in the Zone Definitions screen. The Zones shipping module defines shipping zones differently than the storewide zone definitions I talked about above.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

29 Sep 2012, 7:28 PM
#3
gsh68 avatar

gsh68

Zen Follower

Join Date:
Mar 2011
Posts:
103
Plugin Contributions:
0

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Thanks for the reply.

I have defined a zone for Europe in Admin->Locations/Taxes->Zone Definitions
However I do not have a Shipping Zone Pulldown in the Zone Rates module - I have manually added the countries in the Zone 2 Countries box.
(I will be adding 2 more zones for the rest of the world when I have fixed this issue)
Any countries not included in the Zone 2 Countries box receive no shipping quote, and if logged in cannot progress further. (I have yet to test with a non-registered/logged in customer using Paypal Express button for a country outside the defined zones.)

I want to exclude the ability for international customers to checkout and pay when either of 2 specific items are in the cart (both items are in their own category).
I want them to be able to checkout when their cart has anything but the 2 specific items as I have set my Zone Table weights accordingly - weights/prices up to 1.98lb are defined. Both items are over 2lbs.

At the moment they can check out and pay 0.00 shipping when these items are in their cart.

29 Sep 2012, 10:39 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

My prior post wasn't addressing the idea of isolating any of this to particular products. Merely to restricting based on address.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Oct 2012, 10:40 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

You could customize the code for:
/includes/modules/shipping/zones.php

and check the content in the cart and the Zone being used by changing the code:

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

to be:

[B]// 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 {
[/B]      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => $shipping_method,
                                                     'cost' => $shipping_cost)));
[B]}[/B]

      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:

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

where XXX is the products_id ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

8 Oct 2012, 8:38 AM
#6
gsh68 avatar

gsh68

Zen Follower

Join Date:
Mar 2011
Posts:
103
Plugin Contributions:
0

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Thanks - that looks like what I'm after.
Could I set it for categories rather than product ids?

8 Oct 2012, 1:19 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

If you are using categories_id that are the master_categories_id then you can use:

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

where XXX is the master_categories_id of the Products ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

8 Oct 2012, 3:02 PM
#8
gsh68 avatar

gsh68

Zen Follower

Join Date:
Mar 2011
Posts:
103
Plugin Contributions:
0

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Many thanks, I shall give it a try.

18 Jul 2017, 3:00 PM
#9
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Hi,
We have been using Zen Cart for several years and now wish to sell into Europe. Some of our products are only available for delivery within the UK.

I have tried the code suggested by Ajeh but the error message appears at the top of the tpl_checkout_shipping page and affects the display of the header.

Would it be possible to reference the variable $chk_cat in the tpl_checkout_shipping page around line 73?

Below is an example of what I have tried to add to the tpl_checkout_shipping page but I can’t get the desired results:

<?php if ($chk_cat > 0) { ?> <div id="checkoutShippingContentChoose" class="important"><?php echo TEXT_ZONES_PRODUCTSRESTRICTED; ?></div> <?php } ?>

The suggested code from post #5 is working very well at restricting certain products from being delivered overseas, it is just where the error message displays which I would like to change. Any advice would be much appreciated.
Zen Cart Version: 1.5.5 upgraded from 1.3.9

Many thanks
Richard

19 Jul 2017, 11:08 AM
#10
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

A way I can see this possible is through the use of a $_SESSION variable. The echo that is identified in post 5 pushes content to the page before other processing which is somewhat what is causing the alignment problem. But, if a session variable were used, then the "error" could be stored and then on the applicable page(s) the result displayed as desired.

So at the point where the $cat_id is set to zero, add an additional line either above or below like:

unset($_SESSION['restricted_cat']);

Then where the "error" message is echoed, instead use:

$_SESSION['restricted_cat'] = {error_message};

Where {error_message} is whatever text is there currently as part of the echo. This could also be used to store "data" that is to be retrieved on the other end like an array of the product/categories, or whatever.

Then wherever it is desired to be displayed, your if statement would be:

if (isset($_SESSION['restricted_cat']) {

And you could then echo whatever you want to echo based on that condition.

Further, in this process, if the cart contents change, the message should also be updated/reflect the condition.

Just a thought. :P

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Aug 2017, 4:58 PM
#11
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

Hi,
Many thanks for your response mc12345678. It sounds as though using a $_SESSION variable would be the best way to sort this issue out.

I have tried altering the code to include your suggestions but I always end up with the same result – the page breaks and displays nothing below the point where I have altered the code.

If you could clarify where I should be adding the additional code it would be much appreciated.

I have just made a donation to the Zen Cart team as the service and support is excellent. If you or other Zen Cart users can help me get this working I would be happy to make a donation to the individual of £50.

Many thanks
Richard

7 Aug 2017, 6:05 PM
#12
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Zone shipping - Can I disable purchase of certain items based on a shipping zone?

richard7315:

Hi,
Many thanks for your response mc12345678. It sounds as though using a $_SESSION variable would be the best way to sort this issue out.

I have tried altering the code to include your suggestions but I always end up with the same result – the page breaks and displays nothing below the point where I have altered the code.

If you could clarify where I should be adding the additional code it would be much appreciated.

I have just made a donation to the Zen Cart team as the service and support is excellent. If you or other Zen Cart users can help me get this working I would be happy to make a donation to the individual of £50.

Many thanks
Richard

Well, looking over the provided code again: if (isset($_SESSION['restricted_cat']) {

Is missing a right parenthese:
if (isset($_SESSION['restricted_cat'])) {

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...