Plugin Directory

Changeset 3358698


Ignore:
Timestamp:
09/09/2025 02:55:30 PM (6 months ago)
Author:
ampmode
Message:

Adding 2.5 plugin version

Location:
woo-free-product-sample/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • woo-free-product-sample/trunk/includes/woo-free-product-sample-functions.php

    r3302391 r3358698  
    1818
    1919    function check_product_sample_is_added_in_cart() {
    20         foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
    21             if( isset( $cart_item['free_sample'] ) && isset( $cart_item['sample_price'] ) ) {
    22                 return true;
    23             }
    24         }
     20        if ( function_exists( 'WC' )) {
     21            if(null === WC()->cart){
     22                WC()->initialize_cart();
     23            }
     24            foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
     25                if( isset( $cart_item['free_sample'] ) && isset( $cart_item['sample_price'] ) ) {
     26                    return true;
     27                }
     28            }
     29        }
    2530        return false;
    2631    }
  • woo-free-product-sample/trunk/public/class-woo-free-product-sample-public.php

    r3335878 r3358698  
    631631     */
    632632    public function wfps_set_quantity_input_max( $args, $product ) {
    633         $cart = WC()->cart->get_cart(); // Get cart items
    634         $current_product_id = $product->get_id();
    635         $setting_options   = \Woo_Free_Product_Sample_Helper::wfps_settings();
    636         if ( ! empty( $cart ) ) {
    637             foreach ( $cart as $cart_item_key => $cart_item ) {
    638                 if ( isset( $cart_item['free_sample'] ) && $cart_item['free_sample'] == $current_product_id ) {
    639                     $args['max_value'] = !empty($setting_options['max_qty_per_order']) ? $setting_options['max_qty_per_order'] : $args['max_value'];
    640                     break;
    641                 }
    642             }
    643         }
     633        if ( function_exists( 'WC' )) {
     634            if(null === WC()->cart){
     635                WC()->initialize_cart();
     636            }
     637            $cart = WC()->cart->get_cart(); // Get cart items
     638            $current_product_id = $product->get_id();
     639            $setting_options   = \Woo_Free_Product_Sample_Helper::wfps_settings();
     640            if ( ! empty( $cart ) ) {
     641                foreach ( $cart as $cart_item_key => $cart_item ) {
     642                    if ( isset( $cart_item['free_sample'] ) && $cart_item['free_sample'] == $current_product_id ) {
     643                        $args['max_value'] = !empty($setting_options['max_qty_per_order']) ? $setting_options['max_qty_per_order'] : $args['max_value'];
     644                        break;
     645                    }
     646                }
     647            }
     648        }
    644649        return $args;
    645650    }
     
    724729
    725730    /**
    726      * Check WooCommerce min/max quantities validation message
    727      *
    728      * @since      2.0.0
    729      * @param      array
     731     * Unset all notices.
     732     *
     733     * @since      2.0.0
    730734     */
    731735    public function wfps_check_cart_items() {
    732         if( ! is_admin() ) {
     736        if ( function_exists( 'WC' ) && ! is_admin()) {
     737            if(null === WC()->cart){
     738                WC()->initialize_cart();
     739            }
    733740            if ( class_exists('WC_Min_Max_Quantities') && WC()->cart->get_cart_contents_count() != 0 ) {
    734741                foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
     
    739746            }
    740747        }
    741 
    742748    }
    743749
     
    746752     *
    747753     * @since      2.0.0
    748      * @param      array
    749754     */
    750755    public function wfps_cart_exclude( $exclude, $checking_id, $cart_item_key, $values ) {
    751         if ( class_exists('WC_Min_Max_Quantities') ) {
    752             foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
    753                 if(isset($values['free_sample']) && $values['free_sample'] == $values['product_id']) {
    754                     return 'yes';
    755                 }
    756             }
    757         }
     756        if ( function_exists( 'WC' )) {
     757            if(null === WC()->cart){
     758                WC()->initialize_cart();
     759            }
     760            if ( class_exists('WC_Min_Max_Quantities') ) {
     761                foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
     762                    if(isset($values['free_sample']) && $values['free_sample'] == $values['product_id']) {
     763                        return 'yes';
     764                    }
     765                }
     766            }
     767        }
     768        return $exclude;
    758769    }
    759770
  • woo-free-product-sample/trunk/readme.txt

    r3335878 r3358698  
    77WC tested up to: 7.5.1
    88Requires PHP: 5.6
    9 Stable tag: 2.4
     9Stable tag: 2.5
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    115115
    116116== Changelog ==
     117#### 2.5
     118* FIX: PHP fatal error when cart no initialized
     119
    117120#### 2.4
    118121* DEV: Added FSE Theme Support
  • woo-free-product-sample/trunk/woo-free-product-sample.php

    r3335878 r3358698  
    99 * Plugin URI:        https://wordpress.org/plugins/woo-free-product-sample
    1010 * Description:       It allows customers to order a product sample in a simple way.
    11  * Version:           2.4
     11 * Version:           2.5
    1212 * Author:            AMP-MODE
    1313 * Author URI:        https://amplifyplugins.com
     
    3131}
    3232
    33 define( 'WFPS_VERSION', '2.4' );
     33define( 'WFPS_VERSION', '2.5' );
    3434define( 'WFPS_MINIMUM_PHP_VERSION', '5.6.0' );
    3535define( 'WFPS_MINIMUM_WP_VERSION', '4.4' );
Note: See TracChangeset for help on using the changeset viewer.