Forum
Empty discount variables on result page
I'm trying to display free shipping discounts on my order result page with:
<perch:if id="total_discounts_with_tax_formatted" match="gt" value="0.00">
<dt>Discount (<perch:shop id="discount_code" />)</dt>
<dd>- <perch:shop id="total_discounts_with_tax_formatted" /></dd>
</perch:if>
But only the voucher code is display correctly, the discount value is 0
Discount (FREESHIPPING)
- £0.00
Looking at <perch:showall />
I can see that some of the variables are at 0, even though the order*
variables have values. eg:
orderShippingSubtotal 2.49
orderShippingDiscounts 2.49
orderShippingTax 0.50
orderShippingTaxDiscounts 0.50
orderShippingTotal 2.99
orderDiscountsTotal 2.49
orderTaxDiscountsTotal 0.50
But these are all 0:
total_shipping_discount 0.00
total_shipping_discount_formatted £0.00
total_shipping_tax_discount 0.00
total_shipping_tax_discount_formatted £0.00
total_tax_discount 0.00
total_tax_discount_formatted £0.00
total_discounts 0.00
total_discounts_formatted £0.00
total_discounts_with_tax 0.00
total_discounts_with_tax_formatted £0.00
Should these be populated, or should I be using the order*
variables?
If I should be using the order*
variables, could I put a feature request in for the variables to match, so there's an equivalent to total_discounts_with_tax_formatted
, orderDiscountsWithTaxFormatted
for example.
Diagnostic report:
Perch Runway: 3.0.14, PHP: 7.2.6, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $, with PDO
Server OS: Darwin, fpm-fcgi
Installed apps: content (3.0.14), assets (3.0.14), categories (3.0.14), perch_blog (5.6.1), perch_forms (1.10), perch_shop_orders (1.2.5), perch_shop_products (1.2.5), perch_shop (1.2.5), perch_members (1.6.2)
App runtimes: <?php $apps_list = [ 'perch_forms', 'perch_members', 'perch_shop', 'perch_blog', ];
PERCH_LOGINPATH: /juniper
PERCH_PATH: /Users/garrettc/sandbox/collagin/htdocs/juniper
PERCH_CORE: /Users/garrettc/sandbox/collagin/htdocs/juniper/core
PERCH_RESFILEPATH: /Users/garrettc/sandbox/collagin/htdocs/juniper/resources
Image manipulation: GD
PHP limits: Max upload 20M, Max POST 20M, Memory: 128M, Total max file upload: 20M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /juniper/core/settings/diagnostics/index.php
REQUEST_URI: /juniper/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/garrettc/sandbox/collagin/htdocs
HTTP_HOST: collagin.local
I've been doing some more testing this morning, and a promotion that offers a discount on the main price, either by percent or fixed price, does display the correct discount on the results page. So it looks like this is just limited to free shipping vouchers.
I'd suggest comparing on
0
rather than0.00
, which PHP might be interpreting as a string.Sorry Drew, I wasn't clear enough.
(I did try changing the comparison, but that didn't change the behaviour, I'm seeing).
I want to have one check on the results page to display any promotions against the order, whether they are free shipping or against the item price.
total_discounts_with_tax_formatted
seemed to be the correct variable to check, and it does work with a promotion against the main price.It doesn't seem to work with a free shipping promotion though.
In the example above with a free shipping promotion the
order*
variables for total discounts are populated, but the relevanttotal_*
variables are empty:Compared to an order with a promotion applied to the main item price, and both are populated:
Feels like a bug. Unless I'm missing a difference between free shipping and item discount promotions?
Shipping is calculated separately from the order totals and discounts. You should be able to see shipping costs when those are applied. Shipping isn't a product in the cart, and it's often based on what's in the cart, so they can't be the same.
Okay, so on the results page and confirmation email it's best if I stick with the
order*
variables?I don't understand at all.
Maybe I'm over-explaining (this heat!)
The behaviour of the
total_discounts_*
variables differs before and after checkout.cart_static.html
displays totals on the "checkout" page, before checkout:items.html
displays the totals on the "order success" page after checkout:I'm using
<perch:shop id="total_discounts_with_tax_formatted" />
in both files.Using
<perch:showall>
to list all the variables available with a free shipping promotion, this is what I see (I've cut out lots of variables for brevity):The
total_shipping_discount_*
andtotal_discounts_*
values aren't being populated with any values.My confusion is this:
In the cart, before checkout, I can use
total_discounts_with_tax
and it will show any discount applied, for both a free shipping promotion, or an item discount promotion.On the success page, after checkout,
total_discounts_with_tax
behaviour has changed, and it only has a value if the promotion was an item discount.Does that make my problem clearer?
Hi, any further thoughts on this?