Jump to content

.London Domains - £4
Photo

WooCommerce postcode restrictions + Product categories


  • Please log in to reply
2 replies to this topic

#1 Gibson

Gibson
  • Hefty Member
  • Flogging Gibbo
  • 1,812 posts

Posted 01 December 2018 - 14:54

I'm currently working on a Woo project for a client, however, something is stumping me :

 

They have a variety of categories of products, and they are offering free shipping on everything, which makes the shipping nice and simple.

 

However, they have one particular category which is a kind of "sample pack" which they wish to only be able to ship to certain postcodes. I guess because it's not worth their while to shell out loads of shipping on it to certain other areas.

 

I've been scratching my head over this one. I can set up a Shipping Zone, for example, and allow my client to enter in postcode restrictions to it in the admin backend - for the Shipping Zone, that would be "Zone regions - limit by specific zipcode/postcode" under the "Shipping Zones" tab. No problem, this does basically work, by not offering any shipping options to the customer if they are outside of these postcodes.

 

However, how to limit this postcode restriction to only apply to a case where they have a product from the sample pack category in their cart? 

 

I'm fairly at home with writing functions to iterate through cart items and suchlike, but just can't find anything that will work for me here with these postcode restrictions. It seems to be that Woocommerce sets it up to be all or nothing.

 

I don't think that "Shipping Classes" really helps me out here at all either.

 

I've been mucking around a lot with the woocommerce_package_rates filter but as of yet can't get anything to work.

 

Any ideas? Preferably without using a plugin.

 

Cheers.


  • 0

#2 Renaissance-Design

Renaissance-Design
  • Global Mod
  • Code Poet
  • 1,577 posts

Posted 01 December 2018 - 16:15

I can't think of a way to swing it off the top of my head, and this would likely work out cheaper than the dev time to come up with something bespoke.


  • 0

Chris Cox is a freelance web designer & developer based in Bridgend, South Wales. You should definitely follow @RenaissDesign on Twitter.

Was this post helpful? Buy me a beer.


#3 Gibson

Gibson
  • Hefty Member
  • Flogging Gibbo
  • 1,812 posts

Posted 01 December 2018 - 21:06

I can't think of a way to swing it off the top of my head, and this would likely work out cheaper than the dev time to come up with something bespoke.

 

Thanks mate, I did spot that, but have not put it to the client yet (extra cost) - I'll have a proper look at it and see whether it fits our needs.

 

I spent a little while on this, as it goes, but oh well, guess I learned some things in the process about shipping zones and the woocommerce_package_rates filter and so on, so not a complete loss.

 

I was admittedly slightly surprised this doesn't come out of the box, but them's the breaks.


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users