This repository was archived by the owner on Mar 17, 2022. It is now read-only.
File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 11
11
namespace Hyyan \WPI ;
12
12
13
13
use Hyyan \WPI \Product \Variation ;
14
+ use Hyyan \WPI \Product \Meta ;
14
15
use Hyyan \WPI \Utilities ;
15
16
16
17
/**
@@ -105,6 +106,25 @@ public function translateCartItemProduct($cart_item_data, $cart_item)
105
106
break ;
106
107
}
107
108
109
+
110
+ // If we are changing the product to the right language
111
+ if ( $ cart_item_data_translation ->get_id () != $ cart_item_data ->get_id () ) {
112
+ // Keep the price that's currently saved in the cart,
113
+ // because it might have been modified using the
114
+ // "woocommerce_before_calculate_totals" filter
115
+ // (unless the shop admin has explicitly turned off price synchronisation options)
116
+ $ metas = Meta::getDisabledProductMetaToCopy ();
117
+ if ( ! in_array ( '_regular_price ' , $ metas ) ) {
118
+ $ cart_item_data_translation ->set_regular_price ( $ cart_item_data ->get_regular_price () );
119
+ }
120
+ if ( ! in_array ( '_sale_price ' , $ metas ) ) {
121
+ $ cart_item_data_translation ->set_sale_price ( $ cart_item_data ->get_sale_price () );
122
+ }
123
+ if ( ! in_array ( '_price ' , $ metas ) ) {
124
+ $ cart_item_data_translation ->set_price ( $ cart_item_data ->get_price () );
125
+ }
126
+ }
127
+
108
128
return $ cart_item_data_translation ;
109
129
}
110
130
You can’t perform that action at this time.
0 commit comments