Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
fixes #427 by reversal of #390, #346 Cart
Browse files Browse the repository at this point in the history
reversed retain price when switching languages due to incompatibility
with currency switchers, instead a filter woo-poly.Cart.switchedItem
allows customisation of behaviour where necessary
  • Loading branch information
Jon007 committed Jun 9, 2019
1 parent 8906aa5 commit 77c9599
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,10 @@
# Changelog

### 1.4.0

### 1.4.1
* [fixes #427 by reversal of #390, #346 Cart: retain price when switching languages due to incompatibility with currency switchers, instead a filter woo-poly.Cart.switchedItem allows customisation of behaviour where necessary](https://github.com/hyyan/woo-poly-integration/issues/427)

### 1.4.0 preview

* [fixes #408 WooCommerce 3.6.x: by ensuring product lookup data is recalculated for translations and stale product data cache is cleared](https://github.com/hyyan/woo-poly-integration/issues/408)
* [fixes #408 WooCommerce 3.6.x: cart fragment script updates for 3.6](https://github.com/hyyan/woo-poly-integration/commit/89ef0451dd8c7775fe48e20d71dc7836e8e49a96)
Expand Down
2 changes: 1 addition & 1 deletion __init__.php
Expand Up @@ -10,7 +10,7 @@
* Domain Path: /languages
* GitHub Plugin URI: hyyan/woo-poly-integration
* License: MIT License
* Version: 1.4.0
* Version: 1.4.1
* Requires At Least: 4.7
* Tested Up To: 5.2.1
* WC requires at least: 3.0.0
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Expand Up @@ -3,7 +3,7 @@ Contributors: hyyan, jonathanmoorebcsorg
Tags: cms, woocommerce, multilingual, polylang, bilingual, international, language, localization, multilanguage, multilingual, translate, translation
Requires at least: 3.8
Tested up to: 5.1
Stable tag: 1.4.0
Stable tag: 1.4.1
Tested Up To: 5.2.1
WC requires at least: 3.0.0
WC tested up to: 3.6.4
Expand Down Expand Up @@ -137,7 +137,11 @@ Just make sure to setup your permalinks , and every thing will be fine , I promi

== Changelog ==

== 1.4.0 ==
== 1.4.1 ==
* [fixes #427 by reversal of #390, #346 Cart: retain price when switching languages due to incompatibility with currency switchers, instead a filter woo-poly.Cart.switchedItem allows customisation of behaviour where necessary](https://github.com/hyyan/woo-poly-integration/issues/427)


== 1.4.0 preview ==

**Thanks to :**
**@jon007**
Expand Down
15 changes: 1 addition & 14 deletions src/Hyyan/WPI/Cart.php
Expand Up @@ -113,20 +113,7 @@ public function translateCartItemProduct($cart_item_data, $cart_item)

// If we are changing the product to the right language
if ( $cart_item_data_translation->get_id() != $cart_item_data->get_id() ) {
// Keep the price that's currently saved in the cart,
// because it might have been modified using the
// "woocommerce_before_calculate_totals" filter
// (unless the shop admin has explicitly turned off price synchronisation options)
$metas = Meta::getDisabledProductMetaToCopy();
if ( ! in_array( '_regular_price', $metas ) ) {
$cart_item_data_translation->set_regular_price( $cart_item_data->get_regular_price() );
}
if ( ! in_array( '_sale_price', $metas ) ) {
$cart_item_data_translation->set_sale_price( $cart_item_data->get_sale_price() );
}
if ( ! in_array( '_price', $metas ) ) {
$cart_item_data_translation->set_price( $cart_item_data->get_price() );
}
$cart_item_data_translation = apply_filters( HooksInterface::CART_SWITCHED_ITEM, $cart_item_data_translation, $cart_item_data, $cart_item );
}

return $cart_item_data_translation;
Expand Down
11 changes: 11 additions & 0 deletions src/Hyyan/WPI/HooksInterface.php
Expand Up @@ -265,4 +265,15 @@ interface HooksInterface
* This filter may be used to support custom variables in subjects/headings (replace).
*/
const EMAILS_ORDER_FIND_REPLACE_REPLACE_FILTER = 'woo-poly.Emails.orderFindReplaceReplace';

/**
* Cart switched item filter.
*
* Used when a language variant of the original item will be shown.
* This filter can customise the product to be shown
*
* two parameters, $newItem, $originalItem, $cartItem
*/
const CART_SWITCHED_ITEM = 'woo-poly.Cart.switchedItem';

}

0 comments on commit 77c9599

Please sign in to comment.