Forum

Thread tagged as: Question, Shop

Need advice on shipping options

I have my Perch shop 95% done - I'm just stuck on the shipping arrangements. My client delivers all over the country, but does free local deliveries. So, I'm needing a way to check the customer postcode and if it's in a certain range (2780 to 2786) then offer the option of a free personal delivery.

I could maybe do this using if statements in method_form.html, but I am having trouble working out how to juggle the options. At the moment it's just calling <perch:shop id="shippings_list" /> but I can find nothing in the docs about this. Does each shipping method have its own id?

Happy to hear any suggestions about the best way to do this. Another option might be to add max-postcode and min-postcode fields into the shipping method pages in the admin section but again I don't know how to manipulate these either.

Alan Coggins

Alan Coggins 0 points

  • 2 years ago

OK - I have made some progress. I have found the individual tags for the shipping methods - eg id="form1_shipping1", id="form1_shipping2", etc. So I can make up different shipping method templates and call the appropriate one, depending on the postcode.

But I still can't find any neat way to retrieve the postcode that is entered into the passwordless login form. The only thing I have got working is to set a slug onto the url for the next step (so shipping.php?postcode=2780).

Ah.. finally found the solution! This does the trick...

$postcode = perch_shop_order_addresses([], true);

I had to change the template to just show the postcode id and now it returns a value I can use to display the shipping options relevant to the customer's location.

I don't really understand this ([], true) syntax though.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Alan,

If you are only shipping in one country, you can add states/regions as new "countries" via the control panel. Then you can create a shipping zone for the local state/region. This method was discussed here: https://forum.grabaperch.com/forum/06-07-2018-custom-shipping-zones-for-states

if you still need to do it based on postcode, you can create a promotion that applies free shipping and programmatically apply the promotion if the shipping address is eligible:

perch_shop_set_discount_code('xyz');

Thanks for the reply Hussein,

This is my first attempt at Perch shop so I'm still trying to get my head around all the possible approaches. I had a major setback when all the addresses suddenly stopped displaying, until I realised that it was because I had removed "country" as an option in the sign up form. Apparently country is a necessary requirement, so I have set that to default to Australia and I was planning to just hide it.

I'l check out your suggestion. That might be a better option.

Cheers!