wcap_change_frontend_cart_coupon_form

The Woocommerce Coupon Selector wcap change frontend cart coupon form class.

Defined (1)

The class is defined in the following location(s).

/includes/front-end/cart/wcap_change_frontend_coupon_form.php  
  1. class wcap_change_frontend_cart_coupon_form { 
  2. public function __construct() { 
  3. add_action( 'woocommerce_cart_coupon', array(&$this, 'wcap_add_coupon_selector_link')); 
  4. add_action( 'wp_ajax_show_coupon_selector_form', array(&$this, 'wcap_show_coupon_selector_form') ); 
  5. add_action( 'wp_ajax_nopriv_show_coupon_selector_form', array(&$this, 'wcap_show_coupon_selector_form') ); 
  6.  
  7. public function wcap_add_coupon_selector_link() { 
  8.  
  9. ?> 
  10.  
  11. <div class="messagepop pop" id="wcapresponsediv"> 
  12.  
  13. </div> 
  14.  
  15. <input type="button" class="button" href="#" id="all_coupons" value="<?php echo __('All Coupons', 'wcap'); ?>"> 
  16.  
  17. <?php 
  18.  
  19. public function wcap_show_coupon_selector_form() { 
  20. global $woocommerce; 
  21. $couponargs = array( 'post_type' => 'shop_coupon', 'posts_per_page' => -1); 
  22. $mycoupons = get_posts( $couponargs ); 
  23.  
  24.  
  25. ?> 
  26. <div class="white_content"> 
  27.  
  28. <div id="closediv" style="float:right; margin:0px 10px 0px 2px;"><a class="wcapclose"><img src="<?php echo wcap_PLUGIN_URL; ?>/assets/images/close.png" alt="<?php echo __('close', 'wcap'); ?>"></a></div> 
  29. <br /> 
  30. <table width="100%"> 
  31. <tr> 
  32. <th width="5%"></th> 
  33. <th width="10%"><?php echo __('Code', 'wcap'); ?></th> 
  34. <th width="75%"><?php echo __('Description', 'wcap'); ?></th> 
  35. <th width="10%"><?php echo __('Discount', 'wcap'); ?></th> 
  36. </tr> 
  37. <?php  
  38. $couponnumber=0; 
  39. foreach ($mycoupons as $mycoupon) {  
  40. $exclude_in_coupon_selector = 'no'; 
  41. if ( class_exists('WC_Coupon') ) { 
  42. $coupon = new WC_Coupon(get_the_title($mycoupon->ID)); 
  43. $exclude_in_coupon_selector = $mycoupon->exclude_in_coupon_selector; 
  44. $couponavailibility = $coupon->is_valid(); 
  45. $couponexpiry = $mycoupon->expiry_date; 
  46.  
  47.  
  48. if ($exclude_in_coupon_selector != "yes") { 
  49.  
  50. ?> 
  51. <tr> 
  52. <td> <input type="radio" class="wcapradio " name="couponradiovalue" value="<?php echo get_the_title($mycoupon->ID); ?>" <?php if ($couponavailibility != 1) { echo 'disabled="disabled"'; } ?>> </th> 
  53. <td><span class="wcapcouponcode"><?php echo get_the_title($mycoupon->ID); ?></span></th> 
  54. <td><span class="wcapdescription"><?php echo $mycoupon->post_excerpt; ?></span> 
  55. <?php if (isset($couponexpiry) && ($couponexpiry != '')) { ?><span class="wcapseparator">/</span><span class="wcapexpirytext"><?php echo __('Expiry Date', 'wcap'); ?></span>: <span class="wcapexpirydate"><?php echo date("d-m-Y", strtotime($couponexpiry)); } ?></span> 
  56. <span class="wcapfreeshipping"><?php if (isset($coupon->free_shipping) && ($coupon->free_shipping == 'yes')) { ?><span class="wcapseparator">/</span><?php echo __('Free Shipping', 'wcap'); } ?> </span> 
  57. <span class="minimumspendtext"><?php if (isset($coupon->minimum_amount) && ($coupon->minimum_amount > 0)) { ?><span class="wcapseparator">/</span><?php echo __('Minimum Spend Required', 'wcap'); ?> </span> : <span class="minimumspendamount"><?php echo woocommerce_price($coupon->minimum_amount); } ?></span> 
  58. </th> 
  59. <td><span class="wcapdiscount"><?php  
  60.  
  61. if (isset($coupon->type) && ($coupon->type !='')) { $discounttype= $coupon->type; } else { $discounttype= $coupon->discount_type;} 
  62. switch($discounttype) { 
  63. case "fixed_cart": 
  64. echo ''.woocommerce_price($coupon->coupon_amount).''; 
  65. break; 
  66.  
  67. case "percent": 
  68. echo ''.$coupon->coupon_amount.'%'; 
  69. break; 
  70.  
  71. case "fixed_product": 
  72. echo ''.woocommerce_price($coupon->coupon_amount).''; 
  73. break; 
  74.  
  75. case "percent_product": 
  76. echo ''.$coupon->coupon_amount.'%'; 
  77. break; 
  78.  
  79.  
  80.  
  81.  
  82. ?></span></td> 
  83.  
  84. </tr> 
  85. <?php  
  86. $couponnumber++; 
  87.  
  88. ?> 
  89. </table> 
  90. <?php if ( $couponnumber == 0) { ?> <center><b><?php echo __('There is no Coupon Available at this time.', 'wcap'); ?> </b></center> <?php } else { ?> 
  91. <br /> 
  92. <center><button class="button" id="enter_coupon_code" ><?php echo __('Enter Coupon Code', 'wcap'); ?></button></center> 
  93. <br /> 
  94. <?php } ?> 
  95. </div> 
  96. <?php 
  97.  
  98. die(); 
  99.  
  100.  
  101.  
  102.  
  103.