Reputation: 776
I'm wondering if anybody has any ideas on how I could go about this. I have a woocommerce store that has just two shipping zones: one for local customers, one for out of area. Essentially I have a set of postal code matches in the 'local' zone. Everything works just fine on checkout, and the right zone displays.
The issue is, however, my client would like the delivery charge displayed on the checkout total to appear as the 'local' delivery rate by default. Generally, when a customer lands on the checkout, they don't have the shipping details filled in, and so their zone defaults to 'Rest of World' - which is a flat shipping rate for us. The rate there is turning some customers off, who just don't realize they need to put in their address to see the local rate. I'm wondering if there's a way to simply display the local delivery rate here until the address finds the local zone, and any ideas would be greatly appreciated.
I thought of just changing this with javascript. The issue is though, that when the shipping rate changes, so does the tax/total, and I really don't want to get into calculating that stuff myself. I can't seem to find any hook woocommerce exposes to let me filter the shipping zone. Even a hook that would let me put in a dummy postal code for shipping zone lookup would be great
Thanks in advance to anyone who can help.
Upvotes: 1
Views: 1129
Reputation: 71
You can achieve this by overriding the default using the filter default_checkout_country
, default_checkout_state
and default_checkout_postcode
.
For Country:
add_filter( 'default_checkout_country', 'change_default_checkout_country' , 10, 2);
function change_default_checkout_country($country, $status) {
return 'US';
}
Upvotes: 0