I'm trying to pass a few order details to a third party on the Woocommerce thankyou page. Everything works fine—except getting the coupon ID.
What am I missing? I've read through this question, but didn't illuminate the subject too much.
Doesn't seem like a lot of documentation on WC coupons... Thanks!
function goodcart_tracking( $order_id ) {
$order = new WC_Order( $order_id );
$order_number = $order->get_id();
$currency = $order->get_order_currency();
$email = $order->get_billing_email();
$total = $order->get_total();
$coupon = $order->get_used_coupons().implode(",",$coupons);
$date = $order->order_date;
?>
<script type="text/javascript">
var params = {
'gc_hash': 'HASH_ID',
'customer_email': '<?php echo $email ?>',
'order_id': '<?php echo $order_number; ?>',
'order_amount': '<?php echo $total; ?>',
'order_amount_type': '<?php echo $currency; ?>',
'promo_code': '<?php echo $coupon; ?>'
};
iGCCpnObj = new _iGCBannerObj(params); iGCCpnObj.start();
</script>
<?php }