Forum
Tax Location not Setting
Hello,
We've been in the process of bringing our first Perch Shop website live. Currently, most of the checkout process is complete, with exception for proper tax calculations.
In the backend, we have a couple Tax locations setup, but the front-end form for selecting a Tax location doesn't seem to work.
Here's the IF statement for the checkout page:
if(!perch_member_logged_in())
{
perch_shop_registration_form(array('template'=> 'checkout/customer_create_passwordless.html'));
}
else if (!perch_shop_addresses_set())
{
perch_shop_customer_addresses();
perch_shop_order_address_form();
}
else if (!perch_shop_location_selected()) {
perch_shop_location_form();
}
else
{
perch_shop_customer_addresses();
perch_shop_cart([
'template' => 'cart/cart_overview.html'
]);
//...
}
When the location form submits, it returns to the same page, with the correct value selected; but it still shows the location selection form; which means the perch_shop_location_selected returned false - so there's no location selected.
Is the call order correct here? Or would we have to do the registration form before the location selection?
Here's the basic diagnostic:
Perch: 2.8.29, PHP: 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_forms (1.8.3), perch_shop_orders (1.0.6), perch_shop_products (1.0.6), perch_shop (1.0.6), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_members', 'perch_shop' );
PERCH_LOGINPATH: /admin
PERCH_PATH: /var/www/vhosts/www.thesite.com/httpdocs/admin
PERCH_CORE: /var/www/vhosts/www.thesite.com/httpdocs/admin/core
PERCH_RESFILEPATH: /var/www/vhosts/www.thesite.com/httpdocs/admin/resources
Image manipulation: GD Imagick
PHP limits: Max upload 256M, Max POST 256M, Memory: 512M, Total max file upload: 256M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: site.dev
DOCUMENT_ROOT: /var/www/vhosts/www.thesite.com/httpdocs
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Thanks in advance for any assistance!
Is the tax location not already being set from the address?
It doesn't seem to be, I'm not sure how it would set properly anyway because our Tax Locations are named based on the Provinces here in Canada. So unless there's some sort of comparison made in the Perch code that checks the address Province field against the tax location names, I don't think there would be an automatic association. Is this not correct?
On second thought, which form would be used to set the tax location (besides perch_shop_location_form); the perch_shop_registration_form?
Ah, ok, that would make sense then.
What does debug output when you submit the form?
Here's the perch2_shop_cart row:
It looks like it's using location
2
- does that seem right?Yes, the id does change in the database as I submit the form.
ID 2 is for BC, which is correct. Currently we only have 2 Locations setup for testing; here's the values from perch_shop_location_form <perch:showall/>:
On a second note; I just searched through the code for 'location_set_by_user', it's defined and set to false in PerchShop_Runtime.class.php, but doesn't seem to be assigned to another value anywhere else in the code. Could this be the problem?
From what you're saying it sounds like setting the location is working. Is that right?
Setting the location seems to work; but Perch doesn't seem to realize that it's set. perch_shop_location_selected() returns false every time it's called, as the value returned within it (location_set_by_user) is never updated (unless it's being set somewhere in the code where location_set_by_user cannot be found by a plaintext search).
Ok, that's far less worrying. I'll take a look at it.
I think this should be fixed in 1.0.7 when it's available.