Plugin Directory

Changeset 3333617


Ignore:
Timestamp:
07/24/2025 12:16:11 PM (7 months ago)
Author:
ampmode
Message:

Submitting 2.3.4 plugin version

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

Legend:

Unmodified
Added
Removed
  • woo-free-product-sample/trunk/public/class-woo-free-product-sample-public.php

    r3302391 r3333617  
    408408
    409409    /**
    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 ) {
    416425
    417426        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);
    418440        $setting_options   = \Woo_Free_Product_Sample_Helper::wfps_settings();
    419441        $notice_type       = isset( $setting_options['limit_per_order'] ) ? $setting_options['limit_per_order'] : null;
  • woo-free-product-sample/trunk/readme.txt

    r3302391 r3333617  
    115115
    116116== Changelog ==
     117#### 2.3.4
     118* Prevent Adding Free Product sample twice in one click
     119
    117120#### 2.3.3
    118121* 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  
    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.3.3
     11 * Version:           2.3.4
    1212 * Author:            AMP-MODE
    1313 * Author URI:        https://amplifyplugins.com
     
    3131}
    3232
    33 define( 'WFPS_VERSION', '2.3.3' );
     33define( 'WFPS_VERSION', '2.3.4' );
    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.