Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement