Home    Articles


How to get coupons list used in woocommerce wordpress order


First of all let's assume that you are on the order page and all you need is to get the coupons used for that order.

To do that use the following code:

$coupons = $order->order_custom_fields['coupons'];
foreach ($coupons as $coupon) 
	echo $coupon.'<br />';

$order is the object that contains order data, like items,order total amount...etc.

If you don't have this variable, you need to use the order id to get the object like this:

$order = new WC_Order( $order_id );