Changeset 3333617
- Timestamp:
- 07/24/2025 12:16:11 PM (7 months ago)
- Location:
- woo-free-product-sample/trunk
- Files:
-
- 3 edited
-
public/class-woo-free-product-sample-public.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
woo-free-product-sample.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-free-product-sample/trunk/public/class-woo-free-product-sample-public.php
r3302391 r3333617 408 408 409 409 /** 410 * Display validation message when order a product sample 411 * 412 * @since 2.0.0 413 * @param int, array 414 */ 415 public function wfps_set_limit_per_order( $valid, $product_id ) { 410 * This also prevent duplicate product added in short period of time. 411 * 412 * This function enforces a cooldown period between attempts to add the same product to the cart, 413 * and also applies quantity limits based on plugin settings. Displays a notice and redirects back 414 * to the product page if the user exceeds the allowed limit. 415 * 416 * @param bool $valid Whether the product can be added to the cart (initial state). 417 * @param int $product_id ID of the product being added. 418 * @param int $quantity Quantity of the product being added. 419 * @param int $variation_id Optional. ID of the product variation (default is 0). 420 * @param mixed $variations Optional. Additional variation data (default is null). 421 * 422 * @return bool Returns false if cooldown is triggered or limit exceeded, otherwise returns the original $valid value. 423 */ 424 public function wfps_set_limit_per_order( $valid, $product_id, $quantity, $variation_id = 0, $variations = null ) { 416 425 417 426 global $woocommerce; 427 $key = 'recent_add_' . ($variation_id ?: $product_id); 428 429 $now = time(); 430 $cooldown_seconds = 5; 431 432 // Get the last added timestamp 433 $last_added = WC()->session->get($key); 434 435 if ($last_added && ($now - $last_added) < $cooldown_seconds) { 436 return false; 437 } 438 // Update timestamp in session 439 WC()->session->set($key, $now); 418 440 $setting_options = \Woo_Free_Product_Sample_Helper::wfps_settings(); 419 441 $notice_type = isset( $setting_options['limit_per_order'] ) ? $setting_options['limit_per_order'] : null; -
woo-free-product-sample/trunk/readme.txt
r3302391 r3333617 115 115 116 116 == Changelog == 117 #### 2.3.4 118 * Prevent Adding Free Product sample twice in one click 119 117 120 #### 2.3.3 118 121 * Fix max value bug when Maximum Limit Type is set to Order and apply max input value in UI -
woo-free-product-sample/trunk/woo-free-product-sample.php
r3302391 r3333617 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.3. 311 * Version: 2.3.4 12 12 * Author: AMP-MODE 13 13 * Author URI: https://amplifyplugins.com … … 31 31 } 32 32 33 define( 'WFPS_VERSION', '2.3. 3' );33 define( 'WFPS_VERSION', '2.3.4' ); 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.