Plugin Directory

Changeset 3265731


Ignore:
Timestamp:
04/02/2025 02:43:31 PM (12 months ago)
Author:
Elvin.Haci
Message:

fixed adjustment apply - bugfix

Location:
cartlink-generator
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cartlink-generator/tags/1.0.2/cartlink-generator.php

    r3264731 r3265731  
    33 * Plugin Name: CartLink Generator for WooCommerce
    44 * Description: Create dynamic cart links with pre-filled products, quantities, and custom prices, perfect for businesses interacting via chat to reduce purchase steps and drive faster conversions.
    5  * Version: 1.0.2
     5 * Version: 1.0.2.1
    66 * Author: Guaven Labs
    77 * Text Domain: cartlink-generator
     
    1818define( 'GUAVEN_CARTLINK_GENERATOR_PATH', plugin_dir_path( __FILE__ ) );
    1919define( 'GUAVEN_CARTLINK_GENERATOR_URL', plugin_dir_url( __FILE__ ) );
    20 define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.2.0');
     20define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.2.1');
    2121
    2222
  • cartlink-generator/tags/1.0.2/includes/hooks.php

    r3264731 r3265731  
    5555
    5656
    57 add_action( 'woocommerce_after_calculate_totals', 'gvnclg_apply_fixed_subtotal_adjustment' );
    5857
    59 function gvnclg_apply_fixed_subtotal_adjustment( $cart ) {
     58add_action('woocommerce_cart_calculate_fees', 'gvnclg_apply_fixed_subtotal_adjustment', 20);
     59function gvnclg_apply_fixed_subtotal_adjustment($cart) {
     60    if (is_admin() && !defined('DOING_AJAX')) return;
     61
     62
    6063    $fixed_subtotal = WC()->session->get( 'fixed_subtotal' );
    61 
     64   
     65    // Check if fee already exists to prevent multiple additions
     66    $fees = $cart->get_fees();
     67    foreach ($fees as $fee) {
     68        if ($fee->id === 'fixed-adjustment') {
     69            return; // Fee already exists, don't add again
     70        }
     71    }
    6272    if ( $fixed_subtotal > 0 ) {
    63         $cart->add_fee( __( 'Fixed Adjustment', 'cartlink-generator' ), -1 * $fixed_subtotal );
     73        $cart->add_fee(__('Fixed Adjustment', 'cartlink-generator'), -1*$fixed_subtotal, false);
    6474    }
    6575}
  • cartlink-generator/tags/1.0.2/readme.txt

    r3264731 r3265731  
    88WC tested up to: 9.8
    99Requires Plugins: woocommerce
    10 Stable tag: 1.0.2
     10Stable tag: 1.0.2.1
    1111License: GPLv2 or later
    1212License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    9797== Changelog ==
    9898
     99= 1.0.2.1 =
     100* Fixing "Fixed Adjustment is always zero" bug.
     101
    99102= 1.0.2 =
    100103* "Expire-dates are always 1 hour" bug fix
  • cartlink-generator/trunk/cartlink-generator.php

    r3264731 r3265731  
    33 * Plugin Name: CartLink Generator for WooCommerce
    44 * Description: Create dynamic cart links with pre-filled products, quantities, and custom prices, perfect for businesses interacting via chat to reduce purchase steps and drive faster conversions.
    5  * Version: 1.0.2
     5 * Version: 1.0.2.1
    66 * Author: Guaven Labs
    77 * Text Domain: cartlink-generator
     
    1818define( 'GUAVEN_CARTLINK_GENERATOR_PATH', plugin_dir_path( __FILE__ ) );
    1919define( 'GUAVEN_CARTLINK_GENERATOR_URL', plugin_dir_url( __FILE__ ) );
    20 define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.2.0');
     20define( 'GUAVEN_CARTLINK_GENERATOR_VERSION', '1.0.2.1');
    2121
    2222
  • cartlink-generator/trunk/includes/hooks.php

    r3264731 r3265731  
    5555
    5656
    57 add_action( 'woocommerce_after_calculate_totals', 'gvnclg_apply_fixed_subtotal_adjustment' );
    5857
    59 function gvnclg_apply_fixed_subtotal_adjustment( $cart ) {
     58add_action('woocommerce_cart_calculate_fees', 'gvnclg_apply_fixed_subtotal_adjustment', 20);
     59function gvnclg_apply_fixed_subtotal_adjustment($cart) {
     60    if (is_admin() && !defined('DOING_AJAX')) return;
     61
     62
    6063    $fixed_subtotal = WC()->session->get( 'fixed_subtotal' );
    61 
     64   
     65    // Check if fee already exists to prevent multiple additions
     66    $fees = $cart->get_fees();
     67    foreach ($fees as $fee) {
     68        if ($fee->id === 'fixed-adjustment') {
     69            return; // Fee already exists, don't add again
     70        }
     71    }
    6272    if ( $fixed_subtotal > 0 ) {
    63         $cart->add_fee( __( 'Fixed Adjustment', 'cartlink-generator' ), -1 * $fixed_subtotal );
     73        $cart->add_fee(__('Fixed Adjustment', 'cartlink-generator'), -1*$fixed_subtotal, false);
    6474    }
    6575}
  • cartlink-generator/trunk/readme.txt

    r3264731 r3265731  
    88WC tested up to: 9.8
    99Requires Plugins: woocommerce
    10 Stable tag: 1.0.2
     10Stable tag: 1.0.2.1
    1111License: GPLv2 or later
    1212License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    9797== Changelog ==
    9898
     99= 1.0.2.1 =
     100* Fixing "Fixed Adjustment is always zero" bug.
     101
    99102= 1.0.2 =
    100103* "Expire-dates are always 1 hour" bug fix
Note: See TracChangeset for help on using the changeset viewer.