Forum
Add to cart issue in safari
I'm experiencing a very specific issue where my add to cart functionality works in all browsers but Safari. What's more, it works in safari locally but not on the server.
I'm handling the cart with ajax, the debug on my page with the perch_shop_cart()
function is:
Debug Message - Perch 3.0
[1] SELECT * FROM perch2_pages WHERE pagePath='/get-cart.php' LIMIT 1
[26] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] SELECT locationID FROM perch2_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
INSERT INTO perch2_shop_cart(memberID,locationID,currencyID,cartPricing,cartProperties) VALUES(NULL,'1',103,'standard','[]')
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1023
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1023
------------------------------ Calculating cart ------------------------------
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1023
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1023
[1] SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
[1] SELECT locationID FROM perch2_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
[1] SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=103 LIMIT 1
[1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM perch2_shop_cart_items WHERE cartID=1023
Tax mode: inc
[nil] SELECT * FROM perch2_shop_cart_items WHERE cartID=1023 ORDER BY itemID ASC
Using template: /templates/shop/cart/cart.html
Array
(
[type] => 8
[message] => A session had already been started - ignoring session_start()
[file] => /nfs/c12/h04/mnt/213490/domains/yarrows.co.nz/html/perch/addons/apps/perch_shop/lib/PerchShop_Session.class.php
[line] => 15
)
Some googling led me to possible issues with safari cookie policies, curious to know if this has come up before.
It's not something I'm familiar with. You'd do well to update to the current version though.
I've updated, and now I'm no longer experiencing the issue on Safari desktop, however I still have the issue on Safari mobile, I've tested on 3 different iOS devices. I'm guessing it is something to do with
Because that message doesn't show when an item is added successfully to the cart?
I've tried clearing my mobile safari browsing data, but it hasn't fixed it. You can see the page and debug here if you have an iOS device:
www.yarrows.co.nz/fundraisers
Tapping 'Add to basket' on any item should add the item to the basket, however basket is returned empty.
You'd need to give us some insight as to how you've built your shop.
I've had another go at this and found some reference to
session.auto_start=1
in thephp.ini
file which I have now commented out.This has had the effect of removing the error:
However the add to cart still does not work.. This is now specific to safari on iOS and IE 11. All other browsers appear to work.
My cart is set up so that I have a page
add-to-cart.php
which containsand a
get-cart.php
page which containsI use ajax to add items to the cart and then to retrieve the cart.
To add items:
And then to retrieve the cart (
getCartItems()
)Debug message on
get-cart.php
from IE11 (Add to basket not working) - is the problem with the INSERT?Debug message on
get-cart.php
from Safari Desktop (Add to basket working)If I test the
add-to-cart.php
page via using the URLhttps://www.yarrows.co.nz/add-to-cart?item=4&qty=1&update=true
then it works on IE11, the item is successfully added to the cart, so the issue appears to be with then retrieving the cart viaget-cart.php
This can all be tested live on https://www.yarrows.co.nz/fundraisers
If it's specific to certain browsers, you should look at your front end code as the most likely culprit.