Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35
  1. #1
    Join Date
    May 2010
    Posts
    222
    Plugin Contributions
    0

    Default Hide local delivery from those who are not local

    I would like to offer local delivery to those living in my city. How can I hide this shipping option from those who do not live in my city?

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

    Default Re: Hide local delivery from those who are not local

    Let's say you wanted to only allow local shipping for: Toronto

    You could customize the Store Pickup storepickup shipping module with:
    Code:
    if (strtoupper($order->delivery['city']) == 'TORONTO') {
        $this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_STOREPICKUP_TEXT_WAY,
                                                       'cost' => MODULE_SHIPPING_STOREPICKUP_COST)));
    }
    Be aware, however, if my customer address is: Cleveland and I set the shipping address to Toronto in the checkout, then go off the checkout_ pages and go to the shipping_estimator ... that will reset my address to Cleveland ... and I will have to reset my shipping to my Toronto address when I get to checkout_shipping ...

    If, however, I change in the checkout_shipping to my Toronto address then leave the checkout_ pages but do not touch the shipping_estimator then my address will stay as Toronto and I will not have to reset this ...

    So far, I tried this as a customer that needed to add the new address while in the checkout_shipping and as an existing customer with that address ...

    NOTE: if someone cannot spell their City exactly right there will be no way to do the match ...

    NOTE: be sure to write the city name in all CAPS as you do not know what the customer might use so their city is forced to caps for the logic of the IF ...
    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: v1.5.5]
    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!

  3. #3
    Join Date
    May 2010
    Posts
    222
    Plugin Contributions
    0

    Default Re: Hide local delivery from those who are not local

    Thank you for the reply.

    I am a little confused, though. Am I adding this PHP code to the end of the shpping module? Also, what exactly did you mean by the rest of your post? I am sorry, but I did not really understand that part.

    Thank you!

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

    Default Re: Hide local delivery from those who are not local

    If you look in the code for the file:
    /includes/modules/shipping/storepickup.php

    around lines 92 - 96 ...

    you will see that it currently reads:
    Code:
        $this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_STOREPICKUP_TEXT_WAY,
                                                       'cost' => MODULE_SHIPPING_STOREPICKUP_COST)));
    The code I posted is adding an IF statement around the existing code to test the Order Delivery City name ... in this case it tests for the city TORONTO ...

    If you want that to be: PEORIA then you would change TORONTO to PEORIA ...


    As far as the additional information, I was just explaining that if you are testing for the city:
    PEORIA

    and the customer spells it:
    peioria

    due to a typo ... it will not work and not show for them ...

    The reason the code uppercases their city for the test is you do not know how they will add it ...
    Peoria
    peoria
    PeOria
    PEORIA

    so by testing it with uppercase you do not have to worry ...
    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: v1.5.5]
    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!

  5. #5
    Join Date
    May 2010
    Posts
    222
    Plugin Contributions
    0

    Default Re: Hide local delivery from those who are not local

    Perfect, thank you. One last question: where would I put this for the template override system? I tried /includes/modules/my_template/shipping/storepickup.php and /includes/modules/shipping/my_template/storepickup.php, but neither worked.

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

    Default Re: Hide local delivery from those who are not local

    Glad to hear that you use the templates and overrides ...

    Unfortunately, the Shipping Modules do not use overrides on the CODE files ...

    NOTE: the Shipping Modules DO use the overrides on the LANGUAGE files ...
    /includes/languages/english/modules/shipping

    /includes/languages/english/modules/shipping/your_template_dir


    This is the same with Payment Modules and Order Total Modules ...
    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: v1.5.5]
    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!

  7. #7
    Join Date
    May 2010
    Posts
    222
    Plugin Contributions
    0

    Default Re: Hide local delivery from those who are not local

    Quote Originally Posted by Ajeh View Post
    Glad to hear that you use the templates and overrides ...
    Yup. It is so much easier to upgrade when you use them. I wish more people did.

    Sorry, I lied. I have one more question. How can I make it so it appears for multiple cities? I live in a city with several small towns near it, so I would like to offer them this option too.

    Thank you!

    EDIT: Can I put this edit into the shipping language file or does this have to go in the code file?

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

    Default Re: Hide local delivery from those who are not local

    You are changing the file:
    /includes/modules/shipping/storepickup.php

    I have altered the code so you can add additional cities ...

    Currently, the function quote looks like:
    Code:
      function quote($method = '') {
        global $order;
    
        $this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_STOREPICKUP_TEXT_WAY,
                                                       'cost' => MODULE_SHIPPING_STOREPICKUP_COST)));
    
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
    
        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
        return $this->quotes;
      }
      /**
    This is what the function quote should look like when done adding this change:
    Code:
      function quote($method = '') {
        global $order;
    
    if (in_array(strtoupper($order->delivery['city']), array('TORONTO', 'TAMPA'))) {
        $this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_STOREPICKUP_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_STOREPICKUP_TEXT_WAY,
                                                       'cost' => MODULE_SHIPPING_STOREPICKUP_COST)));
    }
    
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
    
        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
        return $this->quotes;
      }
      /**
    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: v1.5.5]
    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!

  9. #9
    Join Date
    May 2010
    Posts
    222
    Plugin Contributions
    0

    Default Re: Hide local delivery from those who are not local

    Thank you so much. Can I add more than two cities?

  10. #10
    Join Date
    Mar 2006
    Location
    Fresno, California
    Posts
    620
    Plugin Contributions
    0

    Default Re: Hide local delivery from those who are not local

    From glancing at the code, yes you can. Just keep adding cities like this:

    HTML Code:
    if (in_array(strtoupper($order->delivery['city']), array('TORONTO', 'TAMPA', 'SACRAMENTO', 'PHOENIX')))

 

 
Page 1 of 4 123 ... LastLast

Similar Threads

  1. How to link local delivery with local taxes
    By germerican in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 0
    Last Post: 2 Jul 2010, 06:29 PM
  2. Local Delivery
    By Crusty Baker in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 5 Feb 2008, 01:19 AM
  3. Local Delivery
    By caradelrae in forum Addon Shipping Modules
    Replies: 4
    Last Post: 18 Oct 2006, 09:12 AM
  4. Local Delivery by ZIP?
    By TSH4Life in forum Addon Shipping Modules
    Replies: 2
    Last Post: 18 Oct 2006, 09:08 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR