Plugin Directory

Changeset 3485891


Ignore:
Timestamp:
03/18/2026 05:04:29 PM (9 days ago)
Author:
themefic
Message:

1.4.1

Location:
travelfic-toolkit
Files:
124 added
3 edited

Legend:

Unmodified
Added
Removed
  • travelfic-toolkit/trunk/inc/elementor-widgets/travelfic-hotels.php

    r3473432 r3485891  
    22
    33use \Tourfic\Classes\Hotel\Pricing as Hotel_Price;
     4use \Tourfic\Classes\Tour\Pricing as Tour_Price;
     5use \Tourfic\Classes\Helper as Tourfic_Helper;
    46
    57class Travelfic_Toolkit_Hotels extends \Elementor\Widget_Base
    68{
     9
     10    /**
     11     * Get minimum tour card price from Tourfic pricing engine with legacy fallback.
     12     *
     13     * @param int   $post_id     Tour post id.
     14     * @param array $option_meta Tour options meta.
     15     * @return float
     16     */
     17    protected function tft_get_tour_card_price( $post_id, $option_meta = array() ) {
     18        $option_meta = is_array( $option_meta ) ? $option_meta : array();
     19        $pricing_rule = ! empty( $option_meta['pricing'] ) ? $option_meta['pricing'] : '';
     20        $minimum_setting = class_exists( '\Tourfic\Classes\Helper' ) && ! empty( Tourfic_Helper::tfopt( 'tour_archive_price_minimum_settings' ) ) ? Tourfic_Helper::tfopt( 'tour_archive_price_minimum_settings' ) : 'adult';
     21        $disable_adult_price = ! empty( $option_meta['disable_adult_price'] );
     22        $disable_child_price = ! empty( $option_meta['disable_child_price'] );
     23        $disable_infant_price = ! empty( $option_meta['disable_infant_price'] );
     24
     25        if ( class_exists( '\Tourfic\Classes\Tour\Pricing' ) ) {
     26            $avail_prices = Tour_Price::instance( $post_id )->get_avail_price();
     27            $calculated_prices = array();
     28
     29            if ( 'group' === $pricing_rule && ! empty( $avail_prices['group_price'] ) ) {
     30                $calculated_prices[] = (float) $avail_prices['group_price'];
     31            }
     32
     33            if ( 'person' === $pricing_rule || 'package' === $pricing_rule ) {
     34                if ( 'all' === $minimum_setting ) {
     35                    if ( ! empty( $avail_prices['adult_price'] ) && ! $disable_adult_price ) {
     36                        $calculated_prices[] = (float) $avail_prices['adult_price'];
     37                    }
     38                    if ( ! empty( $avail_prices['child_price'] ) && ! $disable_child_price ) {
     39                        $calculated_prices[] = (float) $avail_prices['child_price'];
     40                    }
     41                }
     42                if ( 'adult' === $minimum_setting && ! empty( $avail_prices['adult_price'] ) && ! $disable_adult_price ) {
     43                    $calculated_prices[] = (float) $avail_prices['adult_price'];
     44                }
     45                if ( 'child' === $minimum_setting && ! empty( $avail_prices['child_price'] ) && ! $disable_child_price ) {
     46                    $calculated_prices[] = (float) $avail_prices['child_price'];
     47                }
     48            }
     49
     50            if ( 'package' === $pricing_rule && ! empty( $avail_prices['group_price'] ) ) {
     51                $calculated_prices[] = (float) $avail_prices['group_price'];
     52            }
     53
     54            if ( ! empty( $calculated_prices ) ) {
     55                return (float) min( $calculated_prices );
     56            }
     57
     58            $fallback_prices = array();
     59
     60            if ( ! empty( $avail_prices['adult_price'] ) && ! $disable_adult_price ) {
     61                $fallback_prices[] = (float) $avail_prices['adult_price'];
     62            }
     63            if ( ! empty( $avail_prices['child_price'] ) && ! $disable_child_price ) {
     64                $fallback_prices[] = (float) $avail_prices['child_price'];
     65            }
     66            if ( ! empty( $avail_prices['infant_price'] ) && ! $disable_infant_price ) {
     67                $fallback_prices[] = (float) $avail_prices['infant_price'];
     68            }
     69            if ( ! empty( $avail_prices['group_price'] ) && ( 'group' === $pricing_rule || 'package' === $pricing_rule ) ) {
     70                $fallback_prices[] = (float) $avail_prices['group_price'];
     71            }
     72
     73            if ( ! empty( $fallback_prices ) ) {
     74                return (float) min( $fallback_prices );
     75            }
     76        }
     77
     78        if ( 'group' === $pricing_rule ) {
     79            return isset( $option_meta['group_price'] ) ? (float) $option_meta['group_price'] : 0;
     80        }
     81
     82        $person_prices = array();
     83        $adult_price = isset( $option_meta['adult_price'] ) ? $option_meta['adult_price'] : '';
     84        if ( ! $disable_adult_price && '' !== $adult_price ) {
     85            $person_prices[] = (float) $adult_price;
     86        }
     87
     88        $child_price = isset( $option_meta['child_price'] ) ? $option_meta['child_price'] : '';
     89        if ( ! $disable_child_price && '' !== $child_price ) {
     90            $person_prices[] = (float) $child_price;
     91        }
     92
     93        $infant_price = isset( $option_meta['infant_price'] ) ? $option_meta['infant_price'] : '';
     94        if ( ! $disable_infant_price && '' !== $infant_price ) {
     95            $person_prices[] = (float) $infant_price;
     96        }
     97
     98        return ! empty( $person_prices ) ? (float) min( $person_prices ) : 0;
     99    }
    7100
    8101    /**
     
    26562749
    26572750                                        // pricing
    2658                                         $tf_pricing = !empty($option_meta['pricing']) ? $option_meta['pricing'] : '';
    2659 
    2660                                         if ($tf_pricing === 'group') {
    2661                                             $tf_total_price = $option_meta['group_price'] ?? 0;
    2662                                         } else {
    2663                                             $disable_adult_price  = !empty($option_meta['disable_adult_price']) ? $option_meta['disable_adult_price'] : false;
    2664                                             $disable_child_price  = !empty($option_meta['disable_child_price']) ? $option_meta['disable_child_price'] : false;
    2665                                             $disable_infant_price = !empty($option_meta['disable_infant_price']) ? $option_meta['disable_infant_price'] : false;
    2666 
    2667                                             $person_prices = [];
    2668 
    2669                                             $tf_adult_price = isset($option_meta['adult_price']) ? $option_meta['adult_price'] : '';
    2670                                             if (!$disable_adult_price && '' !== $tf_adult_price) {
    2671                                                 $person_prices[] = (float) $tf_adult_price;
    2672                                             }
    2673 
    2674                                             $tf_child_price = isset($option_meta['child_price']) ? $option_meta['child_price'] : '';
    2675                                             if (!$disable_child_price && '' !== $tf_child_price) {
    2676                                                 $person_prices[] = (float) $tf_child_price;
    2677                                             }
    2678 
    2679                                             $tf_infant_price = isset($option_meta['infant_price']) ? $option_meta['infant_price'] : '';
    2680                                             if (!$disable_infant_price && '' !== $tf_infant_price) {
    2681                                                 $person_prices[] = (float) $tf_infant_price;
    2682                                             }
    2683 
    2684                                             $tf_total_price = !empty($person_prices) ? min($person_prices) : 0;
    2685                                         }
     2751                                        $tf_total_price = $this->tft_get_tour_card_price( $post_id, $option_meta );
    26862752
    26872753                                        // location
  • travelfic-toolkit/trunk/readme.txt

    r3481112 r3485891  
    44Requires at least: 5.4
    55Tested up to: 6.9
    6 Stable tag: 1.4.0
     6Stable tag: 1.4.1
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    149149== Changelog ==
    150150
     151= 1.4.1 – March 18, 2026 =
     152
     153- Fixed: Demo 4 tour card price mismatch with Tourfic pricing engine.
     154
    151155= 1.4.0 – March 12, 2026 =
    152156
  • travelfic-toolkit/trunk/travelfic-toolkit.php

    r3481112 r3485891  
    55 * Description: A companion plugin to the Travelfic Theme with which you can easily build your own Hotel, Accommodation, Tour & Travel Booking website on WordPress.
    66 * Author: Themefic
    7  * Version: 1.4.0
     7 * Version: 1.4.1
    88 * Tested up to: 6.9
    99 * Text Domain: travelfic-toolkit
     
    2525define( 'TRAVELFIC_TOOLKIT_PATH', plugin_dir_path( __FILE__ ) );
    2626define( 'TRAVELFIC_TOOLKIT_ASSETS', TRAVELFIC_TOOLKIT_URL . 'assets/' );
    27 define( 'TRAVELFIC_TOOLKIT_VERSION', '1.4.0' );
     27define( 'TRAVELFIC_TOOLKIT_VERSION', '1.4.1' );
    2828
    2929if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
Note: See TracChangeset for help on using the changeset viewer.