Retrieve coupon details from coupon code WooCommerce

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;//Get Discount amount
echo "Discount Type ".$c->discount_type;//Get type of discount
echo "Individual Use ".$c->individual_use;//Get individual use status
echo "Usage Count ".$c->usage_count;//Get number of times the coupon has been used
echo "Uage Limit ".$c->usage_limit;//Get usage limit
echo "Coupon Description ".$c->description;//Get coupon description

1 comment:

  1. Apollo Medical Ptv Ltd is here to provide you affordable medical billing services around the globe. Our trained and certified coding specialist are here to help you provide medical billing soultions. Get our services today!

    medical billing specialist

    ReplyDelete