0

When i set the percentage off to 20% in a coupon and make a purchase, the value that is returned from this:

{exp:cartthrob:cart_discount_percent_of_total}

tends to differ, on my example purchases, i would get 17%, then 21% etc. I am yet to make a purchase where it had taken 20% off exactly.

Why is the cart_discount_percent_of_total never exactly the percent i entered when i created the coupon, which in this example is 20%? The products are high value so the a few percent could amount to hundreds of pounds.

EE - 2.10.1

CT Pro - 2.7

0

I think that you may be misunderstanding the function of the tag that you are using here.

The discount_percent_of_total tag is calculating the discount amount in relation to the cart total amount. It is not displaying the percent off of the coupon or discount.

The following tag works inside a coupon info loop.

{exp:cartthrob:coupon_info}
    {coupon_percentage_off}
{/exp_cartthrob:coupon_info}

so if your coupon is 20 percent off, the above tag would output 20

Please note that this tag will not work if you have a coupon set for a specific amount off a purchase. For example, I have a different coupon for ¥500 off. When I use that coupon code, the {coupon_percentage_off} tag is shown in the template instead of parsing out a percent. Therefore, you'll need to enclose this tag in an IF loop to prevent it displaying when there is no percent to show.

{if '{coupon_percentage_off}' != ''}
   {coupon_percentage_off}
{/if}
  • I think the way you have explained what the discount_percent_of_total does is what i am questioning, if i have set it to 20%, why is it not calculating 20% of the total, instead its calculated it to 17% or 21% etc. e.g. I have a total of £100, i apply a coupon discount of 20%, i would expect the values returned to be 20% and £80, yet i get 17% and £83. Its this which i cant explain. – BillyMedia Jun 8 '17 at 8:24
  • Percent of total is rendering against the cart total after tax and shipping. However discounts and coupons are normally applied prior to tax and shipping calculation. In other words, discounts are applied to the subtotal. I think this is where you are seeing a difference. Try dividing the discount amount by the total and you should get the percent of total amount – pixldev Jun 8 '17 at 9:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.