Retrieve coupon details from coupon code WooCommerce [duplicate]
I figured it out. In order for the WC_Coupon
function to work, I needed to add the "new" keyword prior to calling the function. As demonstrated below.
$coupon_code = 'save10percent';global $woocommerce;$c = new WC_Coupon($coupon_code);
Now I can get details about the coupon like so
echo "Discount Amount ".$c->amount."<br>";//Get Discount amountecho "Discount Type ".$c->discount_type."<br>";//Get type of discountecho "Individual Use ".$c->individual_use."<br>";//Get individual use statusecho "Usage Count ".$c->usage_count."<br>";//Get number of times the coupon has been usedecho "Uage Limit ".$c->usage_limit."<br>";//Get usage limitecho "Coupon Description ".$c->description."<br>";//Get coupon description