From f263a0a26cb6f5d203909b9cb1bdb097bde5744b Mon Sep 17 00:00:00 2001 From: PaulWijnberg Date: Sat, 19 Oct 2024 11:19:33 +0200 Subject: [PATCH] Improved compatibility for Tiered Pricing Table for WooCommerce --- CHANGELOG.md | 4 ++++ README.txt | 9 ++++++--- block/src/block.json | 2 +- block/src/compatibility/TieredPriceTable.js | 14 ++++++++------ includes/class-wdevs-tax-switch.php | 8 +++++--- package.json | 2 +- public/class-wdevs-tax-switch-public.php | 4 +++- wdevs-tax-switch.php | 4 ++-- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c3c7dc..ce89372 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Wdevs Tax Switch plugin will be documented in this file. +## [1.1.4] - 2024-10-19 +### Updated +- Improved compatibility for Tiered Pricing Table for WooCommerce + ## [1.1.3] - 2024-10-15 ### Added - Compatibility for [Discount Rules for WooCommerce](https://wordpress.org/plugins/woo-discount-rules/) diff --git a/README.txt b/README.txt index 9145101..b2fb2a2 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ Contributors: wijnbergdevelopments Tags: woocommerce, tax, vat Requires at least: 5.0 Tested up to: 6.6 -Stable tag: 1.1.3 +Stable tag: 1.1.4 Requires PHP: 7.2 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt @@ -78,16 +78,19 @@ Some WooCommerce Blocks are not fully compatible with this plugin as they do not == Changelog == += 1.1.4 = +* Improved compatibility for Tiered Pricing Table for WooCommerce + = 1.1.3 = * Migrated filters from only using 'woocommerce_get_price_html' to 'woocommerce_get_price_html' in combination with 'wc_price'. This way, the plugin should be more compatible with other plugins. * Added compatibility for [Discount Rules for WooCommerce](https://wordpress.org/plugins/woo-discount-rules/) * Added compatibility for Tiered Pricing Table for WooCommerce on catalog pages = 1.1.2 = -* Added Measurement Price Calculator for WooCommerce. +* Added compatibility for Measurement Price Calculator for WooCommerce. = 1.1.1 = -* Added Compatibility for Tiered Pricing Table for WooCommerce Premium (single product page). +* Added compatibility for Tiered Pricing Table for WooCommerce Premium (single product page). = 1.1.0 = * Added compatibility for [Tiered Pricing Table for WooCommerce](https://wordpress.org/plugins/tier-pricing-table/) (single product page). diff --git a/block/src/block.json b/block/src/block.json index f9b3df9..8c33387 100644 --- a/block/src/block.json +++ b/block/src/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "wdevs/tax-switch", - "version": "1.1.3", + "version": "1.1.4", "title": "Tax Switch for WooCommerce", "category": "woocommerce", "icon": "money-alt", diff --git a/block/src/compatibility/TieredPriceTable.js b/block/src/compatibility/TieredPriceTable.js index 0103def..1695385 100644 --- a/block/src/compatibility/TieredPriceTable.js +++ b/block/src/compatibility/TieredPriceTable.js @@ -149,9 +149,6 @@ class TieredPriceTable { data.__instance.formatting.formatPrice( data.price_excl_tax ), true ); - summaryTable - .find( '[data-tier-pricing-table-summary-product-price]' ) - .html( productPriceHtml ); // Update total price const totalHtml = this.getWtsHtml( @@ -164,9 +161,14 @@ class TieredPriceTable { ), true ); - summaryTable - .find( '[data-tier-pricing-table-summary-total]' ) - .html( totalHtml ); + setTimeout( function () { + summaryTable + .find( '[data-tier-pricing-table-summary-product-price]' ) + .html( productPriceHtml ); + summaryTable + .find( '[data-tier-pricing-table-summary-total]' ) + .html( totalHtml ); + }, 10 ); } getSummaryTable( productId ) { diff --git a/includes/class-wdevs-tax-switch.php b/includes/class-wdevs-tax-switch.php index c920dfb..1d0777a 100644 --- a/includes/class-wdevs-tax-switch.php +++ b/includes/class-wdevs-tax-switch.php @@ -253,9 +253,11 @@ private function define_compatibility_hooks() { //wc product table compatibility $this->loader->add_filter( 'wcpt_element', $plugin_compatibility, 'activate_wc_product_table_compatibility', 10, 1 ); - //TODO: move check to somewhere else? - if ( is_plugin_active( 'woocommerce-measurement-price-calculator/woocommerce-measurement-price-calculator.php' ) ) { - $this->loader->add_filter( 'woocommerce_available_variation', $plugin_compatibility, 'add_prices_to_variation', 10, 3 ); + if(function_exists('is_plugin_active')){ + //TODO: move check to somewhere else? + if ( is_plugin_active( 'woocommerce-measurement-price-calculator/woocommerce-measurement-price-calculator.php' ) ) { + $this->loader->add_filter( 'woocommerce_available_variation', $plugin_compatibility, 'add_prices_to_variation', 10, 3 ); + } } } } diff --git a/package.json b/package.json index 4e5b268..df24ed7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wdevs-tax-switch", - "version": "1.1.3", + "version": "1.1.4", "description": "Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store.", "author": "Wijnberg Developments", "license": "GPL-2.0-or-later", diff --git a/public/class-wdevs-tax-switch-public.php b/public/class-wdevs-tax-switch-public.php index 0b265dc..9e39d15 100644 --- a/public/class-wdevs-tax-switch-public.php +++ b/public/class-wdevs-tax-switch-public.php @@ -152,7 +152,7 @@ private function combine_price_displays( $current_price_text, $alternate_price_t } return sprintf( - '%s%s', + '%s%s', $classes[0], $current_price_text, $classes[1], @@ -224,6 +224,8 @@ private function calculate_alternate_price( $price, $shop_display_is_incl ) { remove_filter( 'woocommerce_prices_include_tax', [ $this, $woocommerce_prices_include_tax_filter ], 99 ); } + unset($calculator); + return $price; } diff --git a/wdevs-tax-switch.php b/wdevs-tax-switch.php index 16d65d3..d50d0e4 100644 --- a/wdevs-tax-switch.php +++ b/wdevs-tax-switch.php @@ -16,7 +16,7 @@ * Plugin Name: Tax Switch for WooCommerce * Plugin URI: https://wijnberg.dev * Description: Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store. - * Version: 1.1.3 + * Version: 1.1.4 * Author: Wijnberg Developments * Author URI: https://wijnberg.dev/ * License: GPL-2.0+ @@ -41,7 +41,7 @@ * Start at version 1.0.0 and use SemVer - https://semver.org * Rename this for your plugin and update it as you release new versions. */ -define( 'WDEVS_TAX_SWITCH_VERSION', '1.1.3' ); +define( 'WDEVS_TAX_SWITCH_VERSION', '1.1.4' ); /** * The code that runs during plugin activation.