Advertisement
Guest User

wp-travel-customize

a guest
Nov 27th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.80 KB | None | 0 0
  1. <?php
  2. /**
  3.  * WP Travel Checkout.
  4.  *
  5.  * @package WP Travel
  6.  */
  7.  
  8. // Exit if accessed directly.
  9. if ( ! defined( 'ABSPATH' ) ) {
  10.     exit;
  11. }
  12. global $wt_cart;
  13. $trips = $wt_cart->getItems();
  14.  
  15. if ( ! $trips ) {
  16.     $wt_cart->cart_empty_message();
  17.     return;
  18. }
  19.  
  20. $settings = wp_travel_get_settings();
  21.  
  22. $checkout_page_url = wp_travel_get_checkout_url();
  23.  
  24. if ( isset( $settings['checkout_page_id'] ) ) {
  25.     $checkout_page_id = $settings['checkout_page_id'];
  26.     $checkout_page_url = get_permalink( $checkout_page_id );
  27. }
  28.  
  29. $pax_label = __( 'Pax', 'wp-travel' );
  30. $max_attr = '';
  31.  
  32. // For old form
  33. $trip_id = ( isset( $_GET['trip_id'] ) && '' !== $_GET['trip_id'] ) ? $_GET['trip_id'] : '';
  34. $trip_duration = ( isset( $_GET['trip_duration'] ) && '' !== $_GET['trip_duration'] ) ? $_GET['trip_duration'] : 1;
  35.  
  36. $fixed_departure = get_post_meta( $trip_id, 'wp_travel_fixed_departure', true );
  37. $settings        = wp_travel_get_settings();
  38. $currency_code   = ( isset( $settings['currency'] ) ) ? $settings['currency'] : '';
  39. $currency_symbol = wp_travel_get_currency_symbol( $currency_code );
  40. $per_person_text = wp_travel_get_price_per_text( $trip_id );
  41.  
  42. // Print Errors / Notices.
  43. wp_travel_print_notices();
  44. ?>
  45.  
  46. <!-- CART HTML START -->
  47. <div class="ws-theme-cart-page">
  48.     <form action="<?php echo esc_url( $checkout_page_url ); ?>" method="post">
  49.  
  50.         <table class="ws-theme-cart-list">
  51.             <thead>
  52.                 <tr>
  53.                     <th></th>
  54.                     <th></th>
  55.                     <th colspan="2"><?php esc_html_e( 'Tour', 'wp-travel' ); ?></th>
  56.                     <th><?php esc_html_e( 'Price', 'wp-travel' ); ?></th>
  57.                     <th><?php esc_html_e( 'PAX', 'wp-travel' ); ?></th>
  58.                     <th class="text-right"><?php esc_html_e( 'Total', 'wp-travel' ); ?></th>
  59.                 </tr>
  60.             </thead>
  61.             <tbody>            
  62.                 <?php
  63.                 foreach ( $trips as $cart_id => $trip ) :
  64.                     $pricing_label   = false;
  65.                     $trip_id         = $trip['trip_id'];
  66.                     // $price           = $trip['price']; // Price of single qty.
  67.                     $trip_price      = $trip['trip_price'];
  68.                     $trip_duration   = isset( $trip['trip_duration'] ) ? $trip['trip_duration'] : '';
  69.                     $trip_start_date = isset( $trip['trip_start_date'] ) && ! empty( $trip['trip_start_date'] ) ? wp_travel_format_date( $trip['trip_start_date'] ) : false;
  70.                    
  71.                     $pax            = $trip['pax'];
  72.                     $price_key      = isset( $trip['price_key'] ) ? $trip['price_key'] : '';
  73.                     $enable_partial = $trip['enable_partial'];
  74.                     $trip_price_partial = $trip['trip_price_partial'];
  75.                    
  76.                     $pax_label      = isset( $trip['pax_label'] ) ? $trip['pax_label'] : '';
  77.                     $max_available  = isset( $trip['max_available'] ) ? $trip['max_available'] : '';
  78.  
  79.                     $trip_extras = isset( $trip['trip_extras'] ) ? $trip['trip_extras'] : array();
  80.  
  81.                     if ( ! empty( $price_key ) ) :
  82.                         $pricing_options = wp_travel_get_pricing_variation( $trip_id, $price_key );
  83.                         $pricing_option  = ( is_array( $pricing_options ) && ! empty( $pricing_options ) ) ? reset( $pricing_options ) : false;
  84.  
  85.                         if ( $pricing_option )
  86.                             $pricing_label = isset( $pricing_option['pricing_name'] ) ? $pricing_option['pricing_name'] : false;
  87.                     endif;
  88.                     $pax_limit = '';
  89.                     /**
  90.                      * Customization Starts.
  91.                      */
  92.                     if( class_exists( 'WP_Travel_Util_Inventory' ) ) {
  93.                         $inventory  = new WP_Travel_Util_Inventory();
  94.                         // $available_pax = $inventory->get_available_pax( $trip_id, $price_key );
  95.                         $pax_limit = $inventory->get_pricing_option_pax_limit( $trip_id, $price_key );
  96.                     }
  97.                     $data_max_pax = apply_filters( 'wp_travel_data_max_pax', $max_available, $pax_limit );
  98.                     $max_available = apply_filters( 'wp_travel_available_pax', $max_available, $trip_id, $price_key );
  99.                    
  100.                     $min_available  = isset( $trip['min_available'] ) ? $trip['min_available'] : '1';
  101.                     $max_attr = '';
  102.                     $min_attr = 'min="1"';
  103.                     if ( $max_available ) {
  104.                         $max_attr = 'max="' . $max_available . '" data-max="' . $data_max_pax . '"';
  105.                     }
  106.                     /**
  107.                      * Customization Ends.
  108.                      */
  109.                     $min_available  = isset( $trip['min_available'] ) ? $trip['min_available'] : '1';
  110.                     $min_attr = 'min="1"';
  111.                     // if ( $max_available ) {
  112.                     //  $max_attr = 'max="' . $max_available . '"';
  113.                     // }
  114.                     if ( $min_available ) {
  115.                         $min_attr = 'min="' . $min_available . '"';
  116.                     }
  117.                     $single_trip_total = wp_travel_get_formated_price( $trip_price * $pax );
  118.  
  119.                     $price_per = 'trip-default';
  120.  
  121.                     if( isset( $trip['price_key'] ) && ! empty( $trip['price_key'] ) ) {
  122.                         $price_per = wp_travel_get_pricing_variation_price_per( $trip['trip_id'], $trip['price_key'] );
  123.                     }
  124.  
  125.                     if( 'trip-default' === $price_per )
  126.                         $price_per = get_post_meta( $trip['trip_id'], 'wp_travel_price_per', true );
  127.                    
  128.                     if ( 'group' === $price_per ) {
  129.                        
  130.                         $single_trip_total = wp_travel_get_formated_price( $trip_price );
  131.                    
  132.                     }
  133.                    
  134.                     ?>
  135.  
  136.                     <tr class="responsive-cart has_options_selected">
  137.                         <td class="product-remove" >
  138.                             <a href="" class="wp-travel-cart-remove tooltip-area" data-cart-id="<?php echo esc_attr( $cart_id ) ?>" title="<?php esc_attr_e( 'Remove this tour', 'wp-travel' ) ?>">×</a>
  139.                         </td>
  140.                         <td class="product-thumbnail" >
  141.                             <a href="<?php echo esc_html( get_permalink( $trip_id ) ); ?>">
  142.                             <?php echo wp_kses( wp_travel_get_post_thumbnail( $trip_id ), wp_travel_allowed_html( array( 'img' ) ) ); ?>
  143.                             </a>
  144.                         </td>
  145.                         <td class="product-name" colspan="2" data-title="Tour">
  146.                             <div class="item_cart">
  147.                                 <h4>
  148.                                     <a href="<?php echo esc_html( get_permalink( $trip_id ) ); ?>"><?php echo esc_html( get_the_title( $trip_id ) );
  149.                                     if ( $pricing_label ) {
  150.                                         printf( __( ' (%s)', 'wp-travel' ), $pricing_label );
  151.                                     }
  152.                                     ?></a>
  153.                                 </h4>
  154.                                 <?php
  155.                                 if ( $trip_start_date ) :
  156.                                 ?>
  157.                                     <span class="variation">
  158.                                         <span><strong><?php esc_html_e( 'Booking Date:', 'wp-travel' ); ?></strong></span>
  159.                                         <span>
  160.                                         <?php $date_format = get_option( 'date_format' ); ?>
  161.                                             <?php if ( ! $date_format ) : ?>
  162.                                                 <?php $date_format = 'jS M, Y'; ?>
  163.                                             <?php endif; ?>
  164.                                             <?php echo esc_html( $trip_start_date ) ; ?>
  165.                                         </span>
  166.                                     </span>
  167.                                 <?php endif; ?>
  168.                             </div>
  169.                         </td>
  170.                         <td class="product-price" data-title="Price">
  171.                             <?php if ( ! empty( $trip_price ) && '0' !== $trip_price ) : ?>
  172.                                 <span class="person-count">
  173.                                     <ins>
  174.                                         <span class="wp-travel-trip-price" payment_price="<?php echo esc_attr( @$trip_tax_details['actual_trip_price'] ); ?>" trip_price="<?php echo esc_attr( $trip_price ); ?>" >
  175.                                             <?php echo apply_filters( 'wp_travel_itinerary_price', sprintf( ' %s %s ', $currency_symbol, $trip_price ), $currency_symbol, $trip_price ); ?>
  176.                                         </span>
  177.                                     </ins>/<?php echo esc_html( ucfirst( $pax_label ) ); ?>
  178.                                 </span>
  179.                             <?php endif; ?>
  180.                         </td>
  181.                         <td class="product-quantity" data-title="PAX">
  182.                             <div class="st_adults">
  183.                                 <!--<span class="label"><?php echo esc_html( ucfirst( $pax_label ) ); ?></span>-->
  184.                                 <!-- Customization Starts. -->
  185.                                 <input type="number" class="input-text wp-travel-pax text wp-travel-trip-pax wp-travel-trip-<?php echo esc_attr( $trip_id ) ?>" data-trip="wp-travel-trip-<?php echo esc_attr( $trip_id ) ?>" data-trip-id="<?php echo esc_attr( $trip_id ) ?>" step="1" <?php echo $min_attr; ?> <?php echo $max_attr; ?> name="pax" value="<?php echo esc_attr( $pax ); ?>" title="Qty" size="4" pattern="[0-9]*" inputmode="numeric">
  186.                                 <?php
  187.                                 $group_size = get_post_meta( $trip_id, 'wp_travel_group_size', true );
  188.                                 $total_booked_pax = wp_travel_get_total_booked_pax( $trip_id, false );
  189.                                 ?>
  190.                                 <input type="hidden" class="wp-travel-customize-group-size" value="<?php echo esc_attr( $group_size ) ?>" >
  191.                                 <input type="hidden" class="wp-travel-customize-booked-group-size" value="<?php echo esc_attr( $total_booked_pax ) ?>" >
  192.                                
  193.                                 <!-- Customization Ends. -->                               
  194.                                 <input type="hidden" name="cart_id" value="<?php echo esc_attr( $cart_id ) ?>" >
  195.                                 <input type="hidden" name="trip_id" value="<?php echo esc_attr( $trip_id ) ?>" >
  196.                             </div>
  197.                         </td>
  198.                         <td class="product-subtotal text-right" data-title="Total">
  199.                             <?php if ( ! empty( $trip_price ) && '0' !== $trip_price ) : ?>
  200.                                 <div class="item_cart">
  201.                                     <p>
  202.                                         <strong><span class="woocommerce-Price-currencySymbol"><?php echo wp_travel_get_currency_symbol(); ?></span><span class="wp-travel-trip-total"> <?php echo esc_html( $single_trip_total ) ?> </span></strong>
  203.                                     </p>
  204.                                 </div>
  205.                             <?php endif; ?>
  206.                         </td>
  207.                     </tr>
  208.                     <tr class="child_products">
  209.                         <td colspan="8">
  210.                             <?php do_action( 'wp_travel_tour_extras_cart_block', $trip_extras, $cart_id ); ?>
  211.                         </td>
  212.                     </tr>
  213.                 <?php endforeach; ?>                   
  214.             </tbody>
  215.         </table>
  216.         <?php $cart_amounts = $wt_cart->get_total(); ?>
  217.             <table class="ws-theme-cart-list table-total-info">
  218.                 <?php
  219.                 $discounts = $wt_cart->get_discounts();
  220.                 if ( is_array( $discounts ) && ! empty( $discounts ) ) : ?>
  221.                     <tr>
  222.                         <th>
  223.                             <strong><?php esc_html_e( 'Coupon Discount: ', 'wp-travel' ); ?><span class="tax-percent">
  224.                                 <?php echo esc_html( $discounts['value'] ); ?> ( <?php echo 'percentage' === $discounts['type'] ? ' %' : wp_travel_get_currency_symbol(); ?> )
  225.                             </span></strong>
  226.                         </th>
  227.                         <td  class="text-right">
  228.                             <strong> - <span class="wp-travel-tax ws-theme-currencySymbol"><?php echo wp_travel_get_currency_symbol(); ?></span><?php echo esc_html( wp_travel_get_formated_price( $cart_amounts['discount'] ) ); ?></strong>
  229.                         </td>
  230.                     </tr>
  231.  
  232.                 <?php endif; ?>
  233.                 <?php if ( $tax_rate = wp_travel_is_taxable() ) : ?>
  234.                     <tr>
  235.                         <th>
  236.                             <p><strong><?php esc_html_e( 'Subtotal:', 'wp-travel' ); ?></strong></p>
  237.                             <strong><?php esc_html_e( 'Convenience fee: ', 'wp-travel' ); ?>
  238.                             <span class="tax-percent">
  239.                                 <?php echo esc_html( $tax_rate ); esc_html_e( '%', 'wp-travel' ); ?>
  240.                             </span></strong>
  241.                         </th>
  242.                         <td  class="text-right">
  243.                             <p><strong><span class="wp-travel-sub-total ws-theme-currencySymbol"><?php echo wp_travel_get_currency_symbol(); ?></span><?php echo esc_html( wp_travel_get_formated_price( $cart_amounts['sub_total'] ) ); ?></strong></p>
  244.                             <strong><span class="wp-travel-tax ws-theme-currencySymbol"><?php echo wp_travel_get_currency_symbol(); ?></span><?php echo esc_html( wp_travel_get_formated_price( $cart_amounts['tax'] ) ); ?></strong>
  245.                         </td>
  246.                     </tr>
  247.                 <?php endif; ?>
  248.                 <?php if ( ! empty( $trip_price ) && '0' !== $trip_price ) : ?>
  249.                 <tr>
  250.                     <th colspan="2">
  251.                         <strong><?php echo esc_html__( 'Total', 'wp-travel' ); ?></strong>
  252.                         <p class="total">
  253.                             <strong><?php echo wp_travel_get_currency_symbol(); ?><span class="wp-travel-total ws-theme-currencySymbol"><?php echo esc_html( wp_travel_get_formated_price( $cart_amounts['total'] ) ); ?></span></strong>
  254.                         </p>
  255.                     </th>
  256.                 </tr>
  257.                 <?php endif; ?>
  258.                 <tr>
  259.                     <td>
  260.                         <div class="coupon">
  261.                             <input type="text" name="wp_travel_coupon_code_input" class="input-text" id="coupon_code" value="" placeholder="<?php echo esc_attr__( 'Coupon Code', 'wp-travel' ); ?>">
  262.                             <input type="submit" class="button wp-travel-apply-coupon-btn" name="apply_coupon" value="<?php echo esc_attr__( 'Apply Coupon', 'wp-travel' ); ?>">
  263.                         </div>
  264.                     </td>
  265.  
  266.                     <td>
  267.                         <div class="actions">
  268.                             <button disabled onclick="javascript:void(0)"  class="btn_full wp-travel-update-cart-btn update-cart" ><?php esc_html_e( 'Update Cart', 'wp-travel' ) ?></button>                  
  269.                             <input type="submit" class="btn_full book-now-btn" value="<?php esc_html_e( 'Proceed to checkout', 'wp-travel' ) ?>">
  270.                         </div>
  271.                     </td>  
  272.                 </tr>
  273.             </table>
  274.     </form>
  275. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement