Checkout Screen Not Showing Coupon Discount Properly

@fc_adam @Ryuhei -
We use multi-ship checkout for all checkout scenarios and have noticed that when a coupon code is used, the checkout page is not showing the discount properly. See attached screenshot for an example. There seems to be a missing "Discount" line item showing the amount of the discount. Furthermore, the "Ship To: Recipient 1" area at the very bottom of the righthand column fails to account for the discount, even when I expand it by clicking on "Details." This presents the customer with two conflicting totals: the lower number is correct but it doesn't show the discount line item and the other (bottom total) is too high because it doesn't include the discount at all. This leads to abandoned checkouts, as you might imagine.

How do we fix this? Is it a multi-ship bug on your end or did we configure something incorrectly? Thanks.

In the attached screenshot, the item is regularly $59 (before shipping and tax) and a 10% off coupon was entered on the cart page. $60.09 is the correct total (after tax and shipping), while $65.99 is incorrect.
image

Comments
  • fc_adamfc_adam FoxyCart Team
    @Leafcutter,

    I believe you may have hidden the coupons section on your checkout - it should appear right below the subtotal line within the "Order Summary" section. The ship to details section won't factor in the coupons - as they apply to the transaction as a whole, rather than to a specific shipto address.

    If you can let us know the specific store this is for, we'd be happy to help pinpoint what is hiding it on your store.
  • @fc_adam @Ryuhei

    Strange. We intended to hide the coupon line on the checkout page only when a coupon code was NOT already entered on the cart page. The shop is at http://www.leafcutterdesigns.com/shop.html

    Either way, it seems really confusing to have the shipto details section not factor in the coupon. If it applies to the transaction as a whole, then shouldn't it apply to all shipto addresses, instead of none?
  • fc_adamfc_adam FoxyCart Team
    @Leafcutter,

    Thanks for confirming that - sorry for not working it out from your username!

    From looking at your cart include template, I see you've pulled the cart block out of the totals area and included it up the top and only on the sidecart, preventing it from displaying on the checkout.

    To ensure the actual line item displays in the total sections on the checkout, you'll want to reinstate the coupon block back where it is natively on the checkout. Your cart include template currently has this within the order totals area:
    {% set enable_coupon_controls = (has_eligible_coupons and config.with_controls) %}
    {% if context == 'checkout' %}
    {% set enable_coupon_controls = (has_eligible_coupons and config.template_config.custom_checkout_field_requirements.coupon_entry == 'enabled') %}
    {% endif %}


    {% if shipping_address.has_shippable_products %}
    To reinstate the original code, you'd have this: http://pastie.org/private/xnaqn0hj1h3styrepv5ngg

    If you want to prevent the ability to add a coupon on the checkout, you can do that still. If it's a blanket prevention like you have now that you want - you can simply go to your store's configuration page in the FoxyCart administration, and within the "Customize which checkout fields are shown and required" in the checkout section, you can set "coupon entry" to disabled. If you then include the normal coupon entry block within the order summary - it will display any included coupons but not the "add coupon" button.

    If instead you want a dynamic prevention on the checkout instead, you can alter the enable_coupon_controls variable to be false based on certain conditions:
    {% if context == 'checkout' %}
    {% set enable_coupon_controls = (has_eligible_coupons and config.template_config.custom_checkout_field_requirements.coupon_entry == 'enabled') %}
    {% endif %}
    You can also still include the coupon entry up higher on the cart include if you want, simply by wrapping the re-instated coupon entry field in a {% if context == "checkout" %} {% endif %} conditional.

    As an example of how our default checkout looks with multiship addresses and a coupon, it looks like this:

    image
    Either way, it seems really confusing to have the shipto details section not factor in the coupon. If it applies to the transaction as a whole, then shouldn't it apply to all shipto addresses, instead of none?
    Technically the coupons don't apply to the individual shipto addresses. The details section gives a summary of what the charges are that make up that individual address - so would include product total, shipping, taxes and the grand total for that address. The combination of the totals of all the shipto addresses is where the coupon applies, as shown in our default template within the order summary area.

    I can see what you're meaning with the confusion though - and we'll discuss on our side if it would make sense to perhaps divide the coupon discount between the shiptos as well.
  • @fc_adam @Ryuhei

    Thanks for looking into this for us! Ideally, we'd like it to work as follows:

    - Only allow coupon codes to be entered on the cart page (not checkout). This is how it's set up now.
    - If a coupon is entered on the cart page, then checkout summary shows the discount as a line item (as shown in your default checkout example).
    - If no coupon entered on cart page, then everything related to coupons or discounts should be hidden on the checkout page.
    - If there's only one shipto address in the order, then hide the lower "shipto" summary since it's redundant (and confusing when there's a discount applied).

    Is this configuration possible? Thanks.
  • fc_adamfc_adam FoxyCart Team
    @Leafcutter,

    No worries!
    - Only allow coupon codes to be entered on the cart page (not checkout). This is how it's set up now.
    Simply set the "Coupon Entry" option within "Customize which checkout fields are shown and required" on your store's configuration page in the administration to "disabled".
    - If a coupon is entered on the cart page, then checkout summary shows the discount as a line item (as shown in your default checkout example).
    This would be handled by re-inserting the default code I mentioned above
    - If no coupon entered on cart page, then everything related to coupons or discounts should be hidden on the checkout page.
    Also handled by the default code - the discounts section within the totals area will only show if the coupon entry is enabled on the checkout, or if there are coupons present. If both of those are false, it won't even show at all.
    - If there's only one shipto address in the order, then hide the lower "shipto" summary since it's redundant (and confusing when there's a discount applied).
    That's a good point - it is redundant in that instance isn't it. I'll create a ticket for us to handle this natively in the template too - but for your needs, you would customise the cart include template. Look for this line in the cart include template (there should just be the one instance):
    {% if context == "checkout" and has_multiple_addresses %}
    And update it to be this instead:
    {% if context == "checkout" and has_multiple_addresses and multiship_data|length > 1 %}
  • @fc_adam

    Great, thanks for the detailed instructions!

    - Only allow coupon codes to be entered on the cart page (not checkout). This is how it's set up now.
    Simply set the "Coupon Entry" option within "Customize which checkout fields are shown and required" on your store's configuration page in the administration to "disabled".
    Done and it's working, thanks.

    - If a coupon is entered on the cart page, then checkout summary shows the discount as a line item (as shown in your default checkout example).
    This would be handled by re-inserting the default code I mentioned above
    Swapped in the default code and got the following error message when saving my newly cached template:
    Error: Your template was not saved because there was an error in your Twig template syntax: The block 'coupon_entry' has already been defined line 404 in "TEMP_cart_include_template.twig" at line 554

    - If no coupon entered on cart page, then everything related to coupons or discounts should be hidden on the checkout page.
    Also handled by the default code - the discounts section within the totals area will only show if the coupon entry is enabled on the checkout, or if there are coupons present. If both of those are false, it won't even show at all.
    Same comment as above.

    - If there's only one shipto address in the order, then hide the lower "shipto" summary since it's redundant (and confusing when there's a discount applied).
    That's a good point - it is redundant in that instance isn't it. I'll create a ticket for us to handle this natively in the template too - but for your needs, you would customise the cart include template. Look for this line in the cart include template (there should just be the one instance):
    {% if context == "checkout" and has_multiple_addresses %}
    And update it to be this instead:
    {% if context == "checkout" and has_multiple_addresses and multiship_data|length > 1 %}
    Done and it's working, thanks.
  • fc_adamfc_adam FoxyCart Team
    Swapped in the default code and got the following error message when saving my newly cached template:
    Error: Your template was not saved because there was an error in your Twig template syntax: The block 'coupon_entry' has already been defined line 404 in "TEMP_cart_include_template.twig" at line 554
    Ah yep - sorry for not thinking of that. You can't define the same block twice like that. You could remove the one you've included at the top - and just include it where it normally sits in the total items. If you're concerned about people seeing it in sidecart, you could then apply some styling to make it more prominent if you'd like. Would that work?
  • @fc_adam

    Not sure if that would get us where we're trying to go. Basically, I want only the shopping cart page to allow coupon entry (we have sidecart disabled). If a customer does enter a coupon code on the cart page, I then want the checkout page to display the discount as a line item. It seems the standard 'coupon_entry' block code handles both entry and display. Is there a way to break it up and keep entry as currently set up in the cart only, and then only display already entered discounts on the checkout page? Thanks for all your help with this!
  • fc_romanfc_roman Member, FoxyCart Team
    Hi @Leafcutter,

    Thank you for the clarification. Could you try the following:

    1. In your cart include template, find the existing clause:
    {% if context != 'checkout' and not is_subscription_cancel and (enable_coupon_controls or coupons|length > 0) %}

    {% endif %}
    2. Right after it, insert the code below — it should show the coupon as a line item in the checkout:
    {% if context == 'checkout' and coupons|length > 0 %}
    <li class="fc-transaction__discounts fc-transaction__section">
    <table>
    {% for key,coupon in coupons %}
    <tr class="fc-subtotal--row" data-fc-coupon-container-id="{{ coupon.id }}">
    <td class="fc-subtotal__label">
    <span class="fc-coupon__name">{{ coupon.name }}</span>:
    <span class="fc-coupon__code">{{ key }}</span>
    </td>
    <td class="fc-subtotal__value">{{ coupon.amount|money_format }}</td>
    </tr>
    {% endfor %}
    </table>
    </li>
    {% endif %}
    Save, test, and let us know whether this is what you were looking for. Thanks.
  • @fc_roman

    I've added this code but it seems to have no effect. The discount is applied to the order total properly, but no discount line item is showing in the righthand column on the checkout page. Any thoughts?
  • fc_romanfc_roman Member, FoxyCart Team
    @Leafcutter,

    Sorry about the misfire. I looked at your cart include, and it seems that the code suggested above should be placed in a different spot. There are a bunch of {% endif %}'s — could you please try inserting the code after the right one, the one that closes the {% if context != 'checkout' and not is_subscription_cancel and (enable_coupon_controls or coupons|length > 0) %} clause? In this case, the line right after this newly-inserted code should be </ul>, rather than </button>.

    (I did test the code before presenting it to you.)
  • fc_adamfc_adam FoxyCart Team
    Not sure if that would get us where we're trying to go. Basically, I want only the shopping cart page to allow coupon entry (we have sidecart disabled). If a customer does enter a coupon code on the cart page, I then want the checkout page to display the discount as a line item. It seems the standard 'coupon_entry' block code handles both entry and display. Is there a way to break it up and keep entry as currently set up in the cart only, and then only display already entered discounts on the checkout page?
    @leafcutter, just to quickly clarify - if you are ok with the coupon entry within the cart appearing in the totals rather than at the top - then just including it the once where it normally sits will achieve exactly what you're after. You're right that the normal coupon block does handle both entry and display but the entry UI is conditional. The changes we discussed earlier to your store configuration will ensure that the coupon entry option will only happen on the cart - you've disabled it from happening on the checkout. Just including the normal coupon block the once where it normally sits in the totals area will get you exactly what you described.

    If you do specifically want the coupon entry to appear at the very top of the cart sidebar - then you could take the approach that Roman noted which just re-inserts the actual total line item display of the coupon.
  • @fc_adam @fc_roman

    Success! I placed it in a slightly different spot, between shipping and tax under "Order Summary" since the "Subtotal" calculation does not include the discount amount. That way the math flows from top to bottom and it's obvious that the discount is being applied. Thanks for your excellent help sorting this out.
  • fc_romanfc_roman Member, FoxyCart Team
    Splendid! Thanks for the update — glad you've made it work the way you need.
    Let us know whenever you have new questions.
Sign In or Register to comment.