Plugin Directory

Changeset 1894889


Ignore:
Timestamp:
06/19/2018 04:42:00 AM (8 years ago)
Author:
leehld
Message:

Update version 1.8.2

Location:
wp-hotel-booking-woocommerce
Files:
65 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • wp-hotel-booking-woocommerce/trunk/readme.txt

    r1879609 r1894889  
    5959== Changelog ==
    6060
     61= 1.8.2 =
     62+ Update compatible when checkout room with WPML
     63
    6164= 1.8.1 =
    6265+ Update process after checkout by Woocommerce
  • wp-hotel-booking-woocommerce/trunk/wp-hotel-booking-woocommerce.php

    r1882303 r1894889  
    55  Description: Support paying for a booking with the payment system provided by WooCommerce
    66  Author: ThimPress
    7   Version: 1.8.1
     7  Version: 1.8.2
    88  Author URI: http://thimpress.com
    99  Tags: wphb
     
    3939            $this->_defines();
    4040
     41
    4142            require_once "includes/functions.php";
    4243            require_once "includes/class-hb-wc-settings.php";
     
    4849                add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
    4950
    50                 // woommerce currency
     51                //              // woommerce currency
    5152                add_filter( 'hb_currency', array( $this, 'woocommerce_currency' ), 50 );
    5253                add_filter( 'hotel_booking_payment_current_currency', array( $this, 'woocommerce_currency' ), 50 );
     
    6667                    'hotel_booking_cart_item_total_amount'
    6768                ), 10, 4 );
    68                 // add_filter( 'hotel_booking_cart_item_amount_singular', array( $this, 'hotel_booking_cart_item_amount_singular' ), 10, 4 );
     69                add_filter( 'hotel_booking_cart_item_amount_singular', array(
     70                    $this,
     71                    'hotel_booking_cart_item_amount_singular'
     72                ), 10, 4 );
    6973                // tax enable
    7074                add_filter( 'hb_price_including_tax', array( $this, 'hb_price_including_tax' ), 10, 2 );
    7175
    7276                // trigger WC cart room item
    73                 add_filter( 'hotel_booking_added_cart', array( $this, 'hotel_add_to_cart' ), 10, 2 );
     77                add_filter( 'hotel_booking_added_cart', array( $this, 'hotel_add_to_cart' ), 10, 3 );
    7478                // trigger WC remove cart room item
    7579                add_action( 'hotel_booking_remove_cart_item', array( $this, 'hotel_remove_cart_item' ), 10, 2 );
     
    110114                    'get_cart_item_from_session'
    111115                ), 10, 3 );
    112                 // // tax enable
     116                // tax enable
    113117                add_filter( 'hotel_booking_extra_tax_enable', array( $this, 'tax_enable' ) );
    114118
     
    170174         * @param $cart_item_id
    171175         * @param $params
    172          *
    173          * @return string
    174          */
    175         public function hotel_add_to_cart( $cart_item_id, $params ) {
    176             // remove_action( 'hotel_booking_added_cart', array( $this, 'hotel_add_to_cart' ), 10, 2 );
     176         * @param $posts
     177         *
     178         * @return string
     179         */
     180        public function hotel_add_to_cart( $cart_item_id, $params, $posts ) {
    177181            global $woocommerce;
    178182
    179183            if ( ! $woocommerce || ! $woocommerce->cart ) {
    180                 return '';
     184                return $cart_item_id;
    181185            }
    182186
     
    202206                if ( class_exists( 'SitePress' ) ) {
    203207                    global $sitepress;
    204                     if ( $sitepress->get_default_language() == ICL_LANGUAGE_CODE ) {
     208
     209                    $product_id = $woo_cart_param['product_id'];
     210                    $post_type  = get_post_type( $product_id );
     211                    if ( in_array( $post_type, array( 'hb_room', 'hb_extra_room' ) ) ) {
     212                        $languages = $sitepress->get_ls_languages();
     213
     214                        //                  foreach ( array_keys( $languages ) as $language ) {
     215                        //                      $duplicate_product_id = apply_filters( 'wpml_object_id', $woo_cart_param['product_id'], $post_type, false, $language );
     216                        //                      if ( $duplicate_product_id ) {
     217                        //                          $woocommerce->cart->add_to_cart( $duplicate_product_id, $params['quantity'], null, array(), $woo_cart_param );
     218                        //                      }
     219                        //                  }
     220
    205221                        $woocommerce->cart->add_to_cart( $woo_cart_param['product_id'], $params['quantity'], null, array(), $woo_cart_param );
    206222                    }
     
    210226            }
    211227
    212             // add_action( 'hotel_booking_added_cart', array( $this, 'hotel_add_to_cart' ), 10, 2 );
     228            //                      add_action( 'hotel_booking_added_cart', array( $this, 'hotel_add_to_cart' ), 10, 2 );
    213229
    214230            do_action( 'hb_wc_after_add_to_cart', $cart_item_id, $params );
     
    224240            remove_action( 'hotel_booking_remove_cart_item', array( $this, 'hotel_remove_cart_item' ), 10 );
    225241            global $woocommerce;
     242
     243            if ( ! $woocommerce->cart ) {
     244                return;
     245            }
    226246
    227247            $woo_cart_items = $woocommerce->cart->cart_contents;
Note: See TracChangeset for help on using the changeset viewer.