• Resolved Dekadinious

    (@dekadinious)


    Hello!

    I am trying to show or hide things in the order emails based on the discount given. When using $order->get_total_discount(), it frequently returns 0 but sometimes returns the correct value.

    What I have been able to see is that it frequently returns a blank value when the order consists of only a variable product that is on sale.

    If I go into this order in the WooCommerce dashboard, I also see that there is no discount field here. WooCommerce shows the product as you would show a non-discounted one, but with a discounted price.

    I don’t quite understand what is the correct usage of $order->get_total_discount() and how I can show the discount in the order emails?

    $order->get_discount_to_display() also displays 0 when $order->get_total_discount() doesn’t get a correct value.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter Dekadinious

    (@dekadinious)

    It seems I was confused about terms here. The method only returns total discount given by using coupons. If a product is directly discounted, this does not get stored anywhere it seems.

    I think this is something that should be considered added to core. Where can I suggest?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$order->get_total_discount() not working?’ is closed to new replies.