Version Description
- Added support for creating products in secondary languages only.
- Added enhancements for the Woocommerce Multilingual products table (filter by original language, display language flag).
- Added option to synchronize the products and product taxonomies order.
- Bug fixed: The cart was not updating quantities for variable product (when have more than one variable in the cart).
- Bug fixed: The cart total was not updating when using get_cart_total() and get_cart_subtotal() functions in other plugins or themes.
- Bug fixed: Wrong price format and order total were displayed on the new order page in the WP admin
- Bug fixed: The featured image and the gallery images were overridden when updating translations
- Bug fixed: Fixed the 'Keep' option that allows keeping the same currency on teh front end, when switching the language.
- Bug fixed: Fixed a javascript error that was showing when changing currencies order
- Bug fixed: The decimal number was not working correctly for the default currency
- Bug fixed: Fixed a compatibility problem with WooCommerce Product Tabs
- Bug fixed: A coupon was applied incorrectly to all products in the cart when they were defined for specific product variations.
- Bug fixed: WooCommerce note email language was not correct
- Bug fixed: WooCommerce reports were showing duplicate products
- Bug fixed: When using WordPress in a folder, the checkout showed an 'expired session' error message.
- Added support currency argument in raw_price_filter
Download this release
Release Info
Developer | mihaimihai |
Plugin | WooCommerce Multilingual – run WooCommerce with WPML |
Version | 3.5 |
Comparing to | |
See all releases |
Code changes from version 3.4.3 to 3.5
- assets/css/management.css +7 -3
- assets/js/lock_fields.js +2 -0
- assets/js/scripts.js +4 -4
- compatibility/gravityforms.class.php +1 -1
- compatibility/wc_exporter.class.php +2 -2
- compatibility/wc_extra_product_options.class.php +4 -4
- compatibility/wc_product_addons.class.php +1 -1
- compatibility/wc_product_bundles.class.php +2 -2
- compatibility/wc_subscriptions.class.php +1 -1
- compatibility/wc_tab_manager.class.php +2 -2
- inc/ajax-setup.class.php +9 -1
- inc/compatibility.class.php +7 -7
- inc/dependencies.class.php +5 -5
- inc/emails.class.php +62 -16
- inc/functions-troubleshooting.class.php +13 -7
- inc/multi-currency-support.class.php +148 -45
- inc/multi-currency.class.php +63 -201
- inc/orders.class.php +79 -2
- inc/products.class.php +262 -337
- inc/reports.class.php +15 -4
- inc/requests.class.php +1 -0
- inc/store-pages.class.php +100 -31
- inc/terms.class.php +17 -21
- inc/upgrade.class.php +11 -1
- inc/wc-strings.class.php +10 -10
- menu/management.php +1 -1
- menu/sub/currency-switcher-options.php +1 -1
- menu/sub/product-data.php +2 -3
- menu/sub/products.php +48 -22
- menu/sub/settings.php +39 -18
- readme.txt +20 -2
- woocommerce_wpml.class.php +41 -25
- wpml-woocommerce.php +5 -4
assets/css/management.css
CHANGED
@@ -243,15 +243,15 @@
|
|
243 |
.translations_statuses{
|
244 |
float: left;
|
245 |
}
|
246 |
-
|
247 |
font-size: 16px;
|
248 |
vertical-align: middle;
|
249 |
position: static;
|
250 |
margin: 0;
|
251 |
cursor: default;
|
252 |
-
|
253 |
display: inline-block;
|
254 |
-
|
255 |
|
256 |
.wcml_details{
|
257 |
vertical-align: middle;
|
@@ -502,6 +502,7 @@
|
|
502 |
.stat_img{
|
503 |
margin-right: 5px;
|
504 |
padding: 1px;
|
|
|
505 |
}
|
506 |
.product_thumbnail_block .image img{
|
507 |
cursor: pointer;
|
@@ -971,4 +972,7 @@ input[name="wcml_curr_template"]{
|
|
971 |
}
|
972 |
.wcml_content_tr{
|
973 |
width: 100%;
|
|
|
|
|
|
|
974 |
}
|
243 |
.translations_statuses{
|
244 |
float: left;
|
245 |
}
|
246 |
+
.wcml_wrap .translations_statuses i {
|
247 |
font-size: 16px;
|
248 |
vertical-align: middle;
|
249 |
position: static;
|
250 |
margin: 0;
|
251 |
cursor: default;
|
252 |
+
width: 20px;
|
253 |
display: inline-block;
|
254 |
+
}
|
255 |
|
256 |
.wcml_details{
|
257 |
vertical-align: middle;
|
502 |
.stat_img{
|
503 |
margin-right: 5px;
|
504 |
padding: 1px;
|
505 |
+
text-align: center;
|
506 |
}
|
507 |
.product_thumbnail_block .image img{
|
508 |
cursor: pointer;
|
972 |
}
|
973 |
.wcml_content_tr{
|
974 |
width: 100%;
|
975 |
+
}
|
976 |
+
.wcml_miss_lang p:first-child{
|
977 |
+
float:left;
|
978 |
}
|
assets/js/lock_fields.js
CHANGED
@@ -2,6 +2,8 @@ jQuery(document).ready(function($){
|
|
2 |
var i;
|
3 |
var ids = ['_sku','_virtual','_downloadable','product-type','_stock_status','_backorders','_manage_stock','_stock','_sold_individually','_length','_weight','product_length','_regular_price','_sale_price','_sale_price_dates_from','_sale_price_dates_to','menu_order','comment_status','_tax_status','_tax_class','parent_id','crosssell_ids','upsell_ids'];
|
4 |
|
|
|
|
|
5 |
for (i = 0; i < ids.length; i++) {
|
6 |
$('#'+ids[i]).attr('disabled','disabled');
|
7 |
$('#'+ids[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
2 |
var i;
|
3 |
var ids = ['_sku','_virtual','_downloadable','product-type','_stock_status','_backorders','_manage_stock','_stock','_sold_individually','_length','_weight','product_length','_regular_price','_sale_price','_sale_price_dates_from','_sale_price_dates_to','menu_order','comment_status','_tax_status','_tax_class','parent_id','crosssell_ids','upsell_ids'];
|
4 |
|
5 |
+
$('.wcml_prod_hidden_notice').prependTo('#woocommerce-product-data');
|
6 |
+
|
7 |
for (i = 0; i < ids.length; i++) {
|
8 |
$('#'+ids[i]).attr('disabled','disabled');
|
9 |
$('#'+ids[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
assets/js/scripts.js
CHANGED
@@ -12,7 +12,7 @@ jQuery(document).ready(function($){
|
|
12 |
discard = false;
|
13 |
});
|
14 |
|
15 |
-
$('.wcml-section input[type="radio"],#wcml_products_sync_date').click(function(){
|
16 |
discard = true;
|
17 |
$(this).closest('.wcml-section').find('.button-wrap input').css("border-color","#1e8cbe");
|
18 |
});
|
@@ -801,7 +801,7 @@ jQuery(document).ready(function($){
|
|
801 |
|
802 |
}
|
803 |
|
804 |
-
$(document).on('click', '#wcml_fix_strings_language', function(){ // TODO: remove after WPML
|
805 |
|
806 |
var thisb = $(this);
|
807 |
thisb.prop('disabled', true);
|
@@ -1057,7 +1057,7 @@ jQuery(document).ready(function($){
|
|
1057 |
$(this).append('<option value="'+currency_code+'">'+currency_code+'</option>');
|
1058 |
});
|
1059 |
|
1060 |
-
$('#wcml_currencies_order').append('<li class="wcml_currencies_order_'+currency_code+'">'+response.currency_name_formatted_without_rate+'</li>');
|
1061 |
currency_switcher_preview();
|
1062 |
},
|
1063 |
complete: function() {
|
@@ -1361,7 +1361,7 @@ jQuery(document).ready(function($){
|
|
1361 |
$('.wcml_currencies_order_ajx_resp').fadeIn();
|
1362 |
var currencies_order = [];
|
1363 |
$('#wcml_currencies_order').find('li').each(function(){
|
1364 |
-
currencies_order.push($(this).attr('
|
1365 |
});
|
1366 |
$.ajax({
|
1367 |
type: "POST",
|
12 |
discard = false;
|
13 |
});
|
14 |
|
15 |
+
$('.wcml-section input[type="radio"],#wcml_products_sync_date,#wcml_products_sync_order').click(function(){
|
16 |
discard = true;
|
17 |
$(this).closest('.wcml-section').find('.button-wrap input').css("border-color","#1e8cbe");
|
18 |
});
|
801 |
|
802 |
}
|
803 |
|
804 |
+
$(document).on('click', '#wcml_fix_strings_language', function(){ // TODO: remove after WPML release with support strings in different languages
|
805 |
|
806 |
var thisb = $(this);
|
807 |
thisb.prop('disabled', true);
|
1057 |
$(this).append('<option value="'+currency_code+'">'+currency_code+'</option>');
|
1058 |
});
|
1059 |
|
1060 |
+
$('#wcml_currencies_order').append('<li class="wcml_currencies_order_'+currency_code+'" cur="'+currency_code+'>'+response.currency_name_formatted_without_rate+'</li>');
|
1061 |
currency_switcher_preview();
|
1062 |
},
|
1063 |
complete: function() {
|
1361 |
$('.wcml_currencies_order_ajx_resp').fadeIn();
|
1362 |
var currencies_order = [];
|
1363 |
$('#wcml_currencies_order').find('li').each(function(){
|
1364 |
+
currencies_order.push($(this).attr('cur'));
|
1365 |
});
|
1366 |
$.ajax({
|
1367 |
type: "POST",
|
compatibility/gravityforms.class.php
CHANGED
@@ -10,7 +10,7 @@ class WCML_gravityforms{
|
|
10 |
function wcml_convert_price($formatted, $unformatted){
|
11 |
if ( ! is_admin() ) {
|
12 |
$currency = apply_filters('wcml_price_currency', get_woocommerce_currency());
|
13 |
-
$formatted = strip_tags(
|
14 |
}
|
15 |
return $formatted;
|
16 |
}
|
10 |
function wcml_convert_price($formatted, $unformatted){
|
11 |
if ( ! is_admin() ) {
|
12 |
$currency = apply_filters('wcml_price_currency', get_woocommerce_currency());
|
13 |
+
$formatted = strip_tags(wc_price(apply_filters('wcml_raw_price_amount', $unformatted), array('currency'=>$currency)));
|
14 |
}
|
15 |
return $formatted;
|
16 |
}
|
compatibility/wc_exporter.class.php
CHANGED
@@ -39,10 +39,10 @@ class WCML_wcExporter{
|
|
39 |
}
|
40 |
|
41 |
function woo_ce_product_item($data, $product_id){
|
42 |
-
global $sitepress;
|
43 |
|
44 |
$data->language = $sitepress->get_language_for_element($product_id,'post_'.get_post_type($product_id));
|
45 |
-
$data->translation_of = icl_object_id($product_id,get_post_type($product_id),true
|
46 |
|
47 |
return $data;
|
48 |
}
|
39 |
}
|
40 |
|
41 |
function woo_ce_product_item($data, $product_id){
|
42 |
+
global $sitepress,$woocommerce_wpml;
|
43 |
|
44 |
$data->language = $sitepress->get_language_for_element($product_id,'post_'.get_post_type($product_id));
|
45 |
+
$data->translation_of = icl_object_id($product_id,get_post_type($product_id),true, $woocommerce_wpml->products->get_original_product_language( $product_id ) );
|
46 |
|
47 |
return $data;
|
48 |
}
|
compatibility/wc_extra_product_options.class.php
CHANGED
@@ -44,10 +44,10 @@ class WCML_Extra_Product_Options{
|
|
44 |
return $options;
|
45 |
}
|
46 |
|
47 |
-
global $sitepress;
|
48 |
$keys_to_translate = array( 'header_title', 'header_subtitle', 'text_after_price', 'placeholder' );
|
49 |
|
50 |
-
$id = icl_object_id( $id, get_post_type( $id ), true, $
|
51 |
|
52 |
foreach( $options[ 'tmfbuilder' ] as $key => $values ){
|
53 |
foreach( $keys_to_translate as $key_text ){
|
@@ -71,10 +71,10 @@ class WCML_Extra_Product_Options{
|
|
71 |
if( $value ){
|
72 |
if( is_array( $value ) ){
|
73 |
foreach( $value as $key_price => $price ){
|
74 |
-
$options[ 'tmfbuilder' ][ $key ][ $value_key ][ $key_price ] = apply_filters( 'wcml_raw_price_amount', $price
|
75 |
}
|
76 |
}else{
|
77 |
-
$options[ 'tmfbuilder' ][ $key ][ $value_key ] = apply_filters( 'wcml_raw_price_amount', $value
|
78 |
}
|
79 |
}
|
80 |
}
|
44 |
return $options;
|
45 |
}
|
46 |
|
47 |
+
global $sitepress,$woocommerce_wpml;
|
48 |
$keys_to_translate = array( 'header_title', 'header_subtitle', 'text_after_price', 'placeholder' );
|
49 |
|
50 |
+
$id = icl_object_id( $id, get_post_type( $id ), true, $woocommerce_wpml->products->get_original_product_language( $id ) );
|
51 |
|
52 |
foreach( $options[ 'tmfbuilder' ] as $key => $values ){
|
53 |
foreach( $keys_to_translate as $key_text ){
|
71 |
if( $value ){
|
72 |
if( is_array( $value ) ){
|
73 |
foreach( $value as $key_price => $price ){
|
74 |
+
$options[ 'tmfbuilder' ][ $key ][ $value_key ][ $key_price ] = apply_filters( 'wcml_raw_price_amount', $price );
|
75 |
}
|
76 |
}else{
|
77 |
+
$options[ 'tmfbuilder' ][ $key ][ $value_key ] = apply_filters( 'wcml_raw_price_amount', $value );
|
78 |
}
|
79 |
}
|
80 |
}
|
compatibility/wc_product_addons.class.php
CHANGED
@@ -47,7 +47,7 @@ class WCML_Product_Addons{
|
|
47 |
$addons[$add_id]['options'][$key]['label'] = icl_t('wc_product_addons_strings', $object_id.'_addon_'.$addon['type'].'_'.$addon['position'].'_option_label_'.$key, $option['label']);
|
48 |
|
49 |
//price filter
|
50 |
-
$addons[$add_id]['options'][$key]['price'] = apply_filters('wcml_raw_price_amount', $option['price']
|
51 |
}
|
52 |
}
|
53 |
|
47 |
$addons[$add_id]['options'][$key]['label'] = icl_t('wc_product_addons_strings', $object_id.'_addon_'.$addon['type'].'_'.$addon['position'].'_option_label_'.$key, $option['label']);
|
48 |
|
49 |
//price filter
|
50 |
+
$addons[$add_id]['options'][$key]['price'] = apply_filters('wcml_raw_price_amount', $option['price']);
|
51 |
}
|
52 |
}
|
53 |
|
compatibility/wc_product_bundles.class.php
CHANGED
@@ -123,12 +123,12 @@ class WCML_Product_Bundles{
|
|
123 |
|
124 |
// Add Bundles Box to WCML Translation GUI
|
125 |
function product_bundles_box($product_id,$lang, $is_duplicate_product = false ) {
|
126 |
-
global $sitepress;
|
127 |
$isbundle = true;
|
128 |
$translated = true;
|
129 |
$template_data = array();
|
130 |
|
131 |
-
$default_language = $
|
132 |
|
133 |
|
134 |
if($default_language != $lang){
|
123 |
|
124 |
// Add Bundles Box to WCML Translation GUI
|
125 |
function product_bundles_box($product_id,$lang, $is_duplicate_product = false ) {
|
126 |
+
global $sitepress, $woocommerce_wpml;
|
127 |
$isbundle = true;
|
128 |
$translated = true;
|
129 |
$template_data = array();
|
130 |
|
131 |
+
$default_language = $woocommerce_wpml->products->get_original_product_language( $product_id );
|
132 |
|
133 |
|
134 |
if($default_language != $lang){
|
compatibility/wc_subscriptions.class.php
CHANGED
@@ -16,7 +16,7 @@ class WCML_WC_Subscriptions{
|
|
16 |
|
17 |
function product_price_filter($subscription_sign_up_fee, $product){
|
18 |
|
19 |
-
$subscription_sign_up_fee = apply_filters('wcml_raw_price_amount', $subscription_sign_up_fee
|
20 |
|
21 |
return $subscription_sign_up_fee;
|
22 |
}
|
16 |
|
17 |
function product_price_filter($subscription_sign_up_fee, $product){
|
18 |
|
19 |
+
$subscription_sign_up_fee = apply_filters('wcml_raw_price_amount', $subscription_sign_up_fee );
|
20 |
|
21 |
return $subscription_sign_up_fee;
|
22 |
}
|
compatibility/wc_tab_manager.class.php
CHANGED
@@ -10,7 +10,7 @@ class WCML_Tab_Manager{
|
|
10 |
}
|
11 |
|
12 |
function sync_tabs( $original_product_id, $trnsl_product_id, $data = false ){
|
13 |
-
global $wc_tab_manager, $sitepress, $wpdb, $woocommerce;
|
14 |
|
15 |
$lang = $sitepress->get_language_for_element( $trnsl_product_id, 'post_product' );
|
16 |
|
@@ -31,7 +31,7 @@ class WCML_Tab_Manager{
|
|
31 |
foreach( $orig_prod_tabs as $key => $orig_prod_tab ){
|
32 |
switch( $orig_prod_tab[ 'type' ] ){
|
33 |
case 'core':
|
34 |
-
$default_language = $
|
35 |
$current_language = $sitepress->get_current_language();
|
36 |
$trnsl_product_tabs[ $key ] = $orig_prod_tabs[ $key ];
|
37 |
if( isset( $data[ '_product_tabs_'.$lang ] ) ){
|
10 |
}
|
11 |
|
12 |
function sync_tabs( $original_product_id, $trnsl_product_id, $data = false ){
|
13 |
+
global $wc_tab_manager, $sitepress, $wpdb, $woocommerce, $woocommerce_wpml;
|
14 |
|
15 |
$lang = $sitepress->get_language_for_element( $trnsl_product_id, 'post_product' );
|
16 |
|
31 |
foreach( $orig_prod_tabs as $key => $orig_prod_tab ){
|
32 |
switch( $orig_prod_tab[ 'type' ] ){
|
33 |
case 'core':
|
34 |
+
$default_language = $woocommerce_wpml->products->get_original_product_language( $original_product_id );
|
35 |
$current_language = $sitepress->get_current_language();
|
36 |
$trnsl_product_tabs[ $key ] = $orig_prod_tabs[ $key ];
|
37 |
if( isset( $data[ '_product_tabs_'.$lang ] ) ){
|
inc/ajax-setup.class.php
CHANGED
@@ -23,6 +23,7 @@ class WCML_Ajax_Setup{
|
|
23 |
add_filter('wc_add_to_cart_params', array($this, 'add_language_parameter_to_ajax_url'));
|
24 |
|
25 |
add_action( 'woocommerce_checkout_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
|
|
26 |
add_action( 'woocommerce_checkout_update_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
27 |
|
28 |
}
|
@@ -31,7 +32,10 @@ class WCML_Ajax_Setup{
|
|
31 |
global $woocommerce;
|
32 |
unload_textdomain('woocommerce');
|
33 |
$woocommerce->load_plugin_textdomain();
|
34 |
-
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
function add_language_parameter_to_ajax_url($woocommerce_params){
|
@@ -83,6 +87,10 @@ class WCML_Ajax_Setup{
|
|
83 |
}
|
84 |
|
85 |
function localize_woocommerce_on_ajax(){
|
|
|
|
|
|
|
|
|
86 |
global $sitepress;
|
87 |
|
88 |
$current_language = $sitepress->get_current_language();
|
23 |
add_filter('wc_add_to_cart_params', array($this, 'add_language_parameter_to_ajax_url'));
|
24 |
|
25 |
add_action( 'woocommerce_checkout_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
26 |
+
add_action( 'woocommerce_checkout_order_review', array($this,'add_hidden_language_field') );
|
27 |
add_action( 'woocommerce_checkout_update_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
28 |
|
29 |
}
|
32 |
global $woocommerce;
|
33 |
unload_textdomain('woocommerce');
|
34 |
$woocommerce->load_plugin_textdomain();
|
35 |
+
}
|
36 |
+
|
37 |
+
function add_hidden_language_field(){
|
38 |
+
wpml_the_language_input_field();
|
39 |
}
|
40 |
|
41 |
function add_language_parameter_to_ajax_url($woocommerce_params){
|
87 |
}
|
88 |
|
89 |
function localize_woocommerce_on_ajax(){
|
90 |
+
if( isset($_POST['action']) && in_array( $_POST['action'], array('wcml_product_data','wcml_update_product') ) ){
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
|
94 |
global $sitepress;
|
95 |
|
96 |
$current_language = $sitepress->get_current_language();
|
inc/compatibility.class.php
CHANGED
@@ -4,14 +4,8 @@ class WCML_Compatibility {
|
|
4 |
|
5 |
function __construct(){
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
// Dynamic Pricing
|
11 |
-
if(class_exists( 'WC_Dynamic_Pricing' )){
|
12 |
-
require_once WCML_PLUGIN_PATH . '/compatibility/wc_dynamic_pricing.class.php';
|
13 |
-
$this->dynamic_pricing = new WCML_Dynamic_Pricing();
|
14 |
-
}
|
15 |
}
|
16 |
|
17 |
function init(){
|
@@ -82,6 +76,12 @@ class WCML_Compatibility {
|
|
82 |
$this->extra_product_options = new WCML_Extra_Product_Options();
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
}
|
4 |
|
5 |
function __construct(){
|
6 |
|
7 |
+
$this->init();
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
11 |
function init(){
|
76 |
$this->extra_product_options = new WCML_Extra_Product_Options();
|
77 |
}
|
78 |
|
79 |
+
// Dynamic Pricing
|
80 |
+
if(class_exists( 'WC_Dynamic_Pricing' )){
|
81 |
+
require_once WCML_PLUGIN_PATH . '/compatibility/wc_dynamic_pricing.class.php';
|
82 |
+
$this->dynamic_pricing = new WCML_Dynamic_Pricing();
|
83 |
+
}
|
84 |
+
|
85 |
}
|
86 |
|
87 |
}
|
inc/dependencies.class.php
CHANGED
@@ -9,7 +9,7 @@ class WCML_Dependencies{
|
|
9 |
function __construct(){
|
10 |
|
11 |
if(is_admin()){
|
12 |
-
add_action('wp_ajax_wcml_fix_strings_language', array($this, 'fix_strings_language')); // TODO: remove after WPML
|
13 |
|
14 |
add_action('init', array($this, 'check_wpml_config'), 100);
|
15 |
}
|
@@ -20,8 +20,8 @@ class WCML_Dependencies{
|
|
20 |
function check(){
|
21 |
global $woocommerce_wpml, $sitepress;
|
22 |
$allok = true;
|
23 |
-
|
24 |
-
if(!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE){
|
25 |
$this->missing['WPML'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
|
26 |
$allok = false;
|
27 |
} else if(version_compare(ICL_SITEPRESS_VERSION, '3.1.5', '<')){
|
@@ -156,7 +156,7 @@ class WCML_Dependencies{
|
|
156 |
} else {
|
157 |
$shop_page_id = get_option('woocommerce_shop_page_id', false);
|
158 |
if (!empty($shop_page_id)) {
|
159 |
-
$slug = @
|
160 |
$languages = $sitepress->get_active_languages();
|
161 |
if (sizeof($languages) < 2) {
|
162 |
return;
|
@@ -165,7 +165,7 @@ class WCML_Dependencies{
|
|
165 |
if ($language['code'] != $sitepress->get_default_language()) {
|
166 |
$translated_shop_page_id = icl_object_id($shop_page_id, 'page', false, $language['code']);
|
167 |
if (!empty($translated_shop_page_id)) {
|
168 |
-
$translated_slug =
|
169 |
if (!empty($translated_slug) && $translated_slug != $slug) {
|
170 |
$allsame = false;
|
171 |
break;
|
9 |
function __construct(){
|
10 |
|
11 |
if(is_admin()){
|
12 |
+
add_action('wp_ajax_wcml_fix_strings_language', array($this, 'fix_strings_language')); // TODO: remove after WPML release with support strings in different languages
|
13 |
|
14 |
add_action('init', array($this, 'check_wpml_config'), 100);
|
15 |
}
|
20 |
function check(){
|
21 |
global $woocommerce_wpml, $sitepress;
|
22 |
$allok = true;
|
23 |
+
|
24 |
+
if(!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE || is_null( $sitepress ) || !class_exists('SitePress')){
|
25 |
$this->missing['WPML'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
|
26 |
$allok = false;
|
27 |
} else if(version_compare(ICL_SITEPRESS_VERSION, '3.1.5', '<')){
|
156 |
} else {
|
157 |
$shop_page_id = get_option('woocommerce_shop_page_id', false);
|
158 |
if (!empty($shop_page_id)) {
|
159 |
+
$slug = @get_post($shop_page_id)->post_name;
|
160 |
$languages = $sitepress->get_active_languages();
|
161 |
if (sizeof($languages) < 2) {
|
162 |
return;
|
165 |
if ($language['code'] != $sitepress->get_default_language()) {
|
166 |
$translated_shop_page_id = icl_object_id($shop_page_id, 'page', false, $language['code']);
|
167 |
if (!empty($translated_shop_page_id)) {
|
168 |
+
$translated_slug = get_post($translated_shop_page_id)->post_name;
|
169 |
if (!empty($translated_slug) && $translated_slug != $slug) {
|
170 |
$allsame = false;
|
171 |
break;
|
inc/emails.class.php
CHANGED
@@ -1,21 +1,26 @@
|
|
1 |
<?php
|
2 |
class WCML_Emails{
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
function __construct(){
|
5 |
|
6 |
add_action('init', array($this, 'init'));
|
7 |
|
8 |
-
|
9 |
}
|
10 |
|
11 |
function init(){
|
12 |
//wrappers for email's header
|
13 |
if(is_admin() && !defined( 'DOING_AJAX' )){
|
14 |
-
add_action('woocommerce_order_status_completed_notification', array($this, 'email_heading_completed'),9);
|
15 |
-
add_action('woocommerce_new_customer_note_notification', array($this, 'email_heading_note'),9);
|
16 |
add_action('woocommerce_order_status_changed', array($this, 'comments_language'),10);
|
17 |
}
|
18 |
|
|
|
|
|
|
|
19 |
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'email_heading_processing' ) );
|
20 |
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'email_heading_processing' ) );
|
21 |
|
@@ -23,14 +28,14 @@ class WCML_Emails{
|
|
23 |
add_action('woocommerce_before_resend_order_emails', array($this, 'email_header'));
|
24 |
add_action('woocommerce_after_resend_order_email', array($this, 'email_footer'));
|
25 |
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 9, 3 );
|
26 |
-
|
27 |
//WPML job link
|
28 |
add_filter('icl_job_edit_url',array($this,'icl_job_edit_url'),10 ,2);
|
29 |
//filter string language before for emails
|
30 |
add_filter('icl_current_string_language',array($this,'icl_current_string_language'),10 ,2);
|
31 |
|
32 |
//change order status
|
33 |
-
add_action('woocommerce_order_status_completed',array($this,'
|
34 |
add_action('woocommerce_order_status_pending_to_processing_notification',array($this,'refresh_email_lang'),9);
|
35 |
add_action('woocommerce_order_status_pending_to_on-hold_notification',array($this,'refresh_email_lang'),9);
|
36 |
add_action('woocommerce_new_customer_note',array($this,'refresh_email_lang'),9);
|
@@ -45,8 +50,24 @@ class WCML_Emails{
|
|
45 |
add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'admin_email' ), 9 );
|
46 |
|
47 |
add_filter( 'icl_st_admin_string_return_cached', array( $this, 'admin_string_return_cached' ), 10, 2 );
|
|
|
|
|
48 |
}
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
/**
|
51 |
* Translate WooCommerce emails.
|
52 |
*
|
@@ -100,8 +121,8 @@ class WCML_Emails{
|
|
100 |
function comments_language(){
|
101 |
global $sitepress_settings;
|
102 |
|
103 |
-
if (
|
104 |
-
$context_ob = icl_st_get_context( '
|
105 |
if($context_ob){
|
106 |
$this->change_email_language($context_ob->language);
|
107 |
}
|
@@ -111,9 +132,9 @@ class WCML_Emails{
|
|
111 |
|
112 |
}
|
113 |
|
114 |
-
function email_heading_completed($order_id){
|
115 |
global $woocommerce;
|
116 |
-
if(class_exists('WC_Email_Customer_Completed_Order')){
|
117 |
$heading = $this->wcml_get_email_string_info( '[woocommerce_customer_completed_order_settings]heading' );
|
118 |
if($heading)
|
119 |
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_completed_order_settings]heading',$heading[0]->value);
|
@@ -153,10 +174,12 @@ class WCML_Emails{
|
|
153 |
|
154 |
function email_heading_note($args){
|
155 |
global $woocommerce,$sitepress;
|
|
|
156 |
if(class_exists('WC_Email_Customer_Note')){
|
157 |
$heading = $this->wcml_get_email_string_info( '[woocommerce_customer_note_settings]heading' );
|
158 |
if($heading)
|
159 |
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->heading = icl_t($heading[0]->context,'[woocommerce_customer_note_settings]heading',$heading[0]->value);
|
|
|
160 |
$subject = $this->wcml_get_email_string_info( '[woocommerce_customer_note_settings]subject' );
|
161 |
if($subject)
|
162 |
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->subject = icl_t($subject[0]->context,'[woocommerce_customer_note_settings]subject',$subject[0]->value);
|
@@ -200,6 +223,7 @@ class WCML_Emails{
|
|
200 |
function change_email_language($lang){
|
201 |
global $sitepress,$woocommerce;
|
202 |
$sitepress->switch_lang($lang,true);
|
|
|
203 |
unload_textdomain('woocommerce');
|
204 |
unload_textdomain('default');
|
205 |
$woocommerce->load_plugin_textdomain();
|
@@ -224,8 +248,8 @@ class WCML_Emails{
|
|
224 |
$original_product_id = $wpdb->get_var($wpdb->prepare("
|
225 |
SELECT element_id
|
226 |
FROM {$wpdb->prefix}icl_translations
|
227 |
-
WHERE trid = %d AND element_type = 'post_product' AND
|
228 |
-
", $trid
|
229 |
|
230 |
if($original_product_id){
|
231 |
$link = admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$original_product_id);
|
@@ -250,7 +274,7 @@ class WCML_Emails{
|
|
250 |
function wcml_get_email_string_info( $name ){
|
251 |
global $wpdb;
|
252 |
|
253 |
-
if (
|
254 |
$result = $wpdb->get_results( $wpdb->prepare( "SELECT st.value,cn.context FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE st.name = %s ", $name ) );
|
255 |
}else{
|
256 |
global $sitepress_settings;
|
@@ -263,9 +287,21 @@ class WCML_Emails{
|
|
263 |
}
|
264 |
|
265 |
function icl_current_string_language( $current_language, $name ){
|
|
|
|
|
266 |
if( isset($_POST['action']) && $_POST['action'] == 'editpost' && isset($_POST['post_type']) && $_POST['post_type'] == 'shop_order' ){
|
267 |
-
$
|
268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
return $order_language;
|
270 |
}else{
|
271 |
global $sitepress;
|
@@ -276,4 +312,14 @@ class WCML_Emails{
|
|
276 |
return $current_language;
|
277 |
}
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
1 |
<?php
|
2 |
class WCML_Emails{
|
3 |
+
|
4 |
+
private $order_id = false;
|
5 |
+
|
6 |
+
private $locale = false;
|
7 |
+
|
8 |
function __construct(){
|
9 |
|
10 |
add_action('init', array($this, 'init'));
|
11 |
|
|
|
12 |
}
|
13 |
|
14 |
function init(){
|
15 |
//wrappers for email's header
|
16 |
if(is_admin() && !defined( 'DOING_AJAX' )){
|
17 |
+
add_action('woocommerce_order_status_completed_notification', array($this, 'email_heading_completed'),9);
|
|
|
18 |
add_action('woocommerce_order_status_changed', array($this, 'comments_language'),10);
|
19 |
}
|
20 |
|
21 |
+
add_action('woocommerce_new_customer_note_notification', array($this, 'email_heading_note'),9);
|
22 |
+
add_action('wp_ajax_woocommerce_mark_order_complete',array($this,'email_refresh_in_ajax'),9);
|
23 |
+
|
24 |
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'email_heading_processing' ) );
|
25 |
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'email_heading_processing' ) );
|
26 |
|
28 |
add_action('woocommerce_before_resend_order_emails', array($this, 'email_header'));
|
29 |
add_action('woocommerce_after_resend_order_email', array($this, 'email_footer'));
|
30 |
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 9, 3 );
|
31 |
+
|
32 |
//WPML job link
|
33 |
add_filter('icl_job_edit_url',array($this,'icl_job_edit_url'),10 ,2);
|
34 |
//filter string language before for emails
|
35 |
add_filter('icl_current_string_language',array($this,'icl_current_string_language'),10 ,2);
|
36 |
|
37 |
//change order status
|
38 |
+
add_action('woocommerce_order_status_completed',array($this,'refresh_email_lang_complete'),9);
|
39 |
add_action('woocommerce_order_status_pending_to_processing_notification',array($this,'refresh_email_lang'),9);
|
40 |
add_action('woocommerce_order_status_pending_to_on-hold_notification',array($this,'refresh_email_lang'),9);
|
41 |
add_action('woocommerce_new_customer_note',array($this,'refresh_email_lang'),9);
|
50 |
add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'admin_email' ), 9 );
|
51 |
|
52 |
add_filter( 'icl_st_admin_string_return_cached', array( $this, 'admin_string_return_cached' ), 10, 2 );
|
53 |
+
|
54 |
+
add_filter( 'plugin_locale', array( $this, 'set_locale_for_emails' ), 10, 2 );
|
55 |
}
|
56 |
+
function email_refresh_in_ajax(){
|
57 |
+
if(isset($_GET['order_id'])){
|
58 |
+
$this->refresh_email_lang($_GET['order_id']);
|
59 |
+
$this->email_heading_completed($_GET['order_id'],true);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
function refresh_email_lang_complete( $order_id ){
|
64 |
+
|
65 |
+
$this->order_id = $order_id;
|
66 |
+
$this->refresh_email_lang($order_id);
|
67 |
+
$this->email_heading_completed($order_id,true);
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
/**
|
72 |
* Translate WooCommerce emails.
|
73 |
*
|
121 |
function comments_language(){
|
122 |
global $sitepress_settings;
|
123 |
|
124 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
125 |
+
$context_ob = icl_st_get_context( 'woocommerce' );
|
126 |
if($context_ob){
|
127 |
$this->change_email_language($context_ob->language);
|
128 |
}
|
132 |
|
133 |
}
|
134 |
|
135 |
+
function email_heading_completed( $order_id, $no_checking = false ){
|
136 |
global $woocommerce;
|
137 |
+
if(class_exists('WC_Email_Customer_Completed_Order') || $no_checking){
|
138 |
$heading = $this->wcml_get_email_string_info( '[woocommerce_customer_completed_order_settings]heading' );
|
139 |
if($heading)
|
140 |
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_completed_order_settings]heading',$heading[0]->value);
|
174 |
|
175 |
function email_heading_note($args){
|
176 |
global $woocommerce,$sitepress;
|
177 |
+
|
178 |
if(class_exists('WC_Email_Customer_Note')){
|
179 |
$heading = $this->wcml_get_email_string_info( '[woocommerce_customer_note_settings]heading' );
|
180 |
if($heading)
|
181 |
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->heading = icl_t($heading[0]->context,'[woocommerce_customer_note_settings]heading',$heading[0]->value);
|
182 |
+
|
183 |
$subject = $this->wcml_get_email_string_info( '[woocommerce_customer_note_settings]subject' );
|
184 |
if($subject)
|
185 |
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->subject = icl_t($subject[0]->context,'[woocommerce_customer_note_settings]subject',$subject[0]->value);
|
223 |
function change_email_language($lang){
|
224 |
global $sitepress,$woocommerce;
|
225 |
$sitepress->switch_lang($lang,true);
|
226 |
+
$this->locale = $sitepress->get_locale( $lang );
|
227 |
unload_textdomain('woocommerce');
|
228 |
unload_textdomain('default');
|
229 |
$woocommerce->load_plugin_textdomain();
|
248 |
$original_product_id = $wpdb->get_var($wpdb->prepare("
|
249 |
SELECT element_id
|
250 |
FROM {$wpdb->prefix}icl_translations
|
251 |
+
WHERE trid = %d AND element_type = 'post_product' AND source_language_code IS NULL
|
252 |
+
", $trid ));
|
253 |
|
254 |
if($original_product_id){
|
255 |
$link = admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$original_product_id);
|
274 |
function wcml_get_email_string_info( $name ){
|
275 |
global $wpdb;
|
276 |
|
277 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
278 |
$result = $wpdb->get_results( $wpdb->prepare( "SELECT st.value,cn.context FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE st.name = %s ", $name ) );
|
279 |
}else{
|
280 |
global $sitepress_settings;
|
287 |
}
|
288 |
|
289 |
function icl_current_string_language( $current_language, $name ){
|
290 |
+
$order_id = false;
|
291 |
+
|
292 |
if( isset($_POST['action']) && $_POST['action'] == 'editpost' && isset($_POST['post_type']) && $_POST['post_type'] == 'shop_order' ){
|
293 |
+
$order_id = $_POST['post_ID'];
|
294 |
+
}elseif( isset($_POST['action']) && $_POST['action'] == 'woocommerce_add_order_note' && isset($_POST['note_type']) && $_POST['note_type'] == 'customer' ) {
|
295 |
+
$order_id = $_POST['post_id'];
|
296 |
+
}elseif( isset($_GET['action']) && isset($_GET['order_id']) && $_GET['action'] == 'woocommerce_mark_order_complete'){
|
297 |
+
$order_id = $_GET['order_id'];
|
298 |
+
}elseif(isset($_GET['action']) && $_GET['action'] == 'mark_completed' && $this->order_id){
|
299 |
+
$order_id = $this->order_id;
|
300 |
+
}
|
301 |
+
|
302 |
+
if( $order_id ){
|
303 |
+
$order_language = get_post_meta( $order_id, 'wpml_language', true );
|
304 |
+
if( $order_language ){
|
305 |
return $order_language;
|
306 |
}else{
|
307 |
global $sitepress;
|
312 |
return $current_language;
|
313 |
}
|
314 |
|
315 |
+
// set correct locale code for emails
|
316 |
+
function set_locale_for_emails( $locale, $domain ){
|
317 |
+
|
318 |
+
if( $domain == 'woocommerce' && $this->locale ){
|
319 |
+
$locale = $this->locale;
|
320 |
+
}
|
321 |
+
|
322 |
+
return $locale;
|
323 |
+
}
|
324 |
+
|
325 |
}
|
inc/functions-troubleshooting.class.php
CHANGED
@@ -38,7 +38,7 @@ class WCML_Troubleshooting{
|
|
38 |
$get_variation_term_taxonomy_ids = $wpdb->get_var("SELECT tt.term_taxonomy_id FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.name = 'variable'");
|
39 |
$get_variation_term_taxonomy_ids = apply_filters('wcml_variation_term_taxonomy_ids',(array)$get_variation_term_taxonomy_ids);
|
40 |
|
41 |
-
$get_variables_products = $wpdb->get_results("SELECT tr.element_id as id FROM {$wpdb->prefix}icl_translations AS tr LEFT JOIN $wpdb->term_relationships as t ON tr.element_id = t.object_id LEFT JOIN $wpdb->posts AS p ON tr.element_id = p.ID
|
42 |
WHERE p.post_status = 'publish' AND tr.source_language_code is NULL AND tr.element_type = 'post_product' AND t.term_taxonomy_id IN (".join(',',$get_variation_term_taxonomy_ids).") ORDER BY tr.element_id",ARRAY_A);
|
43 |
|
44 |
update_option('wcml_products_to_sync',$get_variables_products);
|
@@ -83,13 +83,13 @@ class WCML_Troubleshooting{
|
|
83 |
|
84 |
$get_variables_products = get_option('wcml_products_to_sync');
|
85 |
$all_active_lang = $sitepress->get_active_languages();
|
86 |
-
$default_lang = $sitepress->get_default_language();
|
87 |
$unset_keys = array();
|
88 |
$products_for_one_ajax = array_slice($get_variables_products,0,3,true);
|
89 |
|
90 |
-
|
91 |
-
if($language['code'] != $default_lang){
|
92 |
foreach ($products_for_one_ajax as $key => $product){
|
|
|
|
|
93 |
$tr_product_id = icl_object_id($product['id'],'product',false,$language['code']);
|
94 |
|
95 |
if(!is_null($tr_product_id)){
|
@@ -156,7 +156,7 @@ class WCML_Troubleshooting{
|
|
156 |
|
157 |
global $wpdb,$sitepress;
|
158 |
|
159 |
-
$all_categories = $wpdb->get_results($wpdb->prepare("SELECT t.term_taxonomy_id,t.term_id FROM $wpdb->term_taxonomy AS t LEFT JOIN {$wpdb->prefix}icl_translations AS tr ON tr.element_id = t.term_taxonomy_id WHERE t.taxonomy = 'product_cat' AND tr.element_type = 'tax_product_cat' AND tr.source_language_code is NULL ORDER BY t.term_taxonomy_id LIMIT %d,5",$page*5));
|
160 |
|
161 |
foreach($all_categories as $category){
|
162 |
if(!get_option('wcml_sync_category_'.$category->term_taxonomy_id)){
|
@@ -166,7 +166,7 @@ class WCML_Troubleshooting{
|
|
166 |
$type = get_woocommerce_term_meta( $category->term_id, 'display_type',true);
|
167 |
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id',true);
|
168 |
foreach($translations as $translation){
|
169 |
-
if($translation->language_code != $
|
170 |
update_woocommerce_term_meta( $translation->term_id, 'display_type', $type );
|
171 |
update_woocommerce_term_meta( $translation->term_id, 'thumbnail_id', icl_object_id($thumbnail_id,'attachment',true,$translation->language_code) );
|
172 |
}
|
@@ -210,7 +210,13 @@ class WCML_Troubleshooting{
|
|
210 |
}
|
211 |
}
|
212 |
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
if ( $new_term && !is_wp_error( $new_term ) ) {
|
215 |
$tt_id = $sitepress->get_element_trid( $term->term_taxonomy_id, 'tax_' . $attr );
|
216 |
$sitepress->set_element_language_details( $new_term[ 'term_taxonomy_id' ], 'tax_' . $attr, $tt_id, $language['code'] );
|
38 |
$get_variation_term_taxonomy_ids = $wpdb->get_var("SELECT tt.term_taxonomy_id FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.name = 'variable'");
|
39 |
$get_variation_term_taxonomy_ids = apply_filters('wcml_variation_term_taxonomy_ids',(array)$get_variation_term_taxonomy_ids);
|
40 |
|
41 |
+
$get_variables_products = $wpdb->get_results("SELECT tr.element_id as id,tr.language_code as lang FROM {$wpdb->prefix}icl_translations AS tr LEFT JOIN $wpdb->term_relationships as t ON tr.element_id = t.object_id LEFT JOIN $wpdb->posts AS p ON tr.element_id = p.ID
|
42 |
WHERE p.post_status = 'publish' AND tr.source_language_code is NULL AND tr.element_type = 'post_product' AND t.term_taxonomy_id IN (".join(',',$get_variation_term_taxonomy_ids).") ORDER BY tr.element_id",ARRAY_A);
|
43 |
|
44 |
update_option('wcml_products_to_sync',$get_variables_products);
|
83 |
|
84 |
$get_variables_products = get_option('wcml_products_to_sync');
|
85 |
$all_active_lang = $sitepress->get_active_languages();
|
|
|
86 |
$unset_keys = array();
|
87 |
$products_for_one_ajax = array_slice($get_variables_products,0,3,true);
|
88 |
|
89 |
+
|
|
|
90 |
foreach ($products_for_one_ajax as $key => $product){
|
91 |
+
foreach($all_active_lang as $language){
|
92 |
+
if($language['code'] != $product['lang']){
|
93 |
$tr_product_id = icl_object_id($product['id'],'product',false,$language['code']);
|
94 |
|
95 |
if(!is_null($tr_product_id)){
|
156 |
|
157 |
global $wpdb,$sitepress;
|
158 |
|
159 |
+
$all_categories = $wpdb->get_results($wpdb->prepare("SELECT t.term_taxonomy_id,t.term_id,tr.language_code FROM $wpdb->term_taxonomy AS t LEFT JOIN {$wpdb->prefix}icl_translations AS tr ON tr.element_id = t.term_taxonomy_id WHERE t.taxonomy = 'product_cat' AND tr.element_type = 'tax_product_cat' AND tr.source_language_code is NULL ORDER BY t.term_taxonomy_id LIMIT %d,5",$page*5));
|
160 |
|
161 |
foreach($all_categories as $category){
|
162 |
if(!get_option('wcml_sync_category_'.$category->term_taxonomy_id)){
|
166 |
$type = get_woocommerce_term_meta( $category->term_id, 'display_type',true);
|
167 |
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id',true);
|
168 |
foreach($translations as $translation){
|
169 |
+
if($translation->language_code != $category->language_code ){
|
170 |
update_woocommerce_term_meta( $translation->term_id, 'display_type', $type );
|
171 |
update_woocommerce_term_meta( $translation->term_id, 'thumbnail_id', icl_object_id($thumbnail_id,'attachment',true,$translation->language_code) );
|
172 |
}
|
210 |
}
|
211 |
}
|
212 |
|
213 |
+
if( version_compare( ICL_SITEPRESS_VERSION, '3.1.8.2', '<=' ) ){
|
214 |
+
$term_name = $term->name.' @'.$language['code'];
|
215 |
+
}else{
|
216 |
+
$term_name = $term->name;
|
217 |
+
}
|
218 |
+
|
219 |
+
$new_term = wp_insert_term( $term_name , $attr, $term_args );
|
220 |
if ( $new_term && !is_wp_error( $new_term ) ) {
|
221 |
$tt_id = $sitepress->get_element_trid( $term->term_taxonomy_id, 'tax_' . $attr );
|
222 |
$sitepress->set_element_language_details( $new_term[ 'term_taxonomy_id' ], 'tax_' . $attr, $tt_id, $language['code'] );
|
inc/multi-currency-support.class.php
CHANGED
@@ -11,8 +11,7 @@ class WCML_Multi_Currency_Support{
|
|
11 |
|
12 |
function __construct(){
|
13 |
|
14 |
-
add_action('init', array($this, 'init'), 5);
|
15 |
-
//add_action('wp_head', array($this, 'set_default_currency')); //@todo - review
|
16 |
$this->init_currencies();
|
17 |
|
18 |
if(is_ajax()){
|
@@ -40,6 +39,9 @@ class WCML_Multi_Currency_Support{
|
|
40 |
|
41 |
add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
|
42 |
add_action( 'init', array( $this, 'register_styles' ) );
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
function _load_filters(){
|
@@ -103,7 +105,13 @@ class WCML_Multi_Currency_Support{
|
|
103 |
|
104 |
add_action('currency_switcher', array($this, 'currency_switcher'));
|
105 |
add_shortcode('currency_switcher', array($this, 'currency_switcher_shortcode'));
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
if(!is_admin()) $this->load_inline_js();
|
108 |
|
109 |
}
|
@@ -478,21 +486,30 @@ class WCML_Multi_Currency_Support{
|
|
478 |
$save = false;
|
479 |
|
480 |
$options = array(
|
481 |
-
'
|
482 |
-
'
|
483 |
-
'
|
484 |
-
'
|
485 |
);
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
|
|
|
|
490 |
$save = true;
|
491 |
-
$this->currencies[$code][$key] = $_POST[$wc_key
|
492 |
}
|
493 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
-
|
496 |
if($save){
|
497 |
$woocommerce_wpml->settings['currency_options'] = $this->currencies;
|
498 |
$woocommerce_wpml->update_settings();
|
@@ -505,17 +522,8 @@ class WCML_Multi_Currency_Support{
|
|
505 |
}
|
506 |
|
507 |
function filter_currency_position_option($value){
|
508 |
-
global $pagenow;
|
509 |
|
510 |
-
|
511 |
-
$currency_code = $_COOKIE[ '_wcml_order_currency' ];
|
512 |
-
}elseif( isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order'){
|
513 |
-
$currency_code = get_post_meta( $_GET['post'], '_order_currency', true );
|
514 |
-
}elseif( isset( $_COOKIE[ '_wcml_dashboard_currency' ] ) && $pagenow == 'index.php' ){
|
515 |
-
$currency_code = $_COOKIE[ '_wcml_dashboard_currency' ];
|
516 |
-
}else{
|
517 |
-
$currency_code = $this->client_currency;
|
518 |
-
}
|
519 |
|
520 |
if(isset($this->currencies[$currency_code]['position']) && get_option('woocommerce_currency') != $currency_code &&
|
521 |
in_array($this->currencies[$currency_code]['position'], array('left', 'right', 'left_space', 'right_space'))){
|
@@ -542,25 +550,54 @@ class WCML_Multi_Currency_Support{
|
|
542 |
}
|
543 |
|
544 |
function filter_currency_thousand_sep_option($value){
|
545 |
-
|
546 |
-
|
|
|
|
|
|
|
547 |
}
|
548 |
return $value;
|
549 |
}
|
550 |
|
551 |
function filter_currency_decimal_sep_option($value){
|
552 |
-
|
553 |
-
|
|
|
|
|
|
|
|
|
554 |
}
|
|
|
555 |
return $value;
|
556 |
}
|
557 |
|
558 |
function filter_currency_num_decimals_option($value){
|
559 |
-
|
560 |
-
|
|
|
|
|
|
|
561 |
}
|
562 |
return $value;
|
563 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
|
565 |
function load_inline_js(){
|
566 |
|
@@ -636,7 +673,7 @@ class WCML_Multi_Currency_Support{
|
|
636 |
}else{
|
637 |
// 2. automatic conversion
|
638 |
$price = get_post_meta($object_id, $meta_key, $single);
|
639 |
-
$price = apply_filters('wcml_raw_price_amount', $price
|
640 |
|
641 |
}
|
642 |
|
@@ -647,8 +684,9 @@ class WCML_Multi_Currency_Support{
|
|
647 |
}
|
648 |
|
649 |
}
|
650 |
-
|
651 |
-
|
|
|
652 |
}
|
653 |
|
654 |
function variation_prices_filter($null, $object_id, $meta_key, $single){
|
@@ -673,7 +711,7 @@ class WCML_Multi_Currency_Support{
|
|
673 |
$variation_fields[$k][$j] = $manual_prices[$k]; // manual price
|
674 |
|
675 |
}else{
|
676 |
-
$variation_fields[$k][$j] = apply_filters('wcml_raw_price_amount', $amount
|
677 |
}
|
678 |
|
679 |
|
@@ -688,12 +726,12 @@ class WCML_Multi_Currency_Support{
|
|
688 |
|
689 |
}
|
690 |
|
691 |
-
return !empty($variation_fields) ? $variation_fields : null;
|
692 |
|
693 |
}
|
694 |
|
695 |
function get_product_custom_prices($product_id, $currency = false){
|
696 |
-
global $wpdb, $sitepress;
|
697 |
|
698 |
$distinct_prices = false;
|
699 |
|
@@ -705,7 +743,7 @@ class WCML_Multi_Currency_Support{
|
|
705 |
$post_type = get_post_type($product_id);
|
706 |
$product_translations = $sitepress->get_element_translations($sitepress->get_element_trid($product_id, 'post_'.$post_type), 'post_'.$post_type);
|
707 |
foreach($product_translations as $translation){
|
708 |
-
if($
|
709 |
$original_product_id = $translation->element_id;
|
710 |
break;
|
711 |
}
|
@@ -803,7 +841,7 @@ class WCML_Multi_Currency_Support{
|
|
803 |
// include the dynamic prices
|
804 |
foreach($variation_ids as $vid){
|
805 |
if(empty($regular_prices[$vid]) && isset($default_regular_prices[$vid])){
|
806 |
-
$regular_prices[$vid] = apply_filters('wcml_raw_price_amount', $default_regular_prices[$vid]
|
807 |
}
|
808 |
}
|
809 |
|
@@ -823,7 +861,7 @@ class WCML_Multi_Currency_Support{
|
|
823 |
// include the dynamic prices
|
824 |
foreach($variation_ids as $vid){
|
825 |
if(empty($sale_prices[$vid]) && isset($default_sale_prices[$vid])){
|
826 |
-
$sale_prices[$vid] = apply_filters('wcml_raw_price_amount', $default_sale_prices[$vid]
|
827 |
}
|
828 |
}
|
829 |
|
@@ -844,7 +882,7 @@ class WCML_Multi_Currency_Support{
|
|
844 |
// include the dynamic prices
|
845 |
foreach($variation_ids as $vid){
|
846 |
if(empty($custom_prices_prices[$vid]) && isset($default_prices[$vid])){
|
847 |
-
$prices[$vid] = apply_filters('wcml_raw_price_amount', $default_prices[$vid]
|
848 |
}
|
849 |
}
|
850 |
|
@@ -993,10 +1031,10 @@ class WCML_Multi_Currency_Support{
|
|
993 |
$active_languages = $sitepress->get_active_languages();
|
994 |
|
995 |
if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
|
996 |
-
|
997 |
}
|
998 |
|
999 |
-
if( is_null($this->client_currency) && isset($default_currencies[$current_language]) && $default_currencies[$current_language] ){
|
1000 |
$this->client_currency = $default_currencies[$current_language];
|
1001 |
}
|
1002 |
|
@@ -1029,6 +1067,7 @@ class WCML_Multi_Currency_Support{
|
|
1029 |
|
1030 |
if(!empty($woocommerce->session) && $this->client_currency){
|
1031 |
$woocommerce->session->set('client_currency', $this->client_currency);
|
|
|
1032 |
}
|
1033 |
|
1034 |
|
@@ -1037,11 +1076,11 @@ class WCML_Multi_Currency_Support{
|
|
1037 |
|
1038 |
function set_client_currency($currency){
|
1039 |
|
1040 |
-
global $woocommerce
|
1041 |
$this->client_currency = $currency;
|
1042 |
|
1043 |
$woocommerce->session->set('client_currency', $currency);
|
1044 |
-
$woocommerce->session->set('
|
1045 |
|
1046 |
|
1047 |
do_action('wcml_set_client_currency', $currency);
|
@@ -1062,8 +1101,52 @@ class WCML_Multi_Currency_Support{
|
|
1062 |
exit;
|
1063 |
|
1064 |
}
|
1065 |
-
|
1066 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1067 |
function get_exchange_rates(){
|
1068 |
|
1069 |
$exchange_rates = apply_filters('wcml_exchange_rates', $this->exchange_rates);
|
@@ -1198,6 +1281,26 @@ class WCML_Multi_Currency_Support{
|
|
1198 |
return $amount;
|
1199 |
|
1200 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1201 |
|
1202 |
}
|
1203 |
|
11 |
|
12 |
function __construct(){
|
13 |
|
14 |
+
add_action('init', array($this, 'init'), 5);
|
|
|
15 |
$this->init_currencies();
|
16 |
|
17 |
if(is_ajax()){
|
39 |
|
40 |
add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
|
41 |
add_action( 'init', array( $this, 'register_styles' ) );
|
42 |
+
|
43 |
+
add_filter( 'woocommerce_cart_contents_total', array( $this, 'filter_woocommerce_cart_contents_total'), 100 );
|
44 |
+
add_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal'), 100, 3 );
|
45 |
}
|
46 |
|
47 |
function _load_filters(){
|
105 |
|
106 |
add_action('currency_switcher', array($this, 'currency_switcher'));
|
107 |
add_shortcode('currency_switcher', array($this, 'currency_switcher_shortcode'));
|
108 |
+
|
109 |
+
if( version_compare( WOOCOMMERCE_VERSION, '2.3', '<' ) ){
|
110 |
+
add_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
|
111 |
+
}
|
112 |
+
|
113 |
+
add_filter( 'wc_price_args', array( $this, 'filter_wc_price_args') );
|
114 |
+
|
115 |
if(!is_admin()) $this->load_inline_js();
|
116 |
|
117 |
}
|
486 |
$save = false;
|
487 |
|
488 |
$options = array(
|
489 |
+
'woocommerce_currency_pos' => 'position',
|
490 |
+
'woocommerce_price_thousand_sep' => 'thousand_sep',
|
491 |
+
'woocommerce_price_decimal_sep' => 'decimal_sep',
|
492 |
+
'woocommerce_price_num_decimals' => 'num_decimals'
|
493 |
);
|
494 |
+
|
495 |
+
$woocommerce_currency = get_option('woocommerce_currency', true);
|
496 |
+
|
497 |
+
foreach($options as $wc_key => $key){
|
498 |
+
foreach($this->get_currencies() as $code => $currency){
|
499 |
+
if(isset($_POST[$wc_key.'_'. $code]) && $_POST[$wc_key.'_'. $code] != $this->currencies[$code][$key]){
|
500 |
$save = true;
|
501 |
+
$this->currencies[$code][$key] = $_POST[$wc_key.'_'. $code];
|
502 |
}
|
503 |
}
|
504 |
+
|
505 |
+
//update default currency
|
506 |
+
if(isset($_POST[$wc_key]) && $_POST[$wc_key] != $this->currencies[$woocommerce_currency][$key]){
|
507 |
+
$save = true;
|
508 |
+
$this->currencies[$woocommerce_currency][$key] = $_POST[$wc_key];
|
509 |
+
}
|
510 |
+
|
511 |
}
|
512 |
+
|
513 |
if($save){
|
514 |
$woocommerce_wpml->settings['currency_options'] = $this->currencies;
|
515 |
$woocommerce_wpml->update_settings();
|
522 |
}
|
523 |
|
524 |
function filter_currency_position_option($value){
|
|
|
525 |
|
526 |
+
$currency_code = $this->check_admin_order_currency_code();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
|
528 |
if(isset($this->currencies[$currency_code]['position']) && get_option('woocommerce_currency') != $currency_code &&
|
529 |
in_array($this->currencies[$currency_code]['position'], array('left', 'right', 'left_space', 'right_space'))){
|
550 |
}
|
551 |
|
552 |
function filter_currency_thousand_sep_option($value){
|
553 |
+
|
554 |
+
$currency_code = $this->check_admin_order_currency_code();
|
555 |
+
|
556 |
+
if(isset($this->currencies[$currency_code]['thousand_sep']) ){
|
557 |
+
$value = $this->currencies[$currency_code]['thousand_sep'];
|
558 |
}
|
559 |
return $value;
|
560 |
}
|
561 |
|
562 |
function filter_currency_decimal_sep_option($value){
|
563 |
+
|
564 |
+
$currency_code = $this->check_admin_order_currency_code();
|
565 |
+
|
566 |
+
if(isset($this->currencies[$currency_code]['decimal_sep']) ){
|
567 |
+
$value = $this->currencies[$currency_code]['decimal_sep'];
|
568 |
+
|
569 |
}
|
570 |
+
|
571 |
return $value;
|
572 |
}
|
573 |
|
574 |
function filter_currency_num_decimals_option($value){
|
575 |
+
|
576 |
+
$currency_code = $this->check_admin_order_currency_code();
|
577 |
+
|
578 |
+
if(isset($this->currencies[$currency_code]['num_decimals']) ){
|
579 |
+
$value = $this->currencies[$currency_code]['num_decimals'];
|
580 |
}
|
581 |
return $value;
|
582 |
}
|
583 |
+
|
584 |
+
|
585 |
+
function check_admin_order_currency_code(){
|
586 |
+
global $pagenow;
|
587 |
+
|
588 |
+
if( ( ( is_ajax() && isset($_POST['action']) && in_array($_POST['action'],array('woocommerce_add_order_item','woocommerce_save_order_items','woocommerce_calc_line_taxes'))) || ( $pagenow == 'post-new.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'shop_order' ) ) && isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
|
589 |
+
$currency_code = $_COOKIE[ '_wcml_order_currency' ];
|
590 |
+
}elseif( isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order'){
|
591 |
+
$currency_code = get_post_meta( $_GET['post'], '_order_currency', true );
|
592 |
+
}elseif( isset( $_COOKIE[ '_wcml_dashboard_currency' ] ) && $pagenow == 'index.php' ){
|
593 |
+
$currency_code = $_COOKIE[ '_wcml_dashboard_currency' ];
|
594 |
+
}else{
|
595 |
+
$currency_code = $this->client_currency;
|
596 |
+
}
|
597 |
+
|
598 |
+
return $currency_code;
|
599 |
+
|
600 |
+
}
|
601 |
|
602 |
function load_inline_js(){
|
603 |
|
673 |
}else{
|
674 |
// 2. automatic conversion
|
675 |
$price = get_post_meta($object_id, $meta_key, $single);
|
676 |
+
$price = apply_filters('wcml_raw_price_amount', $price );
|
677 |
|
678 |
}
|
679 |
|
684 |
}
|
685 |
|
686 |
}
|
687 |
+
|
688 |
+
|
689 |
+
return !empty($price) ? $price : $null;
|
690 |
}
|
691 |
|
692 |
function variation_prices_filter($null, $object_id, $meta_key, $single){
|
711 |
$variation_fields[$k][$j] = $manual_prices[$k]; // manual price
|
712 |
|
713 |
}else{
|
714 |
+
$variation_fields[$k][$j] = apply_filters('wcml_raw_price_amount', $amount ); // automatic conversion
|
715 |
}
|
716 |
|
717 |
|
726 |
|
727 |
}
|
728 |
|
729 |
+
return !empty($variation_fields) ? $variation_fields : $null;
|
730 |
|
731 |
}
|
732 |
|
733 |
function get_product_custom_prices($product_id, $currency = false){
|
734 |
+
global $wpdb, $sitepress, $woocommerce_wpml;
|
735 |
|
736 |
$distinct_prices = false;
|
737 |
|
743 |
$post_type = get_post_type($product_id);
|
744 |
$product_translations = $sitepress->get_element_translations($sitepress->get_element_trid($product_id, 'post_'.$post_type), 'post_'.$post_type);
|
745 |
foreach($product_translations as $translation){
|
746 |
+
if( $woocommerce_wpml->products->is_original_product($translation->element_id) ){
|
747 |
$original_product_id = $translation->element_id;
|
748 |
break;
|
749 |
}
|
841 |
// include the dynamic prices
|
842 |
foreach($variation_ids as $vid){
|
843 |
if(empty($regular_prices[$vid]) && isset($default_regular_prices[$vid])){
|
844 |
+
$regular_prices[$vid] = apply_filters('wcml_raw_price_amount', $default_regular_prices[$vid] );
|
845 |
}
|
846 |
}
|
847 |
|
861 |
// include the dynamic prices
|
862 |
foreach($variation_ids as $vid){
|
863 |
if(empty($sale_prices[$vid]) && isset($default_sale_prices[$vid])){
|
864 |
+
$sale_prices[$vid] = apply_filters('wcml_raw_price_amount', $default_sale_prices[$vid]);
|
865 |
}
|
866 |
}
|
867 |
|
882 |
// include the dynamic prices
|
883 |
foreach($variation_ids as $vid){
|
884 |
if(empty($custom_prices_prices[$vid]) && isset($default_prices[$vid])){
|
885 |
+
$prices[$vid] = apply_filters('wcml_raw_price_amount', $default_prices[$vid]);
|
886 |
}
|
887 |
}
|
888 |
|
1031 |
$active_languages = $sitepress->get_active_languages();
|
1032 |
|
1033 |
if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
|
1034 |
+
$this->client_currency = $_POST['currency'];
|
1035 |
}
|
1036 |
|
1037 |
+
if( is_null($this->client_currency) && isset($default_currencies[$current_language]) && $default_currencies[$current_language] && !empty($woocommerce->session) && $current_language != $woocommerce->session->get('client_currency_language') ){
|
1038 |
$this->client_currency = $default_currencies[$current_language];
|
1039 |
}
|
1040 |
|
1067 |
|
1068 |
if(!empty($woocommerce->session) && $this->client_currency){
|
1069 |
$woocommerce->session->set('client_currency', $this->client_currency);
|
1070 |
+
$woocommerce->session->set('client_currency_language',$current_language);
|
1071 |
}
|
1072 |
|
1073 |
|
1076 |
|
1077 |
function set_client_currency($currency){
|
1078 |
|
1079 |
+
global $woocommerce,$sitepress;
|
1080 |
$this->client_currency = $currency;
|
1081 |
|
1082 |
$woocommerce->session->set('client_currency', $currency);
|
1083 |
+
$woocommerce->session->set('client_currency_language', $sitepress->get_current_language());
|
1084 |
|
1085 |
|
1086 |
do_action('wcml_set_client_currency', $currency);
|
1101 |
exit;
|
1102 |
|
1103 |
}
|
1104 |
+
|
1105 |
+
/*
|
1106 |
+
* Limitation: If the default currency is configured to display more decimals than the other currencies,
|
1107 |
+
* the prices in the secondary currencies would be approximated to the number of decimals that they have more.
|
1108 |
+
*/
|
1109 |
+
function price_in_specific_currency( $return, $price, $args ){
|
1110 |
+
|
1111 |
+
if(isset($args['currency']) && $this->client_currency != $args['currency']){
|
1112 |
+
remove_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
|
1113 |
+
$this->client_currency = $args['currency'];
|
1114 |
+
$return = wc_price($price, $args);
|
1115 |
+
add_filter( 'wc_price', array( $this, 'price_in_specific_currency' ), 10, 3 );
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
return $return;
|
1119 |
+
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
function filter_wc_price_args( $args ){
|
1123 |
+
|
1124 |
+
if( isset($args['currency']) ){
|
1125 |
+
|
1126 |
+
if(isset($this->currencies[$args['currency']]['decimal_sep']) ){
|
1127 |
+
$args['decimal_separator'] = $this->currencies[$args['currency']]['decimal_sep'];
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
if(isset($this->currencies[$args['currency']]['thousand_sep']) ){
|
1131 |
+
$args['thousand_separator'] = $this->currencies[$args['currency']]['thousand_sep'];
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
if(isset($this->currencies[$args['currency']]['num_decimals']) ){
|
1135 |
+
$args['decimals'] = $this->currencies[$args['currency']]['num_decimals'];
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
if( isset($this->currencies[$args['currency']]['position']) ){
|
1139 |
+
$current_currency = $this->client_currency;
|
1140 |
+
$this->client_currency = $args['currency'];
|
1141 |
+
$args['price_format'] = get_woocommerce_price_format();
|
1142 |
+
$this->client_currency = $current_currency;
|
1143 |
+
}
|
1144 |
+
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
return $args;
|
1148 |
+
}
|
1149 |
+
|
1150 |
function get_exchange_rates(){
|
1151 |
|
1152 |
$exchange_rates = apply_filters('wcml_exchange_rates', $this->exchange_rates);
|
1281 |
return $amount;
|
1282 |
|
1283 |
}
|
1284 |
+
|
1285 |
+
function filter_woocommerce_cart_contents_total( $cart_contents_total ){
|
1286 |
+
global $woocommerce;
|
1287 |
+
remove_filter( 'woocommerce_cart_contents_total', array( $this, 'filter_woocommerce_cart_contents_total'), 100 );
|
1288 |
+
$woocommerce->cart->calculate_totals();
|
1289 |
+
$cart_contents_total = $woocommerce->cart->get_cart_total();
|
1290 |
+
add_filter( 'woocommerce_cart_contents_total', array( $this, 'filter_woocommerce_cart_contents_total'), 100 );
|
1291 |
+
|
1292 |
+
return $cart_contents_total;
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
function filter_woocommerce_cart_subtotal( $cart_subtotal, $compound, $obj ){
|
1296 |
+
global $woocommerce;
|
1297 |
+
remove_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal'), 100, 3 );
|
1298 |
+
$woocommerce->cart->calculate_totals();
|
1299 |
+
$cart_subtotal = $woocommerce->cart->get_cart_subtotal( $compound );
|
1300 |
+
add_filter( 'woocommerce_cart_subtotal', array( $this, 'filter_woocommerce_cart_subtotal'), 100, 3 );
|
1301 |
+
|
1302 |
+
return $cart_subtotal;
|
1303 |
+
}
|
1304 |
|
1305 |
}
|
1306 |
|
inc/multi-currency.class.php
CHANGED
@@ -16,7 +16,7 @@ class WCML_WC_MultiCurrency{
|
|
16 |
function __construct(){
|
17 |
|
18 |
add_filter('init', array($this, 'init'), 5);
|
19 |
-
add_filter('woocommerce_adjust_price', array($this, 'raw_price_filter'), 10
|
20 |
|
21 |
}
|
22 |
|
@@ -70,8 +70,6 @@ class WCML_WC_MultiCurrency{
|
|
70 |
add_filter( 'woocommerce_ajax_order_item', array( $this, 'filter_ajax_order_item' ), 10, 2 );
|
71 |
|
72 |
add_action( 'wp_ajax_wcml_order_set_currency', array( $this, 'set_order_currency' ) );
|
73 |
-
add_action( 'wp_ajax_wcml_order_delete_items', array( $this, 'order_delete_items' ) );
|
74 |
-
|
75 |
}
|
76 |
|
77 |
// reports
|
@@ -91,6 +89,7 @@ class WCML_WC_MultiCurrency{
|
|
91 |
|
92 |
//dashboard status screen
|
93 |
if(is_admin() && ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) ){
|
|
|
94 |
add_action( 'wp_dashboard_setup', array( $this, 'dashboard_currency_dropdown' ) );
|
95 |
|
96 |
add_filter( 'woocommerce_dashboard_status_widget_sales_query', array( $this, 'filter_dashboard_status_widget_sales_query' ) );
|
@@ -122,13 +121,12 @@ class WCML_WC_MultiCurrency{
|
|
122 |
$this->set_default_currencies_languages();
|
123 |
}
|
124 |
|
125 |
-
function raw_price_filter($price, $
|
126 |
|
127 |
-
if(
|
128 |
-
$
|
129 |
}
|
130 |
-
|
131 |
-
$price = $this->convert_price_amount($price, $this->get_client_currency());
|
132 |
|
133 |
$price = $this->apply_rounding_rules($price);
|
134 |
|
@@ -491,10 +489,10 @@ class WCML_WC_MultiCurrency{
|
|
491 |
|
492 |
}elseif( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'woocommerce_add_order_item', 'woocommerce_calc_line_taxes', 'woocommerce_save_order_items' ) ) ){
|
493 |
|
494 |
-
if(
|
495 |
-
$currency = get_woocommerce_currency_symbol( get_post_meta( $_POST['order_id'], '_order_currency', true ) );
|
496 |
-
}elseif( isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
|
497 |
$currency = get_woocommerce_currency_symbol($_COOKIE[ '_wcml_order_currency' ]);
|
|
|
|
|
498 |
}
|
499 |
}
|
500 |
|
@@ -670,7 +668,7 @@ class WCML_WC_MultiCurrency{
|
|
670 |
|
671 |
$wc_currencies = get_woocommerce_currencies();
|
672 |
$currencies = $woocommerce_wpml->multi_currency_support->get_currency_codes();
|
673 |
-
|
674 |
?>
|
675 |
<li class="wide">
|
676 |
<label><?php _e('Order currency:'); ?></label>
|
@@ -684,83 +682,39 @@ class WCML_WC_MultiCurrency{
|
|
684 |
|
685 |
</select>
|
686 |
</li>
|
687 |
-
<li class="wide">
|
688 |
-
<label><?php _e('Order language:'); ?></label>
|
689 |
-
<select id="dropdown_shop_order_language" name="wcml_shop_order_language">
|
690 |
-
<?php if(!empty($languages)): ?>
|
691 |
-
|
692 |
-
<?php foreach($languages as $l): ?>
|
693 |
-
|
694 |
-
<option value="<?php echo $l['language_code'] ?>" <?php echo $sitepress->get_default_language() == $l['language_code'] ? 'selected="selected"':''; ?>><?php echo $l['translated_name']; ?></option>
|
695 |
-
|
696 |
-
<?php endforeach; ?>
|
697 |
-
|
698 |
-
<?php endif; ?>
|
699 |
-
</select>
|
700 |
-
</li>
|
701 |
<?php
|
702 |
$wcml_order_set_currency_nonce = wp_create_nonce( 'set_order_currency' );
|
703 |
-
|
704 |
wc_enqueue_js( "
|
705 |
-
jQuery('#dropdown_shop_order_currency').
|
706 |
-
jQuery.ajax({
|
707 |
-
url: ajaxurl,
|
708 |
-
type: 'post',
|
709 |
-
dataType: 'json',
|
710 |
-
data: {action: 'wcml_order_set_currency', order_id: woocommerce_admin_meta_boxes.post_id, currency: jQuery('#dropdown_shop_order_currency').val(), prev_currency: getCookie('_wcml_order_currency'), shipp: jQuery('.wc-order-totals tr:nth-child(1) .amount').html(), disc: jQuery('#_order_discount').val(), total: jQuery('#_order_total').val(), refund: jQuery('.wc-order-totals tr:nth-child(4) .amount').html(), wcml_nonce: '".$wcml_order_set_currency_nonce."' },
|
711 |
-
success: function( response ){
|
712 |
-
if(typeof response.error !== 'undefined'){
|
713 |
-
alert(response.error);
|
714 |
-
}else{
|
715 |
-
if(typeof response.items !== 'undefined'){
|
716 |
-
jQuery.each(response.items, function(index, value) {
|
717 |
-
var item = jQuery('tr[data-order_item_id = '+index+']');
|
718 |
-
item.attr('data-unit_subtotal',value.line_subtotal);
|
719 |
-
item.attr('data-unit_total',value.line_total);
|
720 |
-
item.find('.view .amount').html(value.display_total);
|
721 |
-
item.find('.line_cost .edit .line_subtotal').val(value.line_subtotal);
|
722 |
-
item.find('.line_cost .edit .line_total').val(value.line_total);
|
723 |
-
});
|
724 |
-
}
|
725 |
-
jQuery('.wc-order-totals tr:nth-child(1) .amount').html(response.shipp);
|
726 |
-
jQuery('.wc-order-totals tr:nth-child(2) .amount').html(response.disc_disp);
|
727 |
-
jQuery('.wc-order-totals tr:nth-child(3) .amount').html(response.total_disp);
|
728 |
-
jQuery('.wc-order-totals tr:nth-child(4) .amount').html(response.refund);
|
729 |
-
jQuery('#_order_discount').val(response.disc);
|
730 |
-
jQuery('#_order_total').val(response.total);
|
731 |
-
}
|
732 |
-
}
|
733 |
-
})
|
734 |
-
});
|
735 |
|
|
|
736 |
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
|
|
|
|
|
|
750 |
}
|
751 |
-
}
|
752 |
-
}
|
|
|
|
|
|
|
|
|
753 |
});
|
754 |
|
755 |
-
function getCookie(name){
|
756 |
-
var pattern = RegExp(name + '=.[^;]*');
|
757 |
-
matched = document.cookie.match(pattern);
|
758 |
-
if(matched){
|
759 |
-
var cookie = matched[0].split('=');
|
760 |
-
return cookie[1];
|
761 |
-
}
|
762 |
-
return false;
|
763 |
-
}
|
764 |
");
|
765 |
|
766 |
}
|
@@ -775,117 +729,13 @@ class WCML_WC_MultiCurrency{
|
|
775 |
|
776 |
setcookie('_wcml_order_currency', $_POST['currency'], time() + 86400, COOKIEPATH, COOKIE_DOMAIN);
|
777 |
|
778 |
-
|
779 |
-
if( isset ( $_POST[ 'order_id' ] ) ){
|
780 |
-
global $wpdb,$woocommerce_wpml;
|
781 |
-
|
782 |
-
$items = $wpdb->get_results( $wpdb->prepare( "SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = '%d'" , $_POST[ 'order_id' ] ) );
|
783 |
-
|
784 |
-
$return = array();
|
785 |
-
|
786 |
-
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
787 |
-
|
788 |
-
if(isset($currencies[$_POST[ 'currency' ]])){
|
789 |
-
$currency_info = $currencies[$_POST[ 'currency' ]];
|
790 |
-
$decimals_num = $currency_info['num_decimals'];
|
791 |
-
$decimal_sep = $currency_info['decimal_sep'];
|
792 |
-
$thousand_sep = $currency_info['thousand_sep'];
|
793 |
-
}else{
|
794 |
-
$decimals_num = get_option('woocommerce_price_num_decimals');
|
795 |
-
$decimal_sep = get_option('woocommerce_price_decimal_sep');
|
796 |
-
$thousand_sep = get_option('woocommerce_price_thousand_sep');
|
797 |
-
}
|
798 |
-
|
799 |
-
foreach($items as $item){
|
800 |
-
|
801 |
-
$line_subtotal = wc_get_order_item_meta( $item->order_item_id, '_line_subtotal', true ) ;
|
802 |
-
$line_subtotal_tax = wc_get_order_item_meta( $item->order_item_id, '_line_subtotal_tax', true );
|
803 |
-
$line_total = wc_get_order_item_meta( $item->order_item_id, '_line_total', true );
|
804 |
-
$line_tax = wc_get_order_item_meta( $item->order_item_id, '_line_tax', true );
|
805 |
-
|
806 |
-
$order_item_id = wc_get_order_item_meta($item->order_item_id, '_variation_id', true );
|
807 |
-
|
808 |
-
if( !$order_item_id ){
|
809 |
-
$order_item_id = wc_get_order_item_meta($item->order_item_id, '_product_id', true );
|
810 |
-
}
|
811 |
-
|
812 |
-
if( $_POST[ 'currency' ] == get_option('woocommerce_currency') ){
|
813 |
-
$custom_price = get_post_meta( $order_item_id, '_price', true );
|
814 |
-
}else{
|
815 |
-
$custom_price = get_post_meta( $order_item_id, '_price_'.$_POST[ 'currency' ], true );
|
816 |
-
}
|
817 |
-
|
818 |
-
if( $_POST[ 'prev_currency' ] != 'false' ){
|
819 |
-
|
820 |
-
if( !$custom_price ){
|
821 |
-
$line_subtotal = $this->unconvert_price_amount( $line_subtotal, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
|
822 |
-
$line_total = $this->unconvert_price_amount( $line_total, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
|
823 |
-
}
|
824 |
-
$line_subtotal_tax = $this->unconvert_price_amount( $line_subtotal_tax, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
|
825 |
-
$line_tax = $this->unconvert_price_amount( $line_tax, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
|
826 |
-
}
|
827 |
-
|
828 |
-
if( $custom_price ){
|
829 |
-
$line_subtotal = $custom_price;
|
830 |
-
$line_total = $custom_price;
|
831 |
-
}else{
|
832 |
-
$line_subtotal = $this->apply_rounding_rules( $this->convert_price_amount( $line_subtotal, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
|
833 |
-
$line_total = $this->apply_rounding_rules( $this->convert_price_amount( $line_total, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
|
834 |
-
}
|
835 |
-
|
836 |
-
wc_update_order_item_meta( $item->order_item_id, '_line_subtotal', $line_subtotal );
|
837 |
-
wc_update_order_item_meta( $item->order_item_id, '_line_subtotal_tax', $this->convert_price_amount( $line_subtotal_tax, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ) );
|
838 |
-
wc_update_order_item_meta( $item->order_item_id, '_line_total', $line_total );
|
839 |
-
wc_update_order_item_meta( $item->order_item_id, '_line_tax', $this->convert_price_amount( $line_tax, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ) );
|
840 |
|
841 |
-
|
842 |
-
$return['items'][$item->order_item_id]['line_total'] = $line_total;
|
843 |
-
$return['items'][$item->order_item_id]['display_total'] = $this->apply_currency_position( $line_total, $_POST[ 'currency' ] );
|
844 |
-
|
845 |
-
}
|
846 |
-
|
847 |
-
$shipp = (float) preg_replace('/[^0-9.]*/','',$_POST[ 'shipp' ]);
|
848 |
-
$disc = $_POST[ 'disc' ] ;
|
849 |
-
$total = $_POST[ 'total' ] ;
|
850 |
-
$refund = (float) preg_replace('/[^0-9.]*/','',$_POST[ 'refund' ]);
|
851 |
-
|
852 |
-
if( $_POST[ 'prev_currency' ] != 'false' ){
|
853 |
-
$shipp = $this->unconvert_price_amount( $shipp , $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
|
854 |
-
$disc = $this->unconvert_price_amount( $disc , $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
|
855 |
-
$total = $this->unconvert_price_amount( $total , $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
|
856 |
-
$refund = $this->unconvert_price_amount( $refund , $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
|
857 |
-
}
|
858 |
-
|
859 |
-
$return['shipp'] = $this->apply_currency_position( $this->apply_rounding_rules( $this->convert_price_amount( $shipp , $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] ), $_POST[ 'currency' ] );
|
860 |
-
$return['disc'] = $this->apply_rounding_rules( $this->convert_price_amount( $disc , $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
|
861 |
-
$return['disc_disp'] = $this->apply_currency_position( $return['disc'], $_POST[ 'currency' ] );
|
862 |
-
$return['total'] = $this->apply_rounding_rules( $this->convert_price_amount( $total , $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
|
863 |
-
$return['total_disp'] = $this->apply_currency_position( $return['total'], $_POST[ 'currency' ] );
|
864 |
-
$return['refund'] = $this->apply_currency_position( $this->apply_rounding_rules( $this->convert_price_amount( $refund, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] ), $_POST[ 'currency' ] );
|
865 |
-
|
866 |
-
echo json_encode($return);
|
867 |
-
|
868 |
-
}
|
869 |
|
870 |
die();
|
871 |
}
|
872 |
|
873 |
-
function order_delete_items(){
|
874 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'order_delete_items')){
|
875 |
-
echo json_encode(array('error' => __('Invalid nonce', 'wpml-wcml')));
|
876 |
-
die();
|
877 |
-
}
|
878 |
-
|
879 |
-
if( isset ( $_POST[ 'order_id' ] ) ){
|
880 |
-
global $wpdb;
|
881 |
-
|
882 |
-
$items = $wpdb->get_results( $wpdb->prepare( "SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = '%d'" , $_POST[ 'order_id' ] ) );
|
883 |
-
foreach($items as $item){
|
884 |
-
wc_delete_order_item( absint( $item->order_item_id ) );
|
885 |
-
}
|
886 |
-
}
|
887 |
-
}
|
888 |
-
|
889 |
function get_cookie_order_currency(){
|
890 |
|
891 |
if( isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
|
@@ -902,10 +752,6 @@ class WCML_WC_MultiCurrency{
|
|
902 |
update_post_meta( $post_id, '_order_currency', $_POST['wcml_shop_order_currency'] );
|
903 |
}
|
904 |
|
905 |
-
if( isset( $_POST['wcml_shop_order_language'] ) ){
|
906 |
-
update_post_meta( $post_id, 'wpml_language', $_POST['wcml_shop_order_language'] );
|
907 |
-
}
|
908 |
-
|
909 |
}
|
910 |
|
911 |
function filter_ajax_order_item( $item, $item_id ){
|
@@ -967,10 +813,9 @@ class WCML_WC_MultiCurrency{
|
|
967 |
}
|
968 |
|
969 |
function woocommerce_product_options_custom_pricing(){
|
970 |
-
global $pagenow,$sitepress;
|
971 |
|
972 |
-
$
|
973 |
-
if((isset($_GET['lang']) && $_GET['lang'] != $def_lang) || (isset($_GET['post']) && $sitepress->get_language_for_element($_GET['post'],'post_product') != $def_lang) || $sitepress->get_current_language() != $def_lang){
|
974 |
return;
|
975 |
}
|
976 |
|
@@ -1013,10 +858,10 @@ class WCML_WC_MultiCurrency{
|
|
1013 |
|
1014 |
|
1015 |
function woocommerce_product_after_variable_attributes_custom_pricing($loop, $variation_data, $variation){
|
1016 |
-
global $sitepress;
|
|
|
1017 |
|
1018 |
-
$
|
1019 |
-
if((isset($_GET['lang']) && $_GET['lang'] != $def_lang) || (isset($_GET['post']) && $sitepress->get_language_for_element($_GET['post'],'post_product') != $def_lang) || $sitepress->get_current_language() != $def_lang){
|
1020 |
return;
|
1021 |
}
|
1022 |
|
@@ -1084,14 +929,31 @@ class WCML_WC_MultiCurrency{
|
|
1084 |
");
|
1085 |
}
|
1086 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1087 |
/*
|
1088 |
* Set dashboard currency cookie
|
1089 |
*/
|
1090 |
-
function set_dashboard_currency(){
|
1091 |
-
|
1092 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1093 |
|
1094 |
-
|
1095 |
|
1096 |
}
|
1097 |
|
16 |
function __construct(){
|
17 |
|
18 |
add_filter('init', array($this, 'init'), 5);
|
19 |
+
add_filter('woocommerce_adjust_price', array($this, 'raw_price_filter'), 10 );
|
20 |
|
21 |
}
|
22 |
|
70 |
add_filter( 'woocommerce_ajax_order_item', array( $this, 'filter_ajax_order_item' ), 10, 2 );
|
71 |
|
72 |
add_action( 'wp_ajax_wcml_order_set_currency', array( $this, 'set_order_currency' ) );
|
|
|
|
|
73 |
}
|
74 |
|
75 |
// reports
|
89 |
|
90 |
//dashboard status screen
|
91 |
if(is_admin() && ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) ){
|
92 |
+
add_action( 'init', array( $this, 'set_dashboard_currency') );
|
93 |
add_action( 'wp_dashboard_setup', array( $this, 'dashboard_currency_dropdown' ) );
|
94 |
|
95 |
add_filter( 'woocommerce_dashboard_status_widget_sales_query', array( $this, 'filter_dashboard_status_widget_sales_query' ) );
|
121 |
$this->set_default_currencies_languages();
|
122 |
}
|
123 |
|
124 |
+
function raw_price_filter($price, $currency = false) {
|
125 |
|
126 |
+
if( $currency === false ){
|
127 |
+
$currency = $this->get_client_currency();
|
128 |
}
|
129 |
+
$price = $this->convert_price_amount($price, $currency);
|
|
|
130 |
|
131 |
$price = $this->apply_rounding_rules($price);
|
132 |
|
489 |
|
490 |
}elseif( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'woocommerce_add_order_item', 'woocommerce_calc_line_taxes', 'woocommerce_save_order_items' ) ) ){
|
491 |
|
492 |
+
if( isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
|
|
|
|
|
493 |
$currency = get_woocommerce_currency_symbol($_COOKIE[ '_wcml_order_currency' ]);
|
494 |
+
}elseif( get_post_meta( $_POST['order_id'], '_order_currency' ) ){
|
495 |
+
$currency = get_woocommerce_currency_symbol( get_post_meta( $_POST['order_id'], '_order_currency', true ) );
|
496 |
}
|
497 |
}
|
498 |
|
668 |
|
669 |
$wc_currencies = get_woocommerce_currencies();
|
670 |
$currencies = $woocommerce_wpml->multi_currency_support->get_currency_codes();
|
671 |
+
|
672 |
?>
|
673 |
<li class="wide">
|
674 |
<label><?php _e('Order currency:'); ?></label>
|
682 |
|
683 |
</select>
|
684 |
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
685 |
<?php
|
686 |
$wcml_order_set_currency_nonce = wp_create_nonce( 'set_order_currency' );
|
687 |
+
|
688 |
wc_enqueue_js( "
|
689 |
+
var order_currency_current_value = jQuery('#dropdown_shop_order_currency option:selected').val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
|
691 |
+
jQuery('#dropdown_shop_order_currency').on('change', function(){
|
692 |
|
693 |
+
if(confirm('" . esc_js(__("All the products will be removed from the current order in order to change the currency", 'wpml-wcml')). "')){
|
694 |
+
jQuery.ajax({
|
695 |
+
url: ajaxurl,
|
696 |
+
type: 'post',
|
697 |
+
dataType: 'json',
|
698 |
+
data: {
|
699 |
+
action: 'wcml_order_set_currency',
|
700 |
+
currency: jQuery('#dropdown_shop_order_currency option:selected').val(),
|
701 |
+
wcml_nonce: '".$wcml_order_set_currency_nonce."'
|
702 |
+
},
|
703 |
+
success: function( response ){
|
704 |
+
if(typeof response.error !== 'undefined'){
|
705 |
+
alert(response.error);
|
706 |
+
}else{
|
707 |
+
window.location = window.location.href;
|
708 |
+
}
|
709 |
}
|
710 |
+
});
|
711 |
+
}else{
|
712 |
+
jQuery(this).val( order_currency_current_value );
|
713 |
+
return false;
|
714 |
+
}
|
715 |
+
|
716 |
});
|
717 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
718 |
");
|
719 |
|
720 |
}
|
729 |
|
730 |
setcookie('_wcml_order_currency', $_POST['currency'], time() + 86400, COOKIEPATH, COOKIE_DOMAIN);
|
731 |
|
732 |
+
$return['currency'] = $_POST['currency'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
733 |
|
734 |
+
echo json_encode($return);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
735 |
|
736 |
die();
|
737 |
}
|
738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
function get_cookie_order_currency(){
|
740 |
|
741 |
if( isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
|
752 |
update_post_meta( $post_id, '_order_currency', $_POST['wcml_shop_order_currency'] );
|
753 |
}
|
754 |
|
|
|
|
|
|
|
|
|
755 |
}
|
756 |
|
757 |
function filter_ajax_order_item( $item, $item_id ){
|
813 |
}
|
814 |
|
815 |
function woocommerce_product_options_custom_pricing(){
|
816 |
+
global $pagenow,$sitepress,$woocommerce_wpml;
|
817 |
|
818 |
+
if(isset($_GET['post']) && ( get_post_type($_GET['post']) != 'product' || !$woocommerce_wpml->products->is_original_product($_GET['post']))){
|
|
|
819 |
return;
|
820 |
}
|
821 |
|
858 |
|
859 |
|
860 |
function woocommerce_product_after_variable_attributes_custom_pricing($loop, $variation_data, $variation){
|
861 |
+
global $sitepress,$woocommerce_wpml;
|
862 |
+
|
863 |
|
864 |
+
if(isset($_GET['post']) && ( get_post_type($_GET['post']) != 'product' || !$woocommerce_wpml->products->is_original_product($_GET['post']))){
|
|
|
865 |
return;
|
866 |
}
|
867 |
|
929 |
");
|
930 |
}
|
931 |
|
932 |
+
function set_dashboard_currency_ajax(){
|
933 |
+
|
934 |
+
$this->set_dashboard_currency($_POST['currency']);
|
935 |
+
|
936 |
+
die();
|
937 |
+
}
|
938 |
+
|
939 |
+
|
940 |
/*
|
941 |
* Set dashboard currency cookie
|
942 |
*/
|
943 |
+
function set_dashboard_currency( $currency_code = false ){
|
944 |
+
|
945 |
+
if( !$currency_code && !headers_sent()){
|
946 |
+
$order_currencies = $this->get_orders_currencies();
|
947 |
+
$currency_code = get_woocommerce_currency();
|
948 |
+
if(!isset($order_currencies[$currency_code])){
|
949 |
+
foreach( $order_currencies as $currency_code => $count ){
|
950 |
+
$currency_code = $currency_code;
|
951 |
+
break;
|
952 |
+
}
|
953 |
+
}
|
954 |
+
}
|
955 |
|
956 |
+
setcookie('_wcml_dashboard_currency', $currency_code , time() + 86400, COOKIEPATH, COOKIE_DOMAIN);
|
957 |
|
958 |
}
|
959 |
|
inc/orders.class.php
CHANGED
@@ -14,6 +14,8 @@ class WCML_Orders{
|
|
14 |
//checkout page
|
15 |
add_action( 'wp_ajax_woocommerce_checkout',array($this,'switch_to_current'),9);
|
16 |
add_action( 'wp_ajax_nopriv_woocommerce_checkout',array($this,'switch_to_current'),9);
|
|
|
|
|
17 |
}
|
18 |
|
19 |
function init(){
|
@@ -28,13 +30,16 @@ class WCML_Orders{
|
|
28 |
|
29 |
add_filter('woocommerce_order_get_items',array($this,'woocommerce_order_get_items'),10);
|
30 |
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
function filtered_woocommerce_new_order_note_data($translations, $text, $domain ){
|
34 |
if(in_array($text,$this->standart_order_notes)){
|
35 |
global $sitepress_settings,$wpdb;
|
36 |
|
37 |
-
if (
|
38 |
$string_id = $wpdb->get_var($wpdb->prepare("SELECT st.id FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE cn.context = %s AND st.value = %s ", $domain, $text ));
|
39 |
$language = icl_st_get_string_language( $string_id );
|
40 |
}else{
|
@@ -64,7 +69,7 @@ class WCML_Orders{
|
|
64 |
|
65 |
foreach($comments as $key=>$comment){
|
66 |
|
67 |
-
if (
|
68 |
$comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT st.id FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE st.value = %s ", $comment->comment_content));
|
69 |
}else{
|
70 |
$comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE language = %s AND value = %s ", $sitepress_settings['st']['strings_language'], $comment->comment_content));
|
@@ -167,4 +172,76 @@ class WCML_Orders{
|
|
167 |
$woocommerce_wpml->emails->change_email_language($sitepress->get_current_language());
|
168 |
}
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
14 |
//checkout page
|
15 |
add_action( 'wp_ajax_woocommerce_checkout',array($this,'switch_to_current'),9);
|
16 |
add_action( 'wp_ajax_nopriv_woocommerce_checkout',array($this,'switch_to_current'),9);
|
17 |
+
|
18 |
+
add_action( 'wp_ajax_wcml_order_delete_items', array( $this, 'order_delete_items' ) );
|
19 |
}
|
20 |
|
21 |
function init(){
|
30 |
|
31 |
add_filter('woocommerce_order_get_items',array($this,'woocommerce_order_get_items'),10);
|
32 |
|
33 |
+
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'set_order_language_backend'), 10, 2 );
|
34 |
+
add_action( 'woocommerce_order_actions_start', array( $this, 'order_language_dropdown' ), 11 ); //after order currency drop-down
|
35 |
+
|
36 |
}
|
37 |
|
38 |
function filtered_woocommerce_new_order_note_data($translations, $text, $domain ){
|
39 |
if(in_array($text,$this->standart_order_notes)){
|
40 |
global $sitepress_settings,$wpdb;
|
41 |
|
42 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
43 |
$string_id = $wpdb->get_var($wpdb->prepare("SELECT st.id FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE cn.context = %s AND st.value = %s ", $domain, $text ));
|
44 |
$language = icl_st_get_string_language( $string_id );
|
45 |
}else{
|
69 |
|
70 |
foreach($comments as $key=>$comment){
|
71 |
|
72 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
73 |
$comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT st.id FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE st.value = %s ", $comment->comment_content));
|
74 |
}else{
|
75 |
$comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE language = %s AND value = %s ", $sitepress_settings['st']['strings_language'], $comment->comment_content));
|
172 |
$woocommerce_wpml->emails->change_email_language($sitepress->get_current_language());
|
173 |
}
|
174 |
|
175 |
+
function order_language_dropdown( $order_id ){
|
176 |
+
global $woocommerce_wpml, $sitepress;
|
177 |
+
if( !get_post_meta( $order_id, '_order_currency') ) {
|
178 |
+
$languages = icl_get_languages('skip_missing=0&orderby=code');
|
179 |
+
$selected_lang = isset( $_COOKIE [ '_wcml_dashboard_order_language' ] ) ? $_COOKIE [ '_wcml_dashboard_order_language' ] : $sitepress->get_default_language();
|
180 |
+
?>
|
181 |
+
<li class="wide">
|
182 |
+
<label><?php _e('Order language:'); ?></label>
|
183 |
+
<select id="dropdown_shop_order_language" name="wcml_shop_order_language">
|
184 |
+
<?php if (!empty($languages)): ?>
|
185 |
+
|
186 |
+
<?php foreach ($languages as $l): ?>
|
187 |
+
|
188 |
+
<option
|
189 |
+
value="<?php echo $l['language_code'] ?>" <?php echo $selected_lang == $l['language_code'] ? 'selected="selected"' : ''; ?>><?php echo $l['translated_name']; ?></option>
|
190 |
+
|
191 |
+
<?php endforeach; ?>
|
192 |
+
|
193 |
+
<?php endif; ?>
|
194 |
+
</select>
|
195 |
+
</li>
|
196 |
+
<?php
|
197 |
+
$wcml_set_dashboard_order_languag_nonce = wp_create_nonce( 'set_dashboard_order_languag' );
|
198 |
+
wc_enqueue_js( "
|
199 |
+
var order_lang_current_value = jQuery('#dropdown_shop_order_language option:selected').val();
|
200 |
+
|
201 |
+
jQuery('#dropdown_shop_order_language').on('change', function(){
|
202 |
+
if(confirm('" . esc_js(__("All the products will be removed from the current order in order to change the language", 'wpml-wcml')). "')){
|
203 |
+
var lang = jQuery(this).val();
|
204 |
+
|
205 |
+
jQuery.ajax({
|
206 |
+
url: ajaxurl,
|
207 |
+
type: 'post',
|
208 |
+
dataType: 'json',
|
209 |
+
data: {action: 'wcml_order_delete_items', order_id: woocommerce_admin_meta_boxes.post_id, lang: lang , wcml_nonce: '".$wcml_set_dashboard_order_languag_nonce."' },
|
210 |
+
success: function( response ){
|
211 |
+
if(typeof response.error !== 'undefined'){
|
212 |
+
alert(response.error);
|
213 |
+
}else{
|
214 |
+
window.location = window.location.href;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
});
|
218 |
+
}else{
|
219 |
+
jQuery(this).val( order_lang_current_value );
|
220 |
+
return false;
|
221 |
+
}
|
222 |
+
});
|
223 |
+
|
224 |
+
");
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
function order_delete_items(){
|
229 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'set_dashboard_order_languag')){
|
230 |
+
echo json_encode(array('error' => __('Invalid nonce', 'wpml-wcml')));
|
231 |
+
die();
|
232 |
+
}
|
233 |
+
|
234 |
+
setcookie('_wcml_dashboard_order_language', $_POST['lang'], time() + 86400, COOKIEPATH, COOKIE_DOMAIN);
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
function set_order_language_backend( $post_id, $post ){
|
239 |
+
|
240 |
+
if( isset( $_POST['wcml_shop_order_language'] ) ){
|
241 |
+
update_post_meta( $post_id, 'wpml_language', $_POST['wcml_shop_order_language'] );
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
|
247 |
}
|
inc/products.class.php
CHANGED
@@ -10,7 +10,7 @@ class WCML_Products{
|
|
10 |
|
11 |
add_action('init', array($this, 'init'));
|
12 |
add_action('init', array($this, 'wc_cart_widget_actions'));
|
13 |
-
add_action('init', array($this, '
|
14 |
|
15 |
//add action for coupons data from WC_Coupon construct
|
16 |
add_action('woocommerce_coupon_loaded',array($this,'wcml_coupon_loaded'));
|
@@ -26,9 +26,6 @@ class WCML_Products{
|
|
26 |
add_filter('wpml_post_edit_page_link_to_translation',array($this,'_filter_link_to_translation'));
|
27 |
add_action('admin_init', array($this, 'restrict_admin_with_redirect'));
|
28 |
|
29 |
-
//quick edit hook
|
30 |
-
//add_action( 'quick_edit_custom_box', array($this,'hide_quick_edit_link'), 10, 2 );
|
31 |
-
|
32 |
add_action('admin_init', array($this, 'make_new_attributes_translatable'));
|
33 |
|
34 |
// filters to sync variable products
|
@@ -49,13 +46,15 @@ class WCML_Products{
|
|
49 |
add_action('admin_head', array($this, 'hide_multilingual_content_setup_box'));
|
50 |
|
51 |
add_action('woocommerce_duplicate_product',array($this,'woocommerce_duplicate_product'),10,2);
|
|
|
|
|
52 |
|
53 |
}else{
|
54 |
add_filter('woocommerce_json_search_found_products', array($this, 'filter_found_products_by_language'));
|
55 |
}
|
56 |
add_filter('woocommerce_restore_order_stock_quantity',array($this,'woocommerce_restore_order_stock_quantity'),10,2);
|
57 |
|
58 |
-
add_action('woocommerce_email',array($this,'
|
59 |
add_action('wp_ajax_woocommerce_update_shipping_method',array($this,'wcml_refresh_text_domain'),9);
|
60 |
add_action('wp_ajax_nopriv_woocommerce_update_shipping_method',array($this,'wcml_refresh_text_domain'),9);
|
61 |
add_filter('wpml_link_to_translation',array($this,'_filter_link_to_translation'));
|
@@ -92,7 +91,7 @@ class WCML_Products{
|
|
92 |
|
93 |
// Hooks for translating product attribute values
|
94 |
add_filter('woocommerce_variation_option_name', array($this, 'translate_variation_term_name'));
|
95 |
-
add_filter('woocommerce_attribute', array($this, 'translate_attribute_terms'));
|
96 |
add_action('wp_ajax_woocommerce_remove_variation', array($this,'remove_variation_ajax'),9);
|
97 |
//WooCommerce subscription
|
98 |
add_filter('woocommerce_users_subscriptions',array($this, 'woocommerce_users_subscriptions'),10,2);
|
@@ -106,9 +105,6 @@ class WCML_Products{
|
|
106 |
require WPSEO_PATH . 'admin/class-metabox.php';
|
107 |
}
|
108 |
|
109 |
-
//update icl_translation table after change default language
|
110 |
-
add_action('icl_after_set_default_language',array($this,'after_set_default_language'),10,2);
|
111 |
-
|
112 |
// Override cached widget id
|
113 |
add_filter('woocommerce_cached_widget_id', array($this, 'override_cached_widget_id'));
|
114 |
|
@@ -150,14 +146,18 @@ class WCML_Products{
|
|
150 |
* if($page = 0 && $limit=0) return all products;
|
151 |
* return array;
|
152 |
*/
|
153 |
-
function get_product_list($page = 1,$limit = 20){
|
154 |
global $wpdb,$sitepress;
|
155 |
|
156 |
-
$
|
157 |
-
SELECT p.ID,p.post_parent FROM $wpdb->posts AS p
|
158 |
LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = p.id
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
return $this->display_hierarchical($products,$page,$limit);
|
163 |
}
|
@@ -220,7 +220,12 @@ class WCML_Products{
|
|
220 |
if('post-new.php' == $pagenow){
|
221 |
if(isset($_GET['post_type']) && $_GET['post_type'] == 'product' && isset($_GET['trid'])){
|
222 |
$translations = $sitepress->get_element_translations($_GET['trid'], 'post_product_type');
|
223 |
-
$
|
|
|
|
|
|
|
|
|
|
|
224 |
$terms = get_the_terms($translations[$source_lang]->element_id, 'product_type');
|
225 |
echo '<script type="text/javascript">';
|
226 |
echo PHP_EOL . '// <![CDATA[' . PHP_EOL;
|
@@ -246,69 +251,20 @@ class WCML_Products{
|
|
246 |
/*
|
247 |
* get products count
|
248 |
*/
|
249 |
-
function get_products_count(){
|
250 |
global $sitepress,$wpdb;
|
251 |
-
$count = $wpdb->get_var($wpdb->prepare("SELECT count(p.id) FROM $wpdb->posts AS p LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = p.id WHERE p.post_type = 'product' AND p.post_status IN ('publish','future','draft','pending','private') AND icl.element_type= 'post_product' AND icl.language_code = %s",$sitepress->get_current_language()));
|
252 |
-
return (int)$count;
|
253 |
-
}
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
* $action - content action (duplicate or clean content)
|
259 |
-
*/
|
260 |
-
function product_test_content_action($products,$action,$lang = false,$no_redirect = false){
|
261 |
-
global $sitepress,$wpdb,$sitepress_settings;
|
262 |
-
$languages = $sitepress->get_active_languages();
|
263 |
-
$default_language = $sitepress->get_default_language();
|
264 |
|
265 |
-
|
266 |
-
|
267 |
-
if($lang && $lang != $language['code']){
|
268 |
-
continue;
|
269 |
-
}
|
270 |
-
$args = array();
|
271 |
-
switch ($action){
|
272 |
-
case 'duplicate':
|
273 |
-
if($language['code'] != $default_language){
|
274 |
-
$trid = $sitepress->get_element_trid( $product_id, 'post_' . get_post_type($product_id) );
|
275 |
-
//use query because icl_object_id returned null
|
276 |
-
$tr_product_id = $wpdb->get_var($wpdb->prepare("
|
277 |
-
SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND language_code='%s'
|
278 |
-
", $trid, $language['code']));
|
279 |
-
|
280 |
-
if(!($tr_product_id)){
|
281 |
-
break;
|
282 |
}
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
case 'clean':
|
288 |
-
if($language['code'] != $default_language && !is_null(icl_object_id($product_id, 'product', false, $language['code']))){
|
289 |
-
$tr_product_id = icl_object_id($product_id, 'product', false, $language['code']);
|
290 |
-
if(get_post_meta($tr_product_id,'_icl_lang_duplicate_of',true)){
|
291 |
-
wp_delete_post($tr_product_id,true);
|
292 |
-
|
293 |
-
//delete taxonomies
|
294 |
-
$taxonomies = get_object_taxonomies('product');
|
295 |
-
foreach ($taxonomies as $tax) {
|
296 |
-
$terms = $wpdb->get_results($wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_taxonomy AS tt LEFT JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE t.name LIKE '%s' AND tt.taxonomy = %s AND tt.count = 0", '%@'.$language['code'], $tax));
|
297 |
-
foreach($terms as $term){
|
298 |
-
wp_delete_term($term->term_id,$tax);
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
302 |
-
}
|
303 |
-
break;
|
304 |
-
default:
|
305 |
-
break;
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
if(!$no_redirect){
|
310 |
-
wp_redirect(admin_url('admin.php?page=wpml-wcml&tab=products')); exit;
|
311 |
-
}
|
312 |
}
|
313 |
|
314 |
function create_product_translation_package($product_id,$trid,$language,$status){
|
@@ -344,13 +300,15 @@ class WCML_Products{
|
|
344 |
* $title - product name
|
345 |
* $category - product category
|
346 |
*/
|
347 |
-
function get_products_from_filter($title
|
348 |
-
|
349 |
|
350 |
-
|
351 |
$prepare_arg = array();
|
352 |
$prepare_arg[] = '%'.$title.'%';
|
|
|
353 |
$prepare_arg[] = $current_language;
|
|
|
354 |
|
355 |
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts AS p";
|
356 |
|
@@ -361,23 +319,26 @@ class WCML_Products{
|
|
361 |
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translations AS t ON t.element_id = p.id";
|
362 |
|
363 |
if(in_array($translation_status,array('not','need_update','in_progress','complete'))){
|
364 |
-
if($translation_status_lang != 'all'){
|
365 |
-
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translations iclt
|
366 |
-
ON iclt.trid=t.trid AND iclt.language_code='{$translation_status_lang}'\n";
|
367 |
-
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translation_status iclts ON iclts.translation_id=iclt.translation_id\n";
|
368 |
-
}else{
|
369 |
foreach($sitepress->get_active_languages() as $lang){
|
370 |
-
|
371 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
372 |
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translations iclt_{$tbl_alias_suffix}
|
373 |
-
|
|
|
|
|
|
|
|
|
|
|
374 |
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translation_status iclts_{$tbl_alias_suffix}
|
375 |
ON iclts_{$tbl_alias_suffix}.translation_id=iclt_{$tbl_alias_suffix}.translation_id\n";
|
376 |
}
|
377 |
}
|
378 |
-
}
|
379 |
|
380 |
-
$sql .= " WHERE p.post_title LIKE '%s' AND p.post_type = 'product' AND t.element_type = 'post_product' AND t.
|
|
|
|
|
|
|
|
|
381 |
|
382 |
if($product_status != 'all'){
|
383 |
$sql .= " AND p.post_status = %s ";
|
@@ -392,23 +353,12 @@ class WCML_Products{
|
|
392 |
}
|
393 |
|
394 |
if(in_array($translation_status,array('not','need_update','in_progress','complete'))){
|
395 |
-
if($translation_status_lang != 'all'){
|
396 |
-
if($translation_status == 'not'){
|
397 |
-
$sql .= " AND (iclts.status IS NULL OR iclts.status = ".ICL_TM_WAITING_FOR_TRANSLATOR." OR iclts.needs_update = 1)\n";
|
398 |
-
}elseif($translation_status == 'need_update'){
|
399 |
-
$sql .= " AND iclts.needs_update = 1\n";
|
400 |
-
}elseif($translation_status == 'in_progress'){
|
401 |
-
$sql .= " AND iclts.status = ".ICL_TM_IN_PROGRESS." AND iclts.needs_update = 0\n";
|
402 |
-
}elseif($translation_status == 'complete'){
|
403 |
-
$sql .= " AND iclts.status = ".ICL_TM_COMPLETE." AND iclts.needs_update = 0\n";
|
404 |
-
}
|
405 |
-
}else{
|
406 |
switch($translation_status){
|
407 |
case 'not':
|
408 |
$sql .= " AND (";
|
409 |
$wheres = array();
|
410 |
foreach($sitepress->get_active_languages() as $lang){
|
411 |
-
|
412 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
413 |
$wheres[] = "iclts_{$tbl_alias_suffix}.status IS NULL OR iclts_{$tbl_alias_suffix}.status = ".ICL_TM_WAITING_FOR_TRANSLATOR." OR iclts_{$tbl_alias_suffix}.needs_update = 1\n";
|
414 |
}
|
@@ -418,7 +368,7 @@ class WCML_Products{
|
|
418 |
$sql .= " AND (";
|
419 |
$wheres = array();
|
420 |
foreach($sitepress->get_active_languages() as $lang){
|
421 |
-
|
422 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
423 |
$wheres[] = "iclts_{$tbl_alias_suffix}.needs_update = 1\n";
|
424 |
}
|
@@ -428,7 +378,7 @@ class WCML_Products{
|
|
428 |
$sql .= " AND (";
|
429 |
$wheres = array();
|
430 |
foreach($sitepress->get_active_languages() as $lang){
|
431 |
-
|
432 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
433 |
$wheres[] = "iclts_{$tbl_alias_suffix}.status = ".ICL_TM_IN_PROGRESS."\n";
|
434 |
}
|
@@ -436,18 +386,16 @@ class WCML_Products{
|
|
436 |
break;
|
437 |
case 'complete':
|
438 |
foreach($sitepress->get_active_languages() as $lang){
|
439 |
-
|
440 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
441 |
-
|
442 |
}
|
443 |
break;
|
444 |
}
|
445 |
}
|
446 |
-
}
|
447 |
|
448 |
$sql .= " ORDER BY p.id DESC LIMIT ".($page-1)*$limit.",".$limit;
|
449 |
|
450 |
-
|
451 |
$data = array();
|
452 |
|
453 |
$data['products'] = $wpdb->get_results($wpdb->prepare($sql,$prepare_arg));
|
@@ -479,7 +427,6 @@ class WCML_Products{
|
|
479 |
}
|
480 |
|
481 |
$languages = $sitepress->get_active_languages();
|
482 |
-
$default_language = $sitepress->get_default_language();
|
483 |
|
484 |
$product_trid = $sitepress->get_element_trid($original_product_id, 'post_' . $orig_product->post_type);
|
485 |
$tr_product_id = icl_object_id($original_product_id, 'product', false, $language);
|
@@ -561,9 +508,17 @@ class WCML_Products{
|
|
561 |
|
562 |
$this->sync_default_product_attr($original_product_id, $tr_product_id, $language);
|
563 |
|
|
|
564 |
//sync media
|
565 |
-
|
566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
|
568 |
//sync taxonomies
|
569 |
$this->sync_product_taxonomies($original_product_id, $tr_product_id, $language);
|
@@ -597,7 +552,7 @@ class WCML_Products{
|
|
597 |
ob_start();
|
598 |
$return = array();
|
599 |
|
600 |
-
$this->get_translation_statuses($translations,$languages
|
601 |
$return['status'] = ob_get_clean();
|
602 |
|
603 |
|
@@ -848,7 +803,7 @@ class WCML_Products{
|
|
848 |
$translations = $sitepress->get_element_translations($trid,'post_product',true);
|
849 |
foreach($translations as $translation){
|
850 |
$duplicated_ids = '';
|
851 |
-
if (
|
852 |
foreach($gallery_ids as $image_id){
|
853 |
$duplicated_id = icl_object_id($image_id,'attachment',false,$translation->language_code);
|
854 |
if(!is_null($duplicated_id)){
|
@@ -861,23 +816,28 @@ class WCML_Products{
|
|
861 |
}
|
862 |
}
|
863 |
|
864 |
-
function get_translation_flags($active_languages,$
|
|
|
|
|
865 |
foreach($active_languages as $language){
|
866 |
-
if (
|
867 |
echo '<img src="'. ICL_PLUGIN_URL .'/res/flags/'. $language['code'] .'.png" width="18" height="12" class="flag_img" />';
|
868 |
}
|
869 |
}
|
870 |
}
|
871 |
|
872 |
|
873 |
-
function get_translation_statuses($product_translations,$active_languages,$
|
874 |
-
global $wpdb;
|
875 |
|
876 |
foreach ($active_languages as $language) {
|
877 |
-
if(
|
|
|
|
|
|
|
878 |
$alt = __('No Permissions','wpml-wcml');
|
879 |
echo '<i title="'. $alt .'" class="stat_img"></i>';
|
880 |
-
}elseif ($
|
881 |
if (isset($product_translations[$language['code']])) {
|
882 |
$tr_status = $wpdb->get_row($wpdb->prepare("SELECT status,needs_update FROM " . $wpdb->prefix . "icl_translation_status WHERE translation_id = %d", $product_translations[$language['code']]->translation_id));
|
883 |
if(!$tr_status){
|
@@ -1245,22 +1205,19 @@ class WCML_Products{
|
|
1245 |
|
1246 |
$default_lang = $sitepress->get_default_language();
|
1247 |
$current_lang = $sitepress->get_current_language();
|
1248 |
-
if($pagenow == 'post-new.php' && isset($_GET['post_type']) && !isset($_GET['trid']) && $_GET['post_type']=='product' && $default_lang!=$current_lang){
|
1249 |
-
add_action('admin_notices', array($this, 'warn_creating_product_in_non_default_lang'));
|
1250 |
-
}
|
1251 |
-
|
1252 |
|
1253 |
if(($pagenow == 'post.php' && isset($_GET['post'])) || ($pagenow == 'admin.php' && isset($_GET['action']) && $_GET['action'] == 'duplicate_product' && isset($_GET['post']))){
|
1254 |
$prod_lang = $sitepress->get_language_for_element($_GET['post'],'post_product');
|
1255 |
}
|
1256 |
|
1257 |
-
if(!$woocommerce_wpml->settings['trnsl_interface'] && $pagenow == 'post.php' && isset($_GET['post'])
|
1258 |
add_action('admin_notices', array($this, 'inf_editing_product_in_non_default_lang'));
|
1259 |
}
|
1260 |
|
1261 |
-
if($woocommerce_wpml->settings['trnsl_interface'] && $pagenow == 'post.php' && !is_ajax() && isset($_GET['post']) && $
|
1262 |
if((!isset($_GET['action'])) || (isset($_GET['action']) && !in_array($_GET['action'],array('trash','delete')))){
|
1263 |
-
$
|
|
|
1264 |
wp_redirect(admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$prid)); exit;
|
1265 |
}
|
1266 |
}
|
@@ -1270,37 +1227,31 @@ class WCML_Products{
|
|
1270 |
}
|
1271 |
}
|
1272 |
|
1273 |
-
function warn_creating_product_in_non_default_lang(){
|
1274 |
-
global $sitepress;
|
1275 |
-
$default_lang = $sitepress->get_default_language();
|
1276 |
-
$def_lang_info = $sitepress->get_language_details($default_lang);
|
1277 |
-
$message = '<div class="message error"><p>';
|
1278 |
-
$message .= __('You should not add products in other languages, as this may cause synchronization problems between product translations.');
|
1279 |
-
$message .= '</p><p>';
|
1280 |
-
$message .= sprintf(__('Please add the product in <b>%s</b> and then use the WooCommerce Multilingual admin screen to translate it.', 'wpml-wcml'), $def_lang_info['display_name']);
|
1281 |
-
$message .= '</p></div>';
|
1282 |
-
|
1283 |
-
echo $message;
|
1284 |
-
}
|
1285 |
-
|
1286 |
function inf_editing_product_in_non_default_lang(){
|
1287 |
-
$message = '<div
|
1288 |
-
$message .= sprintf(__('The recommended way to translate WooCommerce products is using the <b><a href="%s">WooCommerce Multilingual
|
1289 |
$message .= '</p></div>';
|
1290 |
|
1291 |
echo $message;
|
1292 |
}
|
1293 |
|
1294 |
//product quickedit
|
1295 |
-
function
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
|
|
|
|
|
|
|
|
|
|
1301 |
}
|
|
|
1302 |
}
|
1303 |
|
|
|
1304 |
/**
|
1305 |
* Makes all new attributes translatable.
|
1306 |
*/
|
@@ -1417,13 +1368,12 @@ class WCML_Products{
|
|
1417 |
foreach($translations as $translation){
|
1418 |
if ($ld->language_code != $translation->language_code) {
|
1419 |
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
$
|
1426 |
-
}
|
1427 |
|
1428 |
if ( $_product && $_product->exists() && $_product->managing_stock() ) {
|
1429 |
$stock = $_product->reduce_stock($item['qty']);
|
@@ -1465,9 +1415,9 @@ class WCML_Products{
|
|
1465 |
*/
|
1466 |
function sync_post_action($post_id, $post){
|
1467 |
global $wpdb, $pagenow, $sitepress, $sitepress_settings,$woocommerce_wpml;
|
1468 |
-
$
|
1469 |
$current_language = $sitepress->get_current_language();
|
1470 |
-
$duplicated_post_id = icl_object_id($post_id, 'product', false, $
|
1471 |
$wpml_media_options = maybe_unserialize(get_option('_wpml_media'));
|
1472 |
|
1473 |
if($wpml_media_options['new_content_settings']['duplicate_media']){
|
@@ -1481,7 +1431,7 @@ class WCML_Products{
|
|
1481 |
//set trid for variations
|
1482 |
if ($post_type == 'product_variation') {
|
1483 |
$var_lang = $sitepress->get_language_for_element(wp_get_post_parent_id($post_id),'post_product');
|
1484 |
-
if($
|
1485 |
$sitepress->set_element_language_details($post_id, 'post_product_variation', false, $var_lang);
|
1486 |
}
|
1487 |
}
|
@@ -1508,7 +1458,7 @@ class WCML_Products{
|
|
1508 |
remove_action('save_post', array($this, 'sync_post_action'), 11, 2);
|
1509 |
|
1510 |
//trnsl_interface option
|
1511 |
-
if (!$woocommerce_wpml->settings['trnsl_interface'] && $
|
1512 |
|
1513 |
$this->sync_status_and_parent( $duplicated_post_id, $post_id, $current_language );
|
1514 |
$this->sync_product_data( $duplicated_post_id, $post_id, $current_language );
|
@@ -1552,7 +1502,7 @@ class WCML_Products{
|
|
1552 |
$posts = array();
|
1553 |
$translations = $sitepress->get_element_translations($language_details->trid, 'post_product');
|
1554 |
foreach ($translations as $translation) {
|
1555 |
-
if ($translation->
|
1556 |
$duplicated_post_id = $translation->element_id;
|
1557 |
} else {
|
1558 |
$posts[$translation->element_id] = $translation;
|
@@ -1560,7 +1510,6 @@ class WCML_Products{
|
|
1560 |
}
|
1561 |
|
1562 |
|
1563 |
-
// TODO: move outside the loop all db queries on duplicated_post_id
|
1564 |
foreach ($posts as $post_id => $translation) {
|
1565 |
$lang = $translation->language_code;
|
1566 |
|
@@ -1930,89 +1879,6 @@ class WCML_Products{
|
|
1930 |
$tr_post = get_post($tr_post_id);
|
1931 |
return $tr_post->post_excerpt;
|
1932 |
break;
|
1933 |
-
case 'product_cat':
|
1934 |
-
global $wpdb,$sitepress;
|
1935 |
-
//get original categories
|
1936 |
-
$prod_terms = get_the_terms($product_id, 'product_cat');
|
1937 |
-
if($sitepress->get_default_language() != $lang_code){
|
1938 |
-
//get current lang categories
|
1939 |
-
$trn_terms = $wpdb->get_results($wpdb->prepare("SELECT tt.term_taxonomy_id,tt.term_id,t.name FROM $wpdb->term_taxonomy AS tt LEFT JOIN $wpdb->terms AS t ON tt.term_id = t.term_id LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'product_cat' AND icl.element_type= 'tax_product_cat' AND icl.language_code = %s",$lang_code));
|
1940 |
-
}
|
1941 |
-
//get translated element categories
|
1942 |
-
$tr_product_terms = get_the_terms($tr_post_id, 'product_cat');
|
1943 |
-
|
1944 |
-
$taxs = array();
|
1945 |
-
$taxs_all = array();
|
1946 |
-
if($tr_product_terms){
|
1947 |
-
foreach($tr_product_terms as $product_term){
|
1948 |
-
$term = get_term_by('id',$product_term->term_id,'product_cat');
|
1949 |
-
$taxs['term_taxonomy_id'] = $term->term_taxonomy_id;
|
1950 |
-
$taxs['name'] = $term->name;
|
1951 |
-
$taxs['checked'] = true;
|
1952 |
-
$taxs_all[$term->term_taxonomy_id] = $taxs;
|
1953 |
-
}
|
1954 |
-
}
|
1955 |
-
|
1956 |
-
if($prod_terms){
|
1957 |
-
foreach ($prod_terms as $prod_term) {
|
1958 |
-
$tr_cat_id = icl_object_id($prod_term->term_id, 'product_cat', false, $lang_code);
|
1959 |
-
|
1960 |
-
if($tr_cat_id && !array_key_exists($tr_cat_id,$taxs_all)){
|
1961 |
-
$term = get_term_by('id',$tr_cat_id,'product_cat');
|
1962 |
-
$taxs['term_taxonomy_id'] = $term->term_taxonomy_id;
|
1963 |
-
$taxs['name'] = $term->name;
|
1964 |
-
$taxs['checked'] = true;
|
1965 |
-
$taxs_all[$term->term_taxonomy_id] = $taxs;
|
1966 |
-
}
|
1967 |
-
}
|
1968 |
-
}
|
1969 |
-
|
1970 |
-
if(isset($trn_terms) && $trn_terms){
|
1971 |
-
foreach($trn_terms as $tr_term){
|
1972 |
-
if(!array_key_exists($tr_term->term_taxonomy_id,$taxs_all)){
|
1973 |
-
$term = get_term_by('id',$tr_term->term_id,'product_cat');
|
1974 |
-
$taxs['term_taxonomy_id'] = $term->term_taxonomy_id;
|
1975 |
-
$taxs['name'] = $term->name;
|
1976 |
-
$taxs['checked'] = false;
|
1977 |
-
$taxs_all[$term->term_taxonomy_id] = $taxs;
|
1978 |
-
}
|
1979 |
-
}
|
1980 |
-
}
|
1981 |
-
|
1982 |
-
return $taxs_all;
|
1983 |
-
break;
|
1984 |
-
case 'product_tag':
|
1985 |
-
$prod_terms = get_the_terms($product_id, 'product_tag');
|
1986 |
-
$tr_product_terms = get_the_terms($tr_post_id, 'product_tag');
|
1987 |
-
|
1988 |
-
$taxs = array();
|
1989 |
-
$taxs_all = array();
|
1990 |
-
|
1991 |
-
if($tr_product_terms){
|
1992 |
-
foreach($tr_product_terms as $product_term){
|
1993 |
-
$term = get_term_by('id',$product_term->term_id,'product_tag');
|
1994 |
-
$taxs['term_taxonomy_id'] = $term->term_taxonomy_id;
|
1995 |
-
$taxs['name'] = $term->name;
|
1996 |
-
$taxs_all[$term->term_taxonomy_id] = $taxs;
|
1997 |
-
}
|
1998 |
-
}
|
1999 |
-
|
2000 |
-
|
2001 |
-
if($prod_terms){
|
2002 |
-
foreach ($prod_terms as $prod_term) {
|
2003 |
-
$tr_tag_id = icl_object_id($prod_term->term_id, 'product_tag', false, $lang_code);
|
2004 |
-
|
2005 |
-
if($tr_tag_id && !array_key_exists($tr_tag_id,$taxs_all)){
|
2006 |
-
$term = get_term_by('id',$tr_tag_id,'product_tag');
|
2007 |
-
$taxs['term_taxonomy_id'] = $term->term_taxonomy_id;
|
2008 |
-
$taxs['name'] = $term->name;
|
2009 |
-
$taxs_all[$term->term_taxonomy_id] = $taxs;
|
2010 |
-
}
|
2011 |
-
}
|
2012 |
-
}
|
2013 |
-
|
2014 |
-
return $taxs_all;
|
2015 |
-
break;
|
2016 |
default:
|
2017 |
global $wpdb,$sitepress;
|
2018 |
|
@@ -2066,7 +1932,8 @@ class WCML_Products{
|
|
2066 |
}
|
2067 |
|
2068 |
if(!$term_name){
|
2069 |
-
$
|
|
|
2070 |
|
2071 |
if(get_post_meta($orig_variation_id,$var_key,true) == ''){
|
2072 |
if(substr($tr_product_attr[$attribute]['name'], 0, 3) == 'pa_'){
|
@@ -2105,16 +1972,16 @@ class WCML_Products{
|
|
2105 |
{
|
2106 |
global $sitepress, $woocommerce_wpml,$wpdb,$woocommerce;
|
2107 |
|
2108 |
-
$
|
2109 |
$template_data = array();
|
2110 |
$template_data['all_variations_ids'] = array();
|
2111 |
|
2112 |
$trn_product_id = null;
|
2113 |
-
if ($
|
2114 |
$trn_product_id = icl_object_id($product_id, 'product', false, $lang);
|
2115 |
}
|
2116 |
|
2117 |
-
if ($
|
2118 |
$template_data['original'] = true;
|
2119 |
} else {
|
2120 |
$template_data['original'] = false;
|
@@ -2136,7 +2003,7 @@ class WCML_Products{
|
|
2136 |
if(is_null($trn_product_id)){
|
2137 |
$template_data['all_file_paths']['count'] = count($files);
|
2138 |
}else{
|
2139 |
-
$template_data['all_file_paths']['count'] = count(maybe_unserialize(get_post_meta(icl_object_id($variation->ID, 'product_variation', false, $
|
2140 |
}
|
2141 |
foreach($files as $file){
|
2142 |
$variables = array();
|
@@ -2157,7 +2024,7 @@ class WCML_Products{
|
|
2157 |
|
2158 |
if (!$is_product_has_variations){
|
2159 |
$template_data['empty_variations'] = true;
|
2160 |
-
} elseif($
|
2161 |
$template_data['empty_translation'] = true;
|
2162 |
}elseif (!$is_downloable){
|
2163 |
$template_data['not_downloaded'] = true;
|
@@ -2168,13 +2035,13 @@ class WCML_Products{
|
|
2168 |
|
2169 |
function product_images_box($product_id,$lang, $is_duplicate_product = false ) {
|
2170 |
global $sitepress,$wpdb;
|
2171 |
-
$
|
2172 |
-
if($
|
2173 |
$product_id = icl_object_id($product_id, 'product', false, $lang);
|
2174 |
}
|
2175 |
$template_data = array();
|
2176 |
|
2177 |
-
if($
|
2178 |
$template_data['original'] = true;
|
2179 |
}else{
|
2180 |
$template_data['original'] = false;
|
@@ -2184,7 +2051,7 @@ class WCML_Products{
|
|
2184 |
if (empty($product_images)) {
|
2185 |
$template_data['empty_images'] = true;
|
2186 |
} else {
|
2187 |
-
if ($
|
2188 |
$template_data['images_thumbnails'] = $product_images;
|
2189 |
}
|
2190 |
foreach ($product_images as $prod_image) {
|
@@ -2207,7 +2074,7 @@ class WCML_Products{
|
|
2207 |
|
2208 |
function custom_box($product_id,$product_content,$trn_contents,$lang,$lang_name,$is_duplicate_product){
|
2209 |
global $sitepress;
|
2210 |
-
$
|
2211 |
$tr_product_id = icl_object_id($product_id, 'product', false, $lang);
|
2212 |
$template_data = array();
|
2213 |
|
@@ -2219,7 +2086,7 @@ class WCML_Products{
|
|
2219 |
$template_data['lang_name'] = $lang_name;
|
2220 |
$template_data['is_duplicate_product'] = $is_duplicate_product;
|
2221 |
|
2222 |
-
if($
|
2223 |
$template_data['original'] = true;
|
2224 |
}else{
|
2225 |
$template_data['original'] = false;
|
@@ -2382,9 +2249,6 @@ class WCML_Products{
|
|
2382 |
|
2383 |
function translate_attribute_terms($terms){
|
2384 |
global $sitepress;
|
2385 |
-
// remove autop
|
2386 |
-
$terms = str_replace('<p>', '', $terms);
|
2387 |
-
$terms = str_replace('</p>', '', $terms);
|
2388 |
|
2389 |
// iterate terms translating
|
2390 |
$terms = explode(",", $terms);
|
@@ -2395,7 +2259,7 @@ class WCML_Products{
|
|
2395 |
$out[] = $term;
|
2396 |
}
|
2397 |
|
2398 |
-
return
|
2399 |
}
|
2400 |
|
2401 |
function sync_product_gallery_duplicate_attachment($att_id, $dup_att_id){
|
@@ -2425,10 +2289,17 @@ class WCML_Products{
|
|
2425 |
|
2426 |
function icl_pro_translation_completed($tr_product_id) {
|
2427 |
global $sitepress;
|
2428 |
-
$default_language = $sitepress->get_default_language();
|
2429 |
|
2430 |
-
$
|
2431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2432 |
return;
|
2433 |
}
|
2434 |
|
@@ -2466,7 +2337,7 @@ class WCML_Products{
|
|
2466 |
$translations = $sitepress->get_element_translations($trid, 'post_product_variation');
|
2467 |
if($translations){
|
2468 |
foreach($translations as $translation){
|
2469 |
-
if(
|
2470 |
wp_delete_post($translation->element_id,true);
|
2471 |
}
|
2472 |
}
|
@@ -2477,7 +2348,7 @@ class WCML_Products{
|
|
2477 |
|
2478 |
function icl_make_duplicate($master_post_id, $lang, $postarr, $id){
|
2479 |
if(get_post_type($master_post_id)=='product'){
|
2480 |
-
$this->
|
2481 |
}
|
2482 |
}
|
2483 |
|
@@ -2486,9 +2357,21 @@ class WCML_Products{
|
|
2486 |
|
2487 |
$new_found_products = array();
|
2488 |
foreach($found_products as $post => $formatted_product_name) {
|
2489 |
-
$
|
2490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2491 |
$new_found_products[$post] = $formatted_product_name;
|
|
|
2492 |
}
|
2493 |
}
|
2494 |
|
@@ -2502,6 +2385,12 @@ class WCML_Products{
|
|
2502 |
$this->wcml_refresh_text_domain();
|
2503 |
}
|
2504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2505 |
function wcml_refresh_text_domain(){
|
2506 |
global $woocommerce;
|
2507 |
$domain = 'woocommerce';
|
@@ -2546,6 +2435,11 @@ class WCML_Products{
|
|
2546 |
foreach($cart->cart_contents as $key=>$cart_item){
|
2547 |
$tr_product_id = icl_object_id($cart_item['product_id'],'product',false,$current_language);
|
2548 |
|
|
|
|
|
|
|
|
|
|
|
2549 |
if(isset($cart->cart_contents[$key]['variation_id']) && $cart->cart_contents[$key]['variation_id']){
|
2550 |
$tr_variation_id = icl_object_id($cart_item['variation_id'],'product_variation',false,$current_language);
|
2551 |
if(!is_null($tr_variation_id)){
|
@@ -2596,30 +2490,9 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2596 |
$term = get_term_by('slug',$attribute,$taxonomy);
|
2597 |
$trnsl_term_id = icl_object_id($term->term_id,$taxonomy,true,$current_language);
|
2598 |
|
2599 |
-
|
2600 |
}else{
|
2601 |
-
$
|
2602 |
-
$unserialized_orig_product_attributes = maybe_unserialize($orig_product_attributes);
|
2603 |
-
foreach($unserialized_orig_product_attributes as $orig_attr_key => $orig_product_attribute){
|
2604 |
-
$orig_attr_key = urldecode($orig_attr_key);
|
2605 |
-
if($taxonomy == $orig_attr_key){
|
2606 |
-
$values = explode('|',$orig_product_attribute['value']);
|
2607 |
-
foreach($values as $key_id => $value){
|
2608 |
-
if(trim($value," ") == $attribute){
|
2609 |
-
$attr_key_id = $key_id;
|
2610 |
-
}
|
2611 |
-
}
|
2612 |
-
}
|
2613 |
-
}
|
2614 |
-
|
2615 |
-
$trnsl_product_attributes = get_post_meta($tr_product_id, '_product_attributes', true);
|
2616 |
-
$unserialized_trnsl_product_attributes = maybe_unserialize($trnsl_product_attributes);
|
2617 |
-
$taxonomy = sanitize_title($taxonomy);
|
2618 |
-
$trnsl_attr_values = explode('|',$unserialized_trnsl_product_attributes[$taxonomy]['value']);
|
2619 |
-
|
2620 |
-
if(isset($trnsl_attr_values[$attr_key_id])){
|
2621 |
-
return trim($trnsl_attr_values[$attr_key_id]);
|
2622 |
-
}
|
2623 |
}
|
2624 |
}
|
2625 |
|
@@ -2634,6 +2507,38 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2634 |
return apply_filters( 'wcml_filter_cart_item_data', $cart_contents );
|
2635 |
}
|
2636 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2637 |
function wcml_coupon_loaded($coupons_data){
|
2638 |
global $sitepress;
|
2639 |
|
@@ -2643,15 +2548,17 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2643 |
$exclude_product_categories_ids = array();
|
2644 |
|
2645 |
foreach($coupons_data->product_ids as $prod_id){
|
2646 |
-
$
|
2647 |
-
$
|
|
|
2648 |
foreach($translations as $translation){
|
2649 |
$product_ids[] = $translation->element_id;
|
2650 |
}
|
2651 |
}
|
2652 |
foreach($coupons_data->exclude_product_ids as $prod_id){
|
2653 |
-
$
|
2654 |
-
$
|
|
|
2655 |
foreach($translations as $translation){
|
2656 |
$exclude_product_ids[] = $translation->element_id;
|
2657 |
}
|
@@ -2685,7 +2592,7 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2685 |
}
|
2686 |
|
2687 |
|
2688 |
-
function
|
2689 |
global $sitepress, $iclTranslationManagement, $sitepress_settings, $wpdb, $woocommerce_wpml;
|
2690 |
|
2691 |
$all_products_taxonomies = get_taxonomies(array('object_type'=>array('product')),'objects');
|
@@ -2694,6 +2601,7 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2694 |
$sitepress_settings["translation-management"]["taxonomies_readonly_config"][$tax_key] = 1;
|
2695 |
$iclTranslationManagement->settings['taxonomies_readonly_config'][$tax_key] = 1;
|
2696 |
$sitepress_settings["taxonomies_sync_option"][$tax_key] = 1;
|
|
|
2697 |
}
|
2698 |
$sitepress->save_settings($sitepress_settings);
|
2699 |
|
@@ -2751,19 +2659,37 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2751 |
function woocommerce_duplicate_product($new_id, $post){
|
2752 |
global $sitepress,$wpdb;
|
2753 |
|
2754 |
-
$sitepress->set_element_language_details($new_id, 'post_' . $post->post_type, false, $sitepress->get_current_language());
|
2755 |
-
$new_trid = $sitepress->get_element_trid( $new_id, 'post_' . $post->post_type );
|
2756 |
-
|
2757 |
|
|
|
2758 |
$trid = $sitepress->get_element_trid( $post->ID, 'post_' . $post->post_type );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2759 |
$translations = $sitepress->get_element_translations( $trid, 'post_' . $post->post_type );
|
2760 |
|
2761 |
|
2762 |
if($translations){
|
2763 |
-
$wc_admin = new WC_Admin_Duplicate_Product();
|
2764 |
|
2765 |
foreach($translations as $translation){
|
2766 |
-
if($translation->element_id != $post->ID){
|
2767 |
$post_to_duplicate = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE ID=$translation->element_id" );
|
2768 |
|
2769 |
if ( ! empty( $post_to_duplicate ) ) {
|
@@ -2773,9 +2699,8 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2773 |
}
|
2774 |
}
|
2775 |
}
|
2776 |
-
|
2777 |
-
}
|
2778 |
|
|
|
2779 |
|
2780 |
}
|
2781 |
|
@@ -2811,52 +2736,27 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2811 |
|
2812 |
function woocommerce_product_quick_edit_save($product){
|
2813 |
global $sitepress;
|
2814 |
-
$
|
2815 |
-
$lang = $sitepress->get_language_for_element($product->id,'post_product');
|
2816 |
|
2817 |
-
if($lang == $default_language){
|
2818 |
$trid = $sitepress->get_element_trid($product->id, 'post_product');
|
2819 |
if ($trid) {
|
2820 |
$translations = $sitepress->get_element_translations($trid, 'post_product');
|
2821 |
if($translations){
|
2822 |
foreach($translations as $translation){
|
2823 |
-
|
|
|
2824 |
$this->sync_product_data($product->id,$translation->element_id,$translation->language_code);
|
2825 |
}
|
|
|
|
|
2826 |
}
|
|
|
2827 |
}
|
2828 |
}
|
2829 |
-
}else{
|
2830 |
-
$original_product_id = icl_object_id($product->id, 'product', false, $default_language);
|
2831 |
-
if(is_null($original_product_id)){
|
2832 |
-
return;
|
2833 |
}
|
2834 |
|
2835 |
-
$this->sync_product_data($original_product_id,$product->id,$lang);
|
2836 |
-
}
|
2837 |
-
}
|
2838 |
-
|
2839 |
-
|
2840 |
-
function after_set_default_language( $code, $previous_code ){
|
2841 |
-
global $wpdb;
|
2842 |
-
|
2843 |
-
$wpdb->update(
|
2844 |
-
$wpdb->prefix.'icl_translations',
|
2845 |
-
array(
|
2846 |
-
'source_language_code' => $code
|
2847 |
-
),
|
2848 |
-
array(
|
2849 |
-
'language_code' => $previous_code,
|
2850 |
-
'element_type' => 'post_product'
|
2851 |
-
)
|
2852 |
-
);
|
2853 |
-
|
2854 |
-
//Use query to set source_language_code to NULL
|
2855 |
-
$wpdb->query("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = NULL WHERE language_code = '".$code."' AND element_type = 'post_product'" );
|
2856 |
-
|
2857 |
}
|
2858 |
|
2859 |
-
|
2860 |
function override_cached_widget_id($widget_id){
|
2861 |
|
2862 |
if (defined('ICL_LANGUAGE_CODE')){
|
@@ -2868,28 +2768,31 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2868 |
|
2869 |
//update menu_order fro translations after ordering original products
|
2870 |
function update_translations_product_ordering(){
|
2871 |
-
global $wpdb, $sitepress;
|
|
|
|
|
2872 |
|
2873 |
$current_language = $sitepress->get_current_language();
|
2874 |
|
2875 |
-
|
2876 |
-
|
2877 |
|
2878 |
-
|
2879 |
|
2880 |
-
|
2881 |
-
|
2882 |
|
2883 |
-
|
2884 |
|
2885 |
-
|
2886 |
-
|
2887 |
}
|
2888 |
}
|
2889 |
|
2890 |
}
|
2891 |
|
2892 |
}
|
|
|
2893 |
|
2894 |
}
|
2895 |
|
@@ -2918,7 +2821,7 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2918 |
global $woocommerce_wpml,$sitepress,$wpdb;
|
2919 |
|
2920 |
$product = get_post( $_POST['product_id'] );
|
2921 |
-
$default_language = $sitepress->
|
2922 |
$active_languages = $sitepress->get_active_languages();
|
2923 |
|
2924 |
if(ob_get_length()){
|
@@ -2955,4 +2858,26 @@ function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_pro
|
|
2955 |
return false;
|
2956 |
}
|
2957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2958 |
}
|
10 |
|
11 |
add_action('init', array($this, 'init'));
|
12 |
add_action('init', array($this, 'wc_cart_widget_actions'));
|
13 |
+
add_action('init', array($this, 'set_tax_and_price_config'), 9999); // After TM parses wpml-config.xml
|
14 |
|
15 |
//add action for coupons data from WC_Coupon construct
|
16 |
add_action('woocommerce_coupon_loaded',array($this,'wcml_coupon_loaded'));
|
26 |
add_filter('wpml_post_edit_page_link_to_translation',array($this,'_filter_link_to_translation'));
|
27 |
add_action('admin_init', array($this, 'restrict_admin_with_redirect'));
|
28 |
|
|
|
|
|
|
|
29 |
add_action('admin_init', array($this, 'make_new_attributes_translatable'));
|
30 |
|
31 |
// filters to sync variable products
|
46 |
add_action('admin_head', array($this, 'hide_multilingual_content_setup_box'));
|
47 |
|
48 |
add_action('woocommerce_duplicate_product',array($this,'woocommerce_duplicate_product'),10,2);
|
49 |
+
|
50 |
+
add_filter('post_row_actions', array($this,'filter_product_actions'), 10, 2);
|
51 |
|
52 |
}else{
|
53 |
add_filter('woocommerce_json_search_found_products', array($this, 'filter_found_products_by_language'));
|
54 |
}
|
55 |
add_filter('woocommerce_restore_order_stock_quantity',array($this,'woocommerce_restore_order_stock_quantity'),10,2);
|
56 |
|
57 |
+
add_action('woocommerce_email',array($this,'woocommerce_email_refresh_text_domain'));
|
58 |
add_action('wp_ajax_woocommerce_update_shipping_method',array($this,'wcml_refresh_text_domain'),9);
|
59 |
add_action('wp_ajax_nopriv_woocommerce_update_shipping_method',array($this,'wcml_refresh_text_domain'),9);
|
60 |
add_filter('wpml_link_to_translation',array($this,'_filter_link_to_translation'));
|
91 |
|
92 |
// Hooks for translating product attribute values
|
93 |
add_filter('woocommerce_variation_option_name', array($this, 'translate_variation_term_name'));
|
94 |
+
add_filter('woocommerce_attribute', array($this, 'translate_attribute_terms'),1);
|
95 |
add_action('wp_ajax_woocommerce_remove_variation', array($this,'remove_variation_ajax'),9);
|
96 |
//WooCommerce subscription
|
97 |
add_filter('woocommerce_users_subscriptions',array($this, 'woocommerce_users_subscriptions'),10,2);
|
105 |
require WPSEO_PATH . 'admin/class-metabox.php';
|
106 |
}
|
107 |
|
|
|
|
|
|
|
108 |
// Override cached widget id
|
109 |
add_filter('woocommerce_cached_widget_id', array($this, 'override_cached_widget_id'));
|
110 |
|
146 |
* if($page = 0 && $limit=0) return all products;
|
147 |
* return array;
|
148 |
*/
|
149 |
+
function get_product_list($page = 1,$limit = 20, $slang){
|
150 |
global $wpdb,$sitepress;
|
151 |
|
152 |
+
$sql = "SELECT p.ID,p.post_parent FROM $wpdb->posts AS p
|
|
|
153 |
LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = p.id
|
154 |
+
WHERE p.post_type = 'product' AND p.post_status IN ('publish','future','draft','pending','private') AND icl.element_type= 'post_product' AND icl.source_language_code IS NULL";
|
155 |
+
|
156 |
+
if($slang){
|
157 |
+
$sql .= " AND icl.language_code = '".$slang."'";
|
158 |
+
}
|
159 |
+
|
160 |
+
$products = $wpdb->get_results($sql);
|
161 |
|
162 |
return $this->display_hierarchical($products,$page,$limit);
|
163 |
}
|
220 |
if('post-new.php' == $pagenow){
|
221 |
if(isset($_GET['post_type']) && $_GET['post_type'] == 'product' && isset($_GET['trid'])){
|
222 |
$translations = $sitepress->get_element_translations($_GET['trid'], 'post_product_type');
|
223 |
+
foreach($translations as $translation){
|
224 |
+
if($translation->original) {
|
225 |
+
$source_lang = $translation->language_code;
|
226 |
+
break;
|
227 |
+
}
|
228 |
+
}
|
229 |
$terms = get_the_terms($translations[$source_lang]->element_id, 'product_type');
|
230 |
echo '<script type="text/javascript">';
|
231 |
echo PHP_EOL . '// <![CDATA[' . PHP_EOL;
|
251 |
/*
|
252 |
* get products count
|
253 |
*/
|
254 |
+
function get_products_count( $slang ){
|
255 |
global $sitepress,$wpdb;
|
|
|
|
|
|
|
256 |
|
257 |
+
$sql = "SELECT count(p.id) FROM $wpdb->posts AS p
|
258 |
+
LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = p.id
|
259 |
+
WHERE p.post_type = 'product' AND p.post_status IN ('publish','future','draft','pending','private') AND icl.element_type= 'post_product' AND icl.source_language_code IS NULL";
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
+
if( $slang ){
|
262 |
+
$sql .= " AND icl.language_code = '".$slang."'";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
}
|
264 |
|
265 |
+
$count = $wpdb->get_var($sql);
|
266 |
+
|
267 |
+
return (int)$count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
function create_product_translation_package($product_id,$trid,$language,$status){
|
300 |
* $title - product name
|
301 |
* $category - product category
|
302 |
*/
|
303 |
+
function get_products_from_filter( $title, $category, $translation_status, $product_status, $slang, $page, $limit ){
|
304 |
+
global $wpdb, $sitepress;
|
305 |
|
306 |
+
$current_language = $slang;
|
307 |
$prepare_arg = array();
|
308 |
$prepare_arg[] = '%'.$title.'%';
|
309 |
+
if( $slang ) {
|
310 |
$prepare_arg[] = $current_language;
|
311 |
+
}
|
312 |
|
313 |
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts AS p";
|
314 |
|
319 |
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translations AS t ON t.element_id = p.id";
|
320 |
|
321 |
if(in_array($translation_status,array('not','need_update','in_progress','complete'))){
|
|
|
|
|
|
|
|
|
|
|
322 |
foreach($sitepress->get_active_languages() as $lang){
|
323 |
+
if( $lang['code'] == $slang ) continue;
|
324 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
325 |
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translations iclt_{$tbl_alias_suffix}
|
326 |
+
ON iclt_{$tbl_alias_suffix}.trid=t.trid ";
|
327 |
+
if( $slang ){
|
328 |
+
$sql .= " AND iclt_{$tbl_alias_suffix}.language_code='{$lang['code']}'\n";
|
329 |
+
}else{
|
330 |
+
$sql .= " AND iclt_{$tbl_alias_suffix}.source_language_code IS NULL ";
|
331 |
+
}
|
332 |
$sql .= " LEFT JOIN {$wpdb->prefix}icl_translation_status iclts_{$tbl_alias_suffix}
|
333 |
ON iclts_{$tbl_alias_suffix}.translation_id=iclt_{$tbl_alias_suffix}.translation_id\n";
|
334 |
}
|
335 |
}
|
|
|
336 |
|
337 |
+
$sql .= " WHERE p.post_title LIKE '%s' AND p.post_type = 'product' AND t.element_type = 'post_product' AND t.source_language_code IS NULL";
|
338 |
+
|
339 |
+
if( $slang ){
|
340 |
+
$sql .= " AND t.language_code = %s";
|
341 |
+
}
|
342 |
|
343 |
if($product_status != 'all'){
|
344 |
$sql .= " AND p.post_status = %s ";
|
353 |
}
|
354 |
|
355 |
if(in_array($translation_status,array('not','need_update','in_progress','complete'))){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
switch($translation_status){
|
357 |
case 'not':
|
358 |
$sql .= " AND (";
|
359 |
$wheres = array();
|
360 |
foreach($sitepress->get_active_languages() as $lang){
|
361 |
+
if($lang['code'] == $slang) continue;
|
362 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
363 |
$wheres[] = "iclts_{$tbl_alias_suffix}.status IS NULL OR iclts_{$tbl_alias_suffix}.status = ".ICL_TM_WAITING_FOR_TRANSLATOR." OR iclts_{$tbl_alias_suffix}.needs_update = 1\n";
|
364 |
}
|
368 |
$sql .= " AND (";
|
369 |
$wheres = array();
|
370 |
foreach($sitepress->get_active_languages() as $lang){
|
371 |
+
if($lang['code'] == $slang) continue;
|
372 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
373 |
$wheres[] = "iclts_{$tbl_alias_suffix}.needs_update = 1\n";
|
374 |
}
|
378 |
$sql .= " AND (";
|
379 |
$wheres = array();
|
380 |
foreach($sitepress->get_active_languages() as $lang){
|
381 |
+
if($lang['code'] == $slang) continue;
|
382 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
383 |
$wheres[] = "iclts_{$tbl_alias_suffix}.status = ".ICL_TM_IN_PROGRESS."\n";
|
384 |
}
|
386 |
break;
|
387 |
case 'complete':
|
388 |
foreach($sitepress->get_active_languages() as $lang){
|
389 |
+
if($lang['code'] == $slang) continue;
|
390 |
$tbl_alias_suffix = str_replace('-','_',$lang['code']);
|
391 |
+
$sql .= " AND (iclts_{$tbl_alias_suffix}.status = ".ICL_TM_COMPLETE." OR iclts_{$tbl_alias_suffix}.status = ".ICL_TM_DUPLICATE.") AND iclts_{$tbl_alias_suffix}.needs_update = 0\n";
|
392 |
}
|
393 |
break;
|
394 |
}
|
395 |
}
|
|
|
396 |
|
397 |
$sql .= " ORDER BY p.id DESC LIMIT ".($page-1)*$limit.",".$limit;
|
398 |
|
|
|
399 |
$data = array();
|
400 |
|
401 |
$data['products'] = $wpdb->get_results($wpdb->prepare($sql,$prepare_arg));
|
427 |
}
|
428 |
|
429 |
$languages = $sitepress->get_active_languages();
|
|
|
430 |
|
431 |
$product_trid = $sitepress->get_element_trid($original_product_id, 'post_' . $orig_product->post_type);
|
432 |
$tr_product_id = icl_object_id($original_product_id, 'product', false, $language);
|
508 |
|
509 |
$this->sync_default_product_attr($original_product_id, $tr_product_id, $language);
|
510 |
|
511 |
+
$wpml_media_options = maybe_unserialize(get_option('_wpml_media'));
|
512 |
//sync media
|
513 |
+
if($wpml_media_options['new_content_settings']['duplicate_featured']){
|
514 |
+
//sync feature image
|
515 |
+
$this->sync_thumbnail_id($original_product_id, $tr_product_id, $language);
|
516 |
+
}
|
517 |
+
|
518 |
+
if($wpml_media_options['new_content_settings']['duplicate_media']){
|
519 |
+
//sync product gallery
|
520 |
+
$this->sync_product_gallery($original_product_id);
|
521 |
+
}
|
522 |
|
523 |
//sync taxonomies
|
524 |
$this->sync_product_taxonomies($original_product_id, $tr_product_id, $language);
|
552 |
ob_start();
|
553 |
$return = array();
|
554 |
|
555 |
+
$this->get_translation_statuses($translations,$languages,isset($_POST['slang']) && $_POST['slang'] != 'all'?$_POST['slang']:false, $product_trid);
|
556 |
$return['status'] = ob_get_clean();
|
557 |
|
558 |
|
803 |
$translations = $sitepress->get_element_translations($trid,'post_product',true);
|
804 |
foreach($translations as $translation){
|
805 |
$duplicated_ids = '';
|
806 |
+
if (!$translation->original) {
|
807 |
foreach($gallery_ids as $image_id){
|
808 |
$duplicated_id = icl_object_id($image_id,'attachment',false,$translation->language_code);
|
809 |
if(!is_null($duplicated_id)){
|
816 |
}
|
817 |
}
|
818 |
|
819 |
+
function get_translation_flags($active_languages,$slang = false){
|
820 |
+
global $wpdb,$sitepress;
|
821 |
+
|
822 |
foreach($active_languages as $language){
|
823 |
+
if (!$slang || ( ($slang != $language['code']) && (current_user_can('wpml_operate_woocommerce_multilingual') || wpml_check_user_is_translator($slang,$language['code'])) && (!isset($_POST['translation_status_lang']) || (isset($_POST['translation_status_lang']) && ($_POST['translation_status_lang'] == $language['code']) || $_POST['translation_status_lang']=='')))){
|
824 |
echo '<img src="'. ICL_PLUGIN_URL .'/res/flags/'. $language['code'] .'.png" width="18" height="12" class="flag_img" />';
|
825 |
}
|
826 |
}
|
827 |
}
|
828 |
|
829 |
|
830 |
+
function get_translation_statuses($product_translations,$active_languages,$slang = false, $trid = false ){
|
831 |
+
global $wpdb,$sitepress;
|
832 |
|
833 |
foreach ($active_languages as $language) {
|
834 |
+
if(!$slang && isset($product_translations[$language['code']]) && $product_translations[$language['code']]->original){
|
835 |
+
$alt = __('Original language','wpml-wcml');
|
836 |
+
echo '<i title="'. $alt .'" class="stat_img icon-minus"></i>';
|
837 |
+
}elseif( $trid && !current_user_can('wpml_operate_woocommerce_multilingual') && !$this->user_can_translate_product( $trid, $language['code'] ) && $slang != $language['code'] ){
|
838 |
$alt = __('No Permissions','wpml-wcml');
|
839 |
echo '<i title="'. $alt .'" class="stat_img"></i>';
|
840 |
+
}elseif ($slang != $language['code'] && (current_user_can('wpml_operate_woocommerce_multilingual') || wpml_check_user_is_translator($slang,$language['code'])) && (!isset($_POST['translation_status_lang']) || (isset($_POST['translation_status_lang']) && ($_POST['translation_status_lang'] == $language['code']) || $_POST['translation_status_lang']==''))) {
|
841 |
if (isset($product_translations[$language['code']])) {
|
842 |
$tr_status = $wpdb->get_row($wpdb->prepare("SELECT status,needs_update FROM " . $wpdb->prefix . "icl_translation_status WHERE translation_id = %d", $product_translations[$language['code']]->translation_id));
|
843 |
if(!$tr_status){
|
1205 |
|
1206 |
$default_lang = $sitepress->get_default_language();
|
1207 |
$current_lang = $sitepress->get_current_language();
|
|
|
|
|
|
|
|
|
1208 |
|
1209 |
if(($pagenow == 'post.php' && isset($_GET['post'])) || ($pagenow == 'admin.php' && isset($_GET['action']) && $_GET['action'] == 'duplicate_product' && isset($_GET['post']))){
|
1210 |
$prod_lang = $sitepress->get_language_for_element($_GET['post'],'post_product');
|
1211 |
}
|
1212 |
|
1213 |
+
if(!$woocommerce_wpml->settings['trnsl_interface'] && $pagenow == 'post.php' && isset($_GET['post'])&& get_post_type($_GET['post'])=='product' && !$this->is_original_product($_GET['post'])){
|
1214 |
add_action('admin_notices', array($this, 'inf_editing_product_in_non_default_lang'));
|
1215 |
}
|
1216 |
|
1217 |
+
if($woocommerce_wpml->settings['trnsl_interface'] && $pagenow == 'post.php' && !is_ajax() && isset($_GET['post']) && !$this->is_original_product($_GET['post']) && get_post_type($_GET['post'])=='product'){
|
1218 |
if((!isset($_GET['action'])) || (isset($_GET['action']) && !in_array($_GET['action'],array('trash','delete')))){
|
1219 |
+
$orig_language = $this->get_original_product_language($_GET['post']);
|
1220 |
+
$prid = icl_object_id($_GET['post'],'product',true,$orig_language);
|
1221 |
wp_redirect(admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$prid)); exit;
|
1222 |
}
|
1223 |
}
|
1227 |
}
|
1228 |
}
|
1229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1230 |
function inf_editing_product_in_non_default_lang(){
|
1231 |
+
$message = '<div class="message error"><p>';
|
1232 |
+
$message .= sprintf(__('The recommended way to translate WooCommerce products is using the <b><a href="%s">WooCommerce Multilingual products translation</a></b> page. Please use this page only for translating elements that are not available in the WooCommerce Multilingual products translation table.', 'wpml-wcml'), 'admin.php?page=wpml-wcml&tab=products');
|
1233 |
$message .= '</p></div>';
|
1234 |
|
1235 |
echo $message;
|
1236 |
}
|
1237 |
|
1238 |
//product quickedit
|
1239 |
+
function filter_product_actions( $actions, $post ){
|
1240 |
+
if( $post->post_type == 'product' && !$this->is_original_product($post->ID) && isset($actions['inline hide-if-no-js']) ){
|
1241 |
+
$new_actions = array();
|
1242 |
+
foreach($actions as $key => $action){
|
1243 |
+
if($key == 'inline hide-if-no-js'){
|
1244 |
+
$new_actions['quick_hide'] = '<a href="#TB_inline?width=200&height=150&inlineId=quick_edit_notice" class="thickbox" title="'.__('Edit this item inline','wpml-wcml').'">'.__('Quick Edit','wpml-wcml').'</a>';
|
1245 |
+
}else{
|
1246 |
+
$new_actions[$key] = $action;
|
1247 |
+
}
|
1248 |
+
}
|
1249 |
+
return $new_actions;
|
1250 |
}
|
1251 |
+
return $actions;
|
1252 |
}
|
1253 |
|
1254 |
+
|
1255 |
/**
|
1256 |
* Makes all new attributes translatable.
|
1257 |
*/
|
1368 |
foreach($translations as $translation){
|
1369 |
if ($ld->language_code != $translation->language_code) {
|
1370 |
|
1371 |
+
//check if product exist
|
1372 |
+
if(get_post_type($translation->element_id) == 'product_variation' && !get_post(wp_get_post_parent_id($translation->element_id))){
|
1373 |
+
continue;
|
1374 |
+
}
|
1375 |
+
|
1376 |
+
$_product = wc_get_product($translation->element_id);
|
|
|
1377 |
|
1378 |
if ( $_product && $_product->exists() && $_product->managing_stock() ) {
|
1379 |
$stock = $_product->reduce_stock($item['qty']);
|
1415 |
*/
|
1416 |
function sync_post_action($post_id, $post){
|
1417 |
global $wpdb, $pagenow, $sitepress, $sitepress_settings,$woocommerce_wpml;
|
1418 |
+
$original_language = $this->get_original_product_language($post_id);
|
1419 |
$current_language = $sitepress->get_current_language();
|
1420 |
+
$duplicated_post_id = icl_object_id($post_id, 'product', false, $original_language);
|
1421 |
$wpml_media_options = maybe_unserialize(get_option('_wpml_media'));
|
1422 |
|
1423 |
if($wpml_media_options['new_content_settings']['duplicate_media']){
|
1431 |
//set trid for variations
|
1432 |
if ($post_type == 'product_variation') {
|
1433 |
$var_lang = $sitepress->get_language_for_element(wp_get_post_parent_id($post_id),'post_product');
|
1434 |
+
if($this->is_original_product(wp_get_post_parent_id($post_id))){
|
1435 |
$sitepress->set_element_language_details($post_id, 'post_product_variation', false, $var_lang);
|
1436 |
}
|
1437 |
}
|
1458 |
remove_action('save_post', array($this, 'sync_post_action'), 11, 2);
|
1459 |
|
1460 |
//trnsl_interface option
|
1461 |
+
if (!$woocommerce_wpml->settings['trnsl_interface'] && $original_language != $current_language) {
|
1462 |
|
1463 |
$this->sync_status_and_parent( $duplicated_post_id, $post_id, $current_language );
|
1464 |
$this->sync_product_data( $duplicated_post_id, $post_id, $current_language );
|
1502 |
$posts = array();
|
1503 |
$translations = $sitepress->get_element_translations($language_details->trid, 'post_product');
|
1504 |
foreach ($translations as $translation) {
|
1505 |
+
if ($translation->original) {
|
1506 |
$duplicated_post_id = $translation->element_id;
|
1507 |
} else {
|
1508 |
$posts[$translation->element_id] = $translation;
|
1510 |
}
|
1511 |
|
1512 |
|
|
|
1513 |
foreach ($posts as $post_id => $translation) {
|
1514 |
$lang = $translation->language_code;
|
1515 |
|
1879 |
$tr_post = get_post($tr_post_id);
|
1880 |
return $tr_post->post_excerpt;
|
1881 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1882 |
default:
|
1883 |
global $wpdb,$sitepress;
|
1884 |
|
1932 |
}
|
1933 |
|
1934 |
if(!$term_name){
|
1935 |
+
$original_language = $sitepress->get_language_for_element($variation->ID,'post_product_variation');
|
1936 |
+
$orig_variation_id = icl_object_id($variation->ID,'product_variation',true,$original_language);
|
1937 |
|
1938 |
if(get_post_meta($orig_variation_id,$var_key,true) == ''){
|
1939 |
if(substr($tr_product_attr[$attribute]['name'], 0, 3) == 'pa_'){
|
1972 |
{
|
1973 |
global $sitepress, $woocommerce_wpml,$wpdb,$woocommerce;
|
1974 |
|
1975 |
+
$original_language = $sitepress->get_language_for_element($product_id,'post_product');
|
1976 |
$template_data = array();
|
1977 |
$template_data['all_variations_ids'] = array();
|
1978 |
|
1979 |
$trn_product_id = null;
|
1980 |
+
if ($original_language != $lang) {
|
1981 |
$trn_product_id = icl_object_id($product_id, 'product', false, $lang);
|
1982 |
}
|
1983 |
|
1984 |
+
if ($original_language == $lang) {
|
1985 |
$template_data['original'] = true;
|
1986 |
} else {
|
1987 |
$template_data['original'] = false;
|
2003 |
if(is_null($trn_product_id)){
|
2004 |
$template_data['all_file_paths']['count'] = count($files);
|
2005 |
}else{
|
2006 |
+
$template_data['all_file_paths']['count'] = count(maybe_unserialize(get_post_meta(icl_object_id($variation->ID, 'product_variation', false, $original_language),'_downloadable_files',true)));
|
2007 |
}
|
2008 |
foreach($files as $file){
|
2009 |
$variables = array();
|
2024 |
|
2025 |
if (!$is_product_has_variations){
|
2026 |
$template_data['empty_variations'] = true;
|
2027 |
+
} elseif($original_language != $lang && is_null($trn_product_id)){
|
2028 |
$template_data['empty_translation'] = true;
|
2029 |
}elseif (!$is_downloable){
|
2030 |
$template_data['not_downloaded'] = true;
|
2035 |
|
2036 |
function product_images_box($product_id,$lang, $is_duplicate_product = false ) {
|
2037 |
global $sitepress,$wpdb;
|
2038 |
+
$original_language = $sitepress->get_language_for_element($product_id,'post_product');
|
2039 |
+
if($original_language != $lang){
|
2040 |
$product_id = icl_object_id($product_id, 'product', false, $lang);
|
2041 |
}
|
2042 |
$template_data = array();
|
2043 |
|
2044 |
+
if($original_language == $lang){
|
2045 |
$template_data['original'] = true;
|
2046 |
}else{
|
2047 |
$template_data['original'] = false;
|
2051 |
if (empty($product_images)) {
|
2052 |
$template_data['empty_images'] = true;
|
2053 |
} else {
|
2054 |
+
if ($original_language == $lang) {
|
2055 |
$template_data['images_thumbnails'] = $product_images;
|
2056 |
}
|
2057 |
foreach ($product_images as $prod_image) {
|
2074 |
|
2075 |
function custom_box($product_id,$product_content,$trn_contents,$lang,$lang_name,$is_duplicate_product){
|
2076 |
global $sitepress;
|
2077 |
+
$original_language = $sitepress->get_language_for_element($product_id,'post_product');
|
2078 |
$tr_product_id = icl_object_id($product_id, 'product', false, $lang);
|
2079 |
$template_data = array();
|
2080 |
|
2086 |
$template_data['lang_name'] = $lang_name;
|
2087 |
$template_data['is_duplicate_product'] = $is_duplicate_product;
|
2088 |
|
2089 |
+
if($original_language == $lang){
|
2090 |
$template_data['original'] = true;
|
2091 |
}else{
|
2092 |
$template_data['original'] = false;
|
2249 |
|
2250 |
function translate_attribute_terms($terms){
|
2251 |
global $sitepress;
|
|
|
|
|
|
|
2252 |
|
2253 |
// iterate terms translating
|
2254 |
$terms = explode(",", $terms);
|
2259 |
$out[] = $term;
|
2260 |
}
|
2261 |
|
2262 |
+
return wptexturize(implode(", ", $out));
|
2263 |
}
|
2264 |
|
2265 |
function sync_product_gallery_duplicate_attachment($att_id, $dup_att_id){
|
2289 |
|
2290 |
function icl_pro_translation_completed($tr_product_id) {
|
2291 |
global $sitepress;
|
|
|
2292 |
|
2293 |
+
$trid = $sitepress->get_element_trid($tr_product_id,'post_product');
|
2294 |
+
$translations = $sitepress->get_element_translations($trid,'post_product');
|
2295 |
+
|
2296 |
+
foreach($translations as $translation){
|
2297 |
+
if($translation->original){
|
2298 |
+
$original_product_id = $translation->element_id;
|
2299 |
+
}
|
2300 |
+
}
|
2301 |
+
|
2302 |
+
if(!isset($original_product_id)){
|
2303 |
return;
|
2304 |
}
|
2305 |
|
2337 |
$translations = $sitepress->get_element_translations($trid, 'post_product_variation');
|
2338 |
if($translations){
|
2339 |
foreach($translations as $translation){
|
2340 |
+
if(!$translation->original){
|
2341 |
wp_delete_post($translation->element_id,true);
|
2342 |
}
|
2343 |
}
|
2348 |
|
2349 |
function icl_make_duplicate($master_post_id, $lang, $postarr, $id){
|
2350 |
if(get_post_type($master_post_id)=='product'){
|
2351 |
+
$this->sync_product_data($master_post_id, $id, $lang);
|
2352 |
}
|
2353 |
}
|
2354 |
|
2357 |
|
2358 |
$new_found_products = array();
|
2359 |
foreach($found_products as $post => $formatted_product_name) {
|
2360 |
+
$parent = wp_get_post_parent_id($post);
|
2361 |
+
|
2362 |
+
if( ( isset( $_COOKIE [ '_wcml_dashboard_order_language' ] )
|
2363 |
+
&& ( ( !$parent && $sitepress->get_language_for_element( $post, 'post_product') == $_COOKIE [ '_wcml_dashboard_order_language' ] )
|
2364 |
+
|| ( $parent && $sitepress->get_language_for_element( $parent, 'post_product') == $_COOKIE [ '_wcml_dashboard_order_language' ] ) )
|
2365 |
+
)
|
2366 |
+
||
|
2367 |
+
( ! isset( $_COOKIE [ '_wcml_dashboard_order_language' ] )
|
2368 |
+
&& ( ( !$parent && $this->is_original_product($post) )
|
2369 |
+
|| ( $parent && $this->is_original_product($parent) ) )
|
2370 |
+
)
|
2371 |
+
) {
|
2372 |
+
|
2373 |
$new_found_products[$post] = $formatted_product_name;
|
2374 |
+
|
2375 |
}
|
2376 |
}
|
2377 |
|
2385 |
$this->wcml_refresh_text_domain();
|
2386 |
}
|
2387 |
|
2388 |
+
function woocommerce_email_refresh_text_domain(){
|
2389 |
+
if( !isset($_GET['page']) || ( isset($_GET['page']) && $_GET['page'] != 'wc-settings' ) ){
|
2390 |
+
$this->wcml_refresh_text_domain();
|
2391 |
+
}
|
2392 |
+
}
|
2393 |
+
|
2394 |
function wcml_refresh_text_domain(){
|
2395 |
global $woocommerce;
|
2396 |
$domain = 'woocommerce';
|
2435 |
foreach($cart->cart_contents as $key=>$cart_item){
|
2436 |
$tr_product_id = icl_object_id($cart_item['product_id'],'product',false,$current_language);
|
2437 |
|
2438 |
+
if( $cart_item['product_id'] == $tr_product_id ){
|
2439 |
+
$new_cart_data[$key] = $cart->cart_contents[$key];
|
2440 |
+
continue;
|
2441 |
+
}
|
2442 |
+
|
2443 |
if(isset($cart->cart_contents[$key]['variation_id']) && $cart->cart_contents[$key]['variation_id']){
|
2444 |
$tr_variation_id = icl_object_id($cart_item['variation_id'],'product_variation',false,$current_language);
|
2445 |
if(!is_null($tr_variation_id)){
|
2490 |
$term = get_term_by('slug',$attribute,$taxonomy);
|
2491 |
$trnsl_term_id = icl_object_id($term->term_id,$taxonomy,true,$current_language);
|
2492 |
|
2493 |
+
return get_term($trnsl_term_id,$taxonomy)->slug;
|
2494 |
}else{
|
2495 |
+
return $this->get_custom_attr_translation( $product_id, $tr_product_id, $taxonomy, $attribute );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2496 |
}
|
2497 |
}
|
2498 |
|
2507 |
return apply_filters( 'wcml_filter_cart_item_data', $cart_contents );
|
2508 |
}
|
2509 |
|
2510 |
+
/*
|
2511 |
+
* Get custom attribute translation
|
2512 |
+
* Returned translated attribute or original if missed
|
2513 |
+
*/
|
2514 |
+
function get_custom_attr_translation( $product_id, $tr_product_id, $taxonomy, $attribute ){
|
2515 |
+
|
2516 |
+
$orig_product_attributes = get_post_meta($product_id, '_product_attributes', true);
|
2517 |
+
$unserialized_orig_product_attributes = maybe_unserialize($orig_product_attributes);
|
2518 |
+
foreach($unserialized_orig_product_attributes as $orig_attr_key => $orig_product_attribute){
|
2519 |
+
$orig_attr_key = urldecode($orig_attr_key);
|
2520 |
+
if( strtolower($taxonomy) == $orig_attr_key){
|
2521 |
+
$values = explode('|',$orig_product_attribute['value']);
|
2522 |
+
foreach($values as $key_id => $value){
|
2523 |
+
if(trim($value," ") == $attribute){
|
2524 |
+
$attr_key_id = $key_id;
|
2525 |
+
}
|
2526 |
+
}
|
2527 |
+
}
|
2528 |
+
}
|
2529 |
+
|
2530 |
+
$trnsl_product_attributes = get_post_meta($tr_product_id, '_product_attributes', true);
|
2531 |
+
$unserialized_trnsl_product_attributes = maybe_unserialize($trnsl_product_attributes);
|
2532 |
+
$taxonomy = sanitize_title($taxonomy);
|
2533 |
+
$trnsl_attr_values = explode('|',$unserialized_trnsl_product_attributes[$taxonomy]['value']);
|
2534 |
+
|
2535 |
+
if(isset($attr_key_id) && isset($trnsl_attr_values[$attr_key_id])){
|
2536 |
+
return trim($trnsl_attr_values[$attr_key_id]);
|
2537 |
+
}
|
2538 |
+
|
2539 |
+
return $attribute;
|
2540 |
+
}
|
2541 |
+
|
2542 |
function wcml_coupon_loaded($coupons_data){
|
2543 |
global $sitepress;
|
2544 |
|
2548 |
$exclude_product_categories_ids = array();
|
2549 |
|
2550 |
foreach($coupons_data->product_ids as $prod_id){
|
2551 |
+
$post_type = get_post_field('post_type', $prod_id);
|
2552 |
+
$trid = $sitepress->get_element_trid($prod_id,'post_' . $post_type);
|
2553 |
+
$translations = $sitepress->get_element_translations($trid,'post_' . $post_type);
|
2554 |
foreach($translations as $translation){
|
2555 |
$product_ids[] = $translation->element_id;
|
2556 |
}
|
2557 |
}
|
2558 |
foreach($coupons_data->exclude_product_ids as $prod_id){
|
2559 |
+
$post_type = get_post_field('post_type', $prod_id);
|
2560 |
+
$trid = $sitepress->get_element_trid($prod_id,'post_' . $post_type);
|
2561 |
+
$translations = $sitepress->get_element_translations($trid,'post_' . $post_type);
|
2562 |
foreach($translations as $translation){
|
2563 |
$exclude_product_ids[] = $translation->element_id;
|
2564 |
}
|
2592 |
}
|
2593 |
|
2594 |
|
2595 |
+
function set_tax_and_price_config() {
|
2596 |
global $sitepress, $iclTranslationManagement, $sitepress_settings, $wpdb, $woocommerce_wpml;
|
2597 |
|
2598 |
$all_products_taxonomies = get_taxonomies(array('object_type'=>array('product')),'objects');
|
2601 |
$sitepress_settings["translation-management"]["taxonomies_readonly_config"][$tax_key] = 1;
|
2602 |
$iclTranslationManagement->settings['taxonomies_readonly_config'][$tax_key] = 1;
|
2603 |
$sitepress_settings["taxonomies_sync_option"][$tax_key] = 1;
|
2604 |
+
$sitepress->verify_taxonomy_translations($tax_key);
|
2605 |
}
|
2606 |
$sitepress->save_settings($sitepress_settings);
|
2607 |
|
2659 |
function woocommerce_duplicate_product($new_id, $post){
|
2660 |
global $sitepress,$wpdb;
|
2661 |
|
|
|
|
|
|
|
2662 |
|
2663 |
+
//duplicate original first
|
2664 |
$trid = $sitepress->get_element_trid( $post->ID, 'post_' . $post->post_type );
|
2665 |
+
$orig_id = $sitepress->get_original_element_id_by_trid( $trid );
|
2666 |
+
$orig_lang = $this->get_original_product_language( $post->ID );
|
2667 |
+
|
2668 |
+
$wc_admin = new WC_Admin_Duplicate_Product();
|
2669 |
+
|
2670 |
+
if( $orig_id == $post->ID ){
|
2671 |
+
$sitepress->set_element_language_details($new_id, 'post_' . $post->post_type, false, $orig_lang);
|
2672 |
+
$new_trid = $sitepress->get_element_trid( $new_id, 'post_' . $post->post_type );
|
2673 |
+
}else{
|
2674 |
+
$post_to_duplicate = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE ID=$orig_id" );
|
2675 |
+
|
2676 |
+
if ( ! empty( $post_to_duplicate ) ) {
|
2677 |
+
$new_orig_id = $wc_admin->duplicate_product( $post_to_duplicate );
|
2678 |
+
|
2679 |
+
$sitepress->set_element_language_details( $new_orig_id, 'post_' . $post->post_type, false, $orig_lang );
|
2680 |
+
$new_trid = $sitepress->get_element_trid( $new_orig_id, 'post_' . $post->post_type );
|
2681 |
+
|
2682 |
+
$sitepress->set_element_language_details( $new_id, 'post_' . $post->post_type, $new_trid, $sitepress->get_current_language() );
|
2683 |
+
}
|
2684 |
+
}
|
2685 |
+
|
2686 |
$translations = $sitepress->get_element_translations( $trid, 'post_' . $post->post_type );
|
2687 |
|
2688 |
|
2689 |
if($translations){
|
|
|
2690 |
|
2691 |
foreach($translations as $translation){
|
2692 |
+
if( !$translation->original && $translation->element_id != $post->ID ){
|
2693 |
$post_to_duplicate = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE ID=$translation->element_id" );
|
2694 |
|
2695 |
if ( ! empty( $post_to_duplicate ) ) {
|
2699 |
}
|
2700 |
}
|
2701 |
}
|
|
|
|
|
2702 |
|
2703 |
+
}
|
2704 |
|
2705 |
}
|
2706 |
|
2736 |
|
2737 |
function woocommerce_product_quick_edit_save($product){
|
2738 |
global $sitepress;
|
2739 |
+
$is_original = $this->is_original_product($product->id);
|
|
|
2740 |
|
|
|
2741 |
$trid = $sitepress->get_element_trid($product->id, 'post_product');
|
2742 |
if ($trid) {
|
2743 |
$translations = $sitepress->get_element_translations($trid, 'post_product');
|
2744 |
if($translations){
|
2745 |
foreach($translations as $translation){
|
2746 |
+
if($is_original){
|
2747 |
+
if(!$translation->original){
|
2748 |
$this->sync_product_data($product->id,$translation->element_id,$translation->language_code);
|
2749 |
}
|
2750 |
+
}elseif($translation->original){
|
2751 |
+
$this->sync_product_data($translation->element_id,$product->id,$sitepress->get_language_for_element($product->id,'post_product'));
|
2752 |
}
|
2753 |
+
|
2754 |
}
|
2755 |
}
|
|
|
|
|
|
|
|
|
2756 |
}
|
2757 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2758 |
}
|
2759 |
|
|
|
2760 |
function override_cached_widget_id($widget_id){
|
2761 |
|
2762 |
if (defined('ICL_LANGUAGE_CODE')){
|
2768 |
|
2769 |
//update menu_order fro translations after ordering original products
|
2770 |
function update_translations_product_ordering(){
|
2771 |
+
global $wpdb, $sitepress, $woocommerce_wpml;
|
2772 |
+
|
2773 |
+
if( $woocommerce_wpml->settings['products_sync_order'] ) {
|
2774 |
|
2775 |
$current_language = $sitepress->get_current_language();
|
2776 |
|
2777 |
+
if ($current_language == $sitepress->get_default_language()) {
|
2778 |
+
$products = $wpdb->get_results($wpdb->prepare("SELECT p.ID, p.menu_order FROM $wpdb->posts AS p LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = p.id WHERE p.post_type = 'product' AND p.post_status IN ( 'publish', 'future', 'draft', 'pending', 'private' ) AND icl.element_type= 'post_product' AND icl.language_code = %s", $current_language));
|
2779 |
|
2780 |
+
foreach ($products as $product) {
|
2781 |
|
2782 |
+
$trid = $sitepress->get_element_trid($product->ID, 'post_product');
|
2783 |
+
$translations = $sitepress->get_element_translations($trid, 'post_product');
|
2784 |
|
2785 |
+
foreach ($translations as $translation) {
|
2786 |
|
2787 |
+
if ($translation->element_id != $product->ID) {
|
2788 |
+
$wpdb->update($wpdb->posts, array('menu_order' => $product->menu_order), array('ID' => $translation->element_id));
|
2789 |
}
|
2790 |
}
|
2791 |
|
2792 |
}
|
2793 |
|
2794 |
}
|
2795 |
+
}
|
2796 |
|
2797 |
}
|
2798 |
|
2821 |
global $woocommerce_wpml,$sitepress,$wpdb;
|
2822 |
|
2823 |
$product = get_post( $_POST['product_id'] );
|
2824 |
+
$default_language = $sitepress->get_language_for_element($_POST['product_id'],'post_product');
|
2825 |
$active_languages = $sitepress->get_active_languages();
|
2826 |
|
2827 |
if(ob_get_length()){
|
2858 |
return false;
|
2859 |
}
|
2860 |
|
2861 |
+
|
2862 |
+
// Check if original product
|
2863 |
+
function is_original_product( $product_id ){
|
2864 |
+
global $wpdb;
|
2865 |
+
|
2866 |
+
$is_original = $wpdb->get_var( $wpdb->prepare( "SELECT source_language_code IS NULL FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type='post_product'", $product_id ) );
|
2867 |
+
|
2868 |
+
return $is_original;
|
2869 |
+
}
|
2870 |
+
|
2871 |
+
// Get original product language
|
2872 |
+
function get_original_product_language( $product_id ){
|
2873 |
+
global $wpdb;
|
2874 |
+
|
2875 |
+
$language = $wpdb->get_var( $wpdb->prepare( "
|
2876 |
+
SELECT t2.language_code FROM {$wpdb->prefix}icl_translations as t1
|
2877 |
+
LEFT JOIN {$wpdb->prefix}icl_translations as t2 ON t1.trid = t2.trid
|
2878 |
+
WHERE t1.element_id=%d AND t1.element_type=%s AND t2.source_language_code IS NULL", $product_id, 'post_'.get_post_type($product_id) ) );
|
2879 |
+
|
2880 |
+
return $language;
|
2881 |
+
}
|
2882 |
+
|
2883 |
}
|
inc/reports.class.php
CHANGED
@@ -22,9 +22,13 @@ class WCML_Reports{
|
|
22 |
if($this->tab == 'orders' && $this->report == 'sales_by_product'){
|
23 |
add_filter('woocommerce_reports_get_order_report_data', array($this, 'combine_report_by_languages'));
|
24 |
}
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
-
|
28 |
function filter_reports_query($query){
|
29 |
global $wpdb, $sitepress;
|
30 |
|
@@ -236,7 +240,14 @@ class WCML_Reports{
|
|
236 |
static function _order_by_total($a, $b){
|
237 |
return $a->order_item_total < $b->order_item_total;
|
238 |
}
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
}
|
22 |
if($this->tab == 'orders' && $this->report == 'sales_by_product'){
|
23 |
add_filter('woocommerce_reports_get_order_report_data', array($this, 'combine_report_by_languages'));
|
24 |
}
|
25 |
+
|
26 |
+
add_filter( 'woocommerce_report_most_stocked_query_from', array( $this, 'filter_reports_stock_query') );
|
27 |
+
add_filter( 'woocommerce_report_out_of_stock_query_from', array( $this, 'filter_reports_stock_query') );
|
28 |
+
add_filter( 'woocommerce_report_low_in_stock_query_from', array( $this, 'filter_reports_stock_query') );
|
29 |
+
|
30 |
}
|
31 |
+
|
32 |
function filter_reports_query($query){
|
33 |
global $wpdb, $sitepress;
|
34 |
|
240 |
static function _order_by_total($a, $b){
|
241 |
return $a->order_item_total < $b->order_item_total;
|
242 |
}
|
243 |
+
|
244 |
+
function filter_reports_stock_query( $query_from ){
|
245 |
+
global $wpdb, $sitepress;
|
246 |
+
|
247 |
+
$query_from = preg_replace("/WHERE/", "LEFT JOIN {$wpdb->prefix}icl_translations AS t ON posts.ID = t.element_id WHERE", $query_from);
|
248 |
+
$query_from .= " AND t.element_type IN ( 'post_product', 'post_product_variation' ) AND t.language_code = '".$sitepress->get_current_language()."'";
|
249 |
+
|
250 |
+
return $query_from;
|
251 |
+
}
|
252 |
|
253 |
}
|
inc/requests.class.php
CHANGED
@@ -78,6 +78,7 @@ class WCML_Requests{
|
|
78 |
|
79 |
if(isset($_POST['wcml_products_sync_prop']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_products_sync_prop')){
|
80 |
$woocommerce_wpml->settings['products_sync_date'] = empty($_POST['products_sync_date']) ? 0 : 1;
|
|
|
81 |
$woocommerce_wpml->update_settings();
|
82 |
}
|
83 |
|
78 |
|
79 |
if(isset($_POST['wcml_products_sync_prop']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_products_sync_prop')){
|
80 |
$woocommerce_wpml->settings['products_sync_date'] = empty($_POST['products_sync_date']) ? 0 : 1;
|
81 |
+
$woocommerce_wpml->settings['products_sync_order'] = empty($_POST['products_sync_order']) ? 0 : 1;
|
82 |
$woocommerce_wpml->update_settings();
|
83 |
}
|
84 |
|
inc/store-pages.class.php
CHANGED
@@ -139,7 +139,26 @@ class WCML_Store_Pages{
|
|
139 |
if ( ! $q->is_main_query() )
|
140 |
return;
|
141 |
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
$q->set( 'post_type', 'product' );
|
144 |
$q->set( 'page_id', '' );
|
145 |
if ( isset( $q->query['paged'] ) )
|
@@ -160,8 +179,22 @@ class WCML_Store_Pages{
|
|
160 |
$q->is_post_type_archive = true;
|
161 |
$q->is_archive = true;
|
162 |
}
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
/**
|
166 |
* Translate shop url
|
167 |
*/
|
@@ -220,13 +253,13 @@ class WCML_Store_Pages{
|
|
220 |
__('View Order','wpml-wcml'),
|
221 |
__('Shop','wpml-wcml'));
|
222 |
|
223 |
-
if ($miss_lang) {
|
224 |
$wp_rewrite = new WP_Rewrite();
|
225 |
|
226 |
$check_pages = $this->get_wc_pages();
|
227 |
-
|
228 |
-
if(in_array($
|
229 |
-
$miss_lang['codes'] = array_merge(array($
|
230 |
}
|
231 |
|
232 |
foreach ($miss_lang['codes'] as $mis_lang) {
|
@@ -238,9 +271,10 @@ class WCML_Store_Pages{
|
|
238 |
|
239 |
foreach ($check_pages as $page) {
|
240 |
$orig_id = get_option($page);
|
241 |
-
$
|
|
|
242 |
|
243 |
-
if ($
|
244 |
$orig_page = get_post($orig_id);
|
245 |
|
246 |
switch( $page ){
|
@@ -265,7 +299,7 @@ class WCML_Store_Pages{
|
|
265 |
$args['post_type'] = $orig_page->post_type;
|
266 |
$args['post_content'] = $orig_page->post_content;
|
267 |
$args['post_excerpt'] = $orig_page->post_excerpt;
|
268 |
-
$args['post_status'] = get_post_status($
|
269 |
$args['menu_order'] = $orig_page->menu_order;
|
270 |
$args['ping_status'] = $orig_page->ping_status;
|
271 |
$args['comment_status'] = $orig_page->comment_status;
|
@@ -273,12 +307,12 @@ class WCML_Store_Pages{
|
|
273 |
$args['post_parent'] = is_null($post_parent)?0:$post_parent;
|
274 |
$new_page_id = wp_insert_post($args);
|
275 |
|
276 |
-
if(get_post_status($
|
277 |
update_option($page, $new_page_id);
|
278 |
}
|
279 |
|
280 |
-
if(!is_null($
|
281 |
-
$sitepress->set_element_language_details($
|
282 |
}
|
283 |
|
284 |
$trid = $sitepress->get_element_trid($orig_id, 'post_page');
|
@@ -288,7 +322,7 @@ class WCML_Store_Pages{
|
|
288 |
}
|
289 |
}
|
290 |
unload_textdomain('wpml-wcml');
|
291 |
-
$sitepress->switch_lang($
|
292 |
$woocommerce_wpml->load_locale();
|
293 |
}
|
294 |
|
@@ -305,43 +339,78 @@ class WCML_Store_Pages{
|
|
305 |
$check_pages = $this->get_wc_pages();
|
306 |
|
307 |
$missing_lang = '';
|
|
|
308 |
|
309 |
foreach ($check_pages as $page) {
|
310 |
$page_id = get_option($page);
|
311 |
|
312 |
-
if(!$page_id || !
|
313 |
return 'non_exist';
|
314 |
}
|
315 |
}
|
316 |
|
317 |
global $sitepress;
|
318 |
$languages = $sitepress->get_active_languages();
|
319 |
-
$default_language = $sitepress->get_default_language();
|
320 |
|
321 |
$missing_lang_codes = array();
|
322 |
-
|
323 |
foreach ($check_pages as $page) {
|
324 |
$store_page_id = get_option($page);
|
325 |
-
$
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
-
$missing_lang_codes[] = $language['code'];
|
333 |
-
break;
|
334 |
-
}
|
335 |
}
|
336 |
}
|
337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
|
339 |
if (!empty($missing_lang)) {
|
340 |
-
$
|
341 |
-
$
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
return false;
|
346 |
}
|
347 |
}
|
139 |
if ( ! $q->is_main_query() )
|
140 |
return;
|
141 |
|
142 |
+
|
143 |
+
//do not alter query_object and query_object_id (part 1 of 2)
|
144 |
+
global $wp_query;
|
145 |
+
$queried_object_original = isset($wp_query->queried_object) ? $wp_query->queried_object : null;
|
146 |
+
$queried_object_id_original = isset($wp_query->queried_object_id) ? $wp_query->queried_object_id : null;
|
147 |
+
|
148 |
+
if (
|
149 |
+
!empty($this->shop_page) &&
|
150 |
+
$q->get('post_type') != 'product' &&
|
151 |
+
$q->get('page_id') !== $this->front_page_id &&
|
152 |
+
(
|
153 |
+
$this->shop_page_id == $q->get('page_id') ||
|
154 |
+
(
|
155 |
+
!$q->get_queried_object_id() &&
|
156 |
+
$q->query &&
|
157 |
+
$this->shop_page_id == $this->front_page_id
|
158 |
+
)
|
159 |
+
)
|
160 |
+
|
161 |
+
){
|
162 |
$q->set( 'post_type', 'product' );
|
163 |
$q->set( 'page_id', '' );
|
164 |
if ( isset( $q->query['paged'] ) )
|
179 |
$q->is_post_type_archive = true;
|
180 |
$q->is_archive = true;
|
181 |
}
|
182 |
+
|
183 |
+
//do not alter query_object and query_object_id (part 2 of 2)
|
184 |
+
if(is_null($queried_object_original)){
|
185 |
+
unset($wp_query->queried_object);
|
186 |
+
}else{
|
187 |
+
$wp_query->queried_object = $queried_object_original;
|
188 |
+
}
|
189 |
+
if(is_null($queried_object_id_original)){
|
190 |
+
unset($wp_query->queried_object_id);
|
191 |
+
}else{
|
192 |
+
$wp_query->queried_object_id = $queried_object_id_original;
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
/**
|
199 |
* Translate shop url
|
200 |
*/
|
253 |
__('View Order','wpml-wcml'),
|
254 |
__('Shop','wpml-wcml'));
|
255 |
|
256 |
+
if (isset($miss_lang['codes'])) {
|
257 |
$wp_rewrite = new WP_Rewrite();
|
258 |
|
259 |
$check_pages = $this->get_wc_pages();
|
260 |
+
$default_language = $sitepress->get_default_language();
|
261 |
+
if(in_array($default_language, $miss_lang['codes'])){
|
262 |
+
$miss_lang['codes'] = array_merge(array($default_language), array_diff($miss_lang['codes'], array($default_language)));
|
263 |
}
|
264 |
|
265 |
foreach ($miss_lang['codes'] as $mis_lang) {
|
271 |
|
272 |
foreach ($check_pages as $page) {
|
273 |
$orig_id = get_option($page);
|
274 |
+
$trid = $sitepress->get_element_trid($orig_id,'post_page');
|
275 |
+
$translations = $sitepress->get_element_translations($trid,'post_page',true);
|
276 |
|
277 |
+
if (!isset( $translations[ $mis_lang ] ) || ( !is_null( $translations[$mis_lang]->element_id ) && get_post_status( $translations[$mis_lang]->element_id )!='publish' ) ) {
|
278 |
$orig_page = get_post($orig_id);
|
279 |
|
280 |
switch( $page ){
|
299 |
$args['post_type'] = $orig_page->post_type;
|
300 |
$args['post_content'] = $orig_page->post_content;
|
301 |
$args['post_excerpt'] = $orig_page->post_excerpt;
|
302 |
+
$args['post_status'] = ( isset($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) != 'publish' ) ? 'publish' : $orig_page->post_status;
|
303 |
$args['menu_order'] = $orig_page->menu_order;
|
304 |
$args['ping_status'] = $orig_page->ping_status;
|
305 |
$args['comment_status'] = $orig_page->comment_status;
|
307 |
$args['post_parent'] = is_null($post_parent)?0:$post_parent;
|
308 |
$new_page_id = wp_insert_post($args);
|
309 |
|
310 |
+
if( isset($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) == 'trash' && $mis_lang == $default_language){
|
311 |
update_option($page, $new_page_id);
|
312 |
}
|
313 |
|
314 |
+
if( isset($translations[$mis_lang]->element_id) && !is_null($translations[$mis_lang]->element_id)){
|
315 |
+
$sitepress->set_element_language_details($translations[$mis_lang]->element_id, 'post_page', false, $mis_lang);
|
316 |
}
|
317 |
|
318 |
$trid = $sitepress->get_element_trid($orig_id, 'post_page');
|
322 |
}
|
323 |
}
|
324 |
unload_textdomain('wpml-wcml');
|
325 |
+
$sitepress->switch_lang($default_language);
|
326 |
$woocommerce_wpml->load_locale();
|
327 |
}
|
328 |
|
339 |
$check_pages = $this->get_wc_pages();
|
340 |
|
341 |
$missing_lang = '';
|
342 |
+
$pages_in_progress = array();
|
343 |
|
344 |
foreach ($check_pages as $page) {
|
345 |
$page_id = get_option($page);
|
346 |
|
347 |
+
if(!$page_id || !get_post($page_id)){
|
348 |
return 'non_exist';
|
349 |
}
|
350 |
}
|
351 |
|
352 |
global $sitepress;
|
353 |
$languages = $sitepress->get_active_languages();
|
|
|
354 |
|
355 |
$missing_lang_codes = array();
|
356 |
+
|
357 |
foreach ($check_pages as $page) {
|
358 |
$store_page_id = get_option($page);
|
359 |
+
$trid = $sitepress->get_element_trid($store_page_id,'post_page');
|
360 |
+
$translations = $sitepress->get_element_translations($trid,'post_page',true);
|
361 |
+
$pages_in_progress_miss_lang = '';
|
362 |
+
foreach ($languages as $language) {
|
363 |
+
if ( !in_array( $language['code'], $missing_lang_codes ) &&
|
364 |
+
( !isset( $translations[ $language['code'] ] ) || ( !is_null( $translations[$language['code']]->element_id ) && get_post_status( $translations[$language['code']]->element_id )!='publish' ) ) ) {
|
365 |
+
|
366 |
+
$missing_lang_codes[] = $language['code'];
|
367 |
+
|
368 |
+
if (!empty($missing_lang)) {
|
369 |
+
$missing_lang .= ', ' . $language['display_name'];
|
370 |
+
} else {
|
371 |
+
$missing_lang .= $language['display_name'];
|
372 |
+
}
|
373 |
+
|
374 |
+
continue;
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( isset($translations[$language['code']] ) && is_null( $translations[$language['code']]->element_id ) ) {
|
378 |
+
|
379 |
+
if (!empty($pages_in_progress_miss_lang)) {
|
380 |
+
$pages_in_progress_miss_lang .= ', ' . $language['display_name'];
|
381 |
+
} else {
|
382 |
+
$pages_in_progress_miss_lang .= $language['display_name'];
|
383 |
+
}
|
384 |
+
|
385 |
+
$pages_in_progress[$store_page_id] = $pages_in_progress_miss_lang;
|
386 |
+
|
387 |
}
|
|
|
|
|
|
|
388 |
}
|
389 |
}
|
390 |
|
391 |
+
$pages_in_progress_notice = '';
|
392 |
+
foreach( $pages_in_progress as $key => $page_in_progress ){
|
393 |
+
if (!empty($pages_in_progress_notice)) {
|
394 |
+
$pages_in_progress_notice .= ', ' . get_the_title( $key ) .' ('.$page_in_progress.')';
|
395 |
+
} else {
|
396 |
+
$pages_in_progress_notice .= get_the_title( $key ) .' ('.$page_in_progress.')';
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
$status = array();
|
401 |
|
402 |
if (!empty($missing_lang)) {
|
403 |
+
$status['lang'] = $missing_lang;
|
404 |
+
$status['codes'] = $missing_lang_codes;
|
405 |
+
}
|
406 |
+
|
407 |
+
if (!empty($pages_in_progress_notice)) {
|
408 |
+
$status['in_progress'] = $pages_in_progress_notice;
|
409 |
+
}
|
410 |
+
|
411 |
+
if(!empty($status)){
|
412 |
+
return $status;
|
413 |
+
}else {
|
414 |
return false;
|
415 |
}
|
416 |
}
|
inc/terms.class.php
CHANGED
@@ -146,7 +146,7 @@ class WCML_Terms{
|
|
146 |
foreach($taxonomies as $taxonomy ){
|
147 |
|
148 |
$taxonomy_obj = get_taxonomy($taxonomy);
|
149 |
-
$slug = isset($taxonomy_obj->rewrite['slug']) ? trim($taxonomy_obj->rewrite['slug'],'/') : false;
|
150 |
|
151 |
if($slug && $sitepress->get_current_language() != $strings_language){
|
152 |
|
@@ -204,7 +204,7 @@ class WCML_Terms{
|
|
204 |
$taxonomy_obj = get_taxonomy($taxonomy);
|
205 |
|
206 |
if(isset($taxonomy_obj->rewrite['slug'])){
|
207 |
-
$exp = explode('/', $taxonomy_obj->rewrite['slug']);
|
208 |
$slug = join('/', array_slice($exp, 0, count($exp) - 1));
|
209 |
}
|
210 |
|
@@ -323,7 +323,7 @@ class WCML_Terms{
|
|
323 |
if(!empty($term_language)){
|
324 |
|
325 |
$permalinks = get_option( 'woocommerce_permalinks' );
|
326 |
-
$base = $taxonomy == 'product_tag' ? $permalinks['tag_base'] : ($taxonomy == 'product_cat' ? $permalinks['category_base'] : $permalinks['attribute_base']);
|
327 |
|
328 |
|
329 |
$string_identifier = $taxonomy == 'product_tag' || $taxonomy == 'product_cat' ? $taxonomy : 'attribute';
|
@@ -341,7 +341,7 @@ class WCML_Terms{
|
|
341 |
JOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id
|
342 |
WHERE s.value='". esc_sql($base)."'";
|
343 |
|
344 |
-
if (
|
345 |
$sql .= " AND s.language = '{$strings_language}' ";
|
346 |
}
|
347 |
|
@@ -353,7 +353,7 @@ class WCML_Terms{
|
|
353 |
$base_translated = $base;
|
354 |
}
|
355 |
|
356 |
-
if(!empty($base_translated) && $base_translated != $base){
|
357 |
|
358 |
$buff = $wp_rewrite->extra_permastructs[$taxonomy]['struct'];
|
359 |
$wp_rewrite->extra_permastructs[$taxonomy]['struct'] = str_replace($base, $base_translated, $wp_rewrite->extra_permastructs[$taxonomy]['struct']);
|
@@ -402,22 +402,13 @@ class WCML_Terms{
|
|
402 |
if(empty($language)){
|
403 |
$language = $sitepress->get_default_language();
|
404 |
}
|
405 |
-
|
406 |
|
407 |
$message = sprintf(__('To translate %s please use the %s translation%s page, inside the %sWooCommerce Multilingual admin%s.', 'wpml-wcml'),
|
408 |
-
|
409 |
-
|
410 |
-
'<strong><a href="' . admin_url('admin.php?page=wpml-wcml">'), '</a></strong>');
|
411 |
-
|
412 |
-
}else{
|
413 |
-
|
414 |
-
$message = sprintf(__('Wait! There is a better way to translate %s. Please go to the %s translation%s page, inside the %sWooCommerce Multilingual admin%s, and translate from there.', 'wpml-wcml'),
|
415 |
-
$taxonomy_obj->labels->name,
|
416 |
-
'<strong><a href="' . admin_url('admin.php?page=wpml-wcml&tab=' . $taxonomy ) . '">' . $taxonomy_obj->labels->singular_name , '</a></strong>',
|
417 |
'<strong><a href="' . admin_url('admin.php?page=wpml-wcml">'), '</a></strong>');
|
418 |
-
|
419 |
-
|
420 |
-
}
|
421 |
echo '<div class="updated"><p>' . $message . '</p></div>';
|
422 |
|
423 |
}
|
@@ -438,7 +429,7 @@ class WCML_Terms{
|
|
438 |
$lang = $sitepress->get_default_language();
|
439 |
$sitepress->switch_lang($lang);
|
440 |
|
441 |
-
$taxes = wc_get_attribute_taxonomies ();
|
442 |
|
443 |
if ($taxes) foreach ($taxes as $woo_tax) {
|
444 |
$tax = 'pa_'.$woo_tax->attribute_name;
|
@@ -503,12 +494,12 @@ class WCML_Terms{
|
|
503 |
if ( isset( $_POST['product_cat_thumbnail_id'] ) ){
|
504 |
global $sitepress,$sitepress_settings;
|
505 |
|
506 |
-
if($sitepress_settings['sync_taxonomy_parents'] && $
|
507 |
$trid = $sitepress->get_element_trid($tt_id,'tax_'.$taxonomy);
|
508 |
$translations = $sitepress->get_element_translations($trid,'tax_'.$taxonomy);
|
509 |
|
510 |
foreach($translations as $translation){
|
511 |
-
if(
|
512 |
if(isset($_POST['display_type'])){
|
513 |
update_woocommerce_term_meta( $translation->term_id, 'display_type', esc_attr( $_POST['display_type'] ) );
|
514 |
}
|
@@ -524,6 +515,11 @@ class WCML_Terms{
|
|
524 |
}
|
525 |
|
526 |
}
|
|
|
|
|
|
|
|
|
|
|
527 |
|
528 |
static function wcml_update_term_translated_warnings(){
|
529 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
146 |
foreach($taxonomies as $taxonomy ){
|
147 |
|
148 |
$taxonomy_obj = get_taxonomy($taxonomy);
|
149 |
+
$slug = isset($taxonomy_obj->rewrite['slug']) ? trim($taxonomy_obj->rewrite['slug'] ,'/') : false;
|
150 |
|
151 |
if($slug && $sitepress->get_current_language() != $strings_language){
|
152 |
|
204 |
$taxonomy_obj = get_taxonomy($taxonomy);
|
205 |
|
206 |
if(isset($taxonomy_obj->rewrite['slug'])){
|
207 |
+
$exp = explode('/', trim($taxonomy_obj->rewrite['slug'],'/'));
|
208 |
$slug = join('/', array_slice($exp, 0, count($exp) - 1));
|
209 |
}
|
210 |
|
323 |
if(!empty($term_language)){
|
324 |
|
325 |
$permalinks = get_option( 'woocommerce_permalinks' );
|
326 |
+
$base = $taxonomy == 'product_tag' ? trim($permalinks['tag_base'],'/') : ($taxonomy == 'product_cat' ? trim($permalinks['category_base'],'/') : trim($permalinks['attribute_base'],'/'));
|
327 |
|
328 |
|
329 |
$string_identifier = $taxonomy == 'product_tag' || $taxonomy == 'product_cat' ? $taxonomy : 'attribute';
|
341 |
JOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id
|
342 |
WHERE s.value='". esc_sql($base)."'";
|
343 |
|
344 |
+
if ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
345 |
$sql .= " AND s.language = '{$strings_language}' ";
|
346 |
}
|
347 |
|
353 |
$base_translated = $base;
|
354 |
}
|
355 |
|
356 |
+
if(!empty($base_translated) && $base_translated != $base && isset( $wp_rewrite->extra_permastructs[$taxonomy] ) ){
|
357 |
|
358 |
$buff = $wp_rewrite->extra_permastructs[$taxonomy]['struct'];
|
359 |
$wp_rewrite->extra_permastructs[$taxonomy]['struct'] = str_replace($base, $base_translated, $wp_rewrite->extra_permastructs[$taxonomy]['struct']);
|
402 |
if(empty($language)){
|
403 |
$language = $sitepress->get_default_language();
|
404 |
}
|
405 |
+
|
406 |
|
407 |
$message = sprintf(__('To translate %s please use the %s translation%s page, inside the %sWooCommerce Multilingual admin%s.', 'wpml-wcml'),
|
408 |
+
$taxonomy_obj->labels->name,
|
409 |
+
'<strong><a href="' . admin_url('admin.php?page=wpml-wcml&tab=' . $taxonomy ) . '">' . $taxonomy_obj->labels->singular_name, '</a></strong>',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
'<strong><a href="' . admin_url('admin.php?page=wpml-wcml">'), '</a></strong>');
|
411 |
+
|
|
|
|
|
412 |
echo '<div class="updated"><p>' . $message . '</p></div>';
|
413 |
|
414 |
}
|
429 |
$lang = $sitepress->get_default_language();
|
430 |
$sitepress->switch_lang($lang);
|
431 |
|
432 |
+
$taxes = wc_get_attribute_taxonomies ();
|
433 |
|
434 |
if ($taxes) foreach ($taxes as $woo_tax) {
|
435 |
$tax = 'pa_'.$woo_tax->attribute_name;
|
494 |
if ( isset( $_POST['product_cat_thumbnail_id'] ) ){
|
495 |
global $sitepress,$sitepress_settings;
|
496 |
|
497 |
+
if($sitepress_settings['sync_taxonomy_parents'] && $this->is_original_category($tt_id,'tax_'.$taxonomy) ){
|
498 |
$trid = $sitepress->get_element_trid($tt_id,'tax_'.$taxonomy);
|
499 |
$translations = $sitepress->get_element_translations($trid,'tax_'.$taxonomy);
|
500 |
|
501 |
foreach($translations as $translation){
|
502 |
+
if(!$translation->original){
|
503 |
if(isset($_POST['display_type'])){
|
504 |
update_woocommerce_term_meta( $translation->term_id, 'display_type', esc_attr( $_POST['display_type'] ) );
|
505 |
}
|
515 |
}
|
516 |
|
517 |
}
|
518 |
+
|
519 |
+
function is_original_category( $tt_id, $taxonomy ){
|
520 |
+
global $wpdb;
|
521 |
+
$is_original = $wpdb->get_var($wpdb->prepare("SELECT source_language_code IS NULL FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type=%s", $tt_id, $taxonomy ));
|
522 |
+
}
|
523 |
|
524 |
static function wcml_update_term_translated_warnings(){
|
525 |
global $woocommerce_wpml, $sitepress, $wpdb;
|
inc/upgrade.class.php
CHANGED
@@ -155,7 +155,7 @@ class WCML_Upgrade{
|
|
155 |
}
|
156 |
|
157 |
function upgrade_3_1(){
|
158 |
-
|
159 |
$wcml_settings = get_option('_wcml_settings');
|
160 |
|
161 |
if(isset($wcml_settings['enable_multi_currency']) && $wcml_settings['enable_multi_currency'] == 'yes'){
|
@@ -282,5 +282,15 @@ class WCML_Upgrade{
|
|
282 |
$wpdb->query("DROP TABLE `{$wpdb->prefix}icl_currencies`");
|
283 |
|
284 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
}
|
155 |
}
|
156 |
|
157 |
function upgrade_3_1(){
|
158 |
+
global $wpdb,$sitepress;
|
159 |
$wcml_settings = get_option('_wcml_settings');
|
160 |
|
161 |
if(isset($wcml_settings['enable_multi_currency']) && $wcml_settings['enable_multi_currency'] == 'yes'){
|
282 |
$wpdb->query("DROP TABLE `{$wpdb->prefix}icl_currencies`");
|
283 |
|
284 |
}
|
285 |
+
|
286 |
+
function upgrade_3_5()
|
287 |
+
{
|
288 |
+
global $wpdb, $sitepress;
|
289 |
+
$wcml_settings = get_option('_wcml_settings');
|
290 |
+
|
291 |
+
$wcml_settings['products_sync_order'] = 1;
|
292 |
+
|
293 |
+
update_option('_wcml_settings', $wcml_settings);
|
294 |
+
}
|
295 |
|
296 |
}
|
inc/wc-strings.class.php
CHANGED
@@ -57,7 +57,7 @@ class WCML_WC_Strings{
|
|
57 |
|
58 |
$string_id = icl_get_string_id('taxonomy singular name: '.$label,'WordPress');
|
59 |
|
60 |
-
if (
|
61 |
$strings_language = icl_st_get_string_language( $string_id );
|
62 |
}else{
|
63 |
$strings_language = $sitepress_settings['st']['strings_language'];
|
@@ -162,14 +162,14 @@ class WCML_WC_Strings{
|
|
162 |
global $sitepress_settings, $sitepress;
|
163 |
|
164 |
if ($context == 'slug' || $context == 'default-slug') {
|
165 |
-
$wc_slug = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
|
166 |
if(is_admin()){
|
167 |
$admin_language = $sitepress->get_admin_language();
|
168 |
}
|
169 |
$current_language = $sitepress->get_current_language();
|
170 |
$strings_language = false;
|
171 |
-
if (
|
172 |
-
$context_ob = icl_st_get_context( '
|
173 |
if($context_ob){
|
174 |
$strings_language = $context_ob->language;
|
175 |
}
|
@@ -267,7 +267,7 @@ class WCML_WC_Strings{
|
|
267 |
global $sitepress_settings, $sitepress;
|
268 |
|
269 |
echo '<div id="wpml_wcml_custom_base_req" style="display:none"><br /><i>';
|
270 |
-
if(
|
271 |
$strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
|
272 |
echo sprintf(__('Please enter string in %s (the strings language)', 'wpml-wcml'), '<strong>' . $strings_language['display_name'] . '</strong>');
|
273 |
}
|
@@ -288,7 +288,7 @@ class WCML_WC_Strings{
|
|
288 |
function show_attribute_label_language_warning(){
|
289 |
global $sitepress_settings, $sitepress;
|
290 |
|
291 |
-
if(
|
292 |
$default_language = $sitepress->get_language_details($sitepress->get_default_language());
|
293 |
$strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
|
294 |
echo '<div id="wpml_wcml_attr_language" style="display:none"><div class="icl_cyan_box"><i>';
|
@@ -345,7 +345,7 @@ class WCML_WC_Strings{
|
|
345 |
$slug_translation_languages = $wpdb->get_col($wpdb->prepare("SELECT tr.language FROM {$wpdb->prefix}icl_strings AS s LEFT JOIN {$wpdb->prefix}icl_string_translations AS tr ON s.id = tr.string_id WHERE s.name = %s AND s.value = %s AND tr.status = %s", 'URL slug: ' . $slug, $slug, ICL_STRING_TRANSLATION_COMPLETE));
|
346 |
$miss_slug_lang = array();
|
347 |
|
348 |
-
if (
|
349 |
|
350 |
$context_ob = icl_st_get_context( 'WordPress' );
|
351 |
if($context_ob){
|
@@ -369,16 +369,16 @@ class WCML_WC_Strings{
|
|
369 |
|
370 |
function product_permalink_slug(){
|
371 |
$permalinks = get_option( 'woocommerce_permalinks' );
|
372 |
-
$slug = empty( $permalinks['product_base'] ) ? 'product' : trim($permalinks['product_base'],
|
373 |
|
374 |
return $slug;
|
375 |
}
|
376 |
|
377 |
function get_wc_context_language(){
|
378 |
|
379 |
-
if (
|
380 |
|
381 |
-
$context_ob = icl_st_get_context( '
|
382 |
if($context_ob){
|
383 |
$context_language = $context_ob->language;
|
384 |
}else{
|
57 |
|
58 |
$string_id = icl_get_string_id('taxonomy singular name: '.$label,'WordPress');
|
59 |
|
60 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
61 |
$strings_language = icl_st_get_string_language( $string_id );
|
62 |
}else{
|
63 |
$strings_language = $sitepress_settings['st']['strings_language'];
|
162 |
global $sitepress_settings, $sitepress;
|
163 |
|
164 |
if ($context == 'slug' || $context == 'default-slug') {
|
165 |
+
$wc_slug = get_option('woocommerce_product_slug') != false ? trim(get_option('woocommerce_product_slug'),'/') : 'product';
|
166 |
if(is_admin()){
|
167 |
$admin_language = $sitepress->get_admin_language();
|
168 |
}
|
169 |
$current_language = $sitepress->get_current_language();
|
170 |
$strings_language = false;
|
171 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
172 |
+
$context_ob = icl_st_get_context( 'WordPress' );
|
173 |
if($context_ob){
|
174 |
$strings_language = $context_ob->language;
|
175 |
}
|
267 |
global $sitepress_settings, $sitepress;
|
268 |
|
269 |
echo '<div id="wpml_wcml_custom_base_req" style="display:none"><br /><i>';
|
270 |
+
if( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG ){
|
271 |
$strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
|
272 |
echo sprintf(__('Please enter string in %s (the strings language)', 'wpml-wcml'), '<strong>' . $strings_language['display_name'] . '</strong>');
|
273 |
}
|
288 |
function show_attribute_label_language_warning(){
|
289 |
global $sitepress_settings, $sitepress;
|
290 |
|
291 |
+
if(!WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $sitepress_settings['st']['strings_language'] != $sitepress->get_default_language()){
|
292 |
$default_language = $sitepress->get_language_details($sitepress->get_default_language());
|
293 |
$strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
|
294 |
echo '<div id="wpml_wcml_attr_language" style="display:none"><div class="icl_cyan_box"><i>';
|
345 |
$slug_translation_languages = $wpdb->get_col($wpdb->prepare("SELECT tr.language FROM {$wpdb->prefix}icl_strings AS s LEFT JOIN {$wpdb->prefix}icl_string_translations AS tr ON s.id = tr.string_id WHERE s.name = %s AND s.value = %s AND tr.status = %s", 'URL slug: ' . $slug, $slug, ICL_STRING_TRANSLATION_COMPLETE));
|
346 |
$miss_slug_lang = array();
|
347 |
|
348 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
349 |
|
350 |
$context_ob = icl_st_get_context( 'WordPress' );
|
351 |
if($context_ob){
|
369 |
|
370 |
function product_permalink_slug(){
|
371 |
$permalinks = get_option( 'woocommerce_permalinks' );
|
372 |
+
$slug = empty( $permalinks['product_base'] ) ? 'product' : trim($permalinks['product_base'],'/');
|
373 |
|
374 |
return $slug;
|
375 |
}
|
376 |
|
377 |
function get_wc_context_language(){
|
378 |
|
379 |
+
if ( WPML_SUPPORT_STRINGS_IN_DIFF_LANG ) {
|
380 |
|
381 |
+
$context_ob = icl_st_get_context( 'woocommerce' );
|
382 |
if($context_ob){
|
383 |
$context_language = $context_ob->language;
|
384 |
}else{
|
menu/management.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//actions
|
3 |
global $woocommerce_wpml, $sitepress,$wpdb,$wp_taxonomies;
|
4 |
|
5 |
-
$
|
6 |
$active_languages = $sitepress->get_active_languages();
|
7 |
|
8 |
$all_products_taxonomies = array();
|
2 |
//actions
|
3 |
global $woocommerce_wpml, $sitepress,$wpdb,$wp_taxonomies;
|
4 |
|
5 |
+
$current_language = $sitepress->get_current_language();
|
6 |
$active_languages = $sitepress->get_active_languages();
|
7 |
|
8 |
$all_products_taxonomies = array();
|
menu/sub/currency-switcher-options.php
CHANGED
@@ -27,7 +27,7 @@ $currency_switcher_style = isset($settings['currency_switcher_style'])?$settings
|
|
27 |
?>
|
28 |
<ul id="wcml_currencies_order">
|
29 |
<?php foreach($currencies as $currency): ?>
|
30 |
-
<li class="wcml_currencies_order_<?php echo $currency ?>" ><?php echo $wc_currencies[$currency].' ('.get_woocommerce_currency_symbol($currency).')'; ?></li>
|
31 |
<?php endforeach; ?>
|
32 |
</ul>
|
33 |
<span style="display:none;" class="wcml_currencies_order_ajx_resp"></span>
|
27 |
?>
|
28 |
<ul id="wcml_currencies_order">
|
29 |
<?php foreach($currencies as $currency): ?>
|
30 |
+
<li class="wcml_currencies_order_<?php echo $currency ?>" cur="<?php echo $currency ?>" ><?php echo $wc_currencies[$currency].' ('.get_woocommerce_currency_symbol($currency).')'; ?></li>
|
31 |
<?php endforeach; ?>
|
32 |
</ul>
|
33 |
<span style="display:none;" class="wcml_currencies_order_ajx_resp"></span>
|
menu/sub/product-data.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
$product_id =
|
3 |
$product_images = $woocommerce_wpml->products->product_images_ids($product->ID);
|
4 |
$product_contents = $woocommerce_wpml->products->get_product_contents($product_id);
|
5 |
$trid = $sitepress->get_element_trid($product_id,'post_'.$product->post_type);
|
@@ -12,7 +12,7 @@ if(!current_user_can('wpml_operate_woocommerce_multilingual')){
|
|
12 |
$lang_codes = array();
|
13 |
foreach ($active_languages as $language) {
|
14 |
if($default_language == $language['code'] || current_user_can('wpml_manage_woocommerce_multilingual') || (wpml_check_user_is_translator($default_language,$language['code']) && !current_user_can('wpml_manage_woocommerce_multilingual')) ){
|
15 |
-
if(!isset($_GET['slang']) || (isset($_GET['slang']) && ($_GET['slang'] == $language['code'] || $default_language == $language['code']
|
16 |
$lang_codes[$language['code']] = $language['display_name'];
|
17 |
}
|
18 |
}
|
@@ -101,7 +101,6 @@ $button_labels = array(
|
|
101 |
foreach ($product_contents as $product_content) : ?>
|
102 |
<td>
|
103 |
<?php
|
104 |
-
|
105 |
$trn_contents = $woocommerce_wpml->products->get_product_content_translation($product_id,$product_content,$key);
|
106 |
|
107 |
$missing_translation = false;
|
1 |
<?php
|
2 |
+
$product_id = $product->ID;
|
3 |
$product_images = $woocommerce_wpml->products->product_images_ids($product->ID);
|
4 |
$product_contents = $woocommerce_wpml->products->get_product_contents($product_id);
|
5 |
$trid = $sitepress->get_element_trid($product_id,'post_'.$product->post_type);
|
12 |
$lang_codes = array();
|
13 |
foreach ($active_languages as $language) {
|
14 |
if($default_language == $language['code'] || current_user_can('wpml_manage_woocommerce_multilingual') || (wpml_check_user_is_translator($default_language,$language['code']) && !current_user_can('wpml_manage_woocommerce_multilingual')) ){
|
15 |
+
if(!isset($_GET['slang']) || (isset($_GET['slang']) && ($_GET['slang'] == $language['code'] || $default_language == $language['code'])))
|
16 |
$lang_codes[$language['code']] = $language['display_name'];
|
17 |
}
|
18 |
}
|
101 |
foreach ($product_contents as $product_content) : ?>
|
102 |
<td>
|
103 |
<?php
|
|
|
104 |
$trn_contents = $woocommerce_wpml->products->get_product_content_translation($product_id,$product_content,$key);
|
105 |
|
106 |
$missing_translation = false;
|
menu/sub/products.php
CHANGED
@@ -7,7 +7,12 @@ $pagination_url = 'admin.php?page=wpml-wcml&tab=products&paged=';
|
|
7 |
$translator_id = false;
|
8 |
|
9 |
if(isset($_GET['prid'])){
|
|
|
|
|
|
|
|
|
10 |
$products[] = get_post($_GET['prid']);
|
|
|
11 |
$products_count = 1;
|
12 |
$pr_edit = true;
|
13 |
}
|
@@ -32,21 +37,21 @@ if( !current_user_can('wpml_operate_woocommerce_multilingual') ) {
|
|
32 |
|
33 |
}
|
34 |
|
|
|
|
|
35 |
if(!isset($products) && isset($_GET['s']) && isset($_GET['cat']) && isset($_GET['trst']) && isset($_GET['st']) && isset($_GET['slang'])){
|
36 |
-
$products_data = $
|
37 |
$products = $products_data['products'];
|
38 |
$products_count = $products_data['count'];
|
39 |
$search = true;
|
40 |
$pagination_url = 'admin.php?page=wpml-wcml&tab=products&s='.$_GET['s'].'&cat='.$_GET['cat'].'&trst='.$_GET['trst'].'&st='.$_GET['st'].'&slang='.$_GET['slang'].'&paged=';
|
41 |
}
|
42 |
|
43 |
-
$current_language = $sitepress->get_current_language();
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
$products = $woocommerce_wpml->products->get_product_list($pn, $lm);
|
48 |
-
$products_count = $woocommerce_wpml->products->get_products_count();
|
49 |
-
}
|
50 |
}
|
51 |
|
52 |
if($lm){
|
@@ -66,10 +71,28 @@ $woocommerce_wpml->update_settings();
|
|
66 |
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
|
67 |
<?php if(!isset($_GET['prid']) && !$translator_id): ?>
|
68 |
<div class="wcml_prod_filters">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
<select class="wcml_product_category">
|
70 |
<option value="0"><?php _e('Any category', 'wpml-wcml'); ?></option>
|
71 |
<?php
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
foreach ($product_categories as $category) {
|
74 |
$selected = (isset($_GET['cat']) && $_GET['cat'] == $category->term_taxonomy_id)?'selected="selected"':'';
|
75 |
echo '<option value="'.$category->term_taxonomy_id.'" '.$selected.'>'.$category->name.'</option>';
|
@@ -95,15 +118,6 @@ $woocommerce_wpml->update_settings();
|
|
95 |
<option value="<?php echo $key; ?>" <?php echo (isset($_GET['st']) && $_GET['st']==$key)?'selected="selected"':''; ?> ><?php echo ucfirst($status); ?></option>
|
96 |
<?php endforeach; ?>
|
97 |
</select>
|
98 |
-
|
99 |
-
<select class="wcml_translation_status_lang">
|
100 |
-
<option value="all"><?php _e('All languages', 'wpml-wcml') ?></option>
|
101 |
-
<?php foreach($active_languages as $lang): ?>
|
102 |
-
<?php if($default_language != $lang['code']): ?>
|
103 |
-
<option value="<?php echo $lang['code'] ?>" <?php echo (isset($_GET['slang']) && $_GET['slang']==$lang['code'])?'selected="selected"':''; ?> ><?php echo $lang['display_name'] ?></option>
|
104 |
-
<?php endif; ?>
|
105 |
-
<?php endforeach; ?>
|
106 |
-
</select>
|
107 |
</div>
|
108 |
|
109 |
<div>
|
@@ -133,7 +147,6 @@ $woocommerce_wpml->update_settings();
|
|
133 |
<?php endif; ?>
|
134 |
</div>
|
135 |
<?php endif; ?>
|
136 |
-
<input type="hidden" class="icl_def_language" value="<?php echo $default_language ?>" />
|
137 |
<input type="hidden" id="upd_product_nonce" value="<?php echo wp_create_nonce('update_product_actions'); ?>" />
|
138 |
<input type="hidden" id="get_product_data_nonce" value="<?php echo wp_create_nonce('wcml_product_data'); ?>" />
|
139 |
|
@@ -142,7 +155,7 @@ $woocommerce_wpml->update_settings();
|
|
142 |
<tr>
|
143 |
<th scope="col" width="5%"><?php _e('Type', 'wpml-wcml') ?></th>
|
144 |
<th scope="col" width="20%"><?php _e('Product', 'wpml-wcml') ?></th>
|
145 |
-
<th scope="col" width="75%"><?php echo $woocommerce_wpml->products->get_translation_flags($active_languages,$
|
146 |
</tr>
|
147 |
</thead>
|
148 |
<tbody>
|
@@ -150,9 +163,19 @@ $woocommerce_wpml->update_settings();
|
|
150 |
<tr><td colspan="4"><h3 class="wcml_no_found_text"><?php _e('No products found','wpml-wcml'); ?></h3></td></tr>
|
151 |
<?php else: ?>
|
152 |
<?php foreach ($products as $product) :
|
153 |
-
|
154 |
-
$trid = $sitepress->get_element_trid($product_id,'post_'.$product->post_type);
|
155 |
$product_translations = $sitepress->get_element_translations($trid,'post_'.$product->post_type,true,true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
?>
|
157 |
<tr>
|
158 |
<td>
|
@@ -170,6 +193,9 @@ $woocommerce_wpml->update_settings();
|
|
170 |
</td>
|
171 |
<td>
|
172 |
<?php echo $product->post_parent != 0 ? '— ' : ''; ?>
|
|
|
|
|
|
|
173 |
<?php echo $product->post_title;
|
174 |
if($product->post_status == 'draft' && ((isset($_GET['st']) && $_GET['st'] != 'draft') || !isset($_GET['st']))): ?>
|
175 |
<span class="wcml_product_status_text"><?php _e(' (draft)','wpml-wcml'); ?></span>
|
@@ -180,7 +206,7 @@ $woocommerce_wpml->update_settings();
|
|
180 |
</td>
|
181 |
<td>
|
182 |
<div class="translations_statuses prid_<?php echo $product->ID; ?>">
|
183 |
-
<?php echo $woocommerce_wpml->products->get_translation_statuses($product_translations,$active_languages,$
|
184 |
</div>
|
185 |
<span class="spinner"></span>
|
186 |
<a href="#prid_<?php echo $product->ID; ?>" id="wcml_details_<?php echo $product->ID; ?>" class="wcml_details" data-text-opened="<?php _e('Close', 'wpml-wcml') ?>" data-text-closed="<?php _e('Edit translation', 'wpml-wcml') ?>"><?php _e('Edit translation', 'wpml-wcml') ?></a>
|
7 |
$translator_id = false;
|
8 |
|
9 |
if(isset($_GET['prid'])){
|
10 |
+
if( !$woocommerce_wpml->products->is_original_product($_GET['prid']) ){
|
11 |
+
$original_language = $this->products->get_original_product_language($_GET['prid']);
|
12 |
+
$products[] = get_post(icl_object_id($_GET['prid'],'product',true,$original_language));
|
13 |
+
}else{
|
14 |
$products[] = get_post($_GET['prid']);
|
15 |
+
}
|
16 |
$products_count = 1;
|
17 |
$pr_edit = true;
|
18 |
}
|
37 |
|
38 |
}
|
39 |
|
40 |
+
$slang = isset($_GET['slang']) && $_GET['slang'] != 'all'? $_GET['slang']: false;
|
41 |
+
|
42 |
if(!isset($products) && isset($_GET['s']) && isset($_GET['cat']) && isset($_GET['trst']) && isset($_GET['st']) && isset($_GET['slang'])){
|
43 |
+
$products_data = $woocommerce_wpml->products->get_products_from_filter($_GET['s'],$_GET['cat'],$_GET['trst'],$_GET['st'],$slang,$pn,$lm);
|
44 |
$products = $products_data['products'];
|
45 |
$products_count = $products_data['count'];
|
46 |
$search = true;
|
47 |
$pagination_url = 'admin.php?page=wpml-wcml&tab=products&s='.$_GET['s'].'&cat='.$_GET['cat'].'&trst='.$_GET['trst'].'&st='.$_GET['st'].'&slang='.$_GET['slang'].'&paged=';
|
48 |
}
|
49 |
|
|
|
50 |
|
51 |
+
|
52 |
+
if(!isset($products) && current_user_can('wpml_operate_woocommerce_multilingual')){
|
53 |
+
$products = $woocommerce_wpml->products->get_product_list($pn, $lm, $slang);
|
54 |
+
$products_count = $woocommerce_wpml->products->get_products_count($slang);
|
|
|
55 |
}
|
56 |
|
57 |
if($lm){
|
71 |
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
|
72 |
<?php if(!isset($_GET['prid']) && !$translator_id): ?>
|
73 |
<div class="wcml_prod_filters">
|
74 |
+
<select class="wcml_translation_status_lang">
|
75 |
+
<option value="all" <?php echo !$slang?'selected="selected"':''; ?> ><?php _e('All languages','wpml-wcml'); ?></option>
|
76 |
+
<?php foreach($active_languages as $lang): ?>
|
77 |
+
<option value="<?php echo $lang['code'] ?>" <?php echo ($slang == $lang['code'])?'selected="selected"':''; ?> ><?php echo $lang['display_name'] ?></option>
|
78 |
+
<?php endforeach; ?>
|
79 |
+
</select>
|
80 |
+
|
81 |
<select class="wcml_product_category">
|
82 |
<option value="0"><?php _e('Any category', 'wpml-wcml'); ?></option>
|
83 |
<?php
|
84 |
+
$sql = "SELECT tt.term_taxonomy_id,tt.term_id,t.name FROM $wpdb->term_taxonomy AS tt
|
85 |
+
LEFT JOIN $wpdb->terms AS t ON tt.term_id = t.term_id
|
86 |
+
LEFT JOIN {$wpdb->prefix}icl_translations AS icl ON icl.element_id = tt.term_taxonomy_id
|
87 |
+
WHERE tt.taxonomy = 'product_cat' AND icl.element_type= 'tax_product_cat' ";
|
88 |
+
|
89 |
+
if( $slang ){
|
90 |
+
$sql .= " AND icl.language_code = '".$slang."'";
|
91 |
+
}else{
|
92 |
+
$sql .= "AND icl.source_language_code IS NULL";
|
93 |
+
}
|
94 |
+
|
95 |
+
$product_categories = $wpdb->get_results($sql);
|
96 |
foreach ($product_categories as $category) {
|
97 |
$selected = (isset($_GET['cat']) && $_GET['cat'] == $category->term_taxonomy_id)?'selected="selected"':'';
|
98 |
echo '<option value="'.$category->term_taxonomy_id.'" '.$selected.'>'.$category->name.'</option>';
|
118 |
<option value="<?php echo $key; ?>" <?php echo (isset($_GET['st']) && $_GET['st']==$key)?'selected="selected"':''; ?> ><?php echo ucfirst($status); ?></option>
|
119 |
<?php endforeach; ?>
|
120 |
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
</div>
|
122 |
|
123 |
<div>
|
147 |
<?php endif; ?>
|
148 |
</div>
|
149 |
<?php endif; ?>
|
|
|
150 |
<input type="hidden" id="upd_product_nonce" value="<?php echo wp_create_nonce('update_product_actions'); ?>" />
|
151 |
<input type="hidden" id="get_product_data_nonce" value="<?php echo wp_create_nonce('wcml_product_data'); ?>" />
|
152 |
|
155 |
<tr>
|
156 |
<th scope="col" width="5%"><?php _e('Type', 'wpml-wcml') ?></th>
|
157 |
<th scope="col" width="20%"><?php _e('Product', 'wpml-wcml') ?></th>
|
158 |
+
<th scope="col" width="75%"><?php echo $woocommerce_wpml->products->get_translation_flags($active_languages,$slang); ?></th>
|
159 |
</tr>
|
160 |
</thead>
|
161 |
<tbody>
|
163 |
<tr><td colspan="4"><h3 class="wcml_no_found_text"><?php _e('No products found','wpml-wcml'); ?></h3></td></tr>
|
164 |
<?php else: ?>
|
165 |
<?php foreach ($products as $product) :
|
166 |
+
$trid = $sitepress->get_element_trid($product->ID,'post_'.$product->post_type);
|
|
|
167 |
$product_translations = $sitepress->get_element_translations($trid,'post_'.$product->post_type,true,true);
|
168 |
+
if(!$slang){
|
169 |
+
foreach($product_translations as $lang_code=>$translation){
|
170 |
+
if($translation->original){
|
171 |
+
$original_lang = $lang_code;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
} else{
|
175 |
+
$original_lang = $slang;
|
176 |
+
}
|
177 |
+
$product_id = icl_object_id($product->ID,'product',true,$original_lang);
|
178 |
+
|
179 |
?>
|
180 |
<tr>
|
181 |
<td>
|
193 |
</td>
|
194 |
<td>
|
195 |
<?php echo $product->post_parent != 0 ? '— ' : ''; ?>
|
196 |
+
<?php if(!$slang): ?>
|
197 |
+
<img src="<?php echo ICL_PLUGIN_URL.'/res/flags/'. $original_lang .'.png'; ?>" width="18" height="12" class="flag_img" />
|
198 |
+
<?php endif; ?>
|
199 |
<?php echo $product->post_title;
|
200 |
if($product->post_status == 'draft' && ((isset($_GET['st']) && $_GET['st'] != 'draft') || !isset($_GET['st']))): ?>
|
201 |
<span class="wcml_product_status_text"><?php _e(' (draft)','wpml-wcml'); ?></span>
|
206 |
</td>
|
207 |
<td>
|
208 |
<div class="translations_statuses prid_<?php echo $product->ID; ?>">
|
209 |
+
<?php echo $woocommerce_wpml->products->get_translation_statuses($product_translations,$active_languages,$slang,$trid,$translator_id); ?>
|
210 |
</div>
|
211 |
<span class="spinner"></span>
|
212 |
<a href="#prid_<?php echo $product->ID; ?>" id="wcml_details_<?php echo $product->ID; ?>" class="wcml_details" data-text-opened="<?php _e('Close', 'wpml-wcml') ?>" data-text-closed="<?php _e('Edit translation', 'wpml-wcml') ?>"><?php _e('Edit translation', 'wpml-wcml') ?></a>
|
menu/sub/settings.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php global $sitepress_settings
|
2 |
$default_language = $sitepress->get_default_language();
|
3 |
?>
|
4 |
|
@@ -43,7 +43,7 @@ $default_language = $sitepress->get_default_language();
|
|
43 |
$miss_slug_lang = $woocommerce_wpml->strings->get_missed_product_slag_translations_languages();
|
44 |
$prod_slug = $woocommerce_wpml->strings->product_permalink_slug();
|
45 |
|
46 |
-
if( (
|
47 |
<div class="wcml-section">
|
48 |
<div class="wcml-section-header">
|
49 |
<h3>
|
@@ -56,11 +56,11 @@ if( ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSI
|
|
56 |
|
57 |
<?php if( !empty( $miss_slug_lang ) ): ?>
|
58 |
|
59 |
-
<p><i class="icon-warning-sign"></i><?php printf(__("Your product permalink base is not translated in %s. The urls for the translated products will not work. Go to the %sString Translation%s to translate.", 'wpml-wcml'), '<b>'. implode(', ',$miss_slug_lang).'</b>' ,'<a href="'.admin_url('admin.php?page='.WPML_ST_FOLDER.'/menu/string-translation.php&search='.$prod_slug.'&context=WordPress').'">', '</a>') ?> </p>
|
60 |
|
61 |
<?php endif;?>
|
62 |
|
63 |
-
<?php if(
|
64 |
|
65 |
<?php if($sitepress_settings['st']['strings_language'] != 'en'): ?>
|
66 |
<p><i class="icon-warning-sign"></i><strong><?php _e('Attention required: probable problem with URLs in different languages', 'wpml-wcml') ?></strong></p>
|
@@ -134,20 +134,37 @@ if( ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSI
|
|
134 |
<?php wp_nonce_field('create_pages', 'wcml_nonce'); ?>
|
135 |
<input type="hidden" name="create_missing_pages" value="1"/>
|
136 |
<div class="wcml_miss_lang">
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
</div>
|
152 |
<p>
|
153 |
<a id="wcmp_show" class="none" href="javascript:void(0);"><?php _e('Show details about missing translations', 'wpml-wcml') ?></a>
|
@@ -273,6 +290,10 @@ if( ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSI
|
|
273 |
<input type="checkbox" name="products_sync_date" value="1" <?php echo checked(1, $woocommerce_wpml->settings['products_sync_date']) ?> id="wcml_products_sync_date" />
|
274 |
<label for="wcml_products_sync_date"><?php _e('Sync publishing date for translated products.', 'wpml-wcml'); ?></label>
|
275 |
</li>
|
|
|
|
|
|
|
|
|
276 |
</ul>
|
277 |
<p class="button-wrap">
|
278 |
<input type='submit' name="wcml_products_sync_prop" value='<?php esc_attr(_e('Save', 'wpml-wcml')); ?>' class='button-secondary' />
|
1 |
+
<?php global $sitepress_settings;
|
2 |
$default_language = $sitepress->get_default_language();
|
3 |
?>
|
4 |
|
43 |
$miss_slug_lang = $woocommerce_wpml->strings->get_missed_product_slag_translations_languages();
|
44 |
$prod_slug = $woocommerce_wpml->strings->product_permalink_slug();
|
45 |
|
46 |
+
if( ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en' && ( $sitepress_settings['st']['strings_language'] != 'en' || empty( $woocommerce_wpml->settings['dismiss_non_default_language_warning'] ) ) ) || !empty($woocommerce_wpml->dependencies->xml_config_errors) || !empty($miss_slug_lang) ): ?>
|
47 |
<div class="wcml-section">
|
48 |
<div class="wcml-section-header">
|
49 |
<h3>
|
56 |
|
57 |
<?php if( !empty( $miss_slug_lang ) ): ?>
|
58 |
|
59 |
+
<p><i class="icon-warning-sign"></i><?php printf(__("Your product permalink base is not translated in %s. The urls for the translated products will not work. Go to the %sString Translation%s to translate.", 'wpml-wcml'), '<b>'. implode(', ',$miss_slug_lang).'</b>' ,'<a href="'.admin_url('admin.php?page='.WPML_ST_FOLDER.'/menu/string-translation.php&search='.$prod_slug.'&context=WordPress&em=1').'">', '</a>') ?> </p>
|
60 |
|
61 |
<?php endif;?>
|
62 |
|
63 |
+
<?php if(!WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en'): ?>
|
64 |
|
65 |
<?php if($sitepress_settings['st']['strings_language'] != 'en'): ?>
|
66 |
<p><i class="icon-warning-sign"></i><strong><?php _e('Attention required: probable problem with URLs in different languages', 'wpml-wcml') ?></strong></p>
|
134 |
<?php wp_nonce_field('create_pages', 'wcml_nonce'); ?>
|
135 |
<input type="hidden" name="create_missing_pages" value="1"/>
|
136 |
<div class="wcml_miss_lang">
|
137 |
+
<p><i class="icon-warning-sign"></i></p>
|
138 |
+
<?php
|
139 |
+
if(isset($miss_lang['codes'])): ?>
|
140 |
+
</p>
|
141 |
+
<?php
|
142 |
+
if(count($miss_lang['codes']) == 1){
|
143 |
+
_e("WooCommerce store pages don't exist for this language:",'wpml-wcml');
|
144 |
+
}else{
|
145 |
+
_e("WooCommerce store pages don't exist for these languages:",'wpml-wcml');
|
146 |
+
}
|
147 |
+
?>
|
148 |
+
</p>
|
149 |
+
<?php endif; ?>
|
150 |
+
|
151 |
+
<?php
|
152 |
+
if(isset($miss_lang['lang'])): ?>
|
153 |
+
<p>
|
154 |
+
<strong><?php echo $miss_lang['lang'] ?></strong>
|
155 |
+
<input class="button" type="submit" name="create_pages" value="<?php esc_attr(_e('Create missing translations.', 'wpml-wcml')) ?>" />
|
156 |
+
</p>
|
157 |
+
<?php endif; ?>
|
158 |
+
|
159 |
+
<?php
|
160 |
+
if(isset($miss_lang['in_progress'])): ?>
|
161 |
+
<p>
|
162 |
+
<?php _e("These pages are currently being translated by translators via WPML: ",'wpml-wcml'); ?>
|
163 |
+
<strong><?php echo $miss_lang['in_progress'] ?></strong>
|
164 |
+
</p>
|
165 |
+
<?php endif; ?>
|
166 |
+
|
167 |
+
<a id="wcmp_hide" class="wcmp_lang_hide" href="javascript:void(0);"><?php _e('Hide this message', 'wpml-wcml') ?></a>
|
168 |
</div>
|
169 |
<p>
|
170 |
<a id="wcmp_show" class="none" href="javascript:void(0);"><?php _e('Show details about missing translations', 'wpml-wcml') ?></a>
|
290 |
<input type="checkbox" name="products_sync_date" value="1" <?php echo checked(1, $woocommerce_wpml->settings['products_sync_date']) ?> id="wcml_products_sync_date" />
|
291 |
<label for="wcml_products_sync_date"><?php _e('Sync publishing date for translated products.', 'wpml-wcml'); ?></label>
|
292 |
</li>
|
293 |
+
<li>
|
294 |
+
<input type="checkbox" name="products_sync_order" value="1" <?php echo checked(1, $woocommerce_wpml->settings['products_sync_order']) ?> id="wcml_products_sync_order" />
|
295 |
+
<label for="wcml_products_sync_order"><?php _e('Sync products and product taxonomies order.', 'wpml-wcml'); ?></label>
|
296 |
+
</li>
|
297 |
</ul>
|
298 |
<p class="button-wrap">
|
299 |
<input type='submit' name="wcml_products_sync_prop" value='<?php esc_attr(_e('Save', 'wpml-wcml')); ?>' class='button-secondary' />
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: http://wpml.org/documentation/related-projects/woocommerce-multilin
|
|
4 |
Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
|
5 |
License: GPLv2
|
6 |
Requires at least: 3.0
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag: 3.
|
9 |
|
10 |
Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
|
11 |
|
@@ -78,6 +78,24 @@ In order for the checkout and store pages to appear translated, you need to crea
|
|
78 |
|
79 |
== Changelog ==
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
= 3.4.3 =
|
82 |
* Bug fixed: Incorrect decimal separator for prices on WordPress admin
|
83 |
* Bug fixed: ‘Insert link’ button not working on products translator interface.
|
4 |
Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
|
5 |
License: GPLv2
|
6 |
Requires at least: 3.0
|
7 |
+
Tested up to: 4.1
|
8 |
+
Stable tag: 3.5
|
9 |
|
10 |
Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
|
11 |
|
78 |
|
79 |
== Changelog ==
|
80 |
|
81 |
+
= 3.5 =
|
82 |
+
* Added support for creating products in secondary languages only.
|
83 |
+
* Added enhancements for the Woocommerce Multilingual products table (filter by original language, display language flag).
|
84 |
+
* Added option to synchronize the products and product taxonomies order.
|
85 |
+
* Bug fixed: The cart was not updating quantities for variable product (when have more than one variable in the cart).
|
86 |
+
* Bug fixed: The cart total was not updating when using get_cart_total() and get_cart_subtotal() functions in other plugins or themes.
|
87 |
+
* Bug fixed: Wrong price format and order total were displayed on the new order page in the WP admin
|
88 |
+
* Bug fixed: The featured image and the gallery images were overridden when updating translations
|
89 |
+
* Bug fixed: Fixed the 'Keep' option that allows keeping the same currency on teh front end, when switching the language.
|
90 |
+
* Bug fixed: Fixed a javascript error that was showing when changing currencies order
|
91 |
+
* Bug fixed: The decimal number was not working correctly for the default currency
|
92 |
+
* Bug fixed: Fixed a compatibility problem with WooCommerce Product Tabs
|
93 |
+
* Bug fixed: A coupon was applied incorrectly to all products in the cart when they were defined for specific product variations.
|
94 |
+
* Bug fixed: WooCommerce note email language was not correct
|
95 |
+
* Bug fixed: WooCommerce reports were showing duplicate products
|
96 |
+
* Bug fixed: When using WordPress in a folder, the checkout showed an 'expired session' error message.
|
97 |
+
* Added support currency argument in raw_price_filter
|
98 |
+
|
99 |
= 3.4.3 =
|
100 |
* Bug fixed: Incorrect decimal separator for prices on WordPress admin
|
101 |
* Bug fixed: ‘Insert link’ button not working on products translator interface.
|
woocommerce_wpml.class.php
CHANGED
@@ -98,8 +98,9 @@ class woocommerce_wpml {
|
|
98 |
remove_action( 'wp_before_admin_bar_render', array($sitepress, 'admin_language_switcher') );
|
99 |
}
|
100 |
|
101 |
-
if((
|
102 |
-
|
|
|
103 |
add_action('init', array($this, 'load_lock_fields_js'));
|
104 |
add_action( 'admin_footer', array($this,'hidden_label'));
|
105 |
}
|
@@ -132,7 +133,7 @@ class woocommerce_wpml {
|
|
132 |
return;
|
133 |
}
|
134 |
|
135 |
-
$slug = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
|
136 |
|
137 |
$string = $wpdb->get_row($wpdb->prepare("SELECT id,status FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'URL slug: ' . $slug, $slug));
|
138 |
|
@@ -222,6 +223,10 @@ class woocommerce_wpml {
|
|
222 |
if(!isset($this->settings['products_sync_date'])){
|
223 |
$this->settings['products_sync_date'] = 1;
|
224 |
}
|
|
|
|
|
|
|
|
|
225 |
|
226 |
self::set_up_capabilities();
|
227 |
|
@@ -280,31 +285,35 @@ class woocommerce_wpml {
|
|
280 |
$products = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type = 'product' AND post_status <> 'auto-draft'");
|
281 |
foreach($products as $product){
|
282 |
$exist = $sitepress->get_language_for_element($product->ID,'post_product');
|
283 |
-
if(!$exist)
|
284 |
$sitepress->set_element_language_details($product->ID, 'post_product',false,$def_lang);
|
285 |
}
|
|
|
286 |
|
287 |
//set language info for taxonomies
|
288 |
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_cat'");
|
289 |
foreach($terms as $term){
|
290 |
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_cat');
|
291 |
-
if(!$exist)
|
292 |
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_cat',false,$def_lang);
|
293 |
}
|
|
|
294 |
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_tag'");
|
295 |
foreach($terms as $term){
|
296 |
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_tag');
|
297 |
-
if(!$exist)
|
298 |
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_tag',false,$def_lang);
|
299 |
}
|
|
|
300 |
|
301 |
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_shipping_class'");
|
302 |
foreach($terms as $term){
|
303 |
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_shipping_class');
|
304 |
-
if(!$exist)
|
305 |
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_shipping_class',false,$def_lang);
|
306 |
}
|
307 |
}
|
|
|
308 |
|
309 |
function menu(){
|
310 |
if($this->dependencies->check()){
|
@@ -411,16 +420,15 @@ class woocommerce_wpml {
|
|
411 |
function hidden_label(){
|
412 |
echo '<img src="'.WCML_PLUGIN_URL.'/assets/images/locked.png" class="wcml_lock_img" alt="'.__('This field is locked for editing because WPML will copy its value from the original language.','wpml-wcml').'" title="'.__('This field is locked for editing because WPML will copy its value from the original language.','wpml-wcml').'" style="display: none;position:relative;left:2px;top:2px;">';
|
413 |
|
414 |
-
if($
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
<?php }
|
424 |
}
|
425 |
|
426 |
function generate_tracking_link($link,$term=false,$content = false, $id = false){
|
@@ -443,10 +451,17 @@ class woocommerce_wpml {
|
|
443 |
|
444 |
if($get_post_type == 'product' && $pagenow == 'edit.php'){
|
445 |
$prot_link = '<span class="button" style="padding:4px;margin-top:10px;"><img align="baseline" src="' . ICL_PLUGIN_URL .'/res/img/icon16.png" width="16" height="16" style="margin-bottom:-4px" /> <a href="'. $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation','#4') .'" target="_blank">' .
|
446 |
-
__('How to translate products', 'sitepress') . '<\/a>' . '<\/span>'
|
|
|
|
|
447 |
?>
|
448 |
<script type="text/javascript">
|
449 |
jQuery(".subsubsub").append('<?php echo $prot_link ?>');
|
|
|
|
|
|
|
|
|
|
|
450 |
</script>
|
451 |
<?php
|
452 |
}
|
@@ -456,7 +471,7 @@ class woocommerce_wpml {
|
|
456 |
|
457 |
if($pos !== false && $pagenow == 'edit-tags.php'){
|
458 |
$prot_link = '<span class="button" style="padding:4px;margin-top:0px; float: left;"><img align="baseline" src="' . ICL_PLUGIN_URL .'/res/img/icon16.png" width="16" height="16" style="margin-bottom:-4px" /> <a href="'. $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation','#3') .'" target="_blank" style="text-decoration: none;">' .
|
459 |
-
__('How to translate attributes', 'sitepress') . '<\/a>' . '<\/span><br \/><br \/>'
|
460 |
?>
|
461 |
<script type="text/javascript">
|
462 |
jQuery("table.widefat").before('<?php echo $prot_link ?>');
|
@@ -468,7 +483,7 @@ class woocommerce_wpml {
|
|
468 |
if(isset($_GET['taxonomy']) && $_GET['taxonomy'] == 'product_cat'){
|
469 |
|
470 |
$prot_link = '<span class="button" style="padding:4px;margin-top:0px; float: left;"><img align="baseline" src="' . ICL_PLUGIN_URL .'/res/img/icon16.png" width="16" height="16" style="margin-bottom:-4px" /> <a href="'. $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation','#3') .'" target="_blank" style="text-decoration: none;">' .
|
471 |
-
__('How to translate product categories', 'sitepress') . '<\/a>' . '<\/span><br \/><br \/>'
|
472 |
?>
|
473 |
<script type="text/javascript">
|
474 |
jQuery("table.widefat").before('<?php echo $prot_link ?>');
|
@@ -510,22 +525,23 @@ class woocommerce_wpml {
|
|
510 |
global $wpdb, $sitepress_settings;
|
511 |
|
512 |
if(isset($value['product_base']) && $value['product_base']){
|
513 |
-
icl_register_string('
|
514 |
// only register. it'll have to be translated via the string translation
|
515 |
}
|
516 |
|
517 |
-
$category_base = !empty($value['category_base']) ?
|
518 |
icl_register_string('URL product_cat slugs - ' . $category_base, 'Url product_cat slug: ' . $category_base, $category_base );
|
519 |
|
520 |
-
$tag_base = !empty($value['tag_base']) ?
|
521 |
icl_register_string('URL product_tag slugs - ' . $tag_base, 'Url product_tag slug: ' . $tag_base, $tag_base);
|
522 |
|
523 |
if(isset($value['attribute_base']) && $value['attribute_base']){
|
524 |
-
|
|
|
525 |
}
|
526 |
|
527 |
if(isset($value['product_base']) && !$value['product_base']){
|
528 |
-
$value['product_base'] = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
|
529 |
}
|
530 |
|
531 |
return $value;
|
98 |
remove_action( 'wp_before_admin_bar_render', array($sitepress, 'admin_language_switcher') );
|
99 |
}
|
100 |
|
101 |
+
if( ($pagenow == 'post.php' && isset($_GET['post']) && get_post_type($_GET['post']) == 'product' && !$this->products->is_original_product($_GET['post'])) ||
|
102 |
+
($pagenow == 'post-new.php' && isset($_GET['source_lang']) )
|
103 |
+
&& !$this->settings['trnsl_interface']){
|
104 |
add_action('init', array($this, 'load_lock_fields_js'));
|
105 |
add_action( 'admin_footer', array($this,'hidden_label'));
|
106 |
}
|
133 |
return;
|
134 |
}
|
135 |
|
136 |
+
$slug = get_option('woocommerce_product_slug') != false ? trim( get_option('woocommerce_product_slug'), '/') : 'product';
|
137 |
|
138 |
$string = $wpdb->get_row($wpdb->prepare("SELECT id,status FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'URL slug: ' . $slug, $slug));
|
139 |
|
223 |
if(!isset($this->settings['products_sync_date'])){
|
224 |
$this->settings['products_sync_date'] = 1;
|
225 |
}
|
226 |
+
|
227 |
+
if(!isset($this->settings['products_sync_order'])){
|
228 |
+
$this->settings['products_sync_order'] = 1;
|
229 |
+
}
|
230 |
|
231 |
self::set_up_capabilities();
|
232 |
|
285 |
$products = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type = 'product' AND post_status <> 'auto-draft'");
|
286 |
foreach($products as $product){
|
287 |
$exist = $sitepress->get_language_for_element($product->ID,'post_product');
|
288 |
+
if(!$exist){
|
289 |
$sitepress->set_element_language_details($product->ID, 'post_product',false,$def_lang);
|
290 |
}
|
291 |
+
}
|
292 |
|
293 |
//set language info for taxonomies
|
294 |
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_cat'");
|
295 |
foreach($terms as $term){
|
296 |
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_cat');
|
297 |
+
if(!$exist){
|
298 |
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_cat',false,$def_lang);
|
299 |
}
|
300 |
+
}
|
301 |
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_tag'");
|
302 |
foreach($terms as $term){
|
303 |
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_tag');
|
304 |
+
if(!$exist){
|
305 |
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_tag',false,$def_lang);
|
306 |
}
|
307 |
+
}
|
308 |
|
309 |
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_shipping_class'");
|
310 |
foreach($terms as $term){
|
311 |
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_shipping_class');
|
312 |
+
if(!$exist){
|
313 |
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_shipping_class',false,$def_lang);
|
314 |
}
|
315 |
}
|
316 |
+
}
|
317 |
|
318 |
function menu(){
|
319 |
if($this->dependencies->check()){
|
420 |
function hidden_label(){
|
421 |
echo '<img src="'.WCML_PLUGIN_URL.'/assets/images/locked.png" class="wcml_lock_img" alt="'.__('This field is locked for editing because WPML will copy its value from the original language.','wpml-wcml').'" title="'.__('This field is locked for editing because WPML will copy its value from the original language.','wpml-wcml').'" style="display: none;position:relative;left:2px;top:2px;">';
|
422 |
|
423 |
+
if( isset($_GET['post']) ){
|
424 |
+
$original_language = $this->products->get_original_product_language($_GET['post']);
|
425 |
+
$original_id = icl_object_id($_GET['post'],'product',true,$original_language);
|
426 |
+
}elseif( isset($_GET['trid']) ){
|
427 |
+
global $sitepress;
|
428 |
+
$original_id = $sitepress->get_original_element_id_by_trid( $_GET['trid'] );
|
429 |
+
}
|
430 |
+
|
431 |
+
echo '<h3 class="wcml_prod_hidden_notice">'.sprintf(__("This is a translation of %s. Some of the fields are not editable. It's recommended to use the %s for translating products.",'wpml-wcml'),'<a href="'.get_edit_post_link($original_id).'" >'.get_the_title($original_id).'</a>','<a href="'.admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$original_id).'" >'.__('WooCommerce Multilingual products translator','wpml-wcml').'</a>').'</h3>';
|
|
|
432 |
}
|
433 |
|
434 |
function generate_tracking_link($link,$term=false,$content = false, $id = false){
|
451 |
|
452 |
if($get_post_type == 'product' && $pagenow == 'edit.php'){
|
453 |
$prot_link = '<span class="button" style="padding:4px;margin-top:10px;"><img align="baseline" src="' . ICL_PLUGIN_URL .'/res/img/icon16.png" width="16" height="16" style="margin-bottom:-4px" /> <a href="'. $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation','#4') .'" target="_blank">' .
|
454 |
+
__('How to translate products', 'sitepress') . '<\/a>' . '<\/span>';
|
455 |
+
$quick_edit_notice = '<div id="quick_edit_notice" style="display:none;"><p>'. sprintf(__("Quick edit is disabled for product translations. It\'s recommended to use the %s for editing products translations. %s",'wpml-wcml'), '<a href="'.admin_url('admin.php?page=wpml-wcml&tab=products').'" >'.__('WooCommerce Multilingual products editor','wpml-wcml').'</a>','<a href="" class="quick_product_trnsl_link" >'.__('Edit this product translation','wpml-wcml').'</a>').'</p></div>';
|
456 |
+
$quick_edit_notice_prod_link = '<input type="hidden" id="wcml_product_trnsl_link" value="'.admin_url('admin.php?page=wpml-wcml&tab=products&prid=').'">';
|
457 |
?>
|
458 |
<script type="text/javascript">
|
459 |
jQuery(".subsubsub").append('<?php echo $prot_link ?>');
|
460 |
+
jQuery(".subsubsub").append('<?php echo $quick_edit_notice ?>');
|
461 |
+
jQuery(".subsubsub").append('<?php echo $quick_edit_notice_prod_link ?>');
|
462 |
+
jQuery(".quick_hide a").on('click',function(){
|
463 |
+
jQuery(".quick_product_trnsl_link").attr('href',jQuery("#wcml_product_trnsl_link").val()+jQuery(this).closest('tr').attr('id').replace(/post-/,''));
|
464 |
+
});
|
465 |
</script>
|
466 |
<?php
|
467 |
}
|
471 |
|
472 |
if($pos !== false && $pagenow == 'edit-tags.php'){
|
473 |
$prot_link = '<span class="button" style="padding:4px;margin-top:0px; float: left;"><img align="baseline" src="' . ICL_PLUGIN_URL .'/res/img/icon16.png" width="16" height="16" style="margin-bottom:-4px" /> <a href="'. $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation','#3') .'" target="_blank" style="text-decoration: none;">' .
|
474 |
+
__('How to translate attributes', 'sitepress') . '<\/a>' . '<\/span><br \/><br \/>';
|
475 |
?>
|
476 |
<script type="text/javascript">
|
477 |
jQuery("table.widefat").before('<?php echo $prot_link ?>');
|
483 |
if(isset($_GET['taxonomy']) && $_GET['taxonomy'] == 'product_cat'){
|
484 |
|
485 |
$prot_link = '<span class="button" style="padding:4px;margin-top:0px; float: left;"><img align="baseline" src="' . ICL_PLUGIN_URL .'/res/img/icon16.png" width="16" height="16" style="margin-bottom:-4px" /> <a href="'. $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation','#3') .'" target="_blank" style="text-decoration: none;">' .
|
486 |
+
__('How to translate product categories', 'sitepress') . '<\/a>' . '<\/span><br \/><br \/>';
|
487 |
?>
|
488 |
<script type="text/javascript">
|
489 |
jQuery("table.widefat").before('<?php echo $prot_link ?>');
|
525 |
global $wpdb, $sitepress_settings;
|
526 |
|
527 |
if(isset($value['product_base']) && $value['product_base']){
|
528 |
+
icl_register_string('URL slugs', 'Url slug: ' . trim( $value['product_base'], '/'), trim( $value['product_base'], '/') );
|
529 |
// only register. it'll have to be translated via the string translation
|
530 |
}
|
531 |
|
532 |
+
$category_base = !empty($value['category_base']) ? $value['category_base'] : 'product-category';
|
533 |
icl_register_string('URL product_cat slugs - ' . $category_base, 'Url product_cat slug: ' . $category_base, $category_base );
|
534 |
|
535 |
+
$tag_base = !empty($value['tag_base']) ? $value['tag_base'] : 'product-tag';
|
536 |
icl_register_string('URL product_tag slugs - ' . $tag_base, 'Url product_tag slug: ' . $tag_base, $tag_base);
|
537 |
|
538 |
if(isset($value['attribute_base']) && $value['attribute_base']){
|
539 |
+
$attr_base = trim( $value['attribute_base'], '/');
|
540 |
+
icl_register_string('URL attribute slugs - ' . $attr_base , 'Url attribute slug: ' .$attr_base, $attr_base );
|
541 |
}
|
542 |
|
543 |
if(isset($value['product_base']) && !$value['product_base']){
|
544 |
+
$value['product_base'] = get_option('woocommerce_product_slug') != false ? trim( get_option('woocommerce_product_slug'), '/') : 'product';
|
545 |
}
|
546 |
|
547 |
return $value;
|
wpml-woocommerce.php
CHANGED
@@ -5,17 +5,18 @@
|
|
5 |
Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
|
6 |
Author: OnTheGoSystems
|
7 |
Author URI: http://www.onthegosystems.com/
|
8 |
-
Version: 3.
|
9 |
*/
|
10 |
|
11 |
|
12 |
if(defined('WCML_VERSION')) return;
|
13 |
-
define('WCML_VERSION', '3.
|
14 |
define('WCML_PLUGIN_PATH', dirname(__FILE__));
|
15 |
define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
|
16 |
define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
|
17 |
define('WCML_LOCALE_PATH',WCML_PLUGIN_FOLDER.'/locale');
|
18 |
define('WPML_LOAD_API_SUPPORT',true);
|
|
|
19 |
|
20 |
define('WCML_MULTI_CURRENCIES_DISABLED', 0);
|
21 |
define('WCML_MULTI_CURRENCIES_PER_LANGUAGE', 1); //obsolete - migrate to 2
|
@@ -47,8 +48,8 @@ $woocommerce_wpml = new woocommerce_wpml();
|
|
47 |
}
|
48 |
|
49 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
|
50 |
-
//@since WPML 3.2
|
51 |
-
add_action( '
|
52 |
} else {
|
53 |
//@since 3.3.2 Create instance of WPML_String_Translation using a late 'plugins_loaded' action
|
54 |
add_action('plugins_loaded', 'wpml_wcml_startup', 10000);
|
5 |
Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
|
6 |
Author: OnTheGoSystems
|
7 |
Author URI: http://www.onthegosystems.com/
|
8 |
+
Version: 3.5
|
9 |
*/
|
10 |
|
11 |
|
12 |
if(defined('WCML_VERSION')) return;
|
13 |
+
define('WCML_VERSION', '3.5');
|
14 |
define('WCML_PLUGIN_PATH', dirname(__FILE__));
|
15 |
define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
|
16 |
define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
|
17 |
define('WCML_LOCALE_PATH',WCML_PLUGIN_FOLDER.'/locale');
|
18 |
define('WPML_LOAD_API_SUPPORT',true);
|
19 |
+
define('WPML_SUPPORT_STRINGS_IN_DIFF_LANG', false);
|
20 |
|
21 |
define('WCML_MULTI_CURRENCIES_DISABLED', 0);
|
22 |
define('WCML_MULTI_CURRENCIES_PER_LANGUAGE', 1); //obsolete - migrate to 2
|
48 |
}
|
49 |
|
50 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
|
51 |
+
//@since WPML 3.2 using dependencies hook
|
52 |
+
add_action( 'wpml_loaded', 'wpml_wcml_startup' );
|
53 |
} else {
|
54 |
//@since 3.3.2 Create instance of WPML_String_Translation using a late 'plugins_loaded' action
|
55 |
add_action('plugins_loaded', 'wpml_wcml_startup', 10000);
|