/**
  * Removes all payment methods when cart has a booking that requires confirmation.
  *
  * @param  array $available_gateways
  * @return array
  */
 public function remove_payment_methods($available_gateways)
 {
     if (wc_booking_cart_requires_confirmation()) {
         unset($available_gateways);
         $available_gateways = array();
         $available_gateways['wc-booking-gateway'] = new WC_Bookings_Gateway();
     }
     return $available_gateways;
 }
 /**
  * Removes all products when cart have a booking which requires confirmation
  *
  * @param  bool $passed
  * @param  int  $product_id
  *
  * @return bool
  */
 public function validate_booking_requires_confirmation($passed, $product_id)
 {
     if (wc_booking_requires_confirmation($product_id)) {
         $items = WC()->cart->get_cart();
         foreach ($items as $item_key => $item) {
             if (!isset($item['booking']) || !wc_booking_requires_confirmation($item['product_id'])) {
                 WC()->cart->remove_cart_item($item_key);
             }
         }
     } elseif (wc_booking_cart_requires_confirmation()) {
         // Remove bookings that requires confirmation.
         $this->remove_booking_that_requires_confirmation();
         wc_add_notice(__('A booking that requires confirmation has been removed from your cart. It is not possible to complete the purchased along with a booking that doesn\'t require confirmation.', 'woocommerce-bookings'), 'notice');
     }
     return $passed;
 }
 /**
  * Removes all products when cart have a booking which requires confirmation
  *
  * @param  bool $passed
  * @param  int  $product_id
  *
  * @return bool
  */
 public function validate_booking_requires_confirmation($passed, $product_id)
 {
     if (wc_booking_requires_confirmation($product_id)) {
         // Remove any other cart items.
         WC()->cart->empty_cart();
     } elseif (wc_booking_cart_requires_confirmation()) {
         // Remove bookings that requires confirmation.
         $this->remove_booking_that_requires_confirmation();
         wc_add_notice(__('A booking that requires confirmation has been removed from your cart. It is not possible to complete the purchased along with a booking that doesn\'t require confirmation.', 'woocommerce-bookings'), 'notice');
     }
     return $passed;
 }