Forum
Perch Shop Sale – Price added to cart is Zero
Hi
I have a situation where I have enabled a sale promotion period in a shop.
Products have variants, some of which have sale prices set.
I am not using the use sale price checkbox.
So in theory only those products with sale prices should carry a sale price through to the cart – which they are successfully.
All other products, that don't have anything entered into the sale price, are displaying as their full price.
However when you add them to the cart, they show a price of 0. Which isn't ideal as you can imagine.
Help me Obi-Wan Kenobi!
Product detail template
<section class="l-product-content g-vertical-spacer">
<article class="l-main-content t-serif g-flex-row g-flex-row-reverse">
<div class="l-product-details g-col-two">
<div class="l-main-copy t-big g-vertical-spacer">
<header>
<h1 class="h2"><perch:shop id="title" type="text" label="Title" /></h1>
<p class="t-small">By <a href="/shop/<perch:shop id="brand" type="shop_brand" output="slug" />"><perch:shop id="brand" type="shop_brand" /></a></p>
</header>
<div class="l-product-categories">
<perch:shop id="description" type="textarea" size="m" />
<perch:if id="stock_status" match="gt" value="0"/>
<perch:if id="stock_level" match="gt" value="0"><p><strong><perch:shop id="stock_level"/> remaining.</strong></p>
</perch:if>
</perch:if>
</div>
<div class="l-product-categories"><perch:categories id="category" set="media" label="Category">
<perch:category id="desc" type="textarea" editor="markitup" markdown="true" />
</perch:categories></div>
</div>
<perch:if exists="stock_level"/>
<perch:if id="stock_level" match="eq" value="0">
<div class="l-variant">
<p><strong>Sold out</strong></p>
</div>
<perch:else/>
<perch:template path="shop/products/variant_detail.html"/>
</perch:if>
<perch:else/>
<perch:if exists="has_variants">
<perch:template path="shop/products/variant_detail.html"/>
</perch:if>
</perch:if>
<div class="l-product-extras">
<p><a href="/delivery-returns/">Delivery information</a></p>
</div>
</div>
<aside class="l-product-gallery g-col-four g-aside-left">
<div class="l-hero-image l-image-border">
<perch:if exists="limited"><div class="l-product-badge l-product-limited">
<div class="l-product-badge-copy t-tiny">Limited Edition</div></div>
</perch:if>
<perch:if exists="special">
<div class="l-product-badge l-product-special">
<div class="l-product-badge-copy t-tiny">Special Offer</div></div>
</perch:if>
<perch:variants>
<perch:if exists="sale_price">
<div class="l-product-badge l-product-sale">
<div class="l-product-badge-copy t-tiny">On Sale</div>
</div>
</perch:if>
</perch:variants>
<img srcset="<perch:shop id="image" type="image" width="560" density="2" bucket="products"/> 2x" src="<perch:shop id="image" type="image" width="560" density="1" bucket="products"/>" alt="<perch:shop id="image_alt" type="text" label="Image alt" />"><perch:shop id="image" type="image" width="560" density="2" bucket="products">
</div>
<div class="l-product-thumbnails">
<perch:repeater id="image_detail_repeater" label="Image details" max="2">
<div class="l-product-thumbnail">
<img srcset="<perch:shop id="image_detail" type="image" width="272" density="2" bucket="products"/> 2x" src="<perch:shop id="image_detail" type="image" width="272" density="1" bucket="products"/>" alt="<perch:shop id="image_detail_alt" type="text" label="Image detail alt"/>">
</div>
</perch:repeater>
</div>
</aside>
</article>
</section>
<perch:showall/>
Variant detail template
<div class="l-variants">
<perch:variants>
<div class="l-variant">
<dl>
<dt><perch:variant id="productVariantDesc" type="text" /></dt>
<perch:if exists="sale_price">
<dd>ON SALE! <span class="t-strikethrough"><perch:variant id="price" type="shop_currency_value" /></span> <perch:variant id="sale_price" type="shop_currency_value" label="Sale price"/></dd>
<perch:else/>
<dd><perch:variant id="price" type="shop_currency_value" /></dd>
</perch:if>
</dl>
<perch:form id="add_to_cart" app="perch_shop" action="/shop/basket" class="l-add-to-cart-form t-sans">
<perch:input id="product" type="hidden" value="<perch:variant id="productID" type="hidden" env-autofill="false" />" />
<perch:input type="submit" value="Add to cart" class="l-btn l-btn-small"/>
</perch:form>
</div>
</perch:variants>
</div>
Cart template
<section class="l-boilerplate g-vertical-spacer">
<h1>Your basket</h1>
<perch:if id="product_count" match="lte" value="0" />
<h2>is empty.</h2>
<p><a href="/shop">Return to the shop</a></p>
</perch:if>
</section><!-- section -->
<perch:if id="product_count" match="gt" value="0">
<section class="l-cart g-vertical-spacer">
<perch:form id="cart" app="perch_shop">
<button type="submit" value="Update" class="l-btn-hidden"></button>
<div class="g-grid g-grid-cart-heading">
<div>Title</div>
<div>Details</div>
<div>Quantity</div>
<div class="g-item-center">Price</div>
<div class="g-item-center">Total</div>
</div>
<perch:cartitems>
<div class="g-grid g-grid-cart t-serif">
<div class="c-image"><img srcset="<perch:cartitem id="image" type="image" width="128" density="2" bucket="products"/> 2x" src="<perch:cartitem id="image" type="image" width="128" density="1" bucket="products"/>" alt="<perch:cartitem id="image_alt" type="text" />"></div>
<div class="c-title"><perch:cartitem id="title" /></div>
<div class="c-details"><perch:if exists="variant_desc"><perch:cartitem id="variant_desc" /><perch:else/><perch:cartitem id="description" type="textarea" markdown="true" /></perch:if></div>
<div class="c-q"><perch:input id="qty:<perch:cartitem id="identifier" />" value="<perch:cartitem id="quantity" />" type="number" min="0" class="l-form-input"/><perch:input value="Update" type="submit" class="l-btn l-btn-small"/></div>
<div class="c-price g-item-center"><perch:cartitem id="price_with_tax_formatted" /></div>
<div class="c-total g-item-center"><perch:cartitem id="total_with_tax_formatted" /></div>
<div class="t-sans t-small c-btn g-item-center"><button type="submit" class="l-btn l-btn-small l-btn-del" name="del:<perch:cartitem id="identifier" />" value="1" >Remove</button></div>
</div>
</perch:cartitems>
<perch:if id="total_discounts" match="gt" value="0.00">
<div class="g-grid g-grid-calc">
<div class="g-item-center">
Voucher applied (<perch:shop id="discount_code" />)
</div>
<div class="g-item-center">
-<perch:shop id="total_discounts_with_tax_formatted" />
</div>
</div>
</perch:if>
<div class="g-grid g-grid-calc">
<div class="g-item-center">
Total<br>
<span class="t-tiny t-serif">Excluding delivery</span>
</div>
<div class="g-item-center">
<perch:shop id="total_items_discounted_with_tax_formatted" />
</div>
</div>
<div class="g-grid g-grid-calc c-voucher">
<div class="c-voucher-label g-item-right">
<perch:label for="discount_code">Do you have a voucher code?</perch:label>
</div>
<div class="c-voucher-input">
<perch:input id="discount_code" type="text" placeholder="Enter code here" class="l-form-input"/>
</div>
<div class="c-voucher-btn t-sans t-small tb-btn"><perch:input value="Update" type="submit" class="l-btn l-btn-small"/></div>
</div>
<div class="g-grid g-grid-calc">
<div class="c-continue"><a href="/shop/" class="l-btn l-btn-small">Continue shopping</a></div>
</div>
<div class="g-grid g-grid-calc">
<div class="c-checkout"><a href="/shop/delivery" class="l-btn l-btn-large">Checkout</a></div>
</div>
</perch:form>
</section>
</perch:if>
Perch Runway: 3.0.11, PHP: 7.0.1, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 7e72f9690b1498a1bead7a637c33a831c0d2f655 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.11), assets (3.0.11), categories (3.0.11), perch_forms (1.9.1), perch_shop_orders (1.2.5), perch_shop_products (1.2.5), perch_shop (1.2.5), perch_members (1.6.2), perch_mailchimp (3.1)
App runtimes: <?php $apps_list = [ 'perch_mailchimp', 'perch_members', 'perch_shop', 'perch_forms', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/sites/e/ellipress.co.uk/public_html/perch
PERCH_CORE: /var/sites/e/ellipress.co.uk/public_html/perch/core
PERCH_RESFILEPATH: /var/sites/e/ellipress.co.uk/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/e/ellipress.co.uk/public_html
HTTP_HOST: ellipress.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Can you show me the debug when that happens?
Sure, here you go:
Debug from product page
Debug from cart page
Which discount code are you applying?
I've been playing around with it offline and the cart also seems to change behaviour between browsers.
If I disable the promotional sale period, and even delete it, then I get even more weird behaviour:
In Safari the full price remains 0 in the cart even though it's set to a number. If I add a sale price to a variant then the sale price appears in the cart. Even though there is no sale and there is a full price set in the variant.
Testing the same product in Firefox and Chrome and the full price appears in the cart.
If I regenerate the variants then I get a Fatal Error:
Are you deleting things that are already in a cart?
Very probably! Ignore the fatal error bit.
There's no discount code. It's just a sales promotion period of time. I assume that triggers any sales prices set on products and their variants?
So it seems that as soon as you set up a sales promotion period, any product variants are forced to take their price from the variant's sale price even if this isn't set. Any conditionals in the variant are ignored – the sale price is always taken by the cart, even if that is null.
The biggest problem I have here is that there's no way (as far as my pickled walnut of a brain can tell) to let non-sale products ignore this state because the sales promotion switch (sale_price or regular_price) is set at the product level not the variant. So full price products sell for 0 as I found out today with a live site, even though they display their full price in the product page.
How is your promotion configured?
Hi Drew
This is how I set it up initially:
Sales promotion date range set and activated
Products have regular price and sales price set at the variant level.
Products not in sale do not have sales price set.