Plugin Directory

Changeset 3374836


Ignore:
Timestamp:
10/08/2025 06:56:26 AM (6 months ago)
Author:
wijnbergdevelopments
Message:

Fixed incorrect tax calculation for variation products loaded via AJAX

Location:
tax-switch-for-woocommerce
Files:
98 added
5 edited

Legend:

Unmodified
Added
Removed
  • tax-switch-for-woocommerce/trunk/README.txt

    r3370439 r3374836  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.5.17
     6Stable tag: 1.5.18
    77Requires PHP: 7.2
    88License: GPL-2.0+
     
    233233
    234234== Changelog ==
     235= 1.5.18 =
     236* Fixed incorrect tax calculation for variation products loaded via AJAX
     237
    235238= 1.5.17 =
    236239* Tested WooCommerce 10.2.2
  • tax-switch-for-woocommerce/trunk/build/label/block.json

    r3370439 r3374836  
    33  "apiVersion": 3,
    44  "name": "wdevs/tax-switch-label",
    5   "version": "1.5.17",
     5  "version": "1.5.18",
    66  "title": "Tax Switch text label",
    77  "category": "woocommerce",
  • tax-switch-for-woocommerce/trunk/build/switch/block.json

    r3370439 r3374836  
    33  "apiVersion": 3,
    44  "name": "wdevs/tax-switch",
    5   "version": "1.5.17",
     5  "version": "1.5.18",
    66  "title": "Tax Switch for WooCommerce",
    77  "category": "woocommerce",
  • tax-switch-for-woocommerce/trunk/includes/trait-wdevs-tax-switch-helper.php

    r3363906 r3374836  
    127127
    128128        if ( ! $product ) {
    129             $product = wc_get_product();
     129            $product = $this->get_current_product();
    130130        }
    131131
     
    319319    }
    320320
     321    /**
     322     * Get the current product, handling AJAX variation requests
     323     *
     324     * During AJAX variation requests, there is no global $post context,
     325     * so we need to manually retrieve the variation product using the
     326     * same logic as WooCommerce uses in WC_AJAX::get_variation()
     327     *
     328     * @return WC_Product|null The current product or null if not available
     329     * @since 1.5.18
     330     */
     331    public function get_current_product() {
     332        if ( doing_action( 'wc_ajax_get_variation' ) && ! empty( $_POST['product_id'] ) ) {
     333            $variable_product = wc_get_product( absint( $_POST['product_id'] ) );
     334
     335            if ( $variable_product ) {
     336                $data_store   = WC_Data_Store::load( 'product' );
     337                $variation_id = $data_store->find_matching_product_variation( $variable_product, wp_unslash( $_POST ) );
     338
     339                if ( $variation_id ) {
     340                    return wc_get_product( $variation_id );
     341                }
     342            }
     343
     344        }
     345
     346        return wc_get_product();
     347    }
     348
    321349}
  • tax-switch-for-woocommerce/trunk/wdevs-tax-switch.php

    r3370439 r3374836  
    1717 * Plugin URI:           https://wijnberg.dev
    1818 * Description:          Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store.
    19  * Version:              1.5.17
     19 * Version:              1.5.18
    2020 * Author:               Wijnberg Developments
    2121 * Author URI:           https://wijnberg.dev/
     
    4141 * Rename this for your plugin and update it as you release new versions.
    4242 */
    43 define( 'WDEVS_TAX_SWITCH_VERSION', '1.5.17' );
     43define( 'WDEVS_TAX_SWITCH_VERSION', '1.5.18' );
    4444
    4545/**
Note: See TracChangeset for help on using the changeset viewer.