Forum

Thread tagged as: Problem, Shop

Add to Cart

Hi,

I'm setting up Perch Shop and am having issues with the add to cart button. If the quantity is set to 1 on the product page the cart shows as empty but if it is any more than 1 it adds perfectly?

product debug

Debug Message - Perch 3.0.12
[37] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/easyphp/jade/designer outdoor lighting 2018/product.php' LIMIT 1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=66
------------------------------ setting loc from adr default ------------------------------
default
[1] SELECT * FROM perch3_shop_cart WHERE cartID=66
Using cart from cache.
[1] Using template: \templates\shop\cart\mini-cart.html
[1] SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch3_shop_index idx JOIN perch3_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch3_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='slug' AND idx.indexValue='test-test')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, productID ) as tbl WHERE (productDeleted IS NULL AND productStatus=1 AND parentID IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
[nil] SELECT * FROM perch3_shop_products WHERE parentID IN ('1') AND productDeleted IS NULL
[1] Using template: \templates\shop\products\product.html
[1] SELECT * FROM perch3_shop_currencies WHERE currencyID=47 LIMIT 1
[1] SELECT * FROM perch3_shop_tax_groups WHERE groupID='1' AND groupDeleted IS NULL LIMIT 1

product template


<!-- breadcrumbs --> <div class="breadcrumbs"> <div class="container"> <ol class="breadcrumb breadcrumb--ys pull-left"> <li class="home-link"><a href="index.php" class="icon icon-home"></a></li> <li><a href="shop.php">Shop Online</a></li> <li class="active"><perch:shop id="title" type="text" label="Title" required="true" order="2" /></li> </ol> </div> </div> <!-- CONTENT section --> <div id="pageContent"> <section class="content offset-top-0"> <div class="container"> <div class="row product-info-outer"> <div class="col-sm-12 col-md-12 col-lg-12 col-xl-12"> <div class="row"> <div class="col-sm-6 col-md-6 col-lg-4 col-xl-4 hidden-xs"> <div class="product-main-image"> <div class="product-main-image__item"><img class="product-zoom" src='<perch:shop id="image" type="image" label="Main product image" order="4" width="533" />' data-zoom-image="<perch:shop id="image" type="image" label="Main product image" order="4" width="533" />" alt="" /></div> <div class="product-main-image__zoom"></div> </div> <div class="product-images-carousel"> <ul id="smallGallery"> <li><a href="#" data-image="<perch:shop id="image" type="image" label="Main product image" order="4" width="553" />" data-zoom-image="<perch:shop id="image" type="image" label="Main product image" order="4" width="533" />"><img src="<perch:shop id="image" type="image" label="Main product image" order="4" width="533" />" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-2.jpg" data-zoom-image="images/product/product-big-2-zoom.jpg"><img src="images/product/product-small-2.jpg" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-3.jpg" data-zoom-image="images/product/product-big-3-zoom.jpg"><img src="images/product/product-small-3.jpg" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-4.jpg" data-zoom-image="images/product/product-big-4-zoom.jpg"><img src="images/product/product-small-4.jpg" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-5.jpg" data-zoom-image="images/product/product-big-5-zoom.jpg"><img src="images/product/product-small-5.jpg" alt="" /></a></li> </ul> </div> </div> <perch:shop id="image" type="image" width="270" height="335" density="1.6" crop="true" bucket="products" suppress="true"/> <div class="product-info col-sm-6 col-md-6 col-lg-6 col-xl-6"> <div class="wrapper hidden-xs"> <div class="product-info__sku pull-left">SKU: <strong><perch:shop id="sku" type="text" label="SKU" required="true" order="1" /></strong></div> <div class="product-info__availability pull-right">Availability: <strong class="color"><perch:shop id="stock_status" type="shop_stock_status" label="Stock status" required="true" /></strong></div> </div> <div class="product-info__title"> <h2><perch:shop id="title" type="text" label="Title" required="true" order="2" /></h2> </div> <div class="wrapper visible-xs"> <div class="product-info__sku pull-left">SKU: <strong><perch:shop id="sku" type="text" label="SKU" required="true" order="1" /></strong></div> <div class="product-info__availability pull-right">Availability: <strong class="color"><perch:shop id="stock_status" type="shop_stock_status" label="Stock status" required="true" /></strong></div> </div> <div class="visible-xs"> <div class="clearfix"></div> <ul id="mobileGallery"> <li><a href="#" data-image="<perch:shop id="image" type="image" label="Main product image" order="4" width="553" />" data-zoom-image="<perch:shop id="image" type="image" label="Main product image" order="4" width="533" />"><img src="<perch:shop id="image" type="image" label="Main product image" order="4" width="533" />" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-2.jpg" data-zoom-image="images/product/product-big-2-zoom.jpg"><img src="images/product/product-small-2.jpg" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-3.jpg" data-zoom-image="images/product/product-big-3-zoom.jpg"><img src="images/product/product-small-3.jpg" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-4.jpg" data-zoom-image="images/product/product-big-4-zoom.jpg"><img src="images/product/product-small-4.jpg" alt="" /></a></li> <li><a href="#" data-image="images/product/product-big-5.jpg" data-zoom-image="images/product/product-big-5-zoom.jpg"><img src="images/product/product-small-5.jpg" alt="" /></a></li> </ul> </div> <div class="price-box product-info__price"> <perch:if id="trade_pricing" value="1"> <perch:shop id="trade_price" type="shop_currency_value" label="Trade Price" /> <perch:else /> <perch:shop id="price" type="shop_currency_value" label="Price" /> </perch:if> </div> <div class="divider divider--xs product-info__divider hidden-xs"></div> <div class="product-info__description hidden-xs"> <div class="product-info__description__text"><perch:shop id="excerpt" type="textarea" label="Excerpt" editor="redactor" order="3" html="true" size="s" /></div> </div> <div class="divider divider--xs product-info__divider"></div> <div class="wrapper"> <perch:form id="add_to_cart" app="perch_shop" action="cart.php"> <perch:if exists="has_variants"> <perch:productopts> <h3><perch:productopt id="title" /></h3> <perch:productvalues> <perch:before><ul class="size-list"></perch:before> <li class="value"> <perch:input id="options" class="form-control input-sm size-variants" name="opt-<perch:productvalue id="optionID" />[]" value="<perch:productvalue id="valueID" />" type="radio" required="required" /> <perch:productvalue id="valueTitle" /> </li> <perch:after></ul></perch:after> </perch:productvalues> </perch:productopts> </perch:if> <div class="pull-left"><span class="qty-label">QTY:</span></div> <div class="pull-left"> <!-- --> <div class="number input-counter"> <!-- --> <perch:input id="qty" value="1" type="number" min="0" placeholder="1" class="form-control"/> </div> </div> <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> <!-- Nav tabs --> <ul class="nav nav-tabs nav-tabs--ys1" role="tablist"> <li class="active"><a href="#Tab1" role="tab" data-toggle="tab" class="text-uppercase">DESCRIPTION</a></li> </ul> <!-- Tab panes --> <div class="tab-content tab-content--ys nav-stacked"> <div role="tabpanel" class="tab-pane active" id="Tab1"> <perch:shop id="description" type="textarea" label="Description" editor="redactor" order="3" html="true" size="s" /> </div> </div> </div> </div> </div> </div> </div> <!-- End CONTENT section --> </div> </section> <perch:shop id="slug" type="slug" editable="true" indelible="true" label="Slug" for="title sku" order="10" divider-before="Meta data" /> <perch:shop id="status" type="shop_status" label="Status" /> <perch:categories id="category" set="products" label="Category"> <perch:category id="catTitle" /> </perch:categories> <perch:shop id="stock_status" type="shop_stock_status" label="Stock status" divider-before="Stock" required="true" /> <perch:shop id="stock_level" type="number" label="Stock level" size="s" /> <perch:shop id="stock_location" type="shop_stock_location" label="Count stock" /> <perch:shop id="max_in_cart" type="number" label="Max quantity in cart" size="s" /> <perch:shop id="requires_shipping" type="shop_requires_shipping" label="Requires shipping" divider-before="Shipping" />

Any help much appreciated

Jade Marling

Jade Marling 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have a minimum quantity set on the product?

No I don't. I've set the stock level to 600, but I'm not sure where the minimum quantity is

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn debug on for your cart page and perform the two actions, how does the output differ?

Quantity set to 1 :

Debug Message - Perch 3.0.12
[37] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/cart.php' LIMIT 1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT itemID, itemQty FROM perch3_shop_cart_items WHERE cartID=1 AND productID=1
[1] SELECT * FROM perch3_shop_products WHERE productID=1 AND productDeleted IS NULL LIMIT 1
------------------------------ Calculating cart ------------------------------
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT * FROM perch3_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
[1] SELECT locationID FROM perch3_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
[1] SELECT * FROM perch3_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch3_shop_currencies WHERE currencyID=47 LIMIT 1
[1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM perch3_shop_cart_items WHERE cartID=1
Tax mode: exc
[nil] SELECT * FROM perch3_shop_cart_items WHERE cartID=1 ORDER BY itemID ASC
UPDATE perch3_shop_cart SET cartTotalItems=NULL, cartTotalProducts='0', cartTotalWithTax='0.00', cartTotalWithoutTax='0.00' WHERE cartID='1'
Invalid query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'cartTotalItems' cannot be null
INSERT INTO perch3_shop_cart_data(cartID,productID,cartData) VALUES('1','1','{\"qty\":\"\",\"product\":\"1\"}')
Using template: /templates/shop/cart/mini_cart.html
Using cart from cache.
Using template: /templates/shop/cart/mini_cart2.html
Using cart from cache.
Using template: /templates/shop/cart/cart.html

Quantity 2:

Debug Message - Perch 3.0.12
[37] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/cart.php' LIMIT 1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT itemID, itemQty FROM perch3_shop_cart_items WHERE cartID=1 AND productID=1
[1] SELECT * FROM perch3_shop_products WHERE productID=1 AND productDeleted IS NULL LIMIT 1
INSERT INTO perch3_shop_cart_items(productID,itemQty,cartID) VALUES('1','2','1')
------------------------------ Calculating cart ------------------------------
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=1
[1] SELECT * FROM perch3_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
[1] SELECT locationID FROM perch3_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
[1] SELECT * FROM perch3_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch3_shop_currencies WHERE currencyID=47 LIMIT 1
[1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM perch3_shop_cart_items WHERE cartID=1
Tax mode: exc
[1] SELECT * FROM perch3_shop_cart_items WHERE cartID=1 ORDER BY itemID ASC
[1] SELECT * FROM perch3_shop_products WHERE productID=1 AND productDeleted IS NULL LIMIT 1
[1] SELECT * FROM perch3_shop_tax_groups WHERE groupID=1 AND groupDeleted IS NULL LIMIT 1
[1] SELECT r.rateValue FROM perch3_shop_tax_group_rates gr, perch3_shop_tax_rates r WHERE gr.rateID=r.rateID AND gr.groupID=1 AND gr.locationID=1
[1] SELECT z.* FROM perch3_shop_shipping_zones z LEFT JOIN perch3_shop_shipping_zone_countries c ON z.zoneID=c.zoneID WHERE z.zoneActive=1 AND z.zoneDeleted IS NULL AND (c.countryID=236 OR zoneIsDefault=1) ORDER BY zoneIsDefault ASC LIMIT 1
[1] SELECT * FROM perch3_shop_shippings WHERE shippingDeleted IS NULL ORDER BY shippingOrder ASC
[1] SELECT * FROM perch3_shop_shipping_zones WHERE zoneDeleted IS NULL AND zoneActive=1 AND zoneID IN (2)
[1] SELECT rateID AS id, rateTitle AS title, rateValue AS rate, locationID FROM perch3_shop_tax_rates WHERE rateDeleted IS NULL ORDER BY rateValue DESC
[nil] SELECT rateID AS id, rateTitle AS title, rateValue AS rate FROM perch3_shop_tax_rates WHERE locationID=2 AND rateDeleted IS NULL ORDER BY rateValue DESC
Qualifying shipping method ‘DPD’
[1] SELECT * FROM perch3_shop_shippings WHERE shippingID='1' AND shippingDeleted IS NULL LIMIT 1
Using shipping zone: UK Mainland
[1] SELECT * FROM perch3_shop_tax_groups WHERE groupID=1 AND groupDeleted IS NULL LIMIT 1
[1] SELECT r.rateValue FROM perch3_shop_tax_group_rates gr, perch3_shop_tax_rates r WHERE gr.rateID=r.rateID AND gr.groupID=1 AND gr.locationID=1
[nil] SELECT * FROM perch3_shop_promotions WHERE promoFrom<='2018-01-09 15:09:00' AND promoTo>'2018-01-09 15:09:00' AND promoActive=1 AND promoDeleted IS NULL ORDER BY promoOrder ASC
UPDATE perch3_shop_cart SET cartTotalItems='2', cartTotalProducts='1', cartTotalWithTax='34.80', cartTotalWithoutTax='20.00' WHERE cartID='1'
INSERT INTO perch3_shop_cart_data(cartID,productID,cartData) VALUES('1','1','{\"qty\":\"2\",\"product\":\"1\"}')
[1] Using template: /templates/shop/cart/mini_cart.html
Missing variant.
Using cart from cache.
[1] Using template: /templates/shop/cart/mini_cart2.html
Missing variant.
Using cart from cache.
[1] Using template: /templates/shop/cart/cart.html
Missing variant.
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is this the same site as your other issue?

Yes it is.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, it might be best to address one issue at a time.