Skip to content

Commit

Permalink
Added compatibility for YITH WooCommerce Product Add-ons & Extra Opti…
Browse files Browse the repository at this point in the history
…ons Premium
  • Loading branch information
Paulsky committed Oct 25, 2024
1 parent fde2a69 commit 5b5744c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to the Tax Switch for Woocommerce plugin will be documented in this file.

## [1.1.8] - 2024-10-25
### Added
- Compatibility for YITH WooCommerce Product Add-ons & Extra Options Premium

## [1.1.7] - 2024-10-24
### Added
- Compatibility for [YITH WooCommerce Product Add-Ons](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/)
Expand Down
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: wijnbergdevelopments
Tags: woocommerce, tax, vat
Requires at least: 5.0
Tested up to: 6.6
Stable tag: 1.1.7
Stable tag: 1.1.8
Requires PHP: 7.2
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Expand Down Expand Up @@ -78,6 +78,9 @@ Some WooCommerce Blocks are not fully compatible with this plugin as they do not

== Changelog ==

= 1.1.8 =
* Added compatibility for YITH WooCommerce Product Add-ons & Extra Options Premium

= 1.1.7 =
* Added compatibility for [YITH WooCommerce Product Add-Ons](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/)

Expand Down
2 changes: 1 addition & 1 deletion block/src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "wdevs/tax-switch",
"version": "1.1.7",
"version": "1.1.8",
"title": "Tax Switch for WooCommerce",
"category": "woocommerce",
"icon": "money-alt",
Expand Down
11 changes: 6 additions & 5 deletions includes/class-wdevs-tax-switch-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ public function enqueue_compatibility_scripts() {
$wcmpc_asset = require( plugin_dir_path( dirname( __FILE__ ) ) . 'build/woocommerce-measurement-price-calculator.asset.php' );
wp_enqueue_script( 'wdevs-tax-switch-woocommerce-measurement-price-calculator', plugin_dir_url( dirname( __FILE__ ) ) . 'build/woocommerce-measurement-price-calculator.js', $wcmpc_asset['dependencies'], $wcmpc_asset['version'] );
}
$ywpado_plugin_path = trailingslashit( WP_PLUGIN_DIR ) . 'yith-woocommerce-product-add-ons/init.php';
if ( in_array( $ywpado_plugin_path, $active_plugins ) ) {
$ywpado_plugin_path = trailingslashit( WP_PLUGIN_DIR ) . 'yith-woocommerce-product-add-ons/init.php';
$ywpadop_plugin_path = trailingslashit( WP_PLUGIN_DIR ) . 'yith-woocommerce-advanced-product-options-premium/init.php';
if ( in_array( $ywpado_plugin_path, $active_plugins ) || in_array( $ywpadop_plugin_path, $active_plugins ) ) {
$ywpado_asset = require( plugin_dir_path( dirname( __FILE__ ) ) . 'build/yith-woocommerce-product-add-ons.asset.php' );
wp_enqueue_script( 'wdevs-tax-switch-yith-woocommerce-product-add-ons', plugin_dir_url( dirname( __FILE__ ) ) . 'build/yith-woocommerce-product-add-ons.js', array_merge($ywpado_asset['dependencies'], ['yith_wapo_front']), $ywpado_asset['version'] );
wp_enqueue_script( 'wdevs-tax-switch-yith-woocommerce-product-add-ons', plugin_dir_url( dirname( __FILE__ ) ) . 'build/yith-woocommerce-product-add-ons.js', array_merge( $ywpado_asset['dependencies'], [ 'yith_wapo_front' ] ), $ywpado_asset['version'] );

// Localize de script met extra data
wp_localize_script(
'wdevs-tax-switch-yith-woocommerce-product-add-ons',
'wtsCompatibilityObject',
[
'baseTaxRate' => $this->get_product_tax_rate(wc_get_product())
'baseTaxRate' => $this->get_product_tax_rate( wc_get_product() )
]
);
}
Expand Down Expand Up @@ -109,7 +110,7 @@ public function add_prices_to_variation( $variation_data, $product, $variation )
* @since 1.1.7
*/
public function add_tax_rate_to_variation( $variation_data, $product, $variation ) {
$variation_data['tax_rate'] = $this->get_product_tax_rate($variation);
$variation_data['tax_rate'] = $this->get_product_tax_rate( $variation );

return $variation_data;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wdevs-tax-switch-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct( $plugin_name, $version ) {
*/
public function declare_compatibility(){
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', 'wdevs-tax-switch/wdevs-tax-switch.php', true );
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', 'tax-switch-for-woocommerce/wdevs-tax-switch.php', true );
}
}

Expand Down
3 changes: 2 additions & 1 deletion includes/class-wdevs-tax-switch.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ private function define_compatibility_hooks() {
//TODO: move check to somewhere else?
$wmpc_plugin_path = trailingslashit( WP_PLUGIN_DIR ) . 'woocommerce-measurement-price-calculator/woocommerce-measurement-price-calculator.php';
$ywpado = trailingslashit( WP_PLUGIN_DIR ) . 'yith-woocommerce-product-add-ons/init.php';
$ywpadop = trailingslashit( WP_PLUGIN_DIR ) . 'yith-woocommerce-advanced-product-options-premium/init.php';

if ( in_array( $wmpc_plugin_path, $active_plugins ) ) {
$this->loader->add_filter( 'woocommerce_available_variation', $plugin_compatibility, 'add_prices_to_variation', 10, 3 );
}
if ( in_array( $ywpado, $active_plugins ) ) {
if ( in_array( $ywpado, $active_plugins ) || in_array( $ywpadop, $active_plugins ) ) {
$this->loader->add_filter( 'woocommerce_available_variation', $plugin_compatibility, 'add_tax_rate_to_variation', 10, 3 );
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wdevs-tax-switch",
"version": "1.1.7",
"version": "1.1.8",
"description": "Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store.",
"author": "Wijnberg Developments",
"license": "GPL-2.0-or-later",
Expand Down
5 changes: 5 additions & 0 deletions public/class-wdevs-tax-switch-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public function wrap_wc_price( $return, $price, $args, $unformatted_price, $orig
return $return;
}

//compatibility with YITH WooCommerce Oroduct Add Ons select
if ( did_filter( 'yith_wapo_option_price' ) ) {
return $return;
}

//already wrapped?
// if ( str_contains( $return, 'wts-price-wrapper' ) ) {
// return $return;
Expand Down
4 changes: 2 additions & 2 deletions wdevs-tax-switch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.7
* Version: 1.1.8
* Author: Wijnberg Developments
* Author URI: https://wijnberg.dev/
* License: GPL-2.0+
Expand All @@ -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.7' );
define( 'WDEVS_TAX_SWITCH_VERSION', '1.1.8' );

/**
* The code that runs during plugin activation.
Expand Down

0 comments on commit 5b5744c

Please sign in to comment.