/app_old/membershipincludes/includes/coupon.form.php

  1. <?php 
  2. $coupon = membership_get_current_coupon(); 
  3. if(isset($_GET['subscription'])) { 
  4. $sub_id = (int) $_GET['subscription']; 
  5.  
  6. // Check if there are any coupons and if there are any valid for this subscription 
  7.  
  8.  
  9. if($coupon != false ) { 
  10. // Check the coupon is a valid one 
  11. $sub_id = (int) $_GET['subscription']; 
  12. if(is_numeric($sub_id) && method_exists( $coupon, 'valid_for_subscription') && $coupon->valid_for_subscription( $sub_id )) { 
  13. // The coupon is valid for this subscription 
  14. $msg = ''; 
  15. // Apply the coupon so that we can check if it was applied at a later date and change the count 
  16. $coupon->record_coupon_application( $sub_id, $pricing ); 
  17. } else { 
  18. // The coupon is not valid for this subscription 
  19. $msg = $coupon->get_not_valid_message( $sub_id ); 
  20. // Remove the coupon as it isn't valid 
  21. $coupon = false; 
  22.  
  23. } else { 
  24. $msg = ''; 
  25.  
  26. if(!empty($msg)) { 
  27. $errormessages = "<div class='alert alert-error'>"; 
  28. $errormessages .= $msg; 
  29. $errormessages .= "</div>"; 
  30.  
  31. echo $errormessages; 
  32.  
  33. ?> 
  34. <div class="membership-coupon"> 
  35. <div class="membership_coupon_form couponbar"> 
  36. <form action='' method='POST'> 
  37. <?php if(empty($coupon) || (method_exists( $coupon, 'valid_for_subscription') && !$coupon->valid_for_subscription( $sub_id ))) { ?> 
  38. <div class="couponQuestion"><?php _e('Have a coupon code?', 'membership'); ?></div> 
  39. <div class="couponEntry"> 
  40. <input type="hidden" id="coupon_sub_id" name="coupon_sub_id" value="<?php echo esc_attr($_GET['subscription']); ?>" /> 
  41. <input type="text" class="couponInput" id="coupon_code" name="coupon_code" value="" /> 
  42. <input type='submit' class="button <?php echo apply_filters('membership_subscription_button_color', 'blue'); ?>" id="submit_coupon_code" value = '<?php _e('Apply Coupon', 'membership'); ?>' /> 
  43. </div> 
  44. <?php } elseif( method_exists( $coupon, 'get_coupon_code') && $coupon->get_coupon_code() != false ) { ?> 
  45. <div class="couponEntry"> 
  46. <?php _e('Using Coupon Code: ', 'membership'); ?> 
  47. <strong><?php echo $coupon->get_coupon_code(); ?></strong> 
  48. <input type="hidden" id="coupon_sub_id" name="coupon_sub_id" value="<?php echo esc_attr($_GET['subscription']); ?>" /> 
  49. <input type="hidden" class="couponInput" id="coupon_code" name="coupon_code" value="" /> 
  50. <input type='submit' class="button <?php echo apply_filters('membership_subscription_button_color', 'blue'); ?>" id="submit_coupon_code" value = '<?php _e('Remove Coupon', 'membership'); ?>' /> 
  51. </div> 
  52. <?php } ?> 
  53. </form> 
  54. </div> 
  55. </div> 
.