Exemplo n.º 1
0
 /**
  * @param boolean $result
  * @param EM_Booking $EM_Booking
  * @return boolean
  */
 public static function em_booking_get_post($result, $EM_Booking)
 {
     if (!empty($_REQUEST['coupon_code'])) {
         $EM_Coupon = EM_Coupons::event_get_coupon($_REQUEST['coupon_code'], $EM_Booking->get_event());
         if ($EM_Coupon === false && !empty($EM_Booking->booking_id)) {
             //if a previously saved booking, account for the fact it may not work
             $EM_Coupon = new EM_Coupon($EM_Booking->booking_meta['coupon']);
         }
         if ($EM_Coupon !== false) {
             $EM_Booking->booking_meta['coupon'] = $EM_Coupon->to_array();
             //we add an clean a coupon array here for the first time
             $EM_Booking->calculate_price();
             //refresh price
         } else {
             $EM_Booking->booking_meta['coupon'] = array('coupon_code' => $_REQUEST['coupon_code']);
             //will not validate later
         }
     }
     return apply_filters('em_coupons_em_booking_get_post', $result, $EM_Booking);
 }