Plugin Directory

Changeset 3341779


Ignore:
Timestamp:
08/08/2025 05:28:07 PM (7 months ago)
Author:
webikon
Message:

Fix free shipping threshold logic for DPD Parcel Shop

Location:
wc-dpd
Files:
88 added
3 edited

Legend:

Unmodified
Added
Removed
  • wc-dpd/trunk/includes/DpdParcelShopShippingMethod.php

    r3339385 r3341779  
    287287    public function calculate_shipping($package = [])
    288288    {
    289         $free_shipping = isset($this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY]) && (float) $this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY] > 0 ? (float) $this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY] : 0;
     289        // Check if free shipping threshold is set (including 0 as a valid value)
     290        $free_shipping_is_set = isset($this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY]) &&
     291                                $this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY] !== '' &&
     292                                $this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY] !== null;
     293
     294        $free_shipping = $free_shipping_is_set ? (float) $this->instance_settings[self::FREE_FIXED_SHIPPING_OPTION_KEY] : false;
    290295
    291296        // Get cart subtotal including tax
     
    300305
    301306        // Deduct tax from free shipping threshold if prices include tax
    302         if (wc_prices_include_tax()) {
     307        if ($free_shipping_is_set && wc_prices_include_tax()) {
    303308            $tax_total = WC()->cart->get_cart_contents_tax();
    304309            $free_shipping -= $tax_total;
     
    308313            'id' => $this->id,
    309314            'label' => $this->title,
    310             'cost' => $free_shipping && $cart_total > $free_shipping ? 0 : (float) $this->fee,
     315            'cost' => ($free_shipping_is_set && $cart_total >= $free_shipping) ? 0 : (float) $this->fee,
    311316            'calc_tax' => 'per_order'
    312317        ];
  • wc-dpd/trunk/readme.txt

    r3339385 r3341779  
    66Tested up to: 6.8.2
    77Requires PHP: 7.4
    8 Stable tag: 8.1.0
     8Stable tag: 8.1.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6262
    6363== Changelog ==
     64
     65= 8.1.1 =
     66* Fixed free shipping threshold logic - empty field now properly disables free shipping
    6467
    6568= 8.1.0 =
  • wc-dpd/trunk/wc-dpd.php

    r3339385 r3341779  
    44 * Plugin Name: DPD SK for WooCommerce
    55 * Description: DPD SK plugin for WooCommerce which exports orders to the DPD through their API
    6  * Version: 8.1.0
     6 * Version: 8.1.1
    77 * Author: Webikon
    88 * Author URI: https://www.webikon.sk
Note: See TracChangeset for help on using the changeset viewer.