Forums / Built-in Shipping and Payment Modules / Reject Shipping to Certain States depending on cart contents

Reject Shipping to Certain States depending on cart contents

Locked

Views: 1,133

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
20 May 2009, 11:59 PM
#1
net3431 avatar

net3431

New Zenner

Join Date:
Dec 2008
Location:
Phoenix, AZ
Posts:
28
Plugin Contributions:
0

Reject Shipping to Certain States depending on cart contents

Zen 1.3.8
Using UPSXML

I would like to Reject Shipping to Certain States depending on cart contents.

I imagine I might search the cart contents for a key word, like "wine", and then I would block the user from continuing checkout if the shipping destination were any of these states: AL, AK, DE, KS, KY, ME, MD, MI, MS, OK, PA, RI, TN, UT.

I think I can write the php, but if you have any hints or suggestions about the easiest way to access the cart contents from the checkout shipping area I would really appreciate it!

22 May 2009, 3:27 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Reject Shipping to Certain States depending on cart contents

Is this a given group of products_id that cannot ship to a given group of states?

As in, are these always these same states?

And will the group of products_id grow over time?

Are you sure you want to base this on a word in the products_description or ... would you rather base it on the products_id so there would not be any errors?

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!

25 May 2009, 10:27 AM
#3
ebusinessman avatar

ebusinessman

Zen Follower

Join Date:
Jul 2006
Posts:
132
Plugin Contributions:
0

Re: Reject Shipping to Certain States depending on cart contents

set up a keywords group to filter the rejected contents, like "gun, adult, medic..."

when checkout, let the PHP script read content, if found items meets at least one of the filter text, reject shipping.

Should not be hard, but you have to code it.

8 Jun 2009, 7:10 PM
#4
net3431 avatar

net3431

New Zenner

Join Date:
Dec 2008
Location:
Phoenix, AZ
Posts:
28
Plugin Contributions:
0

Re: Reject Shipping to Certain States depending on cart contents

Hi,
I'm not trying to impose my own solution yet. Just trying to find out the most "zen-like" way to add this functionality.

Yes, the state list is static - that is, the products I want to be rejectable are all affected by the same state list.

Yes, the list of affected products will change over time - but a php array would be good enough, I think.

Using product_ID is a good method. I'm a bit confused over what module or class or template to add these changes to.

What php code should I concentrate on? Something where product_id, cart items, and shipping state are all accessable at the same time - or perhaps you can point me to some code where I can see how all these things are accessed.

Thanks

8 Jun 2009, 8:10 PM
#5
kdb04d avatar

kdb04d

New Zenner

Join Date:
Feb 2009
Posts:
35
Plugin Contributions:
0

Re: Reject Shipping to Certain States depending on cart contents

the quickest way I would do it is to add it directly to the checkout_shipping page or other way would be to add it the the shipping module your using in includes/modules/shipping/ but I never had your module your working with and finally the most proper would be to create a class add it to the autloader in the application_top.php. I've never bother with the third seems to much effort.

8 Jun 2009, 8:58 PM
#6
kdb04d avatar

kdb04d

New Zenner

Join Date:
Feb 2009
Posts:
35
Plugin Contributions:
0

Re: Reject Shipping to Certain States depending on cart contents

$check_location = db->execute[$location_query];
$check_location->fields[i]
SESSION['cart']->in_cart($products_none_shippable_by_state))

8 Jun 2009, 10:12 PM
#7
net3431 avatar

net3431

New Zenner

Join Date:
Dec 2008
Location:
Phoenix, AZ
Posts:
28
Plugin Contributions:
0

Re: Reject Shipping to Certain States depending on cart contents

Thanks for the help! I was hoping to stick the code in the checkout_shipping page, simply because I understand the code best there.

kdb04d,
Searching the code I can see that your $location_query is not a real zen var, but is an example variable containing some db query that will produce the shipping state?

I am working on a cart that sells wine (among other products like T-Shirts), and we cannot ship wine to certain states.

So I might loop through my wine product_ids, checking to see if the product_id is in the cart, using your line here:
$wine = SESSION['cart']->in_cart($product_id));

If $wine == true then I need to check the customer's state entered into the checkout_shipping page. If the state is included in the list of states I can't ship to then I have to display the form again, with the error explained.

This might work. Anything I've overlooked?
Thanks again for the tips.