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?
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?
Let's say you wanted to only allow local shipping for: Toronto
You could customize the Store Pickup storepickup shipping module with:
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 ...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))); }
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!
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!
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:
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 ...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)));
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!
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.
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!
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?
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:
This is what the function quote should look like when done adding this change: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; } /**
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!
Thank you so much. Can I add more than two cities?
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')))
Bookmarks