Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. /** This function works with WooCommerce URL Coupons
  3. * When a coupon gets deferred, it's added to a list of deferred_url_coupons.
  4. * This function accepts a coupon ID ($coupon_id) as an argument, and gets all of the deferred_coupons
  5. * as an array. The coupon ID would be an array key,which is what this function checks for.
  6. * A message is printed. nothing is returned.
  7. **/
  8. function get_deferred_coupons( $coupon_id ) {
  9. global $woocommerce;
  10.  
  11. $deferred_coupons = $woocommerce->session->get( 'deferred_url_coupons', array() );
  12.  
  13. if( array_key_exists( $coupon_id, $deferred_coupons ) ) {
  14. echo '<p>Hey! Your coupon will be automattically applied at checkout!</p>';
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement