• Resolved Adrian

    (@adrianlacheta)


    Hello,

    How can I get the exact discount that each coupon in an order has generated? (In the WooCommerce backend, this amount is displayed as a ToolTip when hovering over the coupon code used in an order).

    With the following code I can display only the used coupon codes of an order:

    $order = wc_get_order($order_id);
    foreach($order->get_coupon_codes() as $coupon_code) {
    echo $coupon_code;
    }

    To get the current coupon amount I can now do the following:

    $coupon = new WC_Coupon($coupon_code);
    $coupon_amount = $coupon->get_amount();

    But my problem is that I don’t want to get the current value of the coupon, but the exact discount that the coupon triggered when the order was generated.

    • This topic was modified 2 years, 5 months ago by Adrian.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there,

    This is a fairly complex development topic. I’m going to leave this thread 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 Community 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.

    Cheers.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking it as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. You can also consult a developer here – https://woocommerce.com/customizations/.

    If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get coupon discount for each coupon code in order (not current coupon value)’ is closed to new replies.