Forum

Thread tagged as: Question, Shop

Setting Tax Location Equal to Specific Value

Hi! I'm back on the TAX issue, my last critical bit...

Right now, I have the customer selecting a COUNTY from a dropdown when they set their address (step 1 in my checkout flow).
I have set up "tax locations" whose titles mirror this COUNTY list.

I know that the tax location is set automatically from the default address when the cart is initialized.

My question is:
Can I somehow point the tax location to equal the value selected for <perch:shop id="shipping_county" /> ?
I essentially want to programmatically set <?php perch_shop_location_form(); ?> by passing in the value <perch:shop id="shipping_county" /> . This value would be equal to the title of a tax location.

I'm not sure how I might set this up, any guidance is greatly appreciated -- might PerchSystem::set_var() be of any use?

Olympia Kyriakides

Olympia Kyriakides 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'll need to keep an eye on this as it's not officially public API, but:

$ShopRuntime = PerchShop_Runtime::fetch();
$ShopRuntime->set_location_from_address('shipping');

... presuming that shipping is the slug of your shipping address.

Drew, a massive thanks, wow.

I've added this to the top of my order review page, above the stripe token functions. Is this appropriate? Would I have to add it to an app? Create an app? I've not done any APIs before.

It sets the tax to my default location, which is 0%. How would I cause location it to match off with a specific part of the shipping address?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean by part of the address? What do you need to match?

Need to match shipping_county, if one is provided, otherwise charge no tax.

I created multiple shipping locations and named them for the counties in my county-select dropdown (which becomes available if a customer selects a particular state.

I had forgotten about the multiple rates that can be set per location. I could also make the state the location and add multiple counties as rates and match shipping_state to location and shipping-county to rate if that's a better way.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The code I gave matches to the shipping country of the address given.

Can it match to shipping COUNTY --- no "R" in there?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, sorry. It won't at the moment, but I could possibly come up with something once I'm back in the UK tomorrow.

Drew, that would be amazing!! I'm trying to get this thing launched at the end of the week; it's my last big hurdle. <- no pressure :-/ lol. Thank you. You and the Perch team are absolute stars in my life!

Hi Drew! I'm sorry to pester..is this looking like a possibility?

P.s. Just deployed my first perch shop site. So grateful to you guys! What an incredible tool--can't say enough.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm working on it. Release was going to be yesterday, but the time I need to spend answering questions in the forum takes away from development time.