Results 1 to 10 of 12

Hybrid View

  1. #1
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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:
    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:
    Code:
    // 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:
    Code:
    $chk_cat += $_SESSION['cart']->in_cart_check('products_id','XXX');
    
    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!

  2. #2
    Join Date
    Mar 2011
    Posts
    101
    Plugin Contributions
    0

    Default 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?

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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:
    Code:
    $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!

  4. #4
    Join Date
    Mar 2011
    Posts
    101
    Plugin Contributions
    0

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

    Many thanks, I shall give it a try.

  5. #5
    Join Date
    Jul 2017
    Location
    West Midlands, UK
    Posts
    50
    Plugin Contributions
    1

    Default 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

  6. #6
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default 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:
    Code:
    unset($_SESSION['restricted_cat']);
    Then where the "error" message is echoed, instead use:
    Code:
    $_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:
    Code:
    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.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2017
    Location
    West Midlands, UK
    Posts
    50
    Plugin Contributions
    1

    Default 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

 

 

Similar Threads

  1. How can disable the checkbox for the shipping zone ?
    By dmagic in forum General Questions
    Replies: 4
    Last Post: 31 Mar 2014, 04:31 PM
  2. Zone shipping charging rate from zone 3 to zone 1
    By John Zwikstra in forum Built-in Shipping and Payment Modules
    Replies: 21
    Last Post: 28 Dec 2009, 01:10 PM
  3. Zone shipping charging rate from zone 3 to zone 1
    By John Zwikstra in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 1
    Last Post: 6 Aug 2009, 04:32 PM
  4. with zone shipping rates can certain states be excluded?
    By Gerk in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 8 Jun 2006, 06:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg