Last active
July 8, 2019 17:15
-
-
Save jcasabona/7f025ad8dcc14d84d56312f902a5aa12 to your computer and use it in GitHub Desktop.
WooCommerce URL Coupons - Get Deferred Coupons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** This function works with WooCommerce URL Coupons | |
* When a coupon gets deferred, it's added to a list of deferred_url_coupons. | |
* This function accepts a coupon ID ($coupon_id) as an argument, and gets all of the deferred_coupons | |
* as an array. The coupon ID would be an array key,which is what this function checks for. | |
* A message is printed. nothing is returned. | |
**/ | |
function get_deferred_coupons( $coupon_id ) { | |
global $woocommerce; | |
$deferred_coupons = $woocommerce->session->get( 'deferred_url_coupons', array() ); | |
if( array_key_exists( $coupon_id, $deferred_coupons ) ) { | |
echo '<p>Hey! Your coupon will be automattically applied at checkout!</p>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment