Forum
Error when selecting Add to Cart
So I am getting a PHP error when trying to add to or view my cart. I'm sure it's something simple, but as I am not a PHP developer, and this is my first time using Runway and Perch Shop I'm a bit stuck.
The error I am getting is as follows:
Catchable fatal error: Argument 4 passed to PerchShop_Product::get_prices() must be an instance of PerchShop_TaxLocation, boolean given, called in /chroot/home/qof/dev.quilteronfire.com/html/perch/addons/apps/perch_shop/lib/PerchShop_Cart.class.php on line 713 and defined in /chroot/home/qof/dev.quilteronfire.com/html/perch/addons/apps/perch_shop/lib/PerchShop_Product.class.php on line 264
I am using the default cart template, and using <?php perch_shop_cart(); ?>
My guess is that it's something from the Control Panel, but I've selected both a Home and Default Tax location.
I'm hitting "Add to Cart" from my product display page - the code for the template which is here:
<div class="product_view-wrap">
<h1><perch:shop id="title" type="text" label="Title" required="true" order="2" /></h1>
<div class="product_view-flex_wrap">
<div class="product_view-img"><img src="<perch:shop id="image" type="image" width="350" height="350" crop="true" />"></div>
<div class="product_view-copy">
<perch:shop id="description" type="textarea" label="Description" editor="markitup" order="3" markdown="true" size="s" />
<perch:categories id="category" set="products" label="Category">
<perch:category id="catTitle" />
</perch:categories>
<div class="product_view-price_wrap">
<div><strong>Price: </strong><perch:shop id="price" type="shop_currency_value" label="Price" divider-before="Pricing" size="m" min="0" step="any" /></div>
<perch:shop id="tax_group" type="hidden" label="Tax group" />
<div><strong>Stock Status:</strong> <perch:shop id="stock_status" type="shop_stock_status" label="Stock status" divider-before="Stock" required="true" /></div>
<div class="product_view-shipping_info">
<perch:shop id="weight" type="number" label="Shipping weight" size="s" />
<perch:shop id="width" type="number" label="Width" size="s" />
<perch:shop id="height" type="number" label="Height" size="s" />
<perch:shop id="depth" type="number" label="Depth" size="s" />
</div>
<div class="product_view-cart_wrap">
<perch:form id="add_to_cart" app="perch_shop" action="/cart">
<perch:input id="product" type="hidden" env-autofill="false" value="<perch:shop id="productID" type="hidden" env-autofill="false" />" />
<perch:input type="submit" value="Add to cart" />
</perch:form>
</div>
</div>
</div>
</div>
<div class="product_view-link"><a href="/shop">Back to Shop</a></div>
</div>
My diagnostics report is:
Perch Runway: 2.8.31, PHP: 5.6.24, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, fpm-fcgi
Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), 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: /perch
PERCH_PATH: /chroot/home/qof/dev.quilteronfire.com/html/perch
PERCH_CORE: /chroot/home/qof/dev.quilteronfire.com/html/perch/core
PERCH_RESFILEPATH: /chroot/home/qof/dev.quilteronfire.com/html/perch/resources
Image manipulation: GD
PHP limits: Max upload 50M, Max POST 50M, Memory: 128M, Total max file upload: 50M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: dev.quilteronfire.com
DOCUMENT_ROOT: /home/qof/dev.quilteronfire.com/html
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
My development server URL for the cart is dev.quilteronfire.com/cart where you will be able to see the error code as well.
Let me know if you need any other details, Thank you for your time in advance.
It looks like a tax location hasn't been identified. How do you have things configured?
I have one tax location called Canada, with currently one Tax Rate, titled "GST". And one tax group titled "Federal" with the GST selected.
I have just tried to go for a basic configuration right now.
Do you have tax groups assigned to your products?
Yes, both have the "Federal" tax group selected.
Do you have a tax location set up as your home location? Under Shop > Tax > Locations, one should have a green tick in the Home location column.
Yes the "Canada" location is set up as both the Home and Default location (It is the only location I've created).
Have you changed the locations since the cart was created?
For some reason the tax location isn't being found for the customer. What should then happen is the home location should be used instead. Somehow neither of those is working, which isn't something I've ever seen before.
I have changed the locations, as I was learning how my client charges taxes.
Is there a way for me to "reset" everything and start again? I've tried deleting the locations and adding them again, thinking it may reset what the cart was grabbing. I've also tried deleting the cart page and adding it again.
Try emptying the cart.
Ok, so the cart empties. If I go to the cart page directly. It tells me "Your cart is empty".
It still won't let me add a product though, I get the same error.
If you turn debug on, what does it output at the bottom of the cart page?
When the cart is empty this is what shows up. When I hit add to cart there is no debug because of the PHP error:
Can you try with the current version of Shop?
I've updated Shop and unfortunately still am getting the same error. I've tried using the cart.html template from the new version as well (and saved within the control panel). no change.
Thank you again for trying to help me out here.
Any other thoughts on this and what may be happening here? I'm kind of stuck without being able to add items to the cart.
Do you have any rows in your
perch2_shop_cart
table?Hi Drew,
I essentially cleared out the database tables and started over again with the tax information. It must have been trying to pull deleted tax info, as this fixed the problem. However I can see this running into issues in the future if a client tries to delete/add a tax location or rate.
I also had mentioned this in - forum.grabaperch.com/forum/08-24-2016-broken-cart - but never added my fix on this thread