Changeset 3358698
- Timestamp:
- 09/09/2025 02:55:30 PM (6 months ago)
- Location:
- woo-free-product-sample/trunk
- Files:
-
- 4 edited
-
includes/woo-free-product-sample-functions.php (modified) (1 diff)
-
public/class-woo-free-product-sample-public.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
woo-free-product-sample.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-free-product-sample/trunk/includes/woo-free-product-sample-functions.php
r3302391 r3358698 18 18 19 19 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 } 25 30 return false; 26 31 } -
woo-free-product-sample/trunk/public/class-woo-free-product-sample-public.php
r3335878 r3358698 631 631 */ 632 632 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 } 644 649 return $args; 645 650 } … … 724 729 725 730 /** 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 730 734 */ 731 735 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 } 733 740 if ( class_exists('WC_Min_Max_Quantities') && WC()->cart->get_cart_contents_count() != 0 ) { 734 741 foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { … … 739 746 } 740 747 } 741 742 748 } 743 749 … … 746 752 * 747 753 * @since 2.0.0 748 * @param array749 754 */ 750 755 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; 758 769 } 759 770 -
woo-free-product-sample/trunk/readme.txt
r3335878 r3358698 7 7 WC tested up to: 7.5.1 8 8 Requires PHP: 5.6 9 Stable tag: 2. 49 Stable tag: 2.5 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 115 115 116 116 == Changelog == 117 #### 2.5 118 * FIX: PHP fatal error when cart no initialized 119 117 120 #### 2.4 118 121 * DEV: Added FSE Theme Support -
woo-free-product-sample/trunk/woo-free-product-sample.php
r3335878 r3358698 9 9 * Plugin URI: https://wordpress.org/plugins/woo-free-product-sample 10 10 * Description: It allows customers to order a product sample in a simple way. 11 * Version: 2. 411 * Version: 2.5 12 12 * Author: AMP-MODE 13 13 * Author URI: https://amplifyplugins.com … … 31 31 } 32 32 33 define( 'WFPS_VERSION', '2. 4' );33 define( 'WFPS_VERSION', '2.5' ); 34 34 define( 'WFPS_MINIMUM_PHP_VERSION', '5.6.0' ); 35 35 define( 'WFPS_MINIMUM_WP_VERSION', '4.4' );
Note: See TracChangeset
for help on using the changeset viewer.