Version Description
- Performance improvements: optimized database queries
- Support rounding rules for converted prices
- More advanced GUI for Multi-currency options
- GUI for currency switchers (including widget)
- Added option to synchronize product category display type & thumbnail
- Performance improvement for WCML_Terms::translate_category_base (avoid switching locales)
- Send admin notifications to admin default language
- Dependencies update: WooCommerce Multilingual requires WPML 3.1.5
- Set language information for existing products when installing WCML the first time.
- Do not allow disabling all currencies for a language
- Removed 'clean up test content' and 'send to translation' dropdown on products editor page
- Message about overwritten settings in wpml-config made more explicit
- Lock 'Default variation' select field in product translations
- After change shipping method on cart page we will see not translated strings
- Fixed bug related to shipping cost calculation in multi-currency mode
- With php magic quotes on, products translations with quotes have backslashes
- Bug related to translation of grouped products simple product not showing up on front end
- Stock actions on the order page don't work correct with translated products
- For Orders save attributes in default language and display them on order page in admin language
- Attribute Label appearing untranslated in backend order
- Memory issues on the Products tab when we have a large number of products
- 'product-category' not translated in the default language.
- 'WCML_Products' does not have a method 'translated_cart_item_name'
- Order completed emails sent in default currency
- Language suffix (e.g. @en) not hidden for product attributes on the front end
- Quick edit functionality issues fixed
- Fixed 'Call to undefined method WC_Session_Handler::get()'
- Fatal error when updating the order status to 'complete'
- Currency is not converted when you switch language until you refresh the page.
- Super Admin not able to see the WCML menu
- Checkout validation errors in default language instead of user language
- Fixes for compatibility with Tab manager: Can't translate Additional Information tab title
- Bug: SEO title & meta description changed to original
- Bug: 404 on 'view my order' on secondary language using 'language name added as a parameter'
- Bug: Permalink placeholders appear translated when using default language different than English
- Fixes for compatibility with Table Rate shipping: shipping classes not decoded correctly in multi-currency mode
- Bug: 'show all products' link on WCML products page points to the wrong page no products
- Bug fix: product page redirecting to homepage when the product post type slug was identical in different languages and 'language added as a parameter' was set
- Bug fixes related to File paths functionality (WooComemrce 2.1.x)
- Bug: Product parents not synced between translations (grouped products)
- Bug: Grouped products title incomplete
- Bug: Db Error when saving translation of variable products with custom attributes
- Bug: WooCommerce translated product attributes with spaces not showing
- Bug: Deactivated currency still appears if you maintain the default currency for that language to 'Keep'.
- Bug: Incorrect shipping value on translated page
- Bug: Reports for products including only products in the current language (WooCommerce 2.1.x)
- Bug: WooCommerce translated product attributes with spaces not showing
- Bug: Problems creating translations for shop pages when existing pages were trashed
- Bug fix: Fatal error when Multi-currency is not enabled and 'Table Rate Shipping' plugin is active
- Fixed bug in compatibility with Tab Manager
- Bug fix: Cart strings falling to default language after updating chosen shipping method
- Bug fix: Reports not including selected product/category translations
Download this release
Release Info
Developer | mihaimihai |
Plugin | WooCommerce Multilingual – run WooCommerce with WPML |
Version | 3.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.2 to 3.3
- assets/css/currency-switcher.css +37 -0
- assets/css/management.css +88 -3
- assets/css/wcml-prices.css +14 -2
- assets/css/wcml-wc-integration.css +2 -0
- assets/js/lock_fields.js +26 -6
- assets/js/prices.js +1 -1
- assets/js/scripts.js +347 -113
- compatibility/templates/bundles_box.php +63 -0
- compatibility/templates/wc_tab_manager_custom_box_html.php +47 -36
- compatibility/wc_dynamic_pricing.class.php +68 -0
- compatibility/wc_exporter.class.php +70 -0
- compatibility/wc_per_product_shipping.class.php +32 -0
- compatibility/wc_product_addons.class.php +71 -0
- compatibility/wc_product_bundles.class.php +240 -0
- compatibility/wc_subscriptions.class.php +13 -1
- compatibility/wc_tab_manager.class.php +142 -56
- compatibility/wc_variation_swatches_photos.class.php +42 -0
- inc/ajax-setup.class.php +4 -2
- inc/compatibility.class.php +35 -1
- inc/currencies.class.php +0 -407
- inc/currency-switcher.class.php +72 -0
- inc/dependencies.class.php +36 -35
- inc/emails.class.php +72 -21
- inc/functions-troubleshooting.class.php +43 -4
- inc/missing-php-functions.php +36 -0
- inc/multi-currency-support.class.php +598 -78
- inc/multi-currency.class.php +175 -122
- inc/orders.class.php +64 -11
- inc/products.class.php +368 -177
- inc/reports.class.php +240 -0
- inc/requests.class.php +11 -0
- inc/store-pages.class.php +71 -22
- inc/terms.class.php +64 -43
- inc/upgrade.class.php +24 -2
- inc/wc-strings.class.php +53 -7
- inc/woocommerce-2.0-backward-compatibility.php +3 -3
- locale/{wpml-wcml-ko_KO.mo → wpml-wcml-ko_KR.mo} +0 -0
- locale/wpml-wcml-ru_RU.mo +0 -0
- locale/{wpml-wcml-vn.mo → wpml-wcml-vi.mo} +0 -0
- menu/plugins.php +11 -5
- menu/sub/currency-switcher-options.php +79 -0
- menu/sub/custom-box.php +1 -1
- menu/sub/custom-currency-options.php +102 -0
- menu/sub/custom-prices.php +39 -32
- menu/sub/downloadable-files-box.php +16 -0
- menu/sub/images_box.php +0 -56
- menu/sub/products.php +15 -42
- menu/sub/settings.php +124 -105
- menu/sub/troubleshooting.php +52 -0
- menu/sub/variations_box.php +22 -6
- readme.txt +60 -5
- woocommerce_wpml.class.php +104 -18
- wpml-config.xml +5 -1
- wpml-woocommerce.php +3 -3
assets/css/currency-switcher.css
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ul.wcml_currency_switcher{
|
2 |
+
padding: 0 !important;
|
3 |
+
margin: 0 !important;
|
4 |
+
list-style-type: none !important;
|
5 |
+
position: relative;
|
6 |
+
}
|
7 |
+
|
8 |
+
ul.wcml_currency_switcher li{
|
9 |
+
cursor: pointer;
|
10 |
+
border: 1px solid #cdcdcd;
|
11 |
+
}
|
12 |
+
|
13 |
+
ul.wcml_currency_switcher.curr_list_vertical{
|
14 |
+
border-top: 1px solid #cdcdcd;
|
15 |
+
display: inline-block;
|
16 |
+
}
|
17 |
+
|
18 |
+
ul.wcml_currency_switcher.curr_list_horizontal li{
|
19 |
+
float: left;
|
20 |
+
position: relative;
|
21 |
+
padding: 2px 5px;
|
22 |
+
margin-left: 1px;
|
23 |
+
}
|
24 |
+
ul.wcml_currency_switcher.curr_list_horizontal li:first-child{
|
25 |
+
margin-left: 0;
|
26 |
+
}
|
27 |
+
|
28 |
+
ul.wcml_currency_switcher.curr_list_vertical li{
|
29 |
+
border-top-width: 0;
|
30 |
+
padding-left: 10px;
|
31 |
+
cursor: pointer;
|
32 |
+
}
|
33 |
+
|
34 |
+
ul.wcml_currency_switcher.curr_list_vertical li{
|
35 |
+
padding: 3px 10px;
|
36 |
+
margin: 0;
|
37 |
+
}
|
assets/css/management.css
CHANGED
@@ -95,6 +95,13 @@
|
|
95 |
width: 900px;
|
96 |
overflow: hidden;
|
97 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
.wcml-section:last-child {
|
99 |
border: none;
|
100 |
margin: 0;
|
@@ -160,7 +167,9 @@
|
|
160 |
margin: 0;
|
161 |
margin-right: 5px;
|
162 |
}
|
163 |
-
|
|
|
|
|
164 |
.wcml_products_translation{
|
165 |
table-layout: fixed;
|
166 |
width: auto;
|
@@ -617,11 +626,33 @@ textarea[disabled] {
|
|
617 |
float: left;
|
618 |
}
|
619 |
.currency_changed,
|
620 |
-
.currency_value span
|
|
|
621 |
font-size: 10px;
|
622 |
font-style: italic;
|
623 |
color: #9A9A9A;
|
624 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
.currency_code .code_val{
|
626 |
display: block;
|
627 |
}
|
@@ -751,6 +782,7 @@ table.widefat.currency_table{
|
|
751 |
}
|
752 |
#multi-currency-per-language-details{
|
753 |
float: left;
|
|
|
754 |
}
|
755 |
/* on/off buttons */
|
756 |
.currency_languages{
|
@@ -870,4 +902,57 @@ table.widefat.currency_lang_table{
|
|
870 |
.wcml_add_currency.button-wrap{
|
871 |
margin-top: 0;
|
872 |
float: left;
|
873 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
width: 900px;
|
96 |
overflow: hidden;
|
97 |
}
|
98 |
+
.wcml-section-content .wcml-section-content-inner{
|
99 |
+
margin: 0 0 20px 0;
|
100 |
+
padding: 0 0 10px 0;
|
101 |
+
border-bottom: 1px solid #ededed;
|
102 |
+
float: left;
|
103 |
+
width: 100%;
|
104 |
+
}
|
105 |
.wcml-section:last-child {
|
106 |
border: none;
|
107 |
margin: 0;
|
167 |
margin: 0;
|
168 |
margin-right: 5px;
|
169 |
}
|
170 |
+
.wcml_products th:first-child{
|
171 |
+
display: inline-table;
|
172 |
+
}
|
173 |
.wcml_products_translation{
|
174 |
table-layout: fixed;
|
175 |
width: auto;
|
626 |
float: left;
|
627 |
}
|
628 |
.currency_changed,
|
629 |
+
.currency_value span,
|
630 |
+
.currency_position span{
|
631 |
font-size: 10px;
|
632 |
font-style: italic;
|
633 |
color: #9A9A9A;
|
634 |
}
|
635 |
+
|
636 |
+
.currency_position{
|
637 |
+
margin-top:0px;
|
638 |
+
}
|
639 |
+
|
640 |
+
.wcml_currency_options_popup{
|
641 |
+
position: absolute;
|
642 |
+
background: #fff;
|
643 |
+
background-color: rgba(255, 255, 255, 0.9);
|
644 |
+
box-shadow: 10px 10px 5px #888888;
|
645 |
+
border: 1px solid #777;
|
646 |
+
border-radius: 5px;
|
647 |
+
z-index: 999;
|
648 |
+
min-width:400px;
|
649 |
+
display:none;
|
650 |
+
margin-left:230px;
|
651 |
+
}
|
652 |
+
.currency_code .wcml_currency_options_popup tr{height:auto;}
|
653 |
+
.currency_code .wcml_currency_options_popup select{display: inline;}
|
654 |
+
|
655 |
+
|
656 |
.currency_code .code_val{
|
657 |
display: block;
|
658 |
}
|
782 |
}
|
783 |
#multi-currency-per-language-details{
|
784 |
float: left;
|
785 |
+
width: 100%;
|
786 |
}
|
787 |
/* on/off buttons */
|
788 |
.currency_languages{
|
902 |
.wcml_add_currency.button-wrap{
|
903 |
margin-top: 0;
|
904 |
float: left;
|
905 |
+
}
|
906 |
+
|
907 |
+
.currency_table select, .currency_table input{
|
908 |
+
font-size:10px !important;
|
909 |
+
padding: 0px;
|
910 |
+
height: 20px;
|
911 |
+
line-height:20px;
|
912 |
+
}
|
913 |
+
/* Currency switcher*/
|
914 |
+
#wcml_currencies_order{
|
915 |
+
display: block;
|
916 |
+
overflow: hidden;
|
917 |
+
width: 100%;
|
918 |
+
}
|
919 |
+
|
920 |
+
#wcml_currencies_order li {
|
921 |
+
float: left;
|
922 |
+
margin: 0 8px 0 0;
|
923 |
+
padding: 2px 8px;
|
924 |
+
border: 1px solid #DFDFDF;
|
925 |
+
border-radius: 2px;
|
926 |
+
background: linear-gradient(to top, #ECECEC, #F9F9F9) repeat scroll 0 0 #F1F1F1;
|
927 |
+
cursor: move;
|
928 |
+
}
|
929 |
+
.wcml_currencies_order_ajx_resp{
|
930 |
+
padding-top: 5px;
|
931 |
+
color: #E68A00;
|
932 |
+
}
|
933 |
+
.explanation-text {
|
934 |
+
color: #999;
|
935 |
+
}
|
936 |
+
input[name="wcml_curr_template"]{
|
937 |
+
width: 100%;
|
938 |
+
}
|
939 |
+
.wcml_curr_style label{
|
940 |
+
line-height: 30px;
|
941 |
+
}
|
942 |
+
|
943 |
+
#wcml_curr_sel_preview_wrap{
|
944 |
+
clear: both;
|
945 |
+
float: right;
|
946 |
+
padding: 15px 15px;
|
947 |
+
border: 1px solid #ccc;
|
948 |
+
margin-top: 20px;
|
949 |
+
}
|
950 |
+
#wcml_curr_sel_preview_wrap p{
|
951 |
+
margin-top: 0;
|
952 |
+
}
|
953 |
+
.wcml_product_name{
|
954 |
+
line-height: 20px;
|
955 |
+
}
|
956 |
+
.wcml_prod_filters{
|
957 |
+
float: left;
|
958 |
+
}
|
assets/css/wcml-prices.css
CHANGED
@@ -3,7 +3,11 @@
|
|
3 |
margin-top: 10px;
|
4 |
width: 100%;
|
5 |
}
|
6 |
-
.
|
|
|
|
|
|
|
|
|
7 |
display: inline-block;
|
8 |
width: 100%;
|
9 |
}
|
@@ -22,8 +26,13 @@
|
|
22 |
float: left;
|
23 |
}
|
24 |
.woocommerce_options_panel .wcml_custom_prices_options_block label,
|
25 |
-
.wcml_schedule_options label
|
|
|
26 |
width: auto;
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
.wc-metaboxes-wrapper .wcml_custom_prices_manually_block .currency_blck>label,
|
@@ -85,3 +94,6 @@
|
|
85 |
.wc-metaboxes-wrapper .wc-metabox table td .wcml_schedule_dates input{
|
86 |
width: 85px;
|
87 |
}
|
|
|
|
|
|
3 |
margin-top: 10px;
|
4 |
width: 100%;
|
5 |
}
|
6 |
+
#general_product_data .wcml_custom_prices_block{
|
7 |
+
padding-left: 10px;
|
8 |
+
}
|
9 |
+
.wcml_custom_prices_options_block,
|
10 |
+
.custom_prices_message_block{
|
11 |
display: inline-block;
|
12 |
width: 100%;
|
13 |
}
|
26 |
float: left;
|
27 |
}
|
28 |
.woocommerce_options_panel .wcml_custom_prices_options_block label,
|
29 |
+
.wcml_schedule_options label,
|
30 |
+
.custom_prices_message_block label{
|
31 |
width: auto;
|
32 |
+
margin: 0;
|
33 |
+
}
|
34 |
+
.custom_prices_message_block label{
|
35 |
+
color: #9d261d;
|
36 |
}
|
37 |
|
38 |
.wc-metaboxes-wrapper .wcml_custom_prices_manually_block .currency_blck>label,
|
94 |
.wc-metaboxes-wrapper .wc-metabox table td .wcml_schedule_dates input{
|
95 |
width: 85px;
|
96 |
}
|
97 |
+
.options_group.show_if_downloadable{
|
98 |
+
clear: both;
|
99 |
+
}
|
assets/css/wcml-wc-integration.css
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
.wcml_currency_options_menu_item{}
|
2 |
+
.wcml_currency_options_menu_item.selected{font-weight: bold; text-decoration: none; color:#333;}
|
assets/js/lock_fields.js
CHANGED
@@ -1,22 +1,35 @@
|
|
1 |
jQuery(document).ready(function($){
|
2 |
var i;
|
3 |
-
var ids = ['_sku','_virtual','_downloadable','product-type','_stock_status','_backorders','_manage_stock','_stock','_sold_individually','_weight','product_length','_regular_price','_sale_price','_sale_price_dates_from','_sale_price_dates_to','menu_order','comment_status','_tax_status','_tax_class'];
|
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());
|
8 |
}
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
$('.woocommerce_variation input[type="text"],.woocommerce_variation input[type="number"]').each(function(){
|
15 |
$(this).attr('readonly','readonly');
|
16 |
$(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
17 |
});
|
18 |
|
19 |
-
$('.woocommerce_variation select').each(function(){
|
20 |
$(this).attr('disabled','disabled');
|
21 |
$(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
22 |
});
|
@@ -27,5 +40,12 @@ jQuery(document).ready(function($){
|
|
27 |
}
|
28 |
});
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
});
|
31 |
|
1 |
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'];
|
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());
|
8 |
}
|
9 |
|
10 |
+
var buttons = ['add_variation','link_all_variations'];
|
11 |
+
for (i = 0; i < buttons.length; i++) {
|
12 |
+
$('.'+buttons[i]).attr('disabled','disabled');
|
13 |
+
$('.'+buttons[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show().css('float','right'));
|
14 |
+
}
|
15 |
+
|
16 |
+
$('.remove_variation').each(function(){
|
17 |
+
$(this).attr('disabled','disabled');
|
18 |
+
$(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show().css('float','right'));
|
19 |
+
});
|
20 |
+
|
21 |
+
var inpt_names = ['_width','_height'];
|
22 |
+
for (i = 0; i < ids.inpt_names; i++) {
|
23 |
+
$('input[name="'+inpt_names[i]+'"]').attr('readonly','readonly');
|
24 |
+
$('input[name="'+inpt_names[i]+'"]').after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
25 |
+
}
|
26 |
+
|
27 |
$('.woocommerce_variation input[type="text"],.woocommerce_variation input[type="number"]').each(function(){
|
28 |
$(this).attr('readonly','readonly');
|
29 |
$(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
30 |
});
|
31 |
|
32 |
+
$('.woocommerce_variation select,#variable_product_options .toolbar select').each(function(){
|
33 |
$(this).attr('disabled','disabled');
|
34 |
$(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
35 |
});
|
40 |
}
|
41 |
});
|
42 |
|
43 |
+
|
44 |
+
//quick edit fields
|
45 |
+
for (i = 0; i < ids.length; i++) {
|
46 |
+
$('.inline-edit-product [name="'+ids[i]+'"]').attr('disabled','disabled');
|
47 |
+
$('.inline-edit-product [name="'+ids[i]+'"]').after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
|
48 |
+
}
|
49 |
+
|
50 |
});
|
51 |
|
assets/js/prices.js
CHANGED
@@ -165,7 +165,7 @@ jQuery(document).ready(function($){
|
|
165 |
|
166 |
}
|
167 |
});
|
168 |
-
}
|
169 |
|
170 |
|
171 |
});
|
165 |
|
166 |
}
|
167 |
});
|
168 |
+
}
|
169 |
|
170 |
|
171 |
});
|
assets/js/scripts.js
CHANGED
@@ -99,38 +99,6 @@ jQuery(document).ready(function($){
|
|
99 |
});
|
100 |
$(this).closest('.outer').slideUp('3000');
|
101 |
});
|
102 |
-
|
103 |
-
$('.wcml_action_top').click(function(){
|
104 |
-
if($(this).val() == 'apply' && $(this).parent().find('select[name="test_action"]').val() == 'to_translation'){
|
105 |
-
var ids = '',i = 0;
|
106 |
-
$('input[name="product[]"]').each(function(){
|
107 |
-
if($(this).is(':checked')){
|
108 |
-
ids += i+"="+$(this).val()+"&";
|
109 |
-
i++;
|
110 |
-
}
|
111 |
-
});
|
112 |
-
$('.icl_selected_posts').val(ids);
|
113 |
-
$('.wcml_send_to_trnsl').click();
|
114 |
-
return false;
|
115 |
-
}
|
116 |
-
});
|
117 |
-
|
118 |
-
$('.wcml_action_bottom').click(function(){
|
119 |
-
if($(this).val() == 'apply' && $(this).parent().find('select[name="test_action_bottom"]').val() == 'to_translation'){
|
120 |
-
var ids = '',i = 0;
|
121 |
-
$('input[name="product[]"]').each(function(){
|
122 |
-
if($(this).is(':checked')){
|
123 |
-
ids += i+"="+$(this).val()+"&";
|
124 |
-
i++;
|
125 |
-
}
|
126 |
-
});
|
127 |
-
$('.icl_selected_posts').val(ids);
|
128 |
-
$('.wcml_send_to_trnsl').click();
|
129 |
-
return false;
|
130 |
-
}
|
131 |
-
});
|
132 |
-
|
133 |
-
|
134 |
$(".wcml_update").click( function() {
|
135 |
var field = $(this);
|
136 |
|
@@ -460,7 +428,7 @@ jQuery(document).ready(function($){
|
|
460 |
|
461 |
});
|
462 |
|
463 |
-
|
464 |
if($('.wcml_file_paths').size()>0){
|
465 |
// Uploading files
|
466 |
var downloadable_file_frame;
|
@@ -541,6 +509,87 @@ jQuery(document).ready(function($){
|
|
541 |
});
|
542 |
}
|
543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
if($(".wcml_editor_original").size() > 0 ){
|
545 |
$(".wcml_editor_original").resizable({
|
546 |
handles: 'n, s',
|
@@ -564,8 +613,13 @@ jQuery(document).ready(function($){
|
|
564 |
$('#multi_currency_option_select input[name=multi_currency]').change(function(){
|
565 |
|
566 |
if($(this).attr('id') != 'multi_currency_independent'){
|
567 |
-
$('
|
|
|
|
|
568 |
}else{
|
|
|
|
|
|
|
569 |
$('#multi-currency-per-language-details').fadeIn();
|
570 |
}
|
571 |
|
@@ -657,7 +711,8 @@ jQuery(document).ready(function($){
|
|
657 |
})
|
658 |
|
659 |
});
|
660 |
-
|
|
|
661 |
$(document).on('click','.edit_currency',function(){
|
662 |
var $tableRow = $(this).closest('tr');
|
663 |
$tableRow.addClass('edit-mode');
|
@@ -671,11 +726,66 @@ jQuery(document).ready(function($){
|
|
671 |
$tableRow.find('.save_currency').show();
|
672 |
$tableRow.find('.cancel_currency').show();
|
673 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
|
675 |
$(document).on('click','.cancel_currency',function(){
|
676 |
var $tableRow = $(this).closest('tr');
|
677 |
$tableRow.removeClass('edit-mode');
|
678 |
-
if($tableRow.find('.
|
679 |
$tableRow.find('.currency_code .code_val').show();
|
680 |
$tableRow.find('.currency_code select').hide();
|
681 |
$tableRow.find('.currency_value span.curr_val').show();
|
@@ -698,8 +808,8 @@ jQuery(document).ready(function($){
|
|
698 |
});
|
699 |
|
700 |
$('.wcml_add_currency button').click(function(){
|
|
|
701 |
$('.js-table-row-wrapper .curr_val_code').html($('.js-table-row-wrapper select').val());
|
702 |
-
var pluginurl = $('.wcml_plugin_url').val();
|
703 |
var $tableRow = $('.js-table-row-wrapper .js-table-row').clone();
|
704 |
var $LangTableRow = $('.js-currency_lang_table tr').clone();
|
705 |
$('#currency-table').find('tr.default_currency').before( $tableRow );
|
@@ -707,6 +817,7 @@ jQuery(document).ready(function($){
|
|
707 |
});
|
708 |
|
709 |
$(document).on('click','.save_currency',function(e){
|
|
|
710 |
e.preventDefault();
|
711 |
|
712 |
var $this = $(this);
|
@@ -721,16 +832,10 @@ jQuery(document).ready(function($){
|
|
721 |
parent.find('.cancel_currency').hide();
|
722 |
$ajaxLoader.insertBefore($this).show();
|
723 |
|
724 |
-
if(parent.find('.currency_id').val() > 0){
|
725 |
-
var currency_id = parent.find('.currency_id').val();
|
726 |
-
}else{
|
727 |
-
var currency_id = 0;
|
728 |
-
}
|
729 |
-
|
730 |
$currencyCodeWraper = parent.find('.currency_code');
|
731 |
$currencyValueWraper = parent.find('.currency_value');
|
732 |
|
733 |
-
var currency_code = $currencyCodeWraper.find('select').val();
|
734 |
var currency_value = $currencyValueWraper.find('input').val();
|
735 |
var flag = false;
|
736 |
|
@@ -782,54 +887,45 @@ jQuery(document).ready(function($){
|
|
782 |
return false;
|
783 |
}
|
784 |
|
785 |
-
var today = new Date();
|
786 |
-
var dd = today.getDate();
|
787 |
-
var mm = today.getMonth()+1; //January is 0!
|
788 |
-
var yyyy = today.getFullYear();
|
789 |
-
if(dd<10){
|
790 |
-
dd='0'+dd
|
791 |
-
}
|
792 |
-
if(mm<10){
|
793 |
-
mm='0'+mm
|
794 |
-
}
|
795 |
-
var today = dd+'/'+mm+'/'+yyyy;
|
796 |
-
|
797 |
-
|
798 |
$.ajax({
|
799 |
type : "post",
|
800 |
url : ajaxurl,
|
801 |
dataType: 'json',
|
802 |
data : {
|
803 |
-
action: "
|
804 |
-
wcml_nonce: $('#
|
805 |
-
currency_id : currency_id,
|
806 |
currency_code : currency_code,
|
807 |
-
currency_value : currency_value
|
808 |
-
today : today
|
809 |
},
|
810 |
error: function(respnse) {
|
811 |
// TODO: add error handling
|
812 |
},
|
813 |
success: function(response) {
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
parent.find('.
|
822 |
-
parent.find('.currency_value span
|
823 |
-
|
824 |
-
parent.find('.
|
825 |
-
|
826 |
-
parent.find('.
|
827 |
-
|
828 |
-
|
829 |
-
|
|
|
|
|
|
|
830 |
$('.currency_languages select').each(function(){
|
831 |
-
$(this).append('<option value="'+
|
832 |
});
|
|
|
|
|
|
|
833 |
},
|
834 |
complete: function() {
|
835 |
$ajaxLoader.remove();
|
@@ -838,48 +934,87 @@ jQuery(document).ready(function($){
|
|
838 |
});
|
839 |
|
840 |
return false;
|
841 |
-
});
|
842 |
|
843 |
|
844 |
$(document).on('click','.delete_currency',function(e){
|
845 |
e.preventDefault();
|
846 |
|
847 |
-
var
|
848 |
-
|
849 |
-
var $ajaxLoader = $('<span class="spinner">');
|
850 |
-
var currency_id = parent.find('.currency_id').val();
|
851 |
-
$this.hide();
|
852 |
-
$this.parent().append($ajaxLoader).show();
|
853 |
|
|
|
|
|
|
|
|
|
|
|
854 |
$.ajax({
|
855 |
type : "post",
|
856 |
url : ajaxurl,
|
857 |
data : {
|
858 |
action: "wcml_delete_currency",
|
859 |
wcml_nonce: $('#del_currency_nonce').val(),
|
860 |
-
|
861 |
-
code: parent.find('.currency_code select').val()
|
862 |
},
|
863 |
success: function(response) {
|
864 |
-
|
|
|
|
|
865 |
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
|
|
|
|
|
|
|
|
|
|
871 |
});
|
872 |
-
|
873 |
-
parent.remove();
|
874 |
},
|
875 |
done: function() {
|
876 |
-
|
877 |
}
|
878 |
});
|
879 |
|
880 |
return false;
|
881 |
});
|
882 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
883 |
// expand|collapse for product images and product variations tables
|
884 |
$(document).on('click','.js-table-toggle',function(e){
|
885 |
|
@@ -955,27 +1090,37 @@ jQuery(document).ready(function($){
|
|
955 |
$(this).closest('ul').find('.on').removeClass('on');
|
956 |
$(this).parent().addClass('on');
|
957 |
var index = $(this).closest('tr')[0].rowIndex;
|
958 |
-
|
959 |
-
|
960 |
-
$('.currency_languages select[rel="'+lang+'"]').append('<option value="'+code+'">'+code+'</option>');
|
961 |
-
update_currency_lang(1,lang,code,0);
|
962 |
});
|
963 |
|
964 |
$(document).on('click','.currency_languages a.off_btn',function(e){
|
965 |
-
$(this).closest('ul').find('.on').removeClass('on');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
$(this).parent().addClass('on');
|
967 |
var index = $(this).closest('tr')[0].rowIndex;
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
update_currency_lang(0,lang,code,1);
|
972 |
}else{
|
973 |
-
update_currency_lang(0,
|
974 |
}
|
975 |
-
$('.currency_languages select[rel="'+
|
976 |
});
|
977 |
|
978 |
-
function update_currency_lang(value,lang,code,upd_def){
|
979 |
$.ajax({
|
980 |
type: 'post',
|
981 |
url: ajaxurl,
|
@@ -995,7 +1140,7 @@ jQuery(document).ready(function($){
|
|
995 |
}
|
996 |
|
997 |
$('.default_currency select').change(function(){
|
998 |
-
update_default_currency($(this).attr('rel')
|
999 |
});
|
1000 |
|
1001 |
function update_default_currency(lang,code){
|
@@ -1013,9 +1158,98 @@ jQuery(document).ready(function($){
|
|
1013 |
});
|
1014 |
}
|
1015 |
|
1016 |
-
function isNumber(n) {
|
1017 |
-
|
1018 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1019 |
|
1020 |
});
|
1021 |
|
99 |
});
|
100 |
$(this).closest('.outer').slideUp('3000');
|
101 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
$(".wcml_update").click( function() {
|
103 |
var field = $(this);
|
104 |
|
428 |
|
429 |
});
|
430 |
|
431 |
+
//wc 2.0.*
|
432 |
if($('.wcml_file_paths').size()>0){
|
433 |
// Uploading files
|
434 |
var downloadable_file_frame;
|
509 |
});
|
510 |
}
|
511 |
|
512 |
+
//wc 2.1.*
|
513 |
+
if($('.wcml_file_paths_button').size()>0){
|
514 |
+
// Uploading files
|
515 |
+
var downloadable_file_frame;
|
516 |
+
var file_path_field;
|
517 |
+
var file_paths;
|
518 |
+
|
519 |
+
$(document).on( 'click', '.wcml_file_paths_button', function( event ){
|
520 |
+
|
521 |
+
var $el = $(this);
|
522 |
+
|
523 |
+
file_path_field = $el.parent().find('.wcml_file_paths_file');
|
524 |
+
file_paths = file_path_field.val();
|
525 |
+
|
526 |
+
event.preventDefault();
|
527 |
+
|
528 |
+
// If the media frame already exists, reopen it.
|
529 |
+
if ( downloadable_file_frame ) {
|
530 |
+
downloadable_file_frame.open();
|
531 |
+
return;
|
532 |
+
}
|
533 |
+
|
534 |
+
var downloadable_file_states = [
|
535 |
+
// Main states.
|
536 |
+
new wp.media.controller.Library({
|
537 |
+
library: wp.media.query(),
|
538 |
+
multiple: true,
|
539 |
+
title: $el.data('choose'),
|
540 |
+
priority: 20,
|
541 |
+
filterable: 'uploaded'
|
542 |
+
})
|
543 |
+
];
|
544 |
+
|
545 |
+
// Create the media frame.
|
546 |
+
downloadable_file_frame = wp.media.frames.downloadable_file = wp.media({
|
547 |
+
// Set the title of the modal.
|
548 |
+
title: $el.data('choose'),
|
549 |
+
library: {
|
550 |
+
type: ''
|
551 |
+
},
|
552 |
+
button: {
|
553 |
+
text: $el.data('update')
|
554 |
+
},
|
555 |
+
multiple: true,
|
556 |
+
states: downloadable_file_states
|
557 |
+
});
|
558 |
+
|
559 |
+
// When an image is selected, run a callback.
|
560 |
+
downloadable_file_frame.on( 'select', function() {
|
561 |
+
|
562 |
+
var selection = downloadable_file_frame.state().get('selection');
|
563 |
+
|
564 |
+
selection.map( function( attachment ) {
|
565 |
+
|
566 |
+
attachment = attachment.toJSON();
|
567 |
+
|
568 |
+
if ( attachment.url )
|
569 |
+
file_paths = attachment.url
|
570 |
+
|
571 |
+
} );
|
572 |
+
|
573 |
+
file_path_field.val( file_paths );
|
574 |
+
});
|
575 |
+
|
576 |
+
// Set post to 0 and set our custom type
|
577 |
+
downloadable_file_frame.on( 'ready', function() {
|
578 |
+
downloadable_file_frame.uploader.options.uploader.params = {
|
579 |
+
type: 'downloadable_product'
|
580 |
+
};
|
581 |
+
});
|
582 |
+
|
583 |
+
downloadable_file_frame.on( 'close', function() {
|
584 |
+
// TODO: /wp-admin should be a variable. Some plugions, like WP Better Security changes the name of this dir.
|
585 |
+
$.removeCookie('_icl_current_language', { path: '/wp-admin' });
|
586 |
+
});
|
587 |
+
|
588 |
+
// Finally, open the modal.
|
589 |
+
downloadable_file_frame.open();
|
590 |
+
});
|
591 |
+
}
|
592 |
+
|
593 |
if($(".wcml_editor_original").size() > 0 ){
|
594 |
$(".wcml_editor_original").resizable({
|
595 |
handles: 'n, s',
|
613 |
$('#multi_currency_option_select input[name=multi_currency]').change(function(){
|
614 |
|
615 |
if($(this).attr('id') != 'multi_currency_independent'){
|
616 |
+
$('.currencies-table-content').fadeOut();
|
617 |
+
$('.wcml_add_currency').fadeOut();
|
618 |
+
$('#currency-switcher').fadeOut();
|
619 |
}else{
|
620 |
+
$('.currencies-table-content').fadeIn();
|
621 |
+
$('.wcml_add_currency').fadeIn();
|
622 |
+
$('#currency-switcher').fadeIn();
|
623 |
$('#multi-currency-per-language-details').fadeIn();
|
624 |
}
|
625 |
|
711 |
})
|
712 |
|
713 |
});
|
714 |
+
|
715 |
+
/*
|
716 |
$(document).on('click','.edit_currency',function(){
|
717 |
var $tableRow = $(this).closest('tr');
|
718 |
$tableRow.addClass('edit-mode');
|
726 |
$tableRow.find('.save_currency').show();
|
727 |
$tableRow.find('.cancel_currency').show();
|
728 |
});
|
729 |
+
*/
|
730 |
+
|
731 |
+
|
732 |
+
$(document).on('click', '.edit_currency', function(){
|
733 |
+
$('.wcml_currency_options_popup').hide();
|
734 |
+
|
735 |
+
var popup = $('#wcml_currency_options_' + $(this).data('currency'));
|
736 |
+
popup.fadeIn();
|
737 |
+
|
738 |
+
var win = $(window);
|
739 |
+
var viewport = {
|
740 |
+
top : win.scrollTop(),
|
741 |
+
left : win.scrollLeft()
|
742 |
+
};
|
743 |
+
//viewport.right = viewport.left + win.width();
|
744 |
+
viewport.bottom = viewport.top + win.height();
|
745 |
+
|
746 |
+
var bounds = popup.offset();
|
747 |
+
//bounds.right = bounds.left + popup.outerWidth();
|
748 |
+
bounds.bottom = bounds.top + popup.outerHeight();
|
749 |
+
|
750 |
+
var incr = 0;
|
751 |
+
while(viewport.bottom < bounds.bottom){
|
752 |
+
|
753 |
+
var top = popup.css('top');
|
754 |
+
if(top == 'auto'){
|
755 |
+
top = parseInt(viewport.bottom) - parseInt(popup.outerHeight()) - 50;
|
756 |
+
}else{
|
757 |
+
top = parseInt(top) - 50;
|
758 |
+
}
|
759 |
+
popup.css({'top': top + 'px'});
|
760 |
+
|
761 |
+
|
762 |
+
var bounds = popup.offset();
|
763 |
+
//bounds.right = bounds.left + popup.outerWidth();
|
764 |
+
bounds.bottom = bounds.top + popup.outerHeight();
|
765 |
+
|
766 |
+
|
767 |
+
incr++;
|
768 |
+
if(incr == 10) break;
|
769 |
+
|
770 |
+
}
|
771 |
+
|
772 |
+
});
|
773 |
+
|
774 |
+
$(document).on('click', '.currency_options_cancel', function(){
|
775 |
+
var currency = $(this).data('currency');
|
776 |
+
$('#wcml_currency_options_' + currency).fadeOut(function(){
|
777 |
+
|
778 |
+
$('#wcml_currency_options_' + currency).css('top', 'auto');
|
779 |
+
|
780 |
+
});
|
781 |
+
|
782 |
+
});
|
783 |
+
|
784 |
|
785 |
$(document).on('click','.cancel_currency',function(){
|
786 |
var $tableRow = $(this).closest('tr');
|
787 |
$tableRow.removeClass('edit-mode');
|
788 |
+
if($tableRow.find('.currency_current_code').val()){
|
789 |
$tableRow.find('.currency_code .code_val').show();
|
790 |
$tableRow.find('.currency_code select').hide();
|
791 |
$tableRow.find('.currency_value span.curr_val').show();
|
808 |
});
|
809 |
|
810 |
$('.wcml_add_currency button').click(function(){
|
811 |
+
discard = true;
|
812 |
$('.js-table-row-wrapper .curr_val_code').html($('.js-table-row-wrapper select').val());
|
|
|
813 |
var $tableRow = $('.js-table-row-wrapper .js-table-row').clone();
|
814 |
var $LangTableRow = $('.js-currency_lang_table tr').clone();
|
815 |
$('#currency-table').find('tr.default_currency').before( $tableRow );
|
817 |
});
|
818 |
|
819 |
$(document).on('click','.save_currency',function(e){
|
820 |
+
discard = false;
|
821 |
e.preventDefault();
|
822 |
|
823 |
var $this = $(this);
|
832 |
parent.find('.cancel_currency').hide();
|
833 |
$ajaxLoader.insertBefore($this).show();
|
834 |
|
|
|
|
|
|
|
|
|
|
|
|
|
835 |
$currencyCodeWraper = parent.find('.currency_code');
|
836 |
$currencyValueWraper = parent.find('.currency_value');
|
837 |
|
838 |
+
var currency_code = $currencyCodeWraper.find('select[name=code]').val();
|
839 |
var currency_value = $currencyValueWraper.find('input').val();
|
840 |
var flag = false;
|
841 |
|
887 |
return false;
|
888 |
}
|
889 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
890 |
$.ajax({
|
891 |
type : "post",
|
892 |
url : ajaxurl,
|
893 |
dataType: 'json',
|
894 |
data : {
|
895 |
+
action: "wcml_new_currency",
|
896 |
+
wcml_nonce: $('#new_currency_nonce').val(),
|
|
|
897 |
currency_code : currency_code,
|
898 |
+
currency_value : currency_value
|
|
|
899 |
},
|
900 |
error: function(respnse) {
|
901 |
// TODO: add error handling
|
902 |
},
|
903 |
success: function(response) {
|
904 |
+
|
905 |
+
parent.closest('tr').attr('id', 'currency_row_' + currency_code);
|
906 |
+
$('#currency-lang-table tr:last').prev().attr('id', 'currency_row_langs_' + currency_code);
|
907 |
+
|
908 |
+
$('#currency_row_langs_' + currency_code + ' .off_btn').attr('data-currency', currency_code);
|
909 |
+
$('#currency_row_langs_' + currency_code + ' .on_btn').attr('data-currency', currency_code);
|
910 |
+
|
911 |
+
parent.find('.currency_code .code_val').html(response.currency_name_formatted);
|
912 |
+
parent.find('.currency_code .currency_value span').html(response.currency_meta_info);
|
913 |
+
|
914 |
+
parent.find('.currency_code').prepend(response.currency_options);
|
915 |
+
|
916 |
+
parent.find('.currency_code select').remove();
|
917 |
+
parent.find('.currency_value input').remove();
|
918 |
+
|
919 |
+
parent.find('.edit_currency').data('currency', currency_code).show();
|
920 |
+
parent.find('.delete_currency').data('currency', currency_code).show();
|
921 |
+
|
922 |
+
$('.js-table-row-wrapper select option[value="'+currency_code+'"]').remove();
|
923 |
$('.currency_languages select').each(function(){
|
924 |
+
$(this).append('<option value="'+currency_code+'">'+currency_code+'</option>');
|
925 |
});
|
926 |
+
|
927 |
+
$('#wcml_currencies_order').append('<li class="wcml_currencies_order_'+currency_code+'">'+response.currency_name_formatted_without_rate+'</li>');
|
928 |
+
currency_switcher_preview();
|
929 |
},
|
930 |
complete: function() {
|
931 |
$ajaxLoader.remove();
|
934 |
});
|
935 |
|
936 |
return false;
|
937 |
+
});
|
938 |
|
939 |
|
940 |
$(document).on('click','.delete_currency',function(e){
|
941 |
e.preventDefault();
|
942 |
|
943 |
+
var currency = $(this).data('currency');
|
944 |
+
|
|
|
|
|
|
|
|
|
945 |
|
946 |
+
$('#currency_row_' + currency + ' .currency_action_update').hide();
|
947 |
+
var ajaxLoader = $('<span class="spinner">');
|
948 |
+
$(this).hide();
|
949 |
+
$(this).parent().append(ajaxLoader).show();
|
950 |
+
|
951 |
$.ajax({
|
952 |
type : "post",
|
953 |
url : ajaxurl,
|
954 |
data : {
|
955 |
action: "wcml_delete_currency",
|
956 |
wcml_nonce: $('#del_currency_nonce').val(),
|
957 |
+
code: currency
|
|
|
958 |
},
|
959 |
success: function(response) {
|
960 |
+
$('#currency_row_' + currency).remove();
|
961 |
+
$('#currency_row_langs_' + currency).remove();
|
962 |
+
$('#wcml_currencies_order .wcml_currencies_order_'+ currency).remove();
|
963 |
|
964 |
+
$.ajax({
|
965 |
+
type : "post",
|
966 |
+
url : ajaxurl,
|
967 |
+
data : {
|
968 |
+
action: "wcml_currencies_list",
|
969 |
+
wcml_nonce: $('#currencies_list_nonce').val()
|
970 |
+
},
|
971 |
+
success: function(response) {
|
972 |
+
$('.js-table-row-wrapper select').html(response);
|
973 |
+
}
|
974 |
});
|
975 |
+
currency_switcher_preview();
|
|
|
976 |
},
|
977 |
done: function() {
|
978 |
+
ajaxLoader.remove();
|
979 |
}
|
980 |
});
|
981 |
|
982 |
return false;
|
983 |
});
|
984 |
|
985 |
+
|
986 |
+
$(document).on('click', '.wcml_currency_options_popup :submit', function(){
|
987 |
+
|
988 |
+
$('.wcml_currency_options_popup :submit, .wcml_currency_options_popup :button').prop('disabled', true);
|
989 |
+
var currency = $(this).data('currency');
|
990 |
+
|
991 |
+
var ajaxLoader = $('<span class="spinner" style="position:absolute;margin-left:-30px;"></span>');
|
992 |
+
ajaxLoader.show();
|
993 |
+
$(this).parent().prepend(ajaxLoader);
|
994 |
+
|
995 |
+
$.ajax({
|
996 |
+
url: ajaxurl,
|
997 |
+
type: 'POST',
|
998 |
+
dataType: 'json',
|
999 |
+
data: $('#general_options').serialize() + '&action=wcml_save_currency¤cy='+currency,
|
1000 |
+
success: function(response){
|
1001 |
+
$('.wcml_currency_options_popup').fadeOut(function(){
|
1002 |
+
ajaxLoader.remove();
|
1003 |
+
$('.wcml_currency_options_popup :submit, .wcml_currency_options_popup :button').prop('disabled', false);
|
1004 |
+
|
1005 |
+
$('#currency_row_' + currency + ' .currency_code .code_val').html(response.currency_name_formatted);
|
1006 |
+
$('#currency_row_' + currency + ' .currency_value span').html(response.currency_meta_info);
|
1007 |
+
|
1008 |
+
|
1009 |
+
});
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
})
|
1013 |
+
|
1014 |
+
return false;
|
1015 |
+
})
|
1016 |
+
|
1017 |
+
|
1018 |
// expand|collapse for product images and product variations tables
|
1019 |
$(document).on('click','.js-table-toggle',function(e){
|
1020 |
|
1090 |
$(this).closest('ul').find('.on').removeClass('on');
|
1091 |
$(this).parent().addClass('on');
|
1092 |
var index = $(this).closest('tr')[0].rowIndex;
|
1093 |
+
$('.currency_languages select[rel="'+$(this).data('language')+'"]').append('<option value="'+$(this).data('currency')+'">'+$(this).data('currency')+'</option>');
|
1094 |
+
update_currency_lang(1, $(this).data('language'), $(this).data('currency'), 0);
|
|
|
|
|
1095 |
});
|
1096 |
|
1097 |
$(document).on('click','.currency_languages a.off_btn',function(e){
|
1098 |
+
var enbl_elem = $(this).closest('ul').find('.on').removeClass('on');
|
1099 |
+
var flag = true;
|
1100 |
+
var lang = $(this).data('language');
|
1101 |
+
$('#currency-lang-table .on_btn[data-language="'+lang+'"]').each(function(){
|
1102 |
+
if($(this).parent().hasClass('on'))
|
1103 |
+
flag = false;
|
1104 |
+
});
|
1105 |
+
|
1106 |
+
if(flag){
|
1107 |
+
enbl_elem.addClass('on');
|
1108 |
+
alert($('#wcml_warn_disable_language_massage').val());
|
1109 |
+
return;
|
1110 |
+
}
|
1111 |
+
|
1112 |
$(this).parent().addClass('on');
|
1113 |
var index = $(this).closest('tr')[0].rowIndex;
|
1114 |
+
|
1115 |
+
if($('.currency_languages select[rel="'+$(this).data('language')+'"]').val() == $(this).data('currency')){
|
1116 |
+
update_currency_lang(0,$(this).data('language'),$(this).data('currency'),1);
|
|
|
1117 |
}else{
|
1118 |
+
update_currency_lang(0,$(this).data('language'),$(this).data('currency'),0);
|
1119 |
}
|
1120 |
+
$('.currency_languages select[rel="'+$(this).data('language')+'"] option[value="'+$(this).data('currency')+'"]').remove();
|
1121 |
});
|
1122 |
|
1123 |
+
function update_currency_lang(value, lang, code, upd_def){
|
1124 |
$.ajax({
|
1125 |
type: 'post',
|
1126 |
url: ajaxurl,
|
1140 |
}
|
1141 |
|
1142 |
$('.default_currency select').change(function(){
|
1143 |
+
update_default_currency($(this).attr('rel'), $(this).val());
|
1144 |
});
|
1145 |
|
1146 |
function update_default_currency(lang,code){
|
1158 |
});
|
1159 |
}
|
1160 |
|
1161 |
+
function isNumber(n) {
|
1162 |
+
return !isNaN(parseFloat(n)) && isFinite(n);
|
1163 |
+
}
|
1164 |
+
|
1165 |
+
$(document).on('click', '#wcml_dimiss_non_default_language_warning', function(){
|
1166 |
+
$(this).attr('disabled', 'disabled');
|
1167 |
+
var ajaxLoader = $('<span class="spinner">');
|
1168 |
+
$(this).parent().append(ajaxLoader);
|
1169 |
+
ajaxLoader.show();
|
1170 |
+
$.ajax({
|
1171 |
+
type: 'post',
|
1172 |
+
url: ajaxurl,
|
1173 |
+
dataType:'json',
|
1174 |
+
data: {
|
1175 |
+
action: 'wcml_update_setting_ajx',
|
1176 |
+
setting: 'dismiss_non_default_language_warning',
|
1177 |
+
value: 1,
|
1178 |
+
nonce: wcml_settings.nonce
|
1179 |
+
},
|
1180 |
+
success: function(response){
|
1181 |
+
location.reload();
|
1182 |
+
}
|
1183 |
+
});
|
1184 |
+
});
|
1185 |
+
|
1186 |
+
|
1187 |
+
$('#wcml_currencies_order').sortable({
|
1188 |
+
update: function(){
|
1189 |
+
$('.wcml_currencies_order_ajx_resp').fadeIn();
|
1190 |
+
var currencies_order = [];
|
1191 |
+
$('#wcml_currencies_order').find('li').each(function(){
|
1192 |
+
currencies_order.push($(this).attr('class').replace(/wcml_currencies_order_/, ''));
|
1193 |
+
});
|
1194 |
+
$.ajax({
|
1195 |
+
type: "POST",
|
1196 |
+
url: ajaxurl,
|
1197 |
+
dataType: 'json',
|
1198 |
+
data: {
|
1199 |
+
action: 'wcml_currencies_order',
|
1200 |
+
wcml_nonce: $('#wcml_currencies_order_order_nonce').val(),
|
1201 |
+
order: currencies_order.join(';')
|
1202 |
+
},
|
1203 |
+
success: function(resp){
|
1204 |
+
fadeInAjxResp('.wcml_currencies_order_ajx_resp', resp.message);
|
1205 |
+
currency_switcher_preview();
|
1206 |
+
}
|
1207 |
+
});
|
1208 |
+
}
|
1209 |
+
});
|
1210 |
+
|
1211 |
+
$(document).on('click','input[name="currency_switcher_style"]',function(e){
|
1212 |
+
$(this).closest('ul').find('select').hide();
|
1213 |
+
$(this).closest('li').find('select').show();
|
1214 |
+
currency_switcher_preview();
|
1215 |
+
});
|
1216 |
+
|
1217 |
+
$(document).on('change','#wcml_curr_sel_orientation',function(e){
|
1218 |
+
currency_switcher_preview();
|
1219 |
+
});
|
1220 |
+
|
1221 |
+
$(document).on('keyup','input[name="wcml_curr_template"]',function(e){
|
1222 |
+
discard = true;
|
1223 |
+
$(this).closest('.wcml-section').find('.button-wrap input').css("border-color","#1e8cbe");
|
1224 |
+
currency_switcher_preview();
|
1225 |
+
});
|
1226 |
+
|
1227 |
+
$(document).on('change','input[name="wcml_curr_template"]',function(e){
|
1228 |
+
if(!$(this).val()){
|
1229 |
+
$('input[name="wcml_curr_template"]').val($('#currency_switcher_default').val())
|
1230 |
+
}
|
1231 |
+
});
|
1232 |
+
|
1233 |
+
function currency_switcher_preview(){
|
1234 |
+
var template = $('input[name="wcml_curr_template"]').val();
|
1235 |
+
if(!template){
|
1236 |
+
template = $('#currency_switcher_default').val();
|
1237 |
+
}
|
1238 |
+
$.ajax({
|
1239 |
+
type: "POST",
|
1240 |
+
url: ajaxurl,
|
1241 |
+
data: {
|
1242 |
+
action: 'wcml_currencies_switcher_preview',
|
1243 |
+
wcml_nonce: $('#wcml_currencies_switcher_preview_nonce').val(),
|
1244 |
+
switcher_type: $('input[name="currency_switcher_style"]:checked').val(),
|
1245 |
+
orientation: $('#wcml_curr_sel_orientation').val(),
|
1246 |
+
template: template
|
1247 |
+
},
|
1248 |
+
success: function(resp){
|
1249 |
+
$('#wcml_curr_sel_preview').html(resp);
|
1250 |
+
}
|
1251 |
+
});
|
1252 |
+
}
|
1253 |
|
1254 |
});
|
1255 |
|
compatibility/templates/bundles_box.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if(!isset($template_data['empty_bundles'])){ ?>
|
2 |
+
<td>
|
3 |
+
<button id="prod_bundles_link_<?php echo $lang ?>" class="button-secondary js-table-toggle prod_bundles_link<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" data-text-opened="<?php _e('Collapse2','wpml-wcml'); ?>" data-text-closed="<?php _e('Expand2','wpml-wcml'); ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>>
|
4 |
+
<span><?php _e('Expand2','wpml-wcml'); ?></span>
|
5 |
+
<i class="icon-caret-down"></i>
|
6 |
+
</button>
|
7 |
+
<?php $bundles_ids = $template_data['product_bundles']; ?>
|
8 |
+
|
9 |
+
<table id="prod_bundles_<?php echo $lang ?>" class="widefat prod_variations js-table">
|
10 |
+
<tbody>
|
11 |
+
<tr>
|
12 |
+
<?php //if($template_data['original']): ?>
|
13 |
+
<td></td>
|
14 |
+
<?php if(!isset($template_data['empty_bundles'])): ?>
|
15 |
+
<?php foreach($template_data['bundles_data'] as $bundle_original_title=>$bundle_opts): ?>
|
16 |
+
<td>
|
17 |
+
<?php echo $bundle_original_title; ?>
|
18 |
+
</td>
|
19 |
+
<?php endforeach; ?>
|
20 |
+
<?php endif; ?>
|
21 |
+
<?php //endif; ?>
|
22 |
+
</tr>
|
23 |
+
<?php if(isset($template_data['empty_bundles'])): ?>
|
24 |
+
<tr>
|
25 |
+
<td><?php _e('Please set bundles for product','wpml-wcml'); ?></td>
|
26 |
+
</tr>
|
27 |
+
<?php elseif(isset($template_data['empty_translation'])): ?>
|
28 |
+
<tr>
|
29 |
+
<td><?php _e('Please save translation before translate bundles texts','wpml-wcml'); ?></td>
|
30 |
+
</tr>
|
31 |
+
<?php else: ?>
|
32 |
+
<?php $texts = array('bundle_title','bundle_desc'); ?>
|
33 |
+
<?php foreach($texts as $text): ?>
|
34 |
+
<tr>
|
35 |
+
<td>
|
36 |
+
<?php if($text == 'bundle_title'): ?>
|
37 |
+
<?php _e('Title','wpml-wcml'); ?>
|
38 |
+
<?php else: ?>
|
39 |
+
<?php _e('Description','wpml-wcml'); ?>
|
40 |
+
<?php endif; ?>
|
41 |
+
</td>
|
42 |
+
<?php $i = 0; ?>
|
43 |
+
<?php foreach($template_data['bundles_data'] as $bundle_id=>$bundle_opts): ?>
|
44 |
+
<?php if(!empty($bundle_opts)): ?>
|
45 |
+
<td>
|
46 |
+
<?php if($template_data['original']): ?>
|
47 |
+
<input type="text" value="<?php echo $bundle_opts[$text]?>" readonly="readonly"/>
|
48 |
+
<?php else: ?>
|
49 |
+
<input type="text" name="bundles[<?php echo $bundles_ids[$i] ?>][<?php echo $text; ?>]" value="<?php echo $bundle_opts[$text]?>" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"/>
|
50 |
+
<?php endif; ?>
|
51 |
+
</td>
|
52 |
+
|
53 |
+
<?php endif; ?>
|
54 |
+
<?php $i++; ?>
|
55 |
+
<?php endforeach; ?>
|
56 |
+
</tr>
|
57 |
+
|
58 |
+
<?php endforeach; ?>
|
59 |
+
<?php endif; ?>
|
60 |
+
</tbody>
|
61 |
+
</table>
|
62 |
+
</td>
|
63 |
+
<?php } ?>
|
compatibility/templates/wc_tab_manager_custom_box_html.php
CHANGED
@@ -1,48 +1,59 @@
|
|
1 |
<?php if(isset($template_data['orig_tabs'])): ?>
|
2 |
-
<?php foreach($template_data['orig_tabs']
|
3 |
-
$trnsl_tab_id = isset($template_data['tr_tabs']['
|
|
|
4 |
?>
|
5 |
<tr>
|
6 |
<td>
|
7 |
-
<?php if(
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</td>
|
10 |
<td>
|
11 |
-
<?php if($
|
12 |
-
<
|
13 |
<?php else: ?>
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
<
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
$
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
44 |
</div>
|
45 |
-
|
46 |
</td>
|
47 |
</tr>
|
48 |
<?php endforeach; ?>
|
1 |
<?php if(isset($template_data['orig_tabs'])): ?>
|
2 |
+
<?php foreach($template_data['orig_tabs'] as $key=>$values):
|
3 |
+
$trnsl_tab_id = isset($template_data['tr_tabs'][$key]['id'])?$template_data['tr_tabs'][$key]['id']:'';
|
4 |
+
$orig_tab_id = $template_data['orig_tabs'][$key]['id'];
|
5 |
?>
|
6 |
<tr>
|
7 |
<td>
|
8 |
+
<?php if($values['type'] == 'product'): ?>
|
9 |
+
<?php if(!$template_data['original']): ?>
|
10 |
+
<input type="hidden" name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[id][]'; ?>" value="<?php echo $trnsl_tab_id; ?>" />
|
11 |
+
<?php endif;?>
|
12 |
+
<textarea rows="1" <?php if(!$template_data['original']): ?>name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[title][]'; ?>"<?php endif;?> <?php if($template_data['original']): ?> disabled="disabled"<?php endif;?>><?php echo $template_data['original']?get_the_title($orig_tab_id):get_the_title($trnsl_tab_id); ?></textarea>
|
13 |
+
<?php else: ?>
|
14 |
+
<textarea rows="1" <?php if(!$template_data['original']): ?>name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[core_title]['.$key.']'; ?>"<?php endif;?> <?php if($template_data['original']): ?> disabled="disabled"<?php endif;?>><?php echo $template_data['tr_tabs'][$key]['title']; ?></textarea>
|
15 |
+
<?php endif; ?>
|
16 |
</td>
|
17 |
<td>
|
18 |
+
<?php if($values['type'] == 'core'): ?>
|
19 |
+
<textarea rows="1" <?php if(!$template_data['original']): ?>name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[core_heading]['.$key.']'; ?>"<?php endif;?> <?php if($template_data['original']): ?> disabled="disabled"<?php endif;?>><?php echo $template_data['tr_tabs'][$key]['heading']; ?></textarea>
|
20 |
<?php else: ?>
|
21 |
+
<?php if($template_data['original']): ?>
|
22 |
+
<button type="button" class="button-secondary wcml_edit_conten"><?php _e('Show content', 'wpml-wcml') ?></button>
|
23 |
+
<?php else: ?>
|
24 |
+
<button type="button" class="button-secondary wcml_edit_conten<?php if($template_data['is_duplicate_product']): ?> js-dup-disabled<?php endif;?>"<?php if($template_data['is_duplicate_product']): ?> disabled="disabled"<?php endif;?>><?php _e('Edit translation', 'wpml-wcml') ?></button>
|
25 |
+
<?php endif;?>
|
26 |
+
<div class="wcml_editor">
|
27 |
+
<a class="media-modal-close wcml_close_cross" href="javascript:void(0);" title="<?php esc_attr_e('Close', 'wpml-wcml') ?>"><span class="media-modal-icon"></span></a>
|
28 |
+
<div class="wcml_editor_original">
|
29 |
+
<h3><?php _e('Original content:', 'wpml-wcml') ?></h3>
|
30 |
+
<textarea class="wcml_original_content"><?php echo get_post($orig_tab_id)->post_content; ?></textarea>
|
31 |
+
</div>
|
32 |
+
<div class="wcml_line"></div>
|
33 |
+
<div class="wcml_editor_translation">
|
34 |
+
<?php if(!$template_data['original']): ?>
|
35 |
+
<?php
|
36 |
+
if($trnsl_tab_id){
|
37 |
+
$content = get_post($trnsl_tab_id)->post_content;
|
38 |
+
}else{
|
39 |
+
$content = '';
|
40 |
+
}
|
41 |
|
42 |
+
wp_editor($content, 'wcmleditor'.$template_data['product_content'].$key.$template_data['lang'], array('textarea_name'=>$template_data['product_content'] .
|
43 |
+
'_'.$template_data['lang'].'[content][]','textarea_rows'=>20,'editor_class'=>'wcml_content_tr')); ?>
|
44 |
+
<?php endif; ?>
|
45 |
+
</div>
|
46 |
+
<div class="wcml_editor_buttons">
|
47 |
+
<?php if($template_data['original']): ?>
|
48 |
+
<button type="button" class="button-secondary wcml_popup_close"><?php _e('Close', 'wpml-wcml') ?></button>
|
49 |
+
<?php else: ?>
|
50 |
+
<h3><?php printf(__('%s translation', 'wpml-wcml'),$template_data['lang_name']); ?></h3>
|
51 |
+
<button type="button" class="button-secondary wcml_popup_cancel"><?php _e('Cancel', 'wpml-wcml') ?></button>
|
52 |
+
<button type="button" class="button-secondary wcml_popup_ok"><?php _e('Ok', 'wpml-wcml') ?></button>
|
53 |
+
<?php endif; ?>
|
54 |
+
</div>
|
55 |
</div>
|
56 |
+
<?php endif; ?>
|
57 |
</td>
|
58 |
</tr>
|
59 |
<?php endforeach; ?>
|
compatibility/wc_dynamic_pricing.class.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WCML_Dynamic_Pricing{
|
4 |
+
|
5 |
+
function __construct(){
|
6 |
+
if(!is_admin()){
|
7 |
+
add_filter('init', array($this, 'filter_price'), 5);
|
8 |
+
add_filter('woocommerce_dynamic_pricing_is_applied_to', array($this, 'woocommerce_dynamic_pricing_is_applied_to'),10,5);
|
9 |
+
add_filter('woocommerce_dynamic_pricing_get_rule_amount',array($this,'woocommerce_dynamic_pricing_get_rule_amount'),10,4);
|
10 |
+
add_filter('dynamic_pricing_product_rules',array($this,'dynamic_pricing_product_rules'));
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
function filter_price(){
|
15 |
+
if(class_exists('WC_Dynamic_Pricing_Simple_Membership')){
|
16 |
+
$class = 'WC_Dynamic_Pricing_Simple_Membership';
|
17 |
+
}elseif(class_exists('WC_Dynamic_Pricing_Simple_Category')){
|
18 |
+
$class = 'WC_Dynamic_Pricing_Simple_Category';
|
19 |
+
}elseif(class_exists('WC_Dynamic_Pricing_Simple_Group')){
|
20 |
+
$class = 'WC_Dynamic_Pricing_Simple_Category';
|
21 |
+
}
|
22 |
+
|
23 |
+
$rules = $class::instance()->available_rulesets;
|
24 |
+
if($rules){
|
25 |
+
foreach($rules as $r_key=>$rule){
|
26 |
+
if($rule['type'] == 'fixed_product'){
|
27 |
+
$rules[$r_key]['amount'] = apply_filters('wcml_raw_price_amount', $rule['amount']);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
$class::instance()->available_rulesets = $rules;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
function woocommerce_dynamic_pricing_is_applied_to($process_discounts, $_product, $module_id, $obj,$cat_id){
|
36 |
+
if($cat_id && isset($obj->available_rulesets) && count($obj->available_rulesets) > 0){
|
37 |
+
global $sitepress;
|
38 |
+
$cat_id = icl_object_id($cat_id,'product_cat',true,$sitepress->get_current_language());
|
39 |
+
$process_discounts = is_object_in_term($_product->id, 'product_cat', $cat_id);
|
40 |
+
}
|
41 |
+
|
42 |
+
return $process_discounts;
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
function woocommerce_dynamic_pricing_get_rule_amount($amount, $rule, $cart_item, $obj){
|
47 |
+
|
48 |
+
if($rule['type'] == 'price_discount' || $rule['type'] == 'fixed_price'){
|
49 |
+
$amount = apply_filters('wcml_raw_price_amount',$amount);
|
50 |
+
}
|
51 |
+
|
52 |
+
return $amount;
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
function dynamic_pricing_product_rules($rules){
|
58 |
+
foreach($rules as $r_key=>$rule){
|
59 |
+
foreach($rule['rules'] as $key=>$product_rule){
|
60 |
+
if($product_rule['type'] == 'price_discount' || $product_rule['type'] == 'fixed_price'){
|
61 |
+
$rules[$r_key]['rules'][$key]['amount'] = apply_filters('wcml_raw_price_amount', $product_rule['amount']);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return $rules;
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
compatibility/wc_exporter.class.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WCML_wcExporter{
|
4 |
+
|
5 |
+
function __construct(){
|
6 |
+
|
7 |
+
add_filter('woo_ce_product_fields',array($this,'woo_ce_fields'));
|
8 |
+
add_filter('woo_ce_category_fields',array($this,'woo_ce_fields'));
|
9 |
+
add_filter('woo_ce_tag_fields',array($this,'woo_ce_fields'));
|
10 |
+
add_filter('woo_ce_order_fields',array($this,'woo_ce_order_fields'));
|
11 |
+
add_filter('woo_ce_product_item',array($this,'woo_ce_product_item'),10,2);
|
12 |
+
add_filter('woo_ce_category_item',array($this,'woo_ce_category_item'),10);
|
13 |
+
add_filter('woo_ce_tags',array($this,'woo_ce_tags'),10);
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
function woo_ce_fields($fields){
|
18 |
+
$fields[] = array(
|
19 |
+
'name' => 'language',
|
20 |
+
'label' => __( 'Language', 'woo_ce' ),
|
21 |
+
'default' => 1
|
22 |
+
);
|
23 |
+
$fields[] = array(
|
24 |
+
'name' => 'translation_of',
|
25 |
+
'label' => __( 'Translation of', 'woo_ce' ),
|
26 |
+
'default' => 1
|
27 |
+
);
|
28 |
+
return $fields;
|
29 |
+
}
|
30 |
+
|
31 |
+
function woo_ce_order_fields($fields){
|
32 |
+
$fields[] = array(
|
33 |
+
'name' => 'language',
|
34 |
+
'label' => __( 'Language', 'woo_ce' ),
|
35 |
+
'default' => 1
|
36 |
+
);
|
37 |
+
|
38 |
+
return $fields;
|
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,$sitepress->get_default_language());
|
46 |
+
|
47 |
+
return $data;
|
48 |
+
}
|
49 |
+
|
50 |
+
function woo_ce_category_item($data){
|
51 |
+
global $sitepress;
|
52 |
+
|
53 |
+
$data->language = $sitepress->get_language_for_element($data->term_taxonomy_id,'tax_product_cat');
|
54 |
+
$data->translation_of = icl_object_id($data->term_taxonomy_id,'tax_product_cat',true,$sitepress->get_default_language());
|
55 |
+
|
56 |
+
return $data;
|
57 |
+
}
|
58 |
+
|
59 |
+
function woo_ce_tags($tags){
|
60 |
+
global $sitepress;
|
61 |
+
|
62 |
+
foreach($tags as $key=>$tag){
|
63 |
+
$tags[$key]->language = $sitepress->get_language_for_element($tag->term_taxonomy_id,'tax_product_tag');
|
64 |
+
$tags[$key]->translation_of = icl_object_id($tag->term_taxonomy_id,'tax_product_tag',true,$sitepress->get_default_language());
|
65 |
+
}
|
66 |
+
|
67 |
+
return $tags;
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
compatibility/wc_per_product_shipping.class.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WCML_Per_Product_Shipping{
|
4 |
+
|
5 |
+
function __construct(){
|
6 |
+
|
7 |
+
if(!is_admin()){
|
8 |
+
|
9 |
+
add_filter('woocommerce_per_product_shipping_get_matching_rule_product_id', array( $this, 'original_product_id' ) );
|
10 |
+
|
11 |
+
}
|
12 |
+
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
function original_product_id( $product_id ){
|
17 |
+
global $sitepress, $wpdb;
|
18 |
+
|
19 |
+
|
20 |
+
$trid = $sitepress->get_element_trid($product_id, 'post_product');
|
21 |
+
$translations = $sitepress->get_element_translations($trid, 'post_product');
|
22 |
+
foreach($translations as $language_code =>$translation){
|
23 |
+
if($translation->original){
|
24 |
+
$product_id = $translation->element_id;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
return $product_id;
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
compatibility/wc_product_addons.class.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WCML_Product_Addons{
|
4 |
+
|
5 |
+
function __construct(){
|
6 |
+
|
7 |
+
add_action('init', array($this, 'init'),9);
|
8 |
+
add_filter('addons_product_terms',array($this,'addons_product_terms'));
|
9 |
+
add_filter('product_addons_fields',array($this,'product_addons_filter'),10,2);
|
10 |
+
|
11 |
+
global $pagenow;
|
12 |
+
if($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type']=='product' && isset($_GET['page']) && $_GET['page']=='global_addons' && !isset($_GET['edit'])){
|
13 |
+
add_action('admin_notices', array($this, 'inf_translate_strings'));
|
14 |
+
}
|
15 |
+
|
16 |
+
add_action( 'addons_panel_start', array( $this, 'inf_translate_strings' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
function init(){
|
20 |
+
add_action('after_save_global_addons',array($this,'register_addons_strings'),10,2);
|
21 |
+
add_action('after_update_product_addons',array($this,'register_addons_strings'),10,2);
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
function register_addons_strings($id,$addons){
|
26 |
+
foreach($addons as $addon){
|
27 |
+
//register name
|
28 |
+
icl_register_string('wc_product_addons_strings', $id.'_addon_'.$addon['type'].'_'.$addon['position'].'_name', $addon['name']);
|
29 |
+
//register description
|
30 |
+
icl_register_string('wc_product_addons_strings', $id.'_addon_'.$addon['type'].'_'.$addon['position'].'_description', $addon['description']);
|
31 |
+
//register options labels
|
32 |
+
foreach($addon['options'] as $key=>$option){
|
33 |
+
icl_register_string('wc_product_addons_strings', $id.'_addon_'.$addon['type'].'_'.$addon['position'].'_option_label_'.$key, $option['label']);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
function product_addons_filter($addons, $object_id){
|
39 |
+
foreach($addons as $add_id => $addon){
|
40 |
+
$addons[$add_id]['name'] = icl_t('wc_product_addons_strings', $object_id.'_addon_'.$addon['type'].'_'.$addon['position'].'_name', $addon['name']);
|
41 |
+
$addons[$add_id]['description'] = icl_t('wc_product_addons_strings', $object_id.'_addon_'.$addon['type'].'_'.$addon['position'].'_description', $addon['description']);
|
42 |
+
foreach($addon['options'] as $key=>$option){
|
43 |
+
$addons[$add_id]['options'][$key]['label'] = icl_t('wc_product_addons_strings', $object_id.'_addon_'.$addon['type'].'_'.$addon['position'].'_option_label_'.$key, $option['label']);
|
44 |
+
|
45 |
+
//price filter
|
46 |
+
$addons[$add_id]['options'][$key]['price'] = apply_filters('wcml_raw_price_amount', $option['price'],$object_id);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
return $addons;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
function addons_product_terms($product_terms){
|
55 |
+
global $sitepress;
|
56 |
+
|
57 |
+
foreach($product_terms as $key => $product_term){
|
58 |
+
$product_terms[$key] = icl_object_id($product_term,'product_cat',true,$sitepress->get_default_language());
|
59 |
+
}
|
60 |
+
|
61 |
+
return $product_terms;
|
62 |
+
}
|
63 |
+
|
64 |
+
function inf_translate_strings(){
|
65 |
+
$message = '<div><p class="icl_cyan_box">';
|
66 |
+
$message .= sprintf(__('To translate Add-ons strings please save Add-ons and go to the <b><a href="%s">String Translation interface</a></b>', 'wpml-wcml'), 'admin.php?page=wpml-string-translation/menu/string-translation.php&context=wc_product_addons_strings');
|
67 |
+
$message .= '</p></div>';
|
68 |
+
|
69 |
+
echo $message;
|
70 |
+
}
|
71 |
+
}
|
compatibility/wc_product_bundles.class.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WCML_Product_Bundles{
|
4 |
+
|
5 |
+
function __construct(){
|
6 |
+
add_action('init', array($this, 'init'),9);
|
7 |
+
add_action('wcml_gui_additional_box',array($this,'product_bundles_box'),10,3);
|
8 |
+
}
|
9 |
+
|
10 |
+
function init(){
|
11 |
+
global $sitepress;
|
12 |
+
add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_bundled_ids'),10,3);
|
13 |
+
add_action('wcml_extra_titles',array($this,'product_bundles_title'),10,1);
|
14 |
+
add_action('wcml_update_extra_fields',array($this,'bundle_update'),10,2);
|
15 |
+
|
16 |
+
add_filter('wcml_cart_contents', array($this, 'cart_bundle_update_lang_switch'), 10, 4);
|
17 |
+
add_filter('wcml_update_cart_contents_lang_switch', array($this, 'cart_contents_bundle_update_lang_switch'), 10, 4);
|
18 |
+
}
|
19 |
+
|
20 |
+
// Sync Bundled product meta with translated values
|
21 |
+
function sync_bundled_ids($original_product_id, $trnsl_product_id, $data = false){
|
22 |
+
global $sitepress, $wpdb;
|
23 |
+
|
24 |
+
$custom_fields = get_post_custom($original_product_id);
|
25 |
+
$atts = maybe_unserialize(get_post_meta($original_product_id, '_bundled_ids', true));
|
26 |
+
$lang = $sitepress->get_language_for_element($trnsl_product_id,'post_product');
|
27 |
+
$tr_ids = array();
|
28 |
+
|
29 |
+
foreach($atts as $key=>$id){
|
30 |
+
$tr_id = icl_object_id($id,'product',true,$lang);
|
31 |
+
$tr_ids[] = $tr_id;
|
32 |
+
|
33 |
+
// Get original bundle settings
|
34 |
+
$filter_variations = $custom_fields['filter_variations_'.$id][0] ?: 0;
|
35 |
+
$filter_variations = $custom_fields['filter_variations_'.$id][0];
|
36 |
+
$override_defaults = $custom_fields['override_defaults_'.$id][0];
|
37 |
+
$bundle_quantity = $custom_fields['bundle_quantity_'.$id][0];
|
38 |
+
$bundle_discount = $custom_fields['bundle_discount_'.$id][0];
|
39 |
+
$hide_thumbnail = $custom_fields['hide_thumbnail_'.$id][0];
|
40 |
+
$override_title = $custom_fields['override_title_'.$id][0];
|
41 |
+
$product_title = $custom_fields['product_title_'.$id][0];
|
42 |
+
$override_description = $custom_fields['override_description_'.$id][0];
|
43 |
+
$product_description = $custom_fields['product_description_'.$id][0];
|
44 |
+
$hide_filtered_variations = $custom_fields['hide_filtered_variations_'.$id][0];
|
45 |
+
$visibility = $custom_fields['visibility_'.$id][0];
|
46 |
+
|
47 |
+
// Delete original bundle settings
|
48 |
+
delete_post_meta( $trnsl_product_id, 'filter_variations_'.$id );
|
49 |
+
delete_post_meta( $trnsl_product_id, 'override_defaults_'.$id );
|
50 |
+
delete_post_meta( $trnsl_product_id, 'bundle_quantity_'.$id );
|
51 |
+
delete_post_meta( $trnsl_product_id, 'bundle_discount_'.$id );
|
52 |
+
delete_post_meta( $trnsl_product_id, 'hide_thumbnail_'.$id );
|
53 |
+
delete_post_meta( $trnsl_product_id, 'override_title_'.$id );
|
54 |
+
delete_post_meta( $trnsl_product_id, 'product_title_'.$id );
|
55 |
+
delete_post_meta( $trnsl_product_id, 'override_description_'.$id );
|
56 |
+
delete_post_meta( $trnsl_product_id, 'product_description_'.$id );
|
57 |
+
delete_post_meta( $trnsl_product_id, 'hide_filtered_variations_'.$id );
|
58 |
+
delete_post_meta( $trnsl_product_id, 'visibility_'.$id );
|
59 |
+
|
60 |
+
// Duplicate translated bundle settings
|
61 |
+
update_post_meta( $trnsl_product_id, 'filter_variations_'.$tr_id, $filter_variations );
|
62 |
+
update_post_meta( $trnsl_product_id, 'override_defaults_'.$tr_id, $override_defaults );
|
63 |
+
update_post_meta( $trnsl_product_id, 'bundle_quantity_'.$tr_id, $bundle_quantity );
|
64 |
+
update_post_meta( $trnsl_product_id, 'bundle_discount_'.$tr_id, $bundle_discount );
|
65 |
+
update_post_meta( $trnsl_product_id, 'hide_thumbnail_'.$tr_id, $hide_thumbnail );
|
66 |
+
update_post_meta( $trnsl_product_id, 'override_title_'.$tr_id, $override_title );
|
67 |
+
update_post_meta( $trnsl_product_id, 'product_title_'.$tr_id, $product_title );
|
68 |
+
update_post_meta( $trnsl_product_id, 'override_description_'.$tr_id, $override_description );
|
69 |
+
update_post_meta( $trnsl_product_id, 'product_description_'.$tr_id, $product_description );
|
70 |
+
update_post_meta( $trnsl_product_id, 'hide_filtered_variations_'.$tr_id, $hide_filtered_variations );
|
71 |
+
update_post_meta( $trnsl_product_id, 'visibility_'.$tr_id, $hide_filtered_variations );
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
// Update bundle products ids
|
76 |
+
update_post_meta($trnsl_product_id,'_bundled_ids',serialize($tr_ids));
|
77 |
+
|
78 |
+
// Update _allowed_variations
|
79 |
+
$tr_allowed_variations = array();
|
80 |
+
$allowed_variations = maybe_unserialize(get_post_meta($original_product_id, '_allowed_variations', true));
|
81 |
+
foreach($allowed_variations as $prod_id => $allowed_ids){
|
82 |
+
$trans_prod_id = icl_object_id($prod_id, 'product', false, $lang);
|
83 |
+
foreach($allowed_ids as $key => $var_id){
|
84 |
+
$trans_id = icl_object_id($var_id, 'product_variation', false, $lang);
|
85 |
+
$tr_allowed_variations[$trans_prod_id][] = $trans_id;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
update_post_meta($trnsl_product_id,'_allowed_variations',$tr_allowed_variations);
|
89 |
+
|
90 |
+
|
91 |
+
// Update _bundle_defaults
|
92 |
+
$tr_bundle_defaults = array();
|
93 |
+
$bundle_defaults = maybe_unserialize(get_post_meta($original_product_id, '_bundle_defaults', true));
|
94 |
+
foreach($bundle_defaults as $prod_id => $allowed_ids){
|
95 |
+
$trans_prod_id = icl_object_id($prod_id, 'product', false, $lang);
|
96 |
+
$tr_bundle_defaults[$trans_prod_id]=array();
|
97 |
+
foreach($allowed_ids as $key => $var_id){
|
98 |
+
$trans_id = icl_object_id($var_id, 'product_variation', false, $lang);
|
99 |
+
$tr_bundle_defaults[$trans_prod_id][] = $trans_id;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
update_post_meta($trnsl_product_id,'_bundle_defaults',$tr_bundle_defaults);
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
// Update Bundle title and descritpion
|
107 |
+
function bundle_update($tr_id, $data){
|
108 |
+
if(!empty($data['bundles'])){
|
109 |
+
foreach($data['bundles'] as $bundle_id => $bundle_data){
|
110 |
+
update_post_meta( $tr_id, 'product_title_'.$bundle_id, $bundle_data['bundle_title'] );
|
111 |
+
update_post_meta( $tr_id, 'product_description_'.$bundle_id, $bundle_data['bundle_desc'] );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
// Add 'Product Bundles' title to the WCML Product GUI if the current product is a bundled product
|
118 |
+
function product_bundles_title($product_id){
|
119 |
+
$bundles = get_post_meta($product_id, '_bundled_ids', true);
|
120 |
+
if(!empty($bundles)){ ?>
|
121 |
+
<th scope="col">Product Bundles</th>
|
122 |
+
<?php }
|
123 |
+
}
|
124 |
+
|
125 |
+
// Add Bundles Box to WCML Translation GUI
|
126 |
+
function product_bundles_box($product_id,$lang, $is_duplicate_product = false ) {
|
127 |
+
global $sitepress;
|
128 |
+
$default_language = $sitepress->get_default_language();
|
129 |
+
if($default_language != $lang){
|
130 |
+
$product_id = icl_object_id($product_id, 'product', false, $lang);
|
131 |
+
}
|
132 |
+
$template_data = array();
|
133 |
+
|
134 |
+
if($default_language == $lang){
|
135 |
+
$template_data['original'] = true;
|
136 |
+
}else{
|
137 |
+
$template_data['original'] = false;
|
138 |
+
}
|
139 |
+
|
140 |
+
if (!is_null($product_id)) {
|
141 |
+
$product_bundles = maybe_unserialize(get_post_meta($product_id,'_bundled_ids', true));
|
142 |
+
$template_data['product_bundles'] = $product_bundles;
|
143 |
+
if (empty($product_bundles)) {
|
144 |
+
$template_data['empty_bundles'] = true;
|
145 |
+
} else {
|
146 |
+
if ($default_language == $lang) {
|
147 |
+
$template_data['product_bundles'] = $product_bundles;
|
148 |
+
}
|
149 |
+
foreach ($product_bundles as $key=>$bundle_id) {
|
150 |
+
$bundle_title = get_post_meta($product_id,'product_title_'.$bundle_id, true);
|
151 |
+
$bundle_desc = get_post_meta($product_id,'product_description_'.$bundle_id, true);
|
152 |
+
$bundles_texts = array();
|
153 |
+
$bundle_name = get_the_title($bundle_id);
|
154 |
+
$template_data['bundles_data'][$bundle_name]['bundle_title'] = $bundle_title;
|
155 |
+
$template_data['bundles_data'][$bundle_name]['bundle_desc'] = $bundle_desc;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
} else {
|
159 |
+
$template_data['empty_translation'] = true;
|
160 |
+
}
|
161 |
+
include WCML_PLUGIN_PATH . '/compatibility/templates/bundles_box.php';
|
162 |
+
}
|
163 |
+
|
164 |
+
// Update bundled_by cart keys and stamp when language is switched
|
165 |
+
function cart_contents_bundle_update_lang_switch($cart_contents,$key,$new_key,$current_language){
|
166 |
+
$exist_ids_translations = array();
|
167 |
+
|
168 |
+
if(isset($cart_contents[$key]['bundled_items'])){
|
169 |
+
foreach($cart_contents[$key]['bundled_items'] as $index=>$bundled_key){
|
170 |
+
if($cart_contents[$bundled_key]['bundled_by'] == $key){
|
171 |
+
$cart_contents[$bundled_key]['bundled_by'] = $new_key;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
if(isset($cart_contents[$key]['stamp'])){
|
177 |
+
global $woocommerce_wpml;
|
178 |
+
$new_stamp = array();
|
179 |
+
foreach( $cart_contents[$key]['stamp'] as $st_prd => $st_prod_data){
|
180 |
+
$tr_st_p_id = icl_object_id($st_prd,'product',false,$current_language);
|
181 |
+
|
182 |
+
if(isset($st_prod_data['variation_id'])){
|
183 |
+
if(array_key_exists($st_prod_data['variation_id'],$exist_ids_translations)){
|
184 |
+
$tr_st_v_id = $exist_ids_translations[$st_prod_data['variation_id']];
|
185 |
+
}else{
|
186 |
+
$tr_st_v_id = icl_object_id($st_prod_data['variation_id'],'product_variation',false,$current_language);
|
187 |
+
}
|
188 |
+
|
189 |
+
if(!is_null($tr_st_v_id)){
|
190 |
+
$st_prod_data['variation_id'] = $tr_st_v_id;
|
191 |
+
$exist_ids_translations[$st_prod_data['variation_id']] = $tr_st_v_id;
|
192 |
+
}
|
193 |
+
|
194 |
+
foreach($st_prod_data['attributes'] as $taxonomy=>$attribute){
|
195 |
+
if (substr($taxonomy, 0, 10) == 'attribute_') {
|
196 |
+
$tax = substr($taxonomy, 10);
|
197 |
+
}else{
|
198 |
+
$tax = $taxonomy;
|
199 |
+
}
|
200 |
+
$st_prod_data['attributes'][$taxonomy] = $woocommerce_wpml->products->get_cart_attribute_translation($tax,$attribute,$st_prod_data['product_id'],$tr_st_p_id,$current_language);
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
if(!is_null($tr_st_p_id)){
|
206 |
+
$st_prod_data['product_id'] = $tr_st_p_id;
|
207 |
+
$new_stamp[$tr_st_p_id] = $st_prod_data;
|
208 |
+
$exist_ids_translations[$st_prd] = $tr_st_p_id;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
$cart_contents[$key]['stamp'] = $new_stamp;
|
213 |
+
}
|
214 |
+
|
215 |
+
return $cart_contents;
|
216 |
+
}
|
217 |
+
|
218 |
+
// Update bundled items cart keys when language is switched
|
219 |
+
function cart_bundle_update_lang_switch($new_cart_data,$cart_contents, $key, $new_key){
|
220 |
+
|
221 |
+
if(isset($cart_contents[$key]['bundled_by']) && isset($new_cart_data[$cart_contents[$key]['bundled_by']])){
|
222 |
+
global $woocommerce;
|
223 |
+
$buff = $new_cart_data[$new_key];
|
224 |
+
$key_item = $woocommerce->cart->generate_cart_id( $new_cart_data[$new_key]['product_id'], $new_cart_data[$new_key]['variation_id'], $new_cart_data[$new_key]['variation'], array( 'bundled_item_id' => $new_cart_data[$new_key]['product_id'], 'bundled_by' => $new_cart_data[$new_key]['bundled_by'], 'stamp' => $new_cart_data[$new_key][ 'stamp' ], 'dynamic_pricing_allowed' => 'no' ) );
|
225 |
+
|
226 |
+
foreach($new_cart_data[$cart_contents[$key]['bundled_by']]['bundled_items'] as $index => $item){
|
227 |
+
if($item == $key){
|
228 |
+
$new_cart_data[$cart_contents[$key]['bundled_by']]['bundled_items'][$index] = $key_item;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
unset($new_cart_data[$new_key]);
|
233 |
+
$new_cart_data[$key_item] = $buff;
|
234 |
+
}
|
235 |
+
|
236 |
+
return $new_cart_data;
|
237 |
+
}
|
238 |
+
|
239 |
+
}
|
240 |
+
|
compatibility/wc_subscriptions.class.php
CHANGED
@@ -5,10 +5,11 @@ class WCML_WC_Subscriptions{
|
|
5 |
function __construct(){
|
6 |
|
7 |
add_action('init', array($this, 'init'),9);
|
|
|
8 |
}
|
9 |
|
10 |
function init(){
|
11 |
-
if(!is_admin()){
|
12 |
add_filter('woocommerce_subscriptions_product_sign_up_fee', array($this, 'product_price_filter'), 10, 2);
|
13 |
}
|
14 |
}
|
@@ -20,4 +21,15 @@ class WCML_WC_Subscriptions{
|
|
20 |
return $subscription_sign_up_fee;
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
5 |
function __construct(){
|
6 |
|
7 |
add_action('init', array($this, 'init'),9);
|
8 |
+
add_filter('wcml_variation_term_taxonomy_ids',array($this,'wcml_variation_term_taxonomy_ids'));
|
9 |
}
|
10 |
|
11 |
function init(){
|
12 |
+
if(!is_admin() && version_compare( WOOCOMMERCE_VERSION, '2.1', '<' )){
|
13 |
add_filter('woocommerce_subscriptions_product_sign_up_fee', array($this, 'product_price_filter'), 10, 2);
|
14 |
}
|
15 |
}
|
21 |
return $subscription_sign_up_fee;
|
22 |
}
|
23 |
|
24 |
+
function wcml_variation_term_taxonomy_ids($get_variation_term_taxonomy_ids){
|
25 |
+
global $wpdb;
|
26 |
+
$get_variation_term_taxonomy_id = $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.slug = 'variable-subscription'");
|
27 |
+
|
28 |
+
if(!empty($get_variation_term_taxonomy_id)){
|
29 |
+
$get_variation_term_taxonomy_ids[] = $get_variation_term_taxonomy_id;
|
30 |
+
}
|
31 |
+
|
32 |
+
return $get_variation_term_taxonomy_ids;
|
33 |
+
}
|
34 |
+
|
35 |
}
|
compatibility/wc_tab_manager.class.php
CHANGED
@@ -3,30 +3,56 @@
|
|
3 |
class WCML_Tab_Manager{
|
4 |
|
5 |
function __construct(){
|
6 |
-
|
7 |
-
add_action('init', array($this, 'init'),9);
|
8 |
-
}
|
9 |
-
|
10 |
-
function init(){
|
11 |
add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_tabs'),10,3);
|
12 |
add_filter('wcml_product_content_exception',array($this,'is_have_custom_product_tab'),10,2);
|
13 |
-
add_filter('wcml_custom_box_html',array($this,'custom_box_html'),10,
|
14 |
-
|
15 |
}
|
16 |
|
17 |
function sync_tabs($original_product_id, $trnsl_product_id, $data = false){
|
18 |
-
global $wc_tab_manager,$sitepress,$wpdb;
|
19 |
|
20 |
-
$orig_prod_tabs = $wc_tab_manager->get_product_tabs($original_product_id);
|
21 |
$lang = $sitepress->get_language_for_element($trnsl_product_id,'post_product');
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
if($orig_prod_tabs){
|
24 |
$trnsl_product_tabs = array();
|
25 |
$i = 0;
|
26 |
foreach($orig_prod_tabs as $key=>$orig_prod_tab){
|
|
|
27 |
switch($orig_prod_tab['type']){
|
28 |
case 'core':
|
|
|
|
|
29 |
$trnsl_product_tabs[$key] = $orig_prod_tabs[$key];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
break;
|
31 |
case 'global':
|
32 |
$tr_tab_id = icl_object_id($orig_prod_tab['id'],'wc_product_tab',true,$lang);
|
@@ -38,43 +64,69 @@ class WCML_Tab_Manager{
|
|
38 |
);
|
39 |
break;
|
40 |
case 'product':
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
if(isset($data['_product_tabs_'.$lang]['id'][$i])){
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$
|
|
|
|
|
|
|
|
|
50 |
}else{
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$
|
56 |
-
|
57 |
-
$
|
58 |
-
$args['post_parent'] = $trnsl_product_id;
|
59 |
-
$args['post_status'] = 'publish';
|
60 |
-
$wpdb->insert( $wpdb->posts, $args );
|
61 |
-
|
62 |
-
$tab_id = $wpdb->insert_id;
|
63 |
-
$tab_trid = $sitepress->get_element_trid($orig_prod_tab['id'], 'post_wc_product_tab');
|
64 |
-
if(!$tab_trid){
|
65 |
-
$sitepress->set_element_language_details($orig_prod_tab['id'], 'post_wc_product_tab', false,$sitepress->get_default_language());
|
66 |
-
$tab_trid = $sitepress->get_element_trid($orig_prod_tab['id'], 'post_wc_product_tab');
|
67 |
-
}
|
68 |
-
$sitepress->set_element_language_details($tab_id, 'post_wc_product_tab', $tab_trid, $lang);
|
69 |
}
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
$i++;
|
79 |
break;
|
80 |
}
|
@@ -87,7 +139,7 @@ class WCML_Tab_Manager{
|
|
87 |
function is_have_custom_product_tab($exception,$product_id){
|
88 |
$prod_tabs = maybe_unserialize(get_post_meta($product_id,'_product_tabs',true));
|
89 |
foreach($prod_tabs as $prod_tab){
|
90 |
-
if($prod_tab['type']
|
91 |
$exception = false;
|
92 |
break;
|
93 |
}
|
@@ -97,38 +149,72 @@ class WCML_Tab_Manager{
|
|
97 |
}
|
98 |
|
99 |
|
100 |
-
function custom_box_html($html,$template_data){
|
101 |
if($template_data['product_content'] == '_product_tabs'){
|
102 |
global $wc_tab_manager;
|
|
|
103 |
|
104 |
if($template_data['tr_product_id']){
|
105 |
$tr_prod_tabs = $wc_tab_manager->get_product_tabs($template_data['tr_product_id']);
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
|
111 |
foreach($tr_prod_tabs as $key=>$prod_tab){
|
112 |
-
if($prod_tab['type']
|
113 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
-
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
}
|
125 |
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
include WCML_PLUGIN_PATH . '/compatibility/templates/wc_tab_manager_custom_box_html.php';
|
129 |
|
130 |
-
$html = ob_get_clean();
|
131 |
|
|
|
132 |
}
|
133 |
|
134 |
return $html;
|
3 |
class WCML_Tab_Manager{
|
4 |
|
5 |
function __construct(){
|
|
|
|
|
|
|
|
|
|
|
6 |
add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_tabs'),10,3);
|
7 |
add_filter('wcml_product_content_exception',array($this,'is_have_custom_product_tab'),10,2);
|
8 |
+
add_filter('wcml_custom_box_html',array($this,'custom_box_html'),10,3);
|
|
|
9 |
}
|
10 |
|
11 |
function sync_tabs($original_product_id, $trnsl_product_id, $data = false){
|
12 |
+
global $wc_tab_manager,$sitepress,$wpdb,$woocommerce;
|
13 |
|
|
|
14 |
$lang = $sitepress->get_language_for_element($trnsl_product_id,'post_product');
|
15 |
+
if(!isset($data['_product_tabs_'.$lang]) && !isset($_POST['icl_post_language']) && $_POST['icl_post_language'] != $lang){
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
$orig_prod_tabs = $wc_tab_manager->get_product_tabs($original_product_id);
|
20 |
+
|
21 |
|
22 |
if($orig_prod_tabs){
|
23 |
$trnsl_product_tabs = array();
|
24 |
$i = 0;
|
25 |
foreach($orig_prod_tabs as $key=>$orig_prod_tab){
|
26 |
+
|
27 |
switch($orig_prod_tab['type']){
|
28 |
case 'core':
|
29 |
+
$default_language = $sitepress->get_default_language();
|
30 |
+
$current_language = $sitepress->get_current_language();
|
31 |
$trnsl_product_tabs[$key] = $orig_prod_tabs[$key];
|
32 |
+
if(isset($data['_product_tabs_'.$lang])){
|
33 |
+
$title = $data['_product_tabs_'.$lang]['core_title'][$orig_prod_tab['id']];
|
34 |
+
$heading = $data['_product_tabs_'.$lang]['core_heading'][$orig_prod_tab['id']];
|
35 |
+
}else if(isset($_POST['product_tab_title'][$orig_prod_tab['position']])){
|
36 |
+
$title = $_POST['product_tab_title'][$orig_prod_tab['position']];
|
37 |
+
}else if(isset($_POST['product_tab_heading'][$orig_prod_tab['position']])){
|
38 |
+
$heading = $_POST['product_tab_heading'][$orig_prod_tab['position']];
|
39 |
+
}
|
40 |
+
|
41 |
+
if($default_language != $lang){
|
42 |
+
unload_textdomain('woocommerce');
|
43 |
+
$sitepress->switch_lang($lang);
|
44 |
+
$woocommerce->load_plugin_textdomain();
|
45 |
+
if(!$title) $title = $orig_prod_tabs[$key]['title'];
|
46 |
+
$title = __( $title, 'woocommerce' );
|
47 |
+
if(!$heading) $heading = $orig_prod_tabs[$key]['heading'];
|
48 |
+
$heading = __( $heading, 'woocommerce' );
|
49 |
+
unload_textdomain('woocommerce');
|
50 |
+
$sitepress->switch_lang($current_language);
|
51 |
+
$woocommerce->load_plugin_textdomain();
|
52 |
+
}
|
53 |
+
|
54 |
+
$trnsl_product_tabs[$key]['title'] = $title;
|
55 |
+
$trnsl_product_tabs[$key]['heading'] = $heading;
|
56 |
break;
|
57 |
case 'global':
|
58 |
$tr_tab_id = icl_object_id($orig_prod_tab['id'],'wc_product_tab',true,$lang);
|
64 |
);
|
65 |
break;
|
66 |
case 'product':
|
67 |
+
|
68 |
+
$tr_tab_id = icl_object_id($orig_prod_tab['id'],'wc_product_tab',false,$lang);
|
69 |
+
$tab_id = false;
|
70 |
+
if(!is_null($tr_tab_id)){
|
71 |
+
$tab_id = $tr_tab_id;
|
72 |
+
}
|
73 |
if(isset($data['_product_tabs_'.$lang]['id'][$i])){
|
74 |
+
if(get_post_type($data['_product_tabs_'.$lang]['id'][$i]) == 'wc_product_tab'){
|
75 |
+
$tab_id = $data['_product_tabs_'.$lang]['id'][$i];
|
76 |
+
}
|
77 |
+
$title = $data['_product_tabs_'.$lang]['title'][$i];
|
78 |
+
$content = $data['_product_tabs_'.$lang]['content'][$i];
|
79 |
+
}else{
|
80 |
+
if($_POST['product_tab_id'][$orig_prod_tab['position']]){
|
81 |
+
$tab_id = $_POST['product_tab_id'][$orig_prod_tab['position']];
|
82 |
+
}
|
83 |
+
|
84 |
+
if(isset($_POST['product_tab_title'][$orig_prod_tab['position']])){
|
85 |
+
$title = $_POST['product_tab_title'][$orig_prod_tab['position']];
|
86 |
}else{
|
87 |
+
$title = '';
|
88 |
+
}
|
89 |
+
|
90 |
+
if(isset($_POST['product_tab_content'][$orig_prod_tab['position']])){
|
91 |
+
$content = $_POST['product_tab_content'][$orig_prod_tab['position']];
|
92 |
+
}else{
|
93 |
+
$content = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
+
}
|
96 |
|
97 |
+
if($tab_id){
|
98 |
+
//update existing tab
|
99 |
+
$args = array();
|
100 |
+
$args['post_title'] = $title;
|
101 |
+
$args['post_content'] = $content;
|
102 |
+
$wpdb->update( $wpdb->posts, $args, array( 'ID' => $tab_id ) );
|
103 |
+
}else{
|
104 |
+
//tab not exist creating new
|
105 |
+
$args = array();
|
106 |
+
$args['post_title'] = $title;
|
107 |
+
$args['post_content'] = $content;
|
108 |
+
$args['post_author'] = get_current_user_id();
|
109 |
+
$args['post_name'] = sanitize_title($title);
|
110 |
+
$args['post_type'] = 'wc_product_tab';
|
111 |
+
$args['post_parent'] = $trnsl_product_id;
|
112 |
+
$args['post_status'] = 'publish';
|
113 |
+
$wpdb->insert( $wpdb->posts, $args );
|
114 |
+
|
115 |
+
$tab_id = $wpdb->insert_id;
|
116 |
+
$tab_trid = $sitepress->get_element_trid($orig_prod_tab['id'], 'post_wc_product_tab');
|
117 |
+
if(!$tab_trid){
|
118 |
+
$sitepress->set_element_language_details($orig_prod_tab['id'], 'post_wc_product_tab', false,$sitepress->get_default_language());
|
119 |
+
$tab_trid = $sitepress->get_element_trid($orig_prod_tab['id'], 'post_wc_product_tab');
|
120 |
+
}
|
121 |
+
$sitepress->set_element_language_details($tab_id, 'post_wc_product_tab', $tab_trid, $lang);
|
122 |
}
|
123 |
+
|
124 |
+
$trnsl_product_tabs[$orig_prod_tab['type'].'_tab_'.$tab_id] = array(
|
125 |
+
'position' => $orig_prod_tab['position'],
|
126 |
+
'type' => $orig_prod_tab['type'],
|
127 |
+
'id' => $tab_id,
|
128 |
+
'name' => get_post($tab_id)->post_name
|
129 |
+
);
|
130 |
$i++;
|
131 |
break;
|
132 |
}
|
139 |
function is_have_custom_product_tab($exception,$product_id){
|
140 |
$prod_tabs = maybe_unserialize(get_post_meta($product_id,'_product_tabs',true));
|
141 |
foreach($prod_tabs as $prod_tab){
|
142 |
+
if(in_array($prod_tab['type'],array('product','core'))){
|
143 |
$exception = false;
|
144 |
break;
|
145 |
}
|
149 |
}
|
150 |
|
151 |
|
152 |
+
function custom_box_html($html,$template_data,$lang){
|
153 |
if($template_data['product_content'] == '_product_tabs'){
|
154 |
global $wc_tab_manager;
|
155 |
+
$orig_prod_tabs = $wc_tab_manager->get_product_tabs($template_data['product_id']);
|
156 |
|
157 |
if($template_data['tr_product_id']){
|
158 |
$tr_prod_tabs = $wc_tab_manager->get_product_tabs($template_data['tr_product_id']);
|
159 |
|
160 |
+
if(!is_array($tr_prod_tabs)){
|
161 |
+
return __('Please update original product','wpml-wcml');
|
162 |
+
}
|
163 |
|
164 |
foreach($tr_prod_tabs as $key=>$prod_tab){
|
165 |
+
if(in_array($prod_tab['type'],array('product','core'))){
|
166 |
+
if($prod_tab['type'] == 'core'){
|
167 |
+
$template_data['tr_tabs'][$prod_tab['id']]['id'] = $prod_tab['id'];
|
168 |
+
$template_data['tr_tabs'][$prod_tab['id']]['type'] = $prod_tab['type'];
|
169 |
+
$template_data['tr_tabs'][$prod_tab['id']]['title'] = $prod_tab['title'];
|
170 |
+
$template_data['tr_tabs'][$prod_tab['id']]['heading'] = $prod_tab['heading'];
|
171 |
+
}else{
|
172 |
+
$template_data['tr_tabs'][$prod_tab['position']]['id'] = $prod_tab['id'];
|
173 |
+
$template_data['tr_tabs'][$prod_tab['position']]['type'] = $prod_tab['type'];
|
174 |
+
}
|
175 |
}
|
176 |
}
|
177 |
+
}else{
|
178 |
+
global $sitepress,$woocommerce;
|
179 |
+
$current_language = $sitepress->get_current_language();
|
180 |
+
foreach($orig_prod_tabs as $key=>$prod_tab){
|
181 |
+
if($prod_tab['type'] == 'core'){
|
182 |
+
unload_textdomain('woocommerce');
|
183 |
+
$sitepress->switch_lang($lang);
|
184 |
+
$woocommerce->load_plugin_textdomain();
|
185 |
+
$title = __( $prod_tab['title'], 'woocommerce' );
|
186 |
+
if($prod_tab['title'] != $title){
|
187 |
+
$template_data['tr_tabs'][$prod_tab['id']]['title'] = $title;
|
188 |
|
189 |
+
}
|
190 |
|
191 |
+
$heading = __( $prod_tab['heading'], 'woocommerce' );
|
192 |
+
if($prod_tab['heading'] != $heading){
|
193 |
+
$template_data['tr_tabs'][$prod_tab['id']]['heading'] = $heading;
|
194 |
+
}
|
195 |
+
unload_textdomain('woocommerce');
|
196 |
+
$sitepress->switch_lang($current_language);
|
197 |
+
$woocommerce->load_plugin_textdomain();
|
198 |
+
}
|
199 |
}
|
200 |
}
|
201 |
|
202 |
+
foreach($orig_prod_tabs as $key=>$prod_tab){
|
203 |
+
if(in_array($prod_tab['type'],array('product','core'))){
|
204 |
+
if($prod_tab['type'] == 'core'){
|
205 |
+
$template_data['orig_tabs'][$prod_tab['id']]['id'] = $prod_tab['id'];
|
206 |
+
$template_data['orig_tabs'][$prod_tab['id']]['type'] = $prod_tab['type'];
|
207 |
+
}else{
|
208 |
+
$template_data['orig_tabs'][$prod_tab['position']]['id'] = $prod_tab['id'];
|
209 |
+
$template_data['orig_tabs'][$prod_tab['position']]['type'] = $prod_tab['type'];
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
213 |
+
}
|
214 |
|
|
|
215 |
|
|
|
216 |
|
217 |
+
return include WCML_PLUGIN_PATH . '/compatibility/templates/wc_tab_manager_custom_box_html.php';
|
218 |
}
|
219 |
|
220 |
return $html;
|
compatibility/wc_variation_swatches_photos.class.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WCML_Variation_Swatches_and_Photos{
|
4 |
+
|
5 |
+
function __construct(){
|
6 |
+
add_action('init', array($this, 'init'),9);
|
7 |
+
}
|
8 |
+
|
9 |
+
function init(){
|
10 |
+
add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_variation_swatches_and_photos'),10,3);
|
11 |
+
}
|
12 |
+
|
13 |
+
function sync_variation_swatches_and_photos($original_product_id, $trnsl_product_id, $data = false){
|
14 |
+
global $sitepress, $wpdb;
|
15 |
+
|
16 |
+
$atts = maybe_unserialize(get_post_meta($original_product_id, '_swatch_type_options', true));
|
17 |
+
$lang = $sitepress->get_language_for_element($trnsl_product_id,'post_product');
|
18 |
+
$tr_atts = $atts;
|
19 |
+
|
20 |
+
foreach($atts as $att_name=>$att_opts){
|
21 |
+
foreach($att_opts['attributes'] as $slug=>$options){
|
22 |
+
$o_term = get_term_by('slug', $slug, $att_name);
|
23 |
+
$tr_term_id = icl_object_id($o_term->term_id,$att_name,false,$lang);
|
24 |
+
if(!is_null($tr_term_id)){
|
25 |
+
$tr_term = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_term_id, $att_name));
|
26 |
+
$tr_slug = $tr_term->slug;
|
27 |
+
|
28 |
+
if($tr_slug!=''){
|
29 |
+
$tr_atts[$att_name]['attributes'][$tr_term->slug]= $atts[$att_name]['attributes'][$slug];
|
30 |
+
if(isset($options['image'])){
|
31 |
+
$o_img_id = $options['image'];
|
32 |
+
$tr_img_id = icl_object_id($o_img_id,'image',false,$lang);
|
33 |
+
}
|
34 |
+
unset($tr_atts[$att_name]['attributes'][$slug]);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
update_post_meta($trnsl_product_id,'_swatch_type_options',$tr_atts); // Meta gets overwritten
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
inc/ajax-setup.class.php
CHANGED
@@ -11,12 +11,14 @@ class WCML_Ajax_Setup{
|
|
11 |
}
|
12 |
|
13 |
function init(){
|
14 |
-
if (
|
15 |
-
|
16 |
}
|
17 |
|
18 |
add_filter('woocommerce_params', array($this, 'filter_woocommerce_ajax_params'));
|
19 |
add_action( 'woocommerce_checkout_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
|
|
|
|
20 |
}
|
21 |
|
22 |
function filter_woocommerce_order_review(){
|
11 |
}
|
12 |
|
13 |
function init(){
|
14 |
+
if (wpml_is_ajax()){
|
15 |
+
do_action('localize_woocommerce_on_ajax');
|
16 |
}
|
17 |
|
18 |
add_filter('woocommerce_params', array($this, 'filter_woocommerce_ajax_params'));
|
19 |
add_action( 'woocommerce_checkout_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
20 |
+
add_action( 'woocommerce_checkout_update_order_review', array($this,'filter_woocommerce_order_review'), 9 );
|
21 |
+
|
22 |
}
|
23 |
|
24 |
function filter_woocommerce_order_review(){
|
inc/compatibility.class.php
CHANGED
@@ -4,8 +4,14 @@ class WCML_Compatibility {
|
|
4 |
|
5 |
function __construct(){
|
6 |
|
7 |
-
add_action('init', array($this, 'init'));
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
11 |
function init(){
|
@@ -29,6 +35,34 @@ class WCML_Compatibility {
|
|
29 |
$this->wp_subscriptions = new WCML_WC_Subscriptions();
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
}
|
34 |
|
4 |
|
5 |
function __construct(){
|
6 |
|
7 |
+
add_action('init', array($this, 'init'),9);
|
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(){
|
35 |
$this->wp_subscriptions = new WCML_WC_Subscriptions();
|
36 |
}
|
37 |
|
38 |
+
//Product Bundle
|
39 |
+
if(class_exists('WC_Product_Bundle')){
|
40 |
+
require_once WCML_PLUGIN_PATH . '/compatibility/wc_product_bundles.class.php';
|
41 |
+
$this->product_bundles = new WCML_Product_Bundles();
|
42 |
+
}
|
43 |
+
|
44 |
+
// WooCommerce Variation Swatches and Photos
|
45 |
+
if(class_exists('WC_SwatchesPlugin')){
|
46 |
+
require_once WCML_PLUGIN_PATH . '/compatibility/wc_variation_swatches_photos.class.php';
|
47 |
+
$this->variation_sp = new WCML_Variation_Swatches_and_Photos();
|
48 |
+
}
|
49 |
+
|
50 |
+
// Product Add-ons
|
51 |
+
if(class_exists( 'Product_Addon_Display' )){
|
52 |
+
require_once WCML_PLUGIN_PATH . '/compatibility/wc_product_addons.class.php';
|
53 |
+
$this->product_addons = new WCML_Product_Addons();
|
54 |
+
}
|
55 |
+
|
56 |
+
// Product Per Product Shipping
|
57 |
+
if(defined( 'PER_PRODUCT_SHIPPING_VERSION' )){
|
58 |
+
require_once WCML_PLUGIN_PATH . '/compatibility/wc_per_product_shipping.class.php';
|
59 |
+
new WCML_Per_Product_Shipping();
|
60 |
+
}
|
61 |
+
//Store Exporter plugin
|
62 |
+
if(defined('WOO_CE_PATH')){
|
63 |
+
require_once WCML_PLUGIN_PATH . '/compatibility/wc_exporter.class.php';
|
64 |
+
$this->wc_exporter = new WCML_wcExporter();
|
65 |
+
}
|
66 |
|
67 |
}
|
68 |
|
inc/currencies.class.php
DELETED
@@ -1,407 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class WCML_Currencies{
|
4 |
-
|
5 |
-
private $currencies = false;
|
6 |
-
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
|
10 |
-
add_action('init', array($this, 'init'));
|
11 |
-
|
12 |
-
if(get_option('icl_is_wcml_installed') === 'yes'){
|
13 |
-
$this->load_currencies();
|
14 |
-
}
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
function init(){
|
19 |
-
global $woocommerce_wpml;
|
20 |
-
|
21 |
-
add_filter('woocommerce_currency', array($this, 'woocommerce_currency_filter'));
|
22 |
-
if($woocommerce_wpml->settings['enable_multi_currency'] == 'yes'){
|
23 |
-
add_filter('woocommerce_currency_symbol', array($this, 'woocommerce_currency_symbol_filter'), 2);
|
24 |
-
|
25 |
-
if($woocommerce_wpml->settings['currency_converting_option'] == '1'){
|
26 |
-
add_filter('raw_woocommerce_price', array($this, 'woocommerce_price_filter'));
|
27 |
-
add_filter('woocommerce_order_amount_total', array($this, 'woocommerce_price_filter'));
|
28 |
-
add_filter('woocommerce_order_amount_item_total', array($this, 'woocommerce_price_filter'));
|
29 |
-
add_filter('woocommerce_order_amount_item_subtotal',array($this, 'woocommerce_price_filter'));
|
30 |
-
add_filter('woocommerce_order_amount_shipping', array($this, 'woocommerce_price_filter'));
|
31 |
-
add_filter('woocommerce_order_amount_total_tax', array($this, 'woocommerce_price_filter'));
|
32 |
-
add_filter('woocommerce_order_amount_cart_discount',array($this, 'woocommerce_price_filter'));
|
33 |
-
}else{
|
34 |
-
add_action('woocommerce_before_calculate_totals',array($this,'woocommerce_calculate_totals'));
|
35 |
-
}
|
36 |
-
|
37 |
-
add_filter('woocommerce_price_filter_min_price', array($this, 'price_filter_min_price'));
|
38 |
-
add_filter('woocommerce_price_filter_max_price', array($this, 'price_filter_max_price'));
|
39 |
-
|
40 |
-
add_action('wp_ajax_wcml_update_languages_curencies', array($this,'echo_languages_currencies'));
|
41 |
-
add_action('wp_ajax_wcml_update_currency', array($this,'wcml_update_currency'));
|
42 |
-
add_action('wp_ajax_wcml_delete_currency', array($this,'wcml_delete_currency'));
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
// set prices to copy/translate depending on settings
|
48 |
-
add_action('init', array($this, 'set_price_config'), 16); // After TM parses wpml-config.xml
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
function install(){
|
53 |
-
global $wpdb;
|
54 |
-
|
55 |
-
$sql = "CREATE TABLE IF NOT EXISTS `". $wpdb->prefix ."icl_currencies` (
|
56 |
-
`id` int(11) NOT NULL AUTO_INCREMENT,
|
57 |
-
`code` varchar(7) COLLATE utf8_unicode_ci NOT NULL,
|
58 |
-
`value` varchar(7) COLLATE utf8_unicode_ci DEFAULT NULL,
|
59 |
-
`changed` datetime DEFAULT NULL,
|
60 |
-
PRIMARY KEY (`id`)
|
61 |
-
)";
|
62 |
-
$wpdb->query($sql);
|
63 |
-
|
64 |
-
$sql = "CREATE TABLE IF NOT EXISTS `". $wpdb->prefix ."icl_languages_currencies` (
|
65 |
-
`id` int(11) NOT NULL AUTO_INCREMENT,
|
66 |
-
`language_code` varchar(7) COLLATE utf8_unicode_ci NOT NULL,
|
67 |
-
`currency_id` int(11) NOT NULL,
|
68 |
-
PRIMARY KEY (`id`)
|
69 |
-
)";
|
70 |
-
$install = $wpdb->query($sql);
|
71 |
-
if($install){
|
72 |
-
add_option('icl_is_created_languages_currencies', '1');
|
73 |
-
}
|
74 |
-
|
75 |
-
return;
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
function woocommerce_calculate_totals($cart){
|
80 |
-
global $sitepress, $woocommerce;
|
81 |
-
$current_language = $sitepress->get_current_language();
|
82 |
-
|
83 |
-
foreach($cart->cart_contents as $key=>$cart_item){
|
84 |
-
$tr_product_id = icl_object_id($cart_item['product_id'],'product',false,$current_language);
|
85 |
-
if(isset($cart->cart_contents[$key]['variation_id']) && $cart->cart_contents[$key]['variation_id']){
|
86 |
-
$tr_variation_id = icl_object_id($cart_item['variation_id'],'product_variation',false,$current_language);
|
87 |
-
if(!is_null($tr_variation_id)){
|
88 |
-
$price = get_post_meta($tr_variation_id,'_price',true);
|
89 |
-
$cart->cart_contents[$key]['product_id'] = $tr_product_id;
|
90 |
-
$cart->cart_contents[$key]['variation_id'] = $tr_variation_id;
|
91 |
-
$cart->cart_contents[$key]['data'] = get_product( $tr_variation_id );
|
92 |
-
if($cart_item['variation']){
|
93 |
-
foreach($cart_item['variation'] as $attr_key=>$attribute){
|
94 |
-
$trns_attr = get_post_meta($tr_variation_id,'attribute_'.$attr_key,true);
|
95 |
-
$cart->cart_contents[$key]['variation'][$attr_key] = $trns_attr;
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
}else{
|
100 |
-
if(!is_null($tr_product_id)){
|
101 |
-
$price = get_post_meta($tr_product_id,'_price',true);
|
102 |
-
$cart->cart_contents[$key]['product_id'] = $tr_product_id;
|
103 |
-
$cart->cart_contents[$key]['data'] = get_product( $tr_product_id );
|
104 |
-
}
|
105 |
-
}
|
106 |
-
}
|
107 |
-
$woocommerce->session->cart = $cart;
|
108 |
-
return $cart;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Filters the currency symbol.
|
113 |
-
*/
|
114 |
-
function woocommerce_currency_symbol_filter($currency_symbol){
|
115 |
-
global $sitepress, $wpdb, $woocommerce_wpml;
|
116 |
-
|
117 |
-
// Dont process currency symbols in the settings screen
|
118 |
-
if(function_exists('get_current_screen')) {
|
119 |
-
$screen = get_current_screen();
|
120 |
-
if (!empty($screen) && $screen->id == 'woocommerce_page_woocommerce_settings') {
|
121 |
-
return $currency_symbol;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
$db_currency = $wpdb->get_row("SELECT c.code FROM ". $wpdb->prefix ."icl_currencies as c LEFT JOIN ". $wpdb->prefix ."icl_languages_currencies as lc ON c.id=lc.currency_id WHERE lc.language_code = '". $sitepress->get_current_language() ."'");
|
126 |
-
|
127 |
-
if($db_currency && $woocommerce_wpml->settings['enable_multi_currency'] == 'yes'){
|
128 |
-
$db_currency = $db_currency->code;
|
129 |
-
remove_filter('woocommerce_currency_symbol',array($this,'woocommerce_currency_symbol_filter'),2);
|
130 |
-
$currency_symbol = get_woocommerce_currency_symbol($db_currency);
|
131 |
-
if(!$currency_symbol){
|
132 |
-
$currency_symbol = $db_currency;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
return $currency_symbol;
|
137 |
-
}
|
138 |
-
|
139 |
-
// Set multilingual currency.
|
140 |
-
function woocommerce_currency_filter($currency){
|
141 |
-
global $wpdb, $sitepress, $woocommerce_wpml;
|
142 |
-
|
143 |
-
$db_currency = $wpdb->get_row("SELECT c.code FROM ". $wpdb->prefix ."icl_currencies as c LEFT JOIN ". $wpdb->prefix ."icl_languages_currencies as lc ON c.id=lc.currency_id WHERE lc.language_code = '". $sitepress->get_current_language() ."'");
|
144 |
-
|
145 |
-
if(!empty($db_currency) && $woocommerce_wpml->settings['enable_multi_currency'] == 'yes'){
|
146 |
-
|
147 |
-
$currency = strtoupper(trim($db_currency->code));
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
return $currency;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Filters the product price.
|
156 |
-
*/
|
157 |
-
function woocommerce_price_filter($price){
|
158 |
-
global $sitepress, $wpdb, $woocommerce_wpml;
|
159 |
-
|
160 |
-
if ($woocommerce_wpml->settings['enable_multi_currency'] == 'yes') {
|
161 |
-
|
162 |
-
$sql = "SELECT c.value FROM ". $wpdb->prefix ."icl_currencies as c LEFT JOIN ". $wpdb->prefix ."icl_languages_currencies as lc ON c.id=lc.currency_id WHERE lc.language_code = '". $sitepress->get_current_language() ."'";
|
163 |
-
$currency = $wpdb->get_results($sql, OBJECT);
|
164 |
-
|
165 |
-
if($currency){
|
166 |
-
$exchange_rate = $currency[0]->value;
|
167 |
-
$price = round($price * $exchange_rate, (int) get_option( 'woocommerce_price_num_decimals' ));
|
168 |
-
$price = apply_filters('woocommerce_multilingual_price', $price);
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
return $price;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Filters the minimum price of price filter widget, when the multi-currency feature is enabled.
|
177 |
-
*
|
178 |
-
* @param type $min_price
|
179 |
-
* @global type $sitepress
|
180 |
-
* @global type $wpdb
|
181 |
-
* @return type
|
182 |
-
*/
|
183 |
-
function price_filter_min_price($min_price){
|
184 |
-
global $sitepress, $wpdb;
|
185 |
-
|
186 |
-
|
187 |
-
$sql = "SELECT c.value FROM ". $wpdb->prefix ."icl_currencies as c LEFT JOIN ". $wpdb->prefix ."icl_languages_currencies as lc ON c.id=lc.currency_id WHERE lc.language_code = '". $sitepress->get_current_language() ."'";
|
188 |
-
$currency = $wpdb->get_results($sql, OBJECT);
|
189 |
-
|
190 |
-
if($currency){
|
191 |
-
$exchange_rate = $currency[0]->value;
|
192 |
-
$min_price = $min_price / $exchange_rate;
|
193 |
-
$min_price = round($min_price,(int) get_option( 'woocommerce_price_num_decimals' ));
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
return $min_price;
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Filters the maximum price of price filter widget, when the multi-currency feature is enabled.
|
202 |
-
*
|
203 |
-
* @param type $min_price
|
204 |
-
* @global type $sitepress
|
205 |
-
* @global type $wpdb
|
206 |
-
* @return type
|
207 |
-
*/
|
208 |
-
function price_filter_max_price($max_price){
|
209 |
-
global $sitepress, $wpdb;
|
210 |
-
|
211 |
-
|
212 |
-
$sql = "SELECT c.value FROM ". $wpdb->prefix ."icl_currencies as c LEFT JOIN ". $wpdb->prefix ."icl_languages_currencies as lc ON c.id=lc.currency_id WHERE lc.language_code = '". $sitepress->get_current_language() ."'";
|
213 |
-
$currency = $wpdb->get_results($sql, OBJECT);
|
214 |
-
|
215 |
-
if($currency){
|
216 |
-
$exchange_rate = $currency[0]->value;
|
217 |
-
$max_price = $max_price / $exchange_rate;
|
218 |
-
$max_price = round($max_price,(int) get_option( 'woocommerce_price_num_decimals' ));
|
219 |
-
}
|
220 |
-
|
221 |
-
|
222 |
-
return $max_price;
|
223 |
-
}
|
224 |
-
|
225 |
-
private function load_currencies(){
|
226 |
-
global $wpdb;
|
227 |
-
$this->currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` DESC", OBJECT);
|
228 |
-
}
|
229 |
-
|
230 |
-
function get_currencies(){
|
231 |
-
if(false === $this->currencies){
|
232 |
-
$this->load_currencies();
|
233 |
-
}
|
234 |
-
return $this->currencies;
|
235 |
-
}
|
236 |
-
|
237 |
-
function echo_languages_currencies(){
|
238 |
-
global $sitepress,$wpdb;
|
239 |
-
|
240 |
-
foreach($sitepress->get_active_languages() as $language){
|
241 |
-
if($language['code'] != $sitepress->get_default_language()){
|
242 |
-
?>
|
243 |
-
<tr>
|
244 |
-
<td>
|
245 |
-
<img src="<?php echo ICL_PLUGIN_URL ?>/res/flags/<?php echo $language['code'] ?>.png" width="18" height="12" class="flag_img"/><?php echo $language['display_name'] ?>
|
246 |
-
</td>
|
247 |
-
<td>
|
248 |
-
<select name="currency_for[<?php echo $language['code']; ?>]">
|
249 |
-
<option value="<?php echo get_woocommerce_currency() ?>"><?php echo get_woocommerce_currency() ?></option>
|
250 |
-
<?php foreach ($this->currencies as $key => $currency): ?>
|
251 |
-
<?php $exist_currency_code = $wpdb->get_var($wpdb->prepare("SELECT currency_id FROM " . $wpdb->prefix . "icl_languages_currencies WHERE language_code = %s", $language['code'])); ?>
|
252 |
-
<option value="<?php echo $currency->id ?>" <?php echo $currency->id == $exist_currency_code ? 'selected="selected"' : ''; ?>><?php echo $currency->code ?></option>
|
253 |
-
<?php endforeach; ?>
|
254 |
-
</select>
|
255 |
-
</td>
|
256 |
-
</tr>
|
257 |
-
<?php
|
258 |
-
}
|
259 |
-
}
|
260 |
-
}
|
261 |
-
|
262 |
-
function wcml_update_currency(){
|
263 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_update_currency')){
|
264 |
-
die('Invalid nonce');
|
265 |
-
}
|
266 |
-
|
267 |
-
global $wpdb;
|
268 |
-
if($_POST['currency_id'] == 0){
|
269 |
-
$wpdb->insert($wpdb->prefix .'icl_currencies', array(
|
270 |
-
'code' => $_POST['currency_code'],
|
271 |
-
'value' => (double) $_POST['currency_value'],
|
272 |
-
'changed' => date('Y-m-d H:i:s')
|
273 |
-
)
|
274 |
-
);
|
275 |
-
|
276 |
-
echo $wpdb->insert_id;
|
277 |
-
} else {
|
278 |
-
$wpdb->update(
|
279 |
-
$wpdb->prefix .'icl_currencies',
|
280 |
-
array(
|
281 |
-
'code' => $_POST['currency_code'],
|
282 |
-
'value' => (double) $_POST['currency_value'],
|
283 |
-
'changed' => date('Y-m-d H:i:s')
|
284 |
-
),
|
285 |
-
array( 'id' => $_POST['currency_id'] )
|
286 |
-
);
|
287 |
-
}
|
288 |
-
die();
|
289 |
-
}
|
290 |
-
|
291 |
-
function wcml_delete_currency(){
|
292 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_delete_currency')){
|
293 |
-
die('Invalid nonce');
|
294 |
-
}
|
295 |
-
global $wpdb;
|
296 |
-
$wpdb->query($wpdb->prepare("DELETE FROM ". $wpdb->prefix ."icl_currencies WHERE id = %d", $_POST['currency_id']));
|
297 |
-
die();
|
298 |
-
}
|
299 |
-
|
300 |
-
function set_price_config() {
|
301 |
-
global $sitepress, $iclTranslationManagement,$sitepress_settings, $woocommerce_wpml;
|
302 |
-
|
303 |
-
$all_products_taxonomies = get_taxonomies(array('object_type'=>array('product')),'objects');
|
304 |
-
foreach($all_products_taxonomies as $tax_key => $tax){
|
305 |
-
if($tax_key == 'product_type') continue;
|
306 |
-
$sitepress_settings["translation-management"]["taxonomies_readonly_config"][$tax_key] = 1;
|
307 |
-
$sitepress_settings["taxonomies_sync_option"][$tax_key] = 1;
|
308 |
-
}
|
309 |
-
$sitepress->save_settings($sitepress_settings);
|
310 |
-
|
311 |
-
$wpml_settings = $sitepress->get_settings();
|
312 |
-
if (!isset($wpml_settings['translation-management'])) {
|
313 |
-
return;
|
314 |
-
}
|
315 |
-
|
316 |
-
$multi = $woocommerce_wpml->settings['enable_multi_currency'];
|
317 |
-
$option = $woocommerce_wpml->settings['currency_converting_option'];
|
318 |
-
if ($multi && $option == 2) {
|
319 |
-
$mode = 2; // translate
|
320 |
-
} else {
|
321 |
-
$mode = 1; // copy
|
322 |
-
}
|
323 |
-
$keys = array(
|
324 |
-
'_regular_price',
|
325 |
-
'_sale_price',
|
326 |
-
'_price',
|
327 |
-
'_min_variation_regular_price',
|
328 |
-
'_min_variation_sale_price',
|
329 |
-
'_min_variation_price',
|
330 |
-
'_max_variation_regular_price',
|
331 |
-
'_max_variation_sale_price',
|
332 |
-
'_max_variation_price'
|
333 |
-
);
|
334 |
-
$save = false;
|
335 |
-
foreach ($keys as $key) {
|
336 |
-
$iclTranslationManagement->settings['custom_fields_readonly_config'][] = $key;
|
337 |
-
if (!isset($sitepress_settings['translation-management']['custom_fields_translation'][$key]) ||
|
338 |
-
$wpml_settings['translation-management']['custom_fields_translation'][$key] != $mode) {
|
339 |
-
$wpml_settings['translation-management']['custom_fields_translation'][$key] = $mode;
|
340 |
-
$save = true;
|
341 |
-
}
|
342 |
-
}
|
343 |
-
if ($save) {
|
344 |
-
$sitepress->save_settings($wpml_settings);
|
345 |
-
}
|
346 |
-
}
|
347 |
-
|
348 |
-
|
349 |
-
function set_auto_currency_to_all_products_and_variations(){
|
350 |
-
global $wpdb,$sitepress;
|
351 |
-
$active_languages = $sitepress->get_active_languages();
|
352 |
-
$default_language = $sitepress->get_default_language();
|
353 |
-
$all_products = $wpdb->get_results($wpdb->prepare("SELECT element_id FROM " . $wpdb->prefix . "icl_translations WHERE language_code = %s AND element_type = 'post_product'", $default_language));
|
354 |
-
|
355 |
-
foreach($active_languages as $language){
|
356 |
-
if($default_language != $language['code']){
|
357 |
-
foreach($all_products as $product){
|
358 |
-
$product_id = $product->element_id;
|
359 |
-
$trnsl_product = icl_object_id($product_id,'product',false,$language['code']);
|
360 |
-
|
361 |
-
if(!is_null($trnsl_product)){
|
362 |
-
$variations = $wpdb->get_results($wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'product_variation' AND post_parent = %d", $product_id));
|
363 |
-
|
364 |
-
if($variations){
|
365 |
-
foreach($variations as $variation){
|
366 |
-
$variation_id = $variation->ID;
|
367 |
-
$trnsl_variation = icl_object_id($variation_id,'product_variation',false,$language['code']);
|
368 |
-
if(!is_null($trnsl_variation)){
|
369 |
-
$var_regular_price = get_post_meta($variation_id,'_regular_price',true);
|
370 |
-
$var_sale_price = get_post_meta($variation_id,'_sale_price',true);
|
371 |
-
$var_price = get_post_meta($variation_id,'_price',true);
|
372 |
-
update_post_meta($trnsl_variation,'_regular_price',$var_regular_price);
|
373 |
-
update_post_meta($trnsl_variation,'_sale_price',$var_sale_price);
|
374 |
-
update_post_meta($trnsl_variation,'_price',$var_price);
|
375 |
-
}
|
376 |
-
}
|
377 |
-
$price = get_post_meta($product_id,'_price',true);
|
378 |
-
$min_variation_price = get_post_meta($product_id,'_min_variation_price',true);
|
379 |
-
$max_variation_price = get_post_meta($product_id,'_max_variation_price',true);
|
380 |
-
$min_variation_regular_price = get_post_meta($product_id,'_min_variation_regular_price',true);
|
381 |
-
$max_variation_regular_price = get_post_meta($product_id,'_max_variation_regular_price',true);
|
382 |
-
$min_variation_sale_price = get_post_meta($product_id,'_min_variation_sale_price',true);
|
383 |
-
$max_variation_sale_price = get_post_meta($product_id,'_max_variation_sale_price',true);
|
384 |
-
update_post_meta($trnsl_product,'_price',$price);
|
385 |
-
update_post_meta($trnsl_product,'_min_variation_price',$min_variation_price);
|
386 |
-
update_post_meta($trnsl_product,'_max_variation_price',$max_variation_price);
|
387 |
-
update_post_meta($trnsl_product,'_min_variation_regular_price',$min_variation_regular_price);
|
388 |
-
update_post_meta($trnsl_product,'_max_variation_regular_price',$max_variation_regular_price);
|
389 |
-
update_post_meta($trnsl_product,'_min_variation_sale_price',$min_variation_sale_price);
|
390 |
-
update_post_meta($trnsl_product,'_max_variation_sale_price',$max_variation_sale_price);
|
391 |
-
}else{
|
392 |
-
$regular_price = get_post_meta($product_id,'_regular_price',true);
|
393 |
-
$sale_price = get_post_meta($product_id,'_sale_price',true);
|
394 |
-
$price = get_post_meta($product_id,'_price',true);
|
395 |
-
update_post_meta($trnsl_product,'_regular_price',$regular_price);
|
396 |
-
update_post_meta($trnsl_product,'_sale_price',$sale_price);
|
397 |
-
update_post_meta($trnsl_product,'_price',$price);
|
398 |
-
}
|
399 |
-
}
|
400 |
-
}
|
401 |
-
}
|
402 |
-
}
|
403 |
-
}
|
404 |
-
|
405 |
-
|
406 |
-
}
|
407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/currency-switcher.class.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Our case:
|
4 |
+
// customize display currencies
|
5 |
+
//
|
6 |
+
|
7 |
+
class WCML_CurrencySwitcher{
|
8 |
+
|
9 |
+
function __construct(){
|
10 |
+
|
11 |
+
add_filter('init', array($this, 'init'), 5);
|
12 |
+
add_action('widgets_init', array($this, 'register_widget'));
|
13 |
+
}
|
14 |
+
|
15 |
+
function init(){
|
16 |
+
|
17 |
+
add_action('wp_ajax_wcml_currencies_order', array($this,'wcml_currencies_order'));
|
18 |
+
add_action('wp_ajax_wcml_currencies_switcher_preview', array($this,'wcml_currencies_switcher_preview'));
|
19 |
+
}
|
20 |
+
|
21 |
+
function wcml_currencies_order(){
|
22 |
+
if(!wp_verify_nonce($_POST['wcml_nonce'], 'set_currencies_order_nonce')){
|
23 |
+
die('Invalid nonce');
|
24 |
+
}
|
25 |
+
global $woocommerce_wpml;
|
26 |
+
|
27 |
+
$woocommerce_wpml->settings['currencies_order'] = explode(';', $_POST['order']);
|
28 |
+
$woocommerce_wpml->update_settings();
|
29 |
+
echo json_encode(array('message' => __('Currencies order updated', 'wpml-wcml')));
|
30 |
+
die;
|
31 |
+
}
|
32 |
+
|
33 |
+
function wcml_currencies_switcher_preview(){
|
34 |
+
if(!wp_verify_nonce($_POST['wcml_nonce'], 'wcml_currencies_switcher_preview')){
|
35 |
+
die('Invalid nonce');
|
36 |
+
}
|
37 |
+
global $woocommerce_wpml;
|
38 |
+
|
39 |
+
echo $woocommerce_wpml->multi_currency_support->currency_switcher(array('format' => $_POST['template']?$_POST['template']:'%name% (%symbol%) - %code%','switcher_style' => $_POST['switcher_type'],'orientation'=> $_POST['orientation']));
|
40 |
+
|
41 |
+
die();
|
42 |
+
}
|
43 |
+
|
44 |
+
function register_widget(){
|
45 |
+
register_widget('WC_Currency_Switcher_Widget');
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
class WC_Currency_Switcher_Widget extends WP_Widget {
|
51 |
+
|
52 |
+
function __construct() {
|
53 |
+
|
54 |
+
parent::__construct( 'currency_sel_widget', __('Currency switcher', 'wpml-wcml'), __('Currency switcher', 'wpml-wcml'));
|
55 |
+
}
|
56 |
+
|
57 |
+
function widget($args, $instance) {
|
58 |
+
|
59 |
+
echo $args['before_widget'];
|
60 |
+
|
61 |
+
do_action('currency_switcher');
|
62 |
+
|
63 |
+
echo $args['after_widget'];
|
64 |
+
}
|
65 |
+
|
66 |
+
function form( $instance ) {
|
67 |
+
|
68 |
+
printf('<p><a href="%s">%s</a></p>','admin.php?page=wpml-wcml#currency-switcher',__('Configure options','wpml-wcml'));
|
69 |
+
return;
|
70 |
+
|
71 |
+
}
|
72 |
+
}
|
inc/dependencies.class.php
CHANGED
@@ -18,15 +18,15 @@ class WCML_Dependencies{
|
|
18 |
}
|
19 |
|
20 |
function check(){
|
21 |
-
|
22 |
$allok = true;
|
23 |
|
24 |
if(!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE){
|
25 |
if(!function_exists('is_multisite') || !is_multisite()) {
|
26 |
-
$this->missing['WPML'] = 'http://wpml.org';
|
27 |
$allok = false;
|
28 |
}
|
29 |
-
} else if(version_compare(ICL_SITEPRESS_VERSION, '3.
|
30 |
add_action('admin_notices', array($this, '_old_wpml_warning'));
|
31 |
$allok = false;
|
32 |
}
|
@@ -37,7 +37,7 @@ class WCML_Dependencies{
|
|
37 |
}
|
38 |
|
39 |
if(!defined('WPML_TM_VERSION')){
|
40 |
-
$this->missing['WPML Translation Management'] = 'http://wpml.org';
|
41 |
$allok = false;
|
42 |
}elseif(version_compare(WPML_TM_VERSION, '1.9', '<')){
|
43 |
add_action('admin_notices', array($this, '_old_wpml_tm_warning'));
|
@@ -45,7 +45,7 @@ class WCML_Dependencies{
|
|
45 |
}
|
46 |
|
47 |
if(!defined('WPML_ST_VERSION')){
|
48 |
-
$this->missing['WPML String Translation'] = 'http://wpml.org';
|
49 |
$allok = false;
|
50 |
}elseif(version_compare(WPML_ST_VERSION, '2.0', '<')){
|
51 |
add_action('admin_notices', array($this, '_old_wpml_st_warning'));
|
@@ -53,7 +53,7 @@ class WCML_Dependencies{
|
|
53 |
}
|
54 |
|
55 |
if(!defined('WPML_MEDIA_VERSION')){
|
56 |
-
$this->missing['WPML Media'] = 'http://wpml.org';
|
57 |
$allok = false;
|
58 |
}elseif(version_compare(WPML_MEDIA_VERSION, '2.1', '<')){
|
59 |
add_action('admin_notices', array($this, '_old_wpml_media_warning'));
|
@@ -68,30 +68,39 @@ class WCML_Dependencies{
|
|
68 |
$this->check_for_incompatible_permalinks();
|
69 |
}
|
70 |
|
|
|
|
|
|
|
|
|
|
|
71 |
return $allok;
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
* Adds admin notice.
|
76 |
*/
|
77 |
-
function _old_wpml_warning(){
|
|
|
78 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML</a> versions prior %s.',
|
79 |
-
'wpml-wcml'), 'http://wpml.org/', '3.
|
80 |
<?php }
|
81 |
|
82 |
-
function _old_wpml_tm_warning(){
|
|
|
83 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML Translation Management</a> versions prior %s.',
|
84 |
-
'wpml-wcml'), 'http://wpml.org/', '1.9'); ?></p></div>
|
85 |
<?php }
|
86 |
|
87 |
-
function _old_wpml_st_warning(){
|
|
|
88 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML String Translation</a> versions prior %s.',
|
89 |
-
'wpml-wcml'), 'http://wpml.org/', '2.0'); ?></p></div>
|
90 |
<?php }
|
91 |
|
92 |
-
function _old_wpml_media_warning(){
|
|
|
93 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML Media</a> versions prior %s.',
|
94 |
-
'wpml-wcml'), 'http://wpml.org/', '2.1'); ?></p></div>
|
95 |
<?php }
|
96 |
|
97 |
|
@@ -128,28 +137,20 @@ class WCML_Dependencies{
|
|
128 |
private function check_for_incompatible_permalinks() {
|
129 |
global $sitepress, $sitepress_settings, $pagenow;
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
return;
|
136 |
-
}
|
137 |
-
|
138 |
-
$message = sprintf('Because this site uses the default permalink structure, you cannot use slug translation for product permalinks.', 'wpml-wcml');
|
139 |
-
$message .= '<br /><br />';
|
140 |
-
$message .= sprintf('Please choose a different permalink structure or disable slug translation.', 'wpml-wcml');
|
141 |
-
$message .= '<br /><br />';
|
142 |
-
$message .= '<a href="' . admin_url('options-permalink.php') . '">' . __('Permalink settings', 'wpml-wcml') . '</a>';
|
143 |
-
$message .= ' | ';
|
144 |
-
$message .= '<a href="' . admin_url('admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=mcsetup#icl_custom_posts_sync_options') . '">' . __('Configure products slug translation', 'wpml-wcml') . '</a>';
|
145 |
-
|
146 |
-
} else {
|
147 |
-
// WooCommerce 1.x specific checks
|
148 |
-
if (get_option('woocommerce_prepend_shop_page_to_products', 'yes') != "yes") {
|
149 |
-
return;
|
150 |
-
}
|
151 |
-
$message = sprintf(__('If you want to translate product slugs, you need to disable the shop prefix for products in <a href="%s">WooCommerce Settings</a>', 'wpml-wcml'), 'admin.php?page=woocommerce_settings&tab=pages');
|
152 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
// Check if translated shop pages have the same slug (only 1.x)
|
155 |
$allsame = true;
|
18 |
}
|
19 |
|
20 |
function check(){
|
21 |
+
global $woocommerce_wpml, $sitepress;
|
22 |
$allok = true;
|
23 |
|
24 |
if(!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE){
|
25 |
if(!function_exists('is_multisite') || !is_multisite()) {
|
26 |
+
$this->missing['WPML'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
|
27 |
$allok = false;
|
28 |
}
|
29 |
+
} else if(version_compare(ICL_SITEPRESS_VERSION, '3.1.5', '<')){
|
30 |
add_action('admin_notices', array($this, '_old_wpml_warning'));
|
31 |
$allok = false;
|
32 |
}
|
37 |
}
|
38 |
|
39 |
if(!defined('WPML_TM_VERSION')){
|
40 |
+
$this->missing['WPML Translation Management'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
|
41 |
$allok = false;
|
42 |
}elseif(version_compare(WPML_TM_VERSION, '1.9', '<')){
|
43 |
add_action('admin_notices', array($this, '_old_wpml_tm_warning'));
|
45 |
}
|
46 |
|
47 |
if(!defined('WPML_ST_VERSION')){
|
48 |
+
$this->missing['WPML String Translation'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
|
49 |
$allok = false;
|
50 |
}elseif(version_compare(WPML_ST_VERSION, '2.0', '<')){
|
51 |
add_action('admin_notices', array($this, '_old_wpml_st_warning'));
|
53 |
}
|
54 |
|
55 |
if(!defined('WPML_MEDIA_VERSION')){
|
56 |
+
$this->missing['WPML Media'] = $woocommerce_wpml->generate_tracking_link('http://wpml.org/');
|
57 |
$allok = false;
|
58 |
}elseif(version_compare(WPML_MEDIA_VERSION, '2.1', '<')){
|
59 |
add_action('admin_notices', array($this, '_old_wpml_media_warning'));
|
68 |
$this->check_for_incompatible_permalinks();
|
69 |
}
|
70 |
|
71 |
+
if(isset($sitepress)){
|
72 |
+
$allok = $allok & $sitepress->setup();
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
return $allok;
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
* Adds admin notice.
|
81 |
*/
|
82 |
+
function _old_wpml_warning(){
|
83 |
+
global $woocommerce_wpml;?>
|
84 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML</a> versions prior %s.',
|
85 |
+
'wpml-wcml'), $woocommerce_wpml->generate_tracking_link('http://wpml.org/'), '3.1.5'); ?></p></div>
|
86 |
<?php }
|
87 |
|
88 |
+
function _old_wpml_tm_warning(){
|
89 |
+
global $woocommerce_wpml;?>
|
90 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML Translation Management</a> versions prior %s.',
|
91 |
+
'wpml-wcml'), $woocommerce_wpml->generate_tracking_link('http://wpml.org/'), '1.9'); ?></p></div>
|
92 |
<?php }
|
93 |
|
94 |
+
function _old_wpml_st_warning(){
|
95 |
+
global $woocommerce_wpml;?>
|
96 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML String Translation</a> versions prior %s.',
|
97 |
+
'wpml-wcml'), $woocommerce_wpml->generate_tracking_link('http://wpml.org/'), '2.0'); ?></p></div>
|
98 |
<?php }
|
99 |
|
100 |
+
function _old_wpml_media_warning(){
|
101 |
+
global $woocommerce_wpml;?>
|
102 |
<div class="message error"><p><?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML Media</a> versions prior %s.',
|
103 |
+
'wpml-wcml'), $woocommerce_wpml->generate_tracking_link('http://wpml.org/'), '2.1'); ?></p></div>
|
104 |
<?php }
|
105 |
|
106 |
|
137 |
private function check_for_incompatible_permalinks() {
|
138 |
global $sitepress, $sitepress_settings, $pagenow;
|
139 |
|
140 |
+
// WooCommerce 2.x specific checks
|
141 |
+
$permalinks = get_option('woocommerce_permalinks', array('product_base' => ''));
|
142 |
+
if (empty($permalinks['product_base'])) {
|
143 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
+
|
146 |
+
$message = sprintf('Because this site uses the default permalink structure, you cannot use slug translation for product permalinks.', 'wpml-wcml');
|
147 |
+
$message .= '<br /><br />';
|
148 |
+
$message .= sprintf('Please choose a different permalink structure or disable slug translation.', 'wpml-wcml');
|
149 |
+
$message .= '<br /><br />';
|
150 |
+
$message .= '<a href="' . admin_url('options-permalink.php') . '">' . __('Permalink settings', 'wpml-wcml') . '</a>';
|
151 |
+
$message .= ' | ';
|
152 |
+
$message .= '<a href="' . admin_url('admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=mcsetup#icl_custom_posts_sync_options') . '">' . __('Configure products slug translation', 'wpml-wcml') . '</a>';
|
153 |
+
|
154 |
|
155 |
// Check if translated shop pages have the same slug (only 1.x)
|
156 |
$allsame = true;
|
inc/emails.class.php
CHANGED
@@ -21,6 +21,7 @@ class WCML_Emails{
|
|
21 |
//wrappers for email's body
|
22 |
add_action('woocommerce_before_resend_order_emails', array($this, 'email_header'));
|
23 |
add_action('woocommerce_after_resend_order_email', array($this, 'email_footer'));
|
|
|
24 |
|
25 |
//WPML job link
|
26 |
add_filter('icl_job_edit_url',array($this,'icl_job_edit_url'),10 ,2);
|
@@ -32,7 +33,13 @@ class WCML_Emails{
|
|
32 |
add_action('woocommerce_new_customer_note',array($this,'refresh_email_lang'),9);
|
33 |
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
/**
|
@@ -94,18 +101,22 @@ class WCML_Emails{
|
|
94 |
global $woocommerce,$wpdb,$sitepress_settings;
|
95 |
if(class_exists('WC_Email_Customer_Completed_Order')){
|
96 |
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_completed_order_settings]heading'));
|
97 |
-
|
|
|
98 |
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_completed_order_settings]subject'));
|
99 |
-
|
|
|
100 |
$heading_downloadable = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_completed_order_settings]heading_downloadable'));
|
101 |
-
|
|
|
102 |
$subject_downloadable = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_completed_order_settings]subject_downloadable'));
|
103 |
-
|
|
|
104 |
|
105 |
-
$enabled = $woocommerce->
|
106 |
-
$woocommerce->
|
107 |
-
$woocommerce->
|
108 |
-
$woocommerce->
|
109 |
}
|
110 |
}
|
111 |
|
@@ -113,14 +124,16 @@ class WCML_Emails{
|
|
113 |
global $woocommerce,$wpdb,$sitepress_settings;
|
114 |
if(class_exists('WC_Email_Customer_Processing_Order')){
|
115 |
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_processing_order_settings]heading'));
|
116 |
-
|
|
|
117 |
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_processing_order_settings]subject'));
|
118 |
-
|
|
|
119 |
|
120 |
-
$enabled = $woocommerce->
|
121 |
-
$woocommerce->
|
122 |
-
$woocommerce->
|
123 |
-
$woocommerce->
|
124 |
}
|
125 |
}
|
126 |
|
@@ -128,14 +141,46 @@ class WCML_Emails{
|
|
128 |
global $woocommerce,$wpdb,$sitepress_settings,$sitepress;
|
129 |
if(class_exists('WC_Email_Customer_Note')){
|
130 |
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_note_settings]heading'));
|
131 |
-
|
|
|
132 |
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_note_settings]subject'));
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
}
|
141 |
|
@@ -177,4 +222,10 @@ class WCML_Emails{
|
|
177 |
return $link;
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
}
|
21 |
//wrappers for email's body
|
22 |
add_action('woocommerce_before_resend_order_emails', array($this, 'email_header'));
|
23 |
add_action('woocommerce_after_resend_order_email', array($this, 'email_footer'));
|
24 |
+
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 9, 3 );
|
25 |
|
26 |
//WPML job link
|
27 |
add_filter('icl_job_edit_url',array($this,'icl_job_edit_url'),10 ,2);
|
33 |
add_action('woocommerce_new_customer_note',array($this,'refresh_email_lang'),9);
|
34 |
|
35 |
|
36 |
+
//admin emails
|
37 |
+
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'admin_email' ), 9 );
|
38 |
+
add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'admin_email' ), 9 );
|
39 |
+
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'admin_email' ), 9 );
|
40 |
+
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'admin_email' ), 9 );
|
41 |
+
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'admin_email' ), 9 );
|
42 |
+
add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'admin_email' ), 9 );
|
43 |
}
|
44 |
|
45 |
/**
|
101 |
global $woocommerce,$wpdb,$sitepress_settings;
|
102 |
if(class_exists('WC_Email_Customer_Completed_Order')){
|
103 |
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_completed_order_settings]heading'));
|
104 |
+
if($heading)
|
105 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_completed_order_settings]heading',$heading[0]->value);
|
106 |
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_completed_order_settings]subject'));
|
107 |
+
if($subject)
|
108 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->subject = icl_t($subject[0]->context,'[woocommerce_customer_completed_order_settings]subject',$subject[0]->value);
|
109 |
$heading_downloadable = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_completed_order_settings]heading_downloadable'));
|
110 |
+
if($heading_downloadable)
|
111 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading_downloadable = icl_t($heading_downloadable[0]->context,'[woocommerce_customer_completed_order_settings]heading_downloadable',$heading_downloadable[0]->value);
|
112 |
$subject_downloadable = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_completed_order_settings]subject_downloadable'));
|
113 |
+
if($subject_downloadable)
|
114 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->subject_downloadable = icl_t($subject_downloadable[0]->context,'[woocommerce_customer_completed_order_settings]subject_downloadable',$subject_downloadable[0]->value);
|
115 |
|
116 |
+
$enabled = $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->enabled;
|
117 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->enabled = false;
|
118 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->trigger($order_id);
|
119 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->enabled = $enabled;
|
120 |
}
|
121 |
}
|
122 |
|
124 |
global $woocommerce,$wpdb,$sitepress_settings;
|
125 |
if(class_exists('WC_Email_Customer_Processing_Order')){
|
126 |
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_processing_order_settings]heading'));
|
127 |
+
if($heading)
|
128 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_processing_order_settings]heading',$heading[0]->value);
|
129 |
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_processing_order_settings]subject'));
|
130 |
+
if($subject)
|
131 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->subject = icl_t($subject[0]->context,'[woocommerce_customer_processing_order_settings]subject',$subject[0]->value);
|
132 |
|
133 |
+
$enabled = $woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->enabled;
|
134 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->enabled = false;
|
135 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->trigger($order_id);
|
136 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->enabled = $enabled;
|
137 |
}
|
138 |
}
|
139 |
|
141 |
global $woocommerce,$wpdb,$sitepress_settings,$sitepress;
|
142 |
if(class_exists('WC_Email_Customer_Note')){
|
143 |
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_note_settings]heading'));
|
144 |
+
if($heading)
|
145 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->heading = icl_t($heading[0]->context,'[woocommerce_customer_note_settings]heading',$heading[0]->value);
|
146 |
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_note_settings]subject'));
|
147 |
+
if($subject)
|
148 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->subject = icl_t($subject[0]->context,'[woocommerce_customer_note_settings]subject',$subject[0]->value);
|
149 |
+
|
150 |
+
$enabled = $woocommerce->mailer()->emails['WC_Email_Customer_Note']->enabled;
|
151 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->enabled = false;
|
152 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->trigger($args);
|
153 |
+
$woocommerce->mailer()->emails['WC_Email_Customer_Note']->enabled = $enabled;
|
154 |
+
}
|
155 |
+
}
|
156 |
|
157 |
+
|
158 |
+
function admin_email($order_id){
|
159 |
+
global $woocommerce,$sitepress,$wpdb,$sitepress_settings;
|
160 |
+
if(class_exists('WC_Email_New_Order')){
|
161 |
+
$recipients = explode(',',$woocommerce->mailer()->emails['WC_Email_New_Order']->get_recipient());
|
162 |
+
foreach($recipients as $recipient){
|
163 |
+
$user = get_user_by('email',$recipient);
|
164 |
+
if($user){
|
165 |
+
$user_lang = $sitepress->get_user_admin_language($user->ID);
|
166 |
+
}else{
|
167 |
+
$user_lang = get_post_meta($order_id, 'wpml_language', TRUE);
|
168 |
+
}
|
169 |
+
$this->change_email_language($user_lang);
|
170 |
+
$heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_new_order_settings]heading'));
|
171 |
+
if($heading)
|
172 |
+
$woocommerce->mailer()->emails['WC_Email_New_Order']->heading = icl_t($heading[0]->context,'[woocommerce_new_order_settings]heading',$heading[0]->value);
|
173 |
+
$subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_new_order_settings]subject'));
|
174 |
+
if($subject)
|
175 |
+
$woocommerce->mailer()->emails['WC_Email_New_Order']->subject = icl_t($subject[0]->context,'[woocommerce_new_order_settings]subject',$subject[0]->value);
|
176 |
+
|
177 |
+
|
178 |
+
|
179 |
+
$woocommerce->mailer()->emails['WC_Email_New_Order']->recipient = $recipient;
|
180 |
+
$woocommerce->mailer()->emails['WC_Email_New_Order']->trigger($order_id);
|
181 |
+
}
|
182 |
+
$woocommerce->mailer()->emails['WC_Email_New_Order']->enabled = false;
|
183 |
+
$this->refresh_email_lang($order_id);
|
184 |
}
|
185 |
}
|
186 |
|
222 |
return $link;
|
223 |
}
|
224 |
|
225 |
+
function email_instructions($order, $sent_to_admin, $plain_text = false){
|
226 |
+
global $woocommerce_wpml;
|
227 |
+
$this->refresh_email_lang($order->id);
|
228 |
+
$woocommerce_wpml->strings->translate_payment_instructions($order->payment_method);
|
229 |
+
}
|
230 |
+
|
231 |
}
|
inc/functions-troubleshooting.class.php
CHANGED
@@ -12,6 +12,7 @@ class WCML_Troubleshooting{
|
|
12 |
add_action('wp_ajax_trbl_sync_variations', array($this,'trbl_sync_variations'));
|
13 |
add_action('wp_ajax_trbl_gallery_images', array($this,'trbl_gallery_images'));
|
14 |
add_action('wp_ajax_trbl_update_count', array($this,'trbl_update_count'));
|
|
|
15 |
|
16 |
}
|
17 |
|
@@ -33,11 +34,11 @@ class WCML_Troubleshooting{
|
|
33 |
|
34 |
function wcml_sync_variations_update_option(){
|
35 |
global $wpdb;
|
|
|
|
|
36 |
|
37 |
-
$
|
38 |
-
|
39 |
-
$get_variables_products = $wpdb->get_results($wpdb->prepare("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
|
40 |
-
WHERE p.post_status = 'publish' AND tr.source_language_code is NULL AND tr.element_type = 'post_product' AND t.term_taxonomy_id = %d ORDER BY tr.element_id",$get_variation_term_taxonomy_id),ARRAY_A);
|
41 |
|
42 |
update_option('wcml_products_to_sync',$get_variables_products);
|
43 |
}
|
@@ -48,6 +49,12 @@ class WCML_Troubleshooting{
|
|
48 |
return $get_products_count;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
function trbl_sync_variations(){
|
53 |
|
@@ -120,4 +127,36 @@ class WCML_Troubleshooting{
|
|
120 |
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
12 |
add_action('wp_ajax_trbl_sync_variations', array($this,'trbl_sync_variations'));
|
13 |
add_action('wp_ajax_trbl_gallery_images', array($this,'trbl_gallery_images'));
|
14 |
add_action('wp_ajax_trbl_update_count', array($this,'trbl_update_count'));
|
15 |
+
add_action('wp_ajax_trbl_sync_categories', array($this,'trbl_sync_categories'));
|
16 |
|
17 |
}
|
18 |
|
34 |
|
35 |
function wcml_sync_variations_update_option(){
|
36 |
global $wpdb;
|
37 |
+
$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'");
|
38 |
+
$get_variation_term_taxonomy_ids = apply_filters('wcml_variation_term_taxonomy_ids',(array)$get_variation_term_taxonomy_ids);
|
39 |
|
40 |
+
$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
|
41 |
+
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);
|
|
|
|
|
42 |
|
43 |
update_option('wcml_products_to_sync',$get_variables_products);
|
44 |
}
|
49 |
return $get_products_count;
|
50 |
}
|
51 |
|
52 |
+
function wcml_count_product_categories(){
|
53 |
+
global $wpdb;
|
54 |
+
$get_product_categories_count = $wpdb->get_var("SELECT count(t.term_taxonomy_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");
|
55 |
+
return $get_product_categories_count;
|
56 |
+
}
|
57 |
+
|
58 |
|
59 |
function trbl_sync_variations(){
|
60 |
|
127 |
|
128 |
}
|
129 |
|
130 |
+
function trbl_sync_categories(){
|
131 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'trbl_sync_categories')){
|
132 |
+
die('Invalid nonce');
|
133 |
+
}
|
134 |
+
|
135 |
+
$page = isset($_POST['page'])?$_POST['page']:0;
|
136 |
+
|
137 |
+
global $wpdb,$sitepress;
|
138 |
+
|
139 |
+
$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));
|
140 |
+
|
141 |
+
foreach($all_categories as $category){
|
142 |
+
$trid = $sitepress->get_element_trid($category->term_taxonomy_id,'tax_product_cat');
|
143 |
+
$translations = $sitepress->get_element_translations($trid,'tax_product_cat');
|
144 |
+
$type = get_woocommerce_term_meta( $category->term_id, 'display_type',true);
|
145 |
+
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id',true);
|
146 |
+
foreach($translations as $translation){
|
147 |
+
if($translation->language_code != $sitepress->get_default_language()){
|
148 |
+
update_woocommerce_term_meta( $translation->term_id, 'display_type', $type );
|
149 |
+
update_woocommerce_term_meta( $translation->term_id, 'thumbnail_id', icl_object_id($thumbnail_id,'attachment',true,$translation->language_code) );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
echo 1;
|
156 |
+
|
157 |
+
die();
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
}
|
inc/missing-php-functions.php
CHANGED
@@ -16,6 +16,42 @@ if(false === function_exists('lcfirst'))
|
|
16 |
}
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
/* PHP 5.3 - end */
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
?>
|
16 |
}
|
17 |
}
|
18 |
|
19 |
+
if (get_magic_quotes_gpc()) {
|
20 |
+
if(!function_exists('stripslashes_deep')){
|
21 |
+
function stripslashes_deep($value)
|
22 |
+
{
|
23 |
+
$value = is_array($value) ?
|
24 |
+
array_map('stripslashes_deep', $value) :
|
25 |
+
stripslashes($value);
|
26 |
+
|
27 |
+
return $value;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
$_POST = array_map('stripslashes_deep', $_POST);
|
32 |
+
$_GET = array_map('stripslashes_deep', $_GET);
|
33 |
+
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
|
34 |
+
}
|
35 |
/* PHP 5.3 - end */
|
36 |
|
37 |
+
//WPML
|
38 |
+
add_action('plugins_loaded', 'wcml_check_wpml_is_ajax');
|
39 |
+
|
40 |
+
function wcml_check_wpml_is_ajax(){
|
41 |
+
if(version_compare(preg_replace('#-(.+)$#', '', ICL_SITEPRESS_VERSION), '3.1.5', '<')){
|
42 |
+
|
43 |
+
function wpml_is_ajax() {
|
44 |
+
if ( defined( 'DOING_AJAX' ) ) {
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
|
48 |
+
return ( isset( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) ? true : false;
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
?>
|
inc/multi-currency-support.class.php
CHANGED
@@ -1,7 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
class WCML_Multi_Currency_Support{
|
4 |
-
|
|
|
|
|
|
|
5 |
private $client_currency;
|
6 |
private $exchange_rates = array();
|
7 |
|
@@ -9,16 +12,34 @@ class WCML_Multi_Currency_Support{
|
|
9 |
function __construct(){
|
10 |
|
11 |
add_action('init', array($this, 'init'), 5);
|
12 |
-
add_action('wp_head', array($this, 'set_default_currency')); //@todo - review
|
13 |
|
|
|
14 |
if(is_ajax()){
|
15 |
add_action('wp_ajax_nopriv_wcml_switch_currency', array($this, 'switch_currency'));
|
16 |
add_action('wp_ajax_wcml_switch_currency', array($this, 'switch_currency'));
|
17 |
|
18 |
add_action('wp_ajax_legacy_update_custom_rates', array($this, 'legacy_update_custom_rates'));
|
19 |
add_action('wp_ajax_legacy_remove_custom_rates', array($this, 'legacy_remove_custom_rates'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
function _load_filters(){
|
@@ -29,7 +50,7 @@ class WCML_Multi_Currency_Support{
|
|
29 |
}else{
|
30 |
if(is_ajax() && $this->get_client_currency() != get_option('woocommerce_currency')){
|
31 |
if(isset($_REQUEST['action'])){
|
32 |
-
$ajax_actions = array('woocommerce_get_refreshed_fragments', 'woocommerce_update_order_review', 'woocommerce-checkout', 'woocommerce_checkout');
|
33 |
if(version_compare($GLOBALS['woocommerce']->version, '2.1', '>=')){
|
34 |
$ajax_actions[] = 'woocommerce_update_shipping_method';
|
35 |
}
|
@@ -45,16 +66,16 @@ class WCML_Multi_Currency_Support{
|
|
45 |
|
46 |
function init(){
|
47 |
|
|
|
|
|
48 |
if($this->_load_filters()){
|
49 |
-
|
50 |
-
$this->set_default_currency();
|
51 |
|
52 |
add_filter('woocommerce_currency', array($this, 'currency_filter'));
|
53 |
//add_filter('option_woocommerce_currency', array($this, 'currency_filter'));
|
54 |
|
55 |
add_filter('get_post_metadata', array($this, 'product_price_filter'), 10, 4);
|
56 |
add_filter('get_post_metadata', array($this, 'variation_prices_filter'), 12, 4); // second
|
57 |
-
|
58 |
add_filter('woocommerce_package_rates', array($this, 'shipping_taxes_filter'));
|
59 |
|
60 |
add_action('woocommerce_coupon_loaded', array($this, 'filter_coupon_data'));
|
@@ -67,61 +88,469 @@ class WCML_Multi_Currency_Support{
|
|
67 |
add_filter('woocommerce_table_rate_instance_settings', array($this, 'table_rate_instance_settings'));
|
68 |
}
|
69 |
|
70 |
-
|
|
|
|
|
|
|
71 |
|
72 |
}
|
73 |
|
74 |
-
|
|
|
75 |
|
76 |
-
$this->load_inline_js();
|
77 |
|
78 |
}
|
79 |
|
80 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
|
|
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
-
|
108 |
-
|
|
|
109 |
}
|
|
|
110 |
}
|
111 |
|
112 |
function load_inline_js(){
|
113 |
|
114 |
wc_enqueue_js( "
|
115 |
-
jQuery('.wcml_currency_switcher').on('change', function(){
|
116 |
var currency = jQuery(this).val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
jQuery('.wcml_currency_switcher').attr('disabled', 'disabled');
|
118 |
-
jQuery('.wcml_currency_switcher').
|
|
|
119 |
var data = {action: 'wcml_switch_currency', currency: currency}
|
120 |
jQuery.post(woocommerce_params.ajax_url, data, function(){
|
121 |
jQuery('.wcml_currency_switcher').removeAttr('disabled');
|
|
|
122 |
location.reload();
|
123 |
});
|
124 |
-
}
|
125 |
" );
|
126 |
|
127 |
}
|
@@ -146,7 +575,7 @@ class WCML_Multi_Currency_Support{
|
|
146 |
// legacy prior 3.1
|
147 |
$original_object_id = icl_object_id($object_id, get_post_type($object_id), false, $sitepress->get_default_language());
|
148 |
$ccr = get_post_meta($original_object_id, '_custom_conversion_rate', true);
|
149 |
-
if(in_array($meta_key, array('_price', '_regular_price', '_sale_price')) && isset($ccr[$meta_key][$this->get_client_currency()])){
|
150 |
$price_original = get_post_meta($original_object_id, $meta_key, $single);
|
151 |
$price = $price_original * $ccr[$meta_key][$this->get_client_currency()];
|
152 |
|
@@ -232,7 +661,7 @@ class WCML_Multi_Currency_Support{
|
|
232 |
$post_type = get_post_type($product_id);
|
233 |
$product_translations = $sitepress->get_element_translations($sitepress->get_element_trid($product_id, 'post_'.$post_type), 'post_'.$post_type);
|
234 |
foreach($product_translations as $translation){
|
235 |
-
if($translation->
|
236 |
$original_product_id = $translation->element_id;
|
237 |
break;
|
238 |
}
|
@@ -439,7 +868,7 @@ class WCML_Multi_Currency_Support{
|
|
439 |
global $woocommerce;
|
440 |
$woocommerce->shipping->load_shipping_methods();
|
441 |
$shipping_methods = $woocommerce->shipping->get_shipping_methods();
|
442 |
-
|
443 |
foreach($methods as $k => $method){
|
444 |
|
445 |
// exceptions
|
@@ -513,29 +942,105 @@ class WCML_Multi_Currency_Support{
|
|
513 |
}
|
514 |
|
515 |
function get_client_currency(){
|
516 |
-
global $woocommerce;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
|
518 |
-
if(!empty($woocommerce->session)){
|
519 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
|
521 |
if(is_null($this->client_currency)){
|
522 |
-
$
|
523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
524 |
}
|
525 |
-
}else{
|
526 |
-
$this->client_currency = get_option('woocommerce_currency');
|
527 |
}
|
528 |
-
|
529 |
return apply_filters('wcml_client_currency', $this->client_currency);
|
530 |
}
|
531 |
|
532 |
function set_client_currency($currency){
|
533 |
-
|
|
|
|
|
|
|
534 |
$woocommerce->session->set('client_currency', $currency);
|
|
|
|
|
|
|
535 |
do_action('wcml_set_client_currency', $currency);
|
536 |
|
537 |
}
|
538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
function get_exchange_rates(){
|
540 |
|
541 |
$exchange_rates = apply_filters('wcml_exchange_rates', $this->exchange_rates);
|
@@ -565,52 +1070,67 @@ class WCML_Multi_Currency_Support{
|
|
565 |
exit;
|
566 |
}
|
567 |
|
|
|
|
|
|
|
|
|
|
|
568 |
|
569 |
-
function currency_switcher(
|
570 |
-
global $sitepress
|
571 |
-
// format tags
|
572 |
-
// Name - %name
|
573 |
-
// Symbol - %symbol
|
574 |
-
// Code - $code
|
575 |
|
576 |
-
|
577 |
-
|
578 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
579 |
|
580 |
$wc_currencies = get_woocommerce_currencies();
|
581 |
|
582 |
-
$
|
|
|
|
|
|
|
|
|
583 |
|
|
|
584 |
echo '<select class="wcml_currency_switcher">';
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
}
|
594 |
}
|
|
|
595 |
echo '</select>';
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
function switch_currency(){
|
600 |
-
$this->set_client_currency($_POST['currency']);
|
601 |
-
|
602 |
-
// force set user cookie when user is not logged in
|
603 |
-
global $woocommerce, $current_user;
|
604 |
-
if(empty($woocommerce->session->data) && empty($current_user->ID)){
|
605 |
-
$woocommerce->session->set_customer_session_cookie(true);
|
606 |
}
|
607 |
-
|
608 |
-
do_action('wcml_switch_currency', $_POST['currency']);
|
609 |
-
|
610 |
-
exit;
|
611 |
-
|
612 |
-
}
|
613 |
-
|
614 |
|
|
|
|
|
|
|
|
|
615 |
|
616 |
-
}
|
|
1 |
<?php
|
2 |
|
3 |
class WCML_Multi_Currency_Support{
|
4 |
+
|
5 |
+
private $currencies = array();
|
6 |
+
private $currency_codes = array();
|
7 |
+
|
8 |
private $client_currency;
|
9 |
private $exchange_rates = array();
|
10 |
|
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 |
|
17 |
+
|
18 |
if(is_ajax()){
|
19 |
add_action('wp_ajax_nopriv_wcml_switch_currency', array($this, 'switch_currency'));
|
20 |
add_action('wp_ajax_wcml_switch_currency', array($this, 'switch_currency'));
|
21 |
|
22 |
add_action('wp_ajax_legacy_update_custom_rates', array($this, 'legacy_update_custom_rates'));
|
23 |
add_action('wp_ajax_legacy_remove_custom_rates', array($this, 'legacy_remove_custom_rates'));
|
24 |
+
|
25 |
+
add_action('wp_ajax_wcml_new_currency', array($this,'add_currency'));
|
26 |
+
add_action('wp_ajax_wcml_save_currency', array($this,'save_currency'));
|
27 |
+
add_action('wp_ajax_wcml_delete_currency', array($this,'delete_currency'));
|
28 |
+
add_action('wp_ajax_wcml_currencies_list', array($this,'currencies_list'));
|
29 |
+
|
30 |
+
add_action('wp_ajax_wcml_update_currency_lang', array($this,'update_currency_lang'));
|
31 |
+
add_action('wp_ajax_wcml_update_default_currency', array($this,'update_default_currency'));
|
32 |
+
|
33 |
+
|
34 |
}
|
35 |
|
36 |
+
if(is_admin()){
|
37 |
+
add_action('admin_footer', array($this, 'currency_options_wc_integration'));
|
38 |
+
add_action('woocommerce_settings_save_general', array($this, 'currency_options_wc_integration_save_hook'));
|
39 |
+
}
|
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(){
|
50 |
}else{
|
51 |
if(is_ajax() && $this->get_client_currency() != get_option('woocommerce_currency')){
|
52 |
if(isset($_REQUEST['action'])){
|
53 |
+
$ajax_actions = array('woocommerce_get_refreshed_fragments', 'woocommerce_update_order_review', 'woocommerce-checkout', 'woocommerce_checkout', 'woocommerce_add_to_cart');
|
54 |
if(version_compare($GLOBALS['woocommerce']->version, '2.1', '>=')){
|
55 |
$ajax_actions[] = 'woocommerce_update_shipping_method';
|
56 |
}
|
66 |
|
67 |
function init(){
|
68 |
|
69 |
+
$this->init_currencies();
|
70 |
+
|
71 |
if($this->_load_filters()){
|
|
|
|
|
72 |
|
73 |
add_filter('woocommerce_currency', array($this, 'currency_filter'));
|
74 |
//add_filter('option_woocommerce_currency', array($this, 'currency_filter'));
|
75 |
|
76 |
add_filter('get_post_metadata', array($this, 'product_price_filter'), 10, 4);
|
77 |
add_filter('get_post_metadata', array($this, 'variation_prices_filter'), 12, 4); // second
|
78 |
+
|
79 |
add_filter('woocommerce_package_rates', array($this, 'shipping_taxes_filter'));
|
80 |
|
81 |
add_action('woocommerce_coupon_loaded', array($this, 'filter_coupon_data'));
|
88 |
add_filter('woocommerce_table_rate_instance_settings', array($this, 'table_rate_instance_settings'));
|
89 |
}
|
90 |
|
91 |
+
add_filter('option_woocommerce_currency_pos', array($this, 'filter_currency_position_option'));
|
92 |
+
add_filter('option_woocommerce_price_thousand_sep', array($this, 'filter_currency_thousand_sep_option'));
|
93 |
+
add_filter('option_woocommerce_price_decimal_sep', array($this, 'filter_currency_decimal_sep_option'));
|
94 |
+
add_filter('option_woocommerce_price_num_decimals', array($this, 'filter_currency_num_decimals_option'));
|
95 |
|
96 |
}
|
97 |
|
98 |
+
add_action('currency_switcher', array($this, 'currency_switcher'));
|
99 |
+
add_shortcode('currency_switcher', array($this, 'currency_switcher_shortcode'));
|
100 |
|
101 |
+
if(!is_admin()) $this->load_inline_js();
|
102 |
|
103 |
}
|
104 |
|
105 |
+
function init_currencies(){
|
106 |
+
global $woocommerce_wpml, $sitepress;
|
107 |
+
$this->currencies =& $woocommerce_wpml->settings['currency_options']; // ref
|
108 |
+
|
109 |
+
$save_to_db = false;
|
110 |
+
|
111 |
+
$active_languages = $sitepress->get_active_languages();
|
112 |
+
|
113 |
+
$currency_defaults = array(
|
114 |
+
'rate' => 0,
|
115 |
+
'position' => 'left',
|
116 |
+
'thousand_sep' => ',',
|
117 |
+
'decimal_sep' => '.',
|
118 |
+
'num_decimals' => 2,
|
119 |
+
'rounding' => 'disabled',
|
120 |
+
'rounding_increment' => 1,
|
121 |
+
'auto_subtract' => 0
|
122 |
+
);
|
123 |
+
|
124 |
+
foreach($this->currencies as $code => $currency){
|
125 |
+
foreach($currency_defaults as $key => $val){
|
126 |
+
if(!isset($currency[$key])){
|
127 |
+
$this->currencies[$code][$key] = $val;
|
128 |
+
$save_to_db = true;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
foreach($active_languages as $language){
|
133 |
+
if(!isset($currency['languages'][$language['code']])){
|
134 |
+
$this->currencies[$code]['languages'][$language['code']] = 1;
|
135 |
+
$save_to_db = true;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
$this->currency_codes = array_keys($this->currencies);
|
141 |
+
|
142 |
+
// default language currencies
|
143 |
+
foreach($active_languages as $language){
|
144 |
+
if(!isset($woocommerce_wpml->settings['default_currencies'][$language['code']])){
|
145 |
+
$woocommerce_wpml->settings['default_currencies'][$language['code']] = 0;
|
146 |
+
$save_to_db = true;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
// sanity check
|
151 |
+
if(isset($woocommerce_wpml->settings['default_currencies'])){
|
152 |
+
foreach($woocommerce_wpml->settings['default_currencies'] as $language => $value){
|
153 |
+
if(!isset($active_languages[$language])){
|
154 |
+
unset($woocommerce_wpml->settings['default_currencies'][$language]);
|
155 |
+
$save_to_db = true;
|
156 |
+
}
|
157 |
+
if(!empty($value) && !in_array($value, $this->currency_codes)){
|
158 |
+
$woocommerce_wpml->settings['default_currencies'][$language] = 0;
|
159 |
+
$save_to_db = true;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
if($save_to_db){
|
165 |
+
$woocommerce_wpml->update_settings();
|
166 |
+
}
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
+
function get_currencies(){
|
171 |
+
|
172 |
+
// by default, exclude default currency
|
173 |
+
$currencies = array();
|
174 |
+
foreach($this->currencies as $key => $value){
|
175 |
+
if(get_option('woocommerce_currency') != $key){
|
176 |
+
$currencies[$key] = $value;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
return $currencies;
|
181 |
+
}
|
182 |
+
|
183 |
+
function get_currency_codes(){
|
184 |
+
return $this->currency_codes;
|
185 |
+
}
|
186 |
+
|
187 |
+
function add_currency(){
|
188 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_new_currency')){
|
189 |
+
die('Invalid nonce');
|
190 |
+
}
|
191 |
|
192 |
+
global $sitepress, $woocommerce_wpml;;
|
193 |
+
$settings = $woocommerce_wpml->get_settings();
|
194 |
+
|
195 |
+
$return = array();
|
196 |
+
|
197 |
+
if(!empty($_POST['currency_code'])){
|
198 |
+
|
199 |
+
$currency_code = $_POST['currency_code'];
|
200 |
+
|
201 |
+
$active_languages = $sitepress->get_active_languages();
|
202 |
+
$return['languages'] ='';
|
203 |
+
foreach($active_languages as $language){
|
204 |
+
if(!isset($settings['currency_options'][$currency_code]['languages'][$language['code']])){
|
205 |
+
$settings['currency_options'][$currency_code]['languages'][$language['code']] = 1;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
$settings['currency_options'][$currency_code]['rate'] = (double) $_POST['currency_value'];
|
209 |
+
$settings['currency_options'][$currency_code]['updated'] = date('Y-m-d H:i:s');
|
210 |
|
211 |
+
$wc_currency = get_option('woocommerce_currency');
|
212 |
+
if(!isset($settings['currencies_order']))
|
213 |
+
$settings['currencies_order'][] = $wc_currency;
|
214 |
|
215 |
+
$settings['currencies_order'][] = $currency_code;
|
216 |
+
|
217 |
+
$woocommerce_wpml->update_settings($settings);
|
218 |
+
|
219 |
+
$wc_currencies = get_woocommerce_currencies();
|
220 |
+
$return['currency_name_formatted'] = sprintf('%s (%s)', $wc_currencies[$currency_code], sprintf('%s 99.99', get_woocommerce_currency_symbol($currency_code)));
|
221 |
+
$return['currency_name_formatted_without_rate'] = sprintf('%s (%s)', $wc_currencies[$currency_code], get_woocommerce_currency_symbol($currency_code));
|
222 |
+
$return['currency_meta_info'] = sprintf('1 %s = %s %s', $wc_currency, $settings['currency_options'][$currency_code]['rate'], $currency_code);
|
223 |
+
|
224 |
+
ob_start();
|
225 |
+
$code = $currency_code;
|
226 |
+
$this->init_currencies();
|
227 |
+
$currency = $this->currencies[$currency_code];
|
228 |
+
include WCML_PLUGIN_PATH . '/menu/sub/custom-currency-options.php';
|
229 |
+
$return['currency_options'] = ob_get_contents();
|
230 |
+
ob_end_clean();
|
231 |
+
|
232 |
+
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
echo json_encode($return);
|
237 |
+
die();
|
238 |
+
}
|
239 |
+
|
240 |
+
function save_currency(){
|
241 |
+
global $woocommerce_wpml;
|
242 |
+
|
243 |
+
$currency_code = $_POST['currency'];
|
244 |
+
$options = $_POST['currency_options'][$currency_code];
|
245 |
+
|
246 |
+
$changed = false;
|
247 |
+
$rate_changed = false;
|
248 |
+
foreach($this->currencies[$currency_code] as $key => $value){
|
249 |
+
|
250 |
+
if(isset($options[$key]) && $options[$key] != $value){
|
251 |
+
$this->currencies[$currency_code][$key] = $options[$key];
|
252 |
+
$changed = true;
|
253 |
+
if($key == 'rate'){
|
254 |
+
$rate_changed = true;
|
255 |
}
|
256 |
}
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
if($changed){
|
261 |
+
if($rate_changed){
|
262 |
+
$this->currencies[$currency_code]['updated'] = date('Y-m-d H:i:s');
|
263 |
+
}
|
264 |
+
$woocommerce_wpml->settings['currency_options'] = $this->currencies;
|
265 |
+
$woocommerce_wpml->update_settings();
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
$wc_currency = get_option('woocommerce_currency');
|
270 |
+
$wc_currencies = get_woocommerce_currencies();
|
271 |
+
|
272 |
+
switch($this->currencies[$currency_code]['position']){
|
273 |
+
case 'left': $price = sprintf('%s99.99', get_woocommerce_currency_symbol($currency_code)); break;
|
274 |
+
case 'right': $price = sprintf('99.99%s', get_woocommerce_currency_symbol($currency_code)); break;
|
275 |
+
case 'left_space': $price = sprintf('%s 99.99', get_woocommerce_currency_symbol($currency_code)); break;
|
276 |
+
case 'right_space': $price = sprintf('99.99 %s', get_woocommerce_currency_symbol($currency_code)); break;
|
277 |
+
}
|
278 |
+
$return['currency_name_formatted'] = sprintf('%s (%s)', $wc_currencies[$currency_code], $price);
|
279 |
+
|
280 |
+
$return['currency_meta_info'] = sprintf('1 %s = %s %s', $wc_currency, $this->currencies[$currency_code]['rate'], $currency_code);
|
281 |
+
|
282 |
+
echo json_encode($return);
|
283 |
+
exit;
|
284 |
+
}
|
285 |
+
|
286 |
+
function delete_currency(){
|
287 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_delete_currency')){
|
288 |
+
die('Invalid nonce');
|
289 |
+
}
|
290 |
+
global $woocommerce_wpml;
|
291 |
+
|
292 |
+
$settings = $woocommerce_wpml->get_settings();
|
293 |
+
unset($settings['currency_options'][$_POST['code']]);
|
294 |
+
|
295 |
+
if(isset($settings['currencies_order'])){
|
296 |
+
foreach($settings['currencies_order'] as $key=>$cur_code){
|
297 |
+
if($cur_code == $_POST['code']) unset($settings['currencies_order'][$key]);
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
$woocommerce_wpml->update_settings($settings);
|
302 |
+
|
303 |
+
exit;
|
304 |
+
}
|
305 |
+
|
306 |
+
function currencies_list(){
|
307 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_currencies_list')){
|
308 |
+
die('Invalid nonce');
|
309 |
+
}
|
310 |
+
global $woocommerce_wpml;
|
311 |
+
$wc_currencies = get_woocommerce_currencies();
|
312 |
+
$wc_currency = get_option('woocommerce_currency');
|
313 |
+
unset($wc_currencies[$wc_currency]);
|
314 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
315 |
+
$html = '<select name="code">';
|
316 |
+
foreach($wc_currencies as $wc_code=>$currency_name){
|
317 |
+
if(empty($currencies[$wc_code])){
|
318 |
+
$html .= '<option value="'.$wc_code.'">'.$currency_name.'</option>';
|
319 |
+
}
|
320 |
+
}
|
321 |
+
$html .= '</select>';
|
322 |
+
ob_clean();
|
323 |
+
echo $html;
|
324 |
|
325 |
+
die();
|
326 |
+
}
|
327 |
+
|
328 |
+
function update_currency_lang(){
|
329 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_update_currency_lang')){
|
330 |
+
die('Invalid nonce');
|
331 |
+
}
|
332 |
+
global $woocommerce_wpml;
|
333 |
+
|
334 |
+
$settings = $woocommerce_wpml->get_settings();
|
335 |
+
$settings['currency_options'][$_POST['code']]['languages'][$_POST['lang']] = $_POST['value'];
|
336 |
|
337 |
+
$woocommerce_wpml->update_settings($settings);
|
338 |
+
exit;
|
339 |
+
}
|
340 |
+
|
341 |
+
function update_default_currency(){
|
342 |
+
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_update_default_currency')){
|
343 |
+
die('Invalid nonce');
|
344 |
}
|
345 |
+
global $woocommerce_wpml;
|
346 |
+
$woocommerce_wpml->settings['default_currencies'][$_POST['lang']] = $_POST['code'];
|
347 |
+
$woocommerce_wpml->update_settings();
|
348 |
+
|
349 |
+
|
350 |
+
exit;
|
351 |
}
|
352 |
+
|
353 |
+
function currency_options_wc_integration(){
|
354 |
+
global $woocommerce_wpml;
|
355 |
+
|
356 |
+
if($woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT && isset($_GET['page']) && $_GET['page'] == 'wc-settings' && empty($_GET['tab'])){
|
357 |
+
|
358 |
+
wp_enqueue_style('wcml_wc', WCML_PLUGIN_URL . '/assets/css/wcml-wc-integration.css', array(), WCML_VERSION);
|
359 |
+
|
360 |
+
$wc_currencies = get_woocommerce_currencies();
|
361 |
+
$wc_currency = get_option('woocommerce_currency');
|
362 |
+
|
363 |
+
foreach($this->currencies as $code => $currency){
|
364 |
+
$selected = $code == $wc_currency ? ' selected' : '';
|
365 |
+
$menu[] = '<a class="wcml_currency_options_menu_item' . $selected . '" href="#" data-currency="' . $code . '">' .
|
366 |
+
sprintf('%s (%s)', $wc_currencies[$code], get_woocommerce_currency_symbol($code)) . '</a>';
|
367 |
+
|
368 |
+
if($code != $wc_currency){
|
369 |
+
$symbols[] = get_woocommerce_currency_symbol($code);
|
370 |
+
|
371 |
+
$options_currency_pos[] = $currency['position'];
|
372 |
+
$options_thousand_sep[] = $currency['thousand_sep'];
|
373 |
+
$options_decimal_sep[] = $currency['decimal_sep'];
|
374 |
+
$options_num_decimals[] = $currency['num_decimals'];
|
375 |
+
}
|
376 |
+
|
377 |
+
}
|
378 |
+
|
379 |
+
$menu = '<p>' . esc_js(__('Select the currency you want to set the options for:', 'wpml-wcml')) . '</p><br />' . join (' | ', $menu);
|
380 |
+
|
381 |
+
$codes = "['" . join("', '", array_keys($this->get_currencies())) . "']";
|
382 |
+
$symbols = "['" . join("', '", $symbols) . "']";
|
383 |
+
$symbol_default = get_woocommerce_currency_symbol($wc_currency);
|
384 |
+
$symbol_default = html_entity_decode($symbol_default);
|
385 |
+
|
386 |
+
$options_currency_pos = "['" . join("', '", $options_currency_pos) . "']";
|
387 |
+
$options_thousand_sep = "['" . join("', '", $options_thousand_sep) . "']";
|
388 |
+
$options_decimal_sep = "['" . join("', '", $options_decimal_sep) . "']";
|
389 |
+
$options_num_decimals = "['" . join("', '", $options_num_decimals) . "']";
|
390 |
+
|
391 |
+
wc_enqueue_js( "
|
392 |
+
var wcml_wc_currency_options_integration = {
|
393 |
+
|
394 |
+
init: function(){
|
395 |
+
|
396 |
+
var table = jQuery('.form-table').eq(1);
|
397 |
+
var currencies = {$codes};
|
398 |
+
var symbols = {$symbols};
|
399 |
+
var symbol_default = '{$symbol_default}';
|
400 |
+
|
401 |
+
var options_currency_pos = {$options_currency_pos};
|
402 |
+
var options_thousand_sep = {$options_thousand_sep};
|
403 |
+
var options_decimal_sep = {$options_decimal_sep};
|
404 |
+
var options_num_decimals = {$options_num_decimals};
|
405 |
+
|
406 |
+
table.find('tr').each(function( index ){
|
407 |
+
if(index > 0){
|
408 |
+
jQuery(this).addClass('wcml_co_row');
|
409 |
+
jQuery(this).addClass('wcml_co_row_{$wc_currency}');
|
410 |
+
}
|
411 |
+
});
|
412 |
+
|
413 |
+
table.find('tr').each(function( index ){
|
414 |
+
if(index > 0){
|
415 |
+
for(var i in currencies){
|
416 |
+
var currency_option_row = jQuery(this).clone();
|
417 |
+
currency_option_row.removeClass('wcml_co_row_{$wc_currency}');
|
418 |
+
currency_option_row.addClass('wcml_co_row_' + currencies[i]);
|
419 |
+
currency_option_row.addClass('hidden');
|
420 |
+
|
421 |
+
var html = currency_option_row.html();
|
422 |
+
|
423 |
+
html = html.replace(/woocommerce_currency_pos/g, 'woocommerce_currency_pos_' + currencies[i]);
|
424 |
+
html = html.replace(/woocommerce_price_thousand_sep/g, 'woocommerce_price_thousand_sep_' + currencies[i]);
|
425 |
+
html = html.replace(/woocommerce_price_decimal_sep/g, 'woocommerce_price_decimal_sep_' + currencies[i]);
|
426 |
+
html = html.replace(/woocommerce_price_num_decimals/g, 'woocommerce_price_num_decimals_' + currencies[i]);
|
427 |
+
|
428 |
+
html = html.replace(new RegExp(symbol_default, 'g'), symbols[i]);
|
429 |
+
|
430 |
+
currency_option_row.html(html);
|
431 |
+
|
432 |
+
currency_option_row.find('select[name=woocommerce_currency_pos_' + currencies[i] + ']').val(options_currency_pos[i]);
|
433 |
+
currency_option_row.find('input[name=woocommerce_price_thousand_sep_' + currencies[i] + ']').val(options_thousand_sep[i]);
|
434 |
+
currency_option_row.find('input[name=woocommerce_price_decimal_sep_' + currencies[i] + ']').val(options_decimal_sep[i]);
|
435 |
+
currency_option_row.find('input[name=woocommerce_price_num_decimals_' + currencies[i] + ']').val(options_num_decimals[i]);
|
436 |
+
|
437 |
+
jQuery(this).after(currency_option_row);
|
438 |
+
}
|
439 |
+
}
|
440 |
+
});
|
441 |
+
|
442 |
+
table.find('tr').eq(0).after('<tr valign=\"top\"><td> </td><td>{$menu}</td></tr>');
|
443 |
+
jQuery(document).on('click', '.wcml_currency_options_menu_item', function(){
|
444 |
+
jQuery('.wcml_currency_options_menu_item').removeClass('selected');
|
445 |
+
jQuery(this).addClass('selected');
|
446 |
+
|
447 |
+
jQuery('.wcml_co_row').hide();
|
448 |
+
jQuery('.wcml_co_row_' + jQuery(this).data('currency')).show();
|
449 |
+
|
450 |
+
return false;
|
451 |
+
});
|
452 |
+
|
453 |
+
|
454 |
+
}
|
455 |
+
|
456 |
+
}
|
457 |
+
|
458 |
+
wcml_wc_currency_options_integration.init();
|
459 |
+
|
460 |
+
|
461 |
+
" );
|
462 |
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
+
function currency_options_wc_integration_save_hook(){
|
467 |
+
global $woocommerce_wpml;
|
468 |
+
|
469 |
+
if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
|
470 |
+
|
471 |
+
$save = false;
|
472 |
+
|
473 |
+
$options = array(
|
474 |
+
'woocommerce_currency_pos_' => 'position',
|
475 |
+
'woocommerce_price_thousand_sep_' => 'thousand_sep',
|
476 |
+
'woocommerce_price_decimal_sep_' => 'decimal_sep',
|
477 |
+
'woocommerce_price_num_decimals_' => 'num_decimals'
|
478 |
+
);
|
479 |
+
|
480 |
+
foreach($this->get_currencies() as $code => $currency){
|
481 |
+
foreach($options as $wc_key => $key){
|
482 |
+
if(isset($_POST[$wc_key . $code]) && $_POST[$wc_key . $code] != $this->currencies[$code][$key]){
|
483 |
+
$save = true;
|
484 |
+
$this->currencies[$code][$key] = $_POST[$wc_key . $code];
|
485 |
+
}
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
if($save){
|
490 |
+
$woocommerce_wpml->settings['currency_options'] = $this->currencies;
|
491 |
+
$woocommerce_wpml->update_settings();
|
492 |
+
|
493 |
+
$this->init_currencies();
|
494 |
+
}
|
495 |
+
|
496 |
+
}
|
497 |
+
|
498 |
+
}
|
499 |
+
|
500 |
+
function filter_currency_position_option($value){
|
501 |
+
if(isset($this->currencies[$this->client_currency]['position']) &&
|
502 |
+
in_array($this->currencies[$this->client_currency]['position'], array('left', 'right', 'left_space', 'right_space'))){
|
503 |
+
$value = $this->currencies[$this->client_currency]['position'];
|
504 |
+
}
|
505 |
+
return $value;
|
506 |
+
}
|
507 |
+
|
508 |
+
function filter_currency_thousand_sep_option($value){
|
509 |
+
if(isset($this->currencies[$this->client_currency]['thousand_sep']) ){
|
510 |
+
$value = $this->currencies[$this->client_currency]['thousand_sep'];
|
511 |
+
}
|
512 |
+
return $value;
|
513 |
+
}
|
514 |
+
|
515 |
+
function filter_currency_decimal_sep_option($value){
|
516 |
+
if(isset($this->currencies[$this->client_currency]['decimal_sep']) ){
|
517 |
+
$value = $this->currencies[$this->client_currency]['decimal_sep'];
|
518 |
+
}
|
519 |
+
return $value;
|
520 |
+
}
|
521 |
|
522 |
+
function filter_currency_num_decimals_option($value){
|
523 |
+
if(isset($this->currencies[$this->client_currency]['num_decimals']) ){
|
524 |
+
$value = $this->currencies[$this->client_currency]['num_decimals'];
|
525 |
}
|
526 |
+
return $value;
|
527 |
}
|
528 |
|
529 |
function load_inline_js(){
|
530 |
|
531 |
wc_enqueue_js( "
|
532 |
+
jQuery('.wcml_currency_switcher').on('change', function(){
|
533 |
var currency = jQuery(this).val();
|
534 |
+
load_currency(currency);
|
535 |
+
});
|
536 |
+
jQuery('.wcml_currency_switcher li').on('click', function(){
|
537 |
+
var currency = jQuery(this).attr('rel');
|
538 |
+
load_currency(currency);
|
539 |
+
});
|
540 |
+
|
541 |
+
|
542 |
+
function load_currency(currency){
|
543 |
+
var ajax_loader = jQuery('<img style=\"margin-left:10px;\" width=\"16\" heigth=\"16\" src=\"" . WCML_PLUGIN_URL . "/assets/images/ajax-loader.gif\" />')
|
544 |
jQuery('.wcml_currency_switcher').attr('disabled', 'disabled');
|
545 |
+
jQuery('.wcml_currency_switcher').after()
|
546 |
+
ajax_loader.insertAfter(jQuery('.wcml_currency_switcher'));
|
547 |
var data = {action: 'wcml_switch_currency', currency: currency}
|
548 |
jQuery.post(woocommerce_params.ajax_url, data, function(){
|
549 |
jQuery('.wcml_currency_switcher').removeAttr('disabled');
|
550 |
+
ajax_loader.remove();
|
551 |
location.reload();
|
552 |
});
|
553 |
+
}
|
554 |
" );
|
555 |
|
556 |
}
|
575 |
// legacy prior 3.1
|
576 |
$original_object_id = icl_object_id($object_id, get_post_type($object_id), false, $sitepress->get_default_language());
|
577 |
$ccr = get_post_meta($original_object_id, '_custom_conversion_rate', true);
|
578 |
+
if(in_array($meta_key, array('_price', '_regular_price', '_sale_price')) && !empty($ccr) && isset($ccr[$meta_key][$this->get_client_currency()])){
|
579 |
$price_original = get_post_meta($original_object_id, $meta_key, $single);
|
580 |
$price = $price_original * $ccr[$meta_key][$this->get_client_currency()];
|
581 |
|
661 |
$post_type = get_post_type($product_id);
|
662 |
$product_translations = $sitepress->get_element_translations($sitepress->get_element_trid($product_id, 'post_'.$post_type), 'post_'.$post_type);
|
663 |
foreach($product_translations as $translation){
|
664 |
+
if($translation->language_code == $sitepress->get_default_language()){
|
665 |
$original_product_id = $translation->element_id;
|
666 |
break;
|
667 |
}
|
868 |
global $woocommerce;
|
869 |
$woocommerce->shipping->load_shipping_methods();
|
870 |
$shipping_methods = $woocommerce->shipping->get_shipping_methods();
|
871 |
+
|
872 |
foreach($methods as $k => $method){
|
873 |
|
874 |
// exceptions
|
942 |
}
|
943 |
|
944 |
function get_client_currency(){
|
945 |
+
global $woocommerce, $woocommerce_wpml, $sitepress;
|
946 |
+
|
947 |
+
$default_currencies = $woocommerce_wpml->settings['default_currencies'];
|
948 |
+
$current_language = $sitepress->get_current_language();
|
949 |
+
$active_languages = $sitepress->get_active_languages();
|
950 |
+
|
951 |
+
if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
|
952 |
+
return $this->client_currency = $_POST['currency'];
|
953 |
+
}
|
954 |
+
|
955 |
|
956 |
+
if(empty($this->client_currency) && !empty($woocommerce->session)){
|
957 |
+
$session_currency = $woocommerce->session->get('client_currency_' . $current_language);
|
958 |
+
if(isset($this->currencies[$session_currency]) && !empty($this->currencies[$session_currency]['languages'][$current_language])){
|
959 |
+
$this->client_currency = $session_currency;
|
960 |
+
}
|
961 |
+
}
|
962 |
+
|
963 |
+
if(!$this->client_currency && $default_currencies[$current_language]){
|
964 |
+
$this->client_currency = $default_currencies[$current_language];
|
965 |
+
if(!empty($woocommerce->session)){
|
966 |
+
$woocommerce->session->set('client_currency_' . $current_language, $this->client_currency);
|
967 |
+
}
|
968 |
+
}
|
969 |
+
|
970 |
+
//reset other languages
|
971 |
+
if(!$this->client_currency && !empty($woocommerce->session)){
|
972 |
+
foreach($active_languages as $language){
|
973 |
+
if($language['code'] != $current_language){
|
974 |
+
$woocommerce->session->__unset('client_currency_' . $current_language);
|
975 |
+
}
|
976 |
+
}
|
977 |
+
}
|
978 |
+
|
979 |
+
if(empty($this->client_currency)){
|
980 |
+
|
981 |
+
// client currency in general / if enabled for this language
|
982 |
+
if( !empty($woocommerce->session) ){
|
983 |
+
$session_currency = $woocommerce->session->get('client_currency');
|
984 |
+
if($session_currency && !empty($this->currencies[$session_currency]['languages'][$current_language])){
|
985 |
+
$this->client_currency = $woocommerce->session->get('client_currency');
|
986 |
+
}
|
987 |
+
|
988 |
+
}
|
989 |
|
990 |
if(is_null($this->client_currency)){
|
991 |
+
$woocommerce_currency = get_option('woocommerce_currency');
|
992 |
+
|
993 |
+
// fall on WC currency if enabled for this language
|
994 |
+
if(!empty($this->currencies[$woocommerce_currency]['languages'][$current_language])){
|
995 |
+
$this->client_currency = $woocommerce_currency;
|
996 |
+
}else{
|
997 |
+
// first currency enabled for this language
|
998 |
+
foreach($this->currencies as $code => $data){
|
999 |
+
if(!empty($data['languages'][$current_language])){
|
1000 |
+
$this->client_currency = $code;
|
1001 |
+
break;
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
if(!empty($woocommerce->session)){
|
1007 |
+
$woocommerce->session->set('client_currency', $this->client_currency);
|
1008 |
+
}
|
1009 |
}
|
|
|
|
|
1010 |
}
|
1011 |
+
|
1012 |
return apply_filters('wcml_client_currency', $this->client_currency);
|
1013 |
}
|
1014 |
|
1015 |
function set_client_currency($currency){
|
1016 |
+
|
1017 |
+
global $woocommerce, $sitepress;
|
1018 |
+
$this->client_currency = $currency;
|
1019 |
+
|
1020 |
$woocommerce->session->set('client_currency', $currency);
|
1021 |
+
$woocommerce->session->set('client_currency_' . $sitepress->get_current_language(), $currency);
|
1022 |
+
|
1023 |
+
|
1024 |
do_action('wcml_set_client_currency', $currency);
|
1025 |
|
1026 |
}
|
1027 |
|
1028 |
+
function switch_currency(){
|
1029 |
+
$this->set_client_currency($_POST['currency']);
|
1030 |
+
|
1031 |
+
// force set user cookie when user is not logged in
|
1032 |
+
global $woocommerce, $current_user;
|
1033 |
+
if(empty($woocommerce->session->data) && empty($current_user->ID)){
|
1034 |
+
$woocommerce->session->set_customer_session_cookie(true);
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
do_action('wcml_switch_currency', $_POST['currency']);
|
1038 |
+
|
1039 |
+
exit;
|
1040 |
+
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
|
1044 |
function get_exchange_rates(){
|
1045 |
|
1046 |
$exchange_rates = apply_filters('wcml_exchange_rates', $this->exchange_rates);
|
1070 |
exit;
|
1071 |
}
|
1072 |
|
1073 |
+
function currency_switcher_shortcode($atts){
|
1074 |
+
extract( shortcode_atts( array(), $atts ) );
|
1075 |
+
|
1076 |
+
$this->currency_switcher($atts);
|
1077 |
+
}
|
1078 |
|
1079 |
+
function currency_switcher($args = array()){
|
1080 |
+
global $sitepress, $woocommerce_wpml;
|
|
|
|
|
|
|
|
|
1081 |
|
1082 |
+
$settings = $woocommerce_wpml->get_settings();
|
1083 |
+
if(!isset($args['switcher_style'])){
|
1084 |
+
$args['switcher_style'] = isset($settings['currency_switcher_style'])?$settings['currency_switcher_style']:'dropdown';
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
if(!isset($args['orientation'])){
|
1088 |
+
$args['orientation'] = isset($settings['wcml_curr_sel_orientation'])?$settings['wcml_curr_sel_orientation']:'vertical';
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
if(!isset($args['format'])){
|
1092 |
+
$args['format'] = isset($settings['wcml_curr_template']) && $settings['wcml_curr_template'] != '' ? $settings['wcml_curr_template']:'%name% (%symbol%) - %code%';
|
1093 |
+
}
|
1094 |
+
|
1095 |
|
1096 |
$wc_currencies = get_woocommerce_currencies();
|
1097 |
|
1098 |
+
if(!isset($settings['currencies_order'])){
|
1099 |
+
$currencies = $this->get_currency_codes();
|
1100 |
+
}else{
|
1101 |
+
$currencies = $settings['currencies_order'];
|
1102 |
+
}
|
1103 |
|
1104 |
+
if($args['switcher_style'] == 'dropdown'){
|
1105 |
echo '<select class="wcml_currency_switcher">';
|
1106 |
+
}else{
|
1107 |
+
$args['orientation'] = $args['orientation'] == 'horizontal'?'curr_list_horizontal':'curr_list_vertical';
|
1108 |
+
echo '<ul class="wcml_currency_switcher '.$args['orientation'].'">';
|
1109 |
+
}
|
1110 |
+
foreach($currencies as $currency){
|
1111 |
+
if($woocommerce_wpml->settings['currency_options'][$currency]['languages'][$sitepress->get_current_language()] == 1 ){
|
1112 |
+
$selected = $currency == $this->get_client_currency() ? ' selected="selcted"' : '';
|
1113 |
+
|
1114 |
+
$currency_format = preg_replace(array('#%name%#', '#%symbol%#', '#%code%#'),
|
1115 |
+
array($wc_currencies[$currency], get_woocommerce_currency_symbol($currency), $currency), $args['format']);
|
1116 |
+
if($args['switcher_style'] == 'dropdown'){
|
1117 |
+
echo '<option value="' . $currency . '"' . $selected . '>' . $currency_format . '</option>';
|
1118 |
+
}else{
|
1119 |
+
echo '<li rel="' . $currency . '" >' . $currency_format . '</li>';
|
1120 |
+
}
|
1121 |
}
|
1122 |
}
|
1123 |
+
if($args['switcher_style'] == 'dropdown'){
|
1124 |
echo '</select>';
|
1125 |
+
}else{
|
1126 |
+
echo '</ul>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1127 |
}
|
1128 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1129 |
|
1130 |
+
function register_styles(){
|
1131 |
+
wp_register_style('currency-switcher', WCML_PLUGIN_URL . '/assets/css/currency-switcher.css', null, WCML_VERSION);
|
1132 |
+
wp_enqueue_style('currency-switcher');
|
1133 |
+
}
|
1134 |
|
1135 |
+
}
|
1136 |
+
|
inc/multi-currency.class.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
//
|
7 |
|
8 |
class WCML_WC_MultiCurrency{
|
9 |
-
|
10 |
private $client_currency;
|
11 |
|
12 |
private $exchange_rates = array();
|
@@ -78,34 +78,78 @@ class WCML_WC_MultiCurrency{
|
|
78 |
|
79 |
|
80 |
static function install(){
|
81 |
-
global $wpdb;
|
82 |
|
83 |
-
$
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
`changed` datetime DEFAULT NULL,
|
88 |
-
PRIMARY KEY (`id`)
|
89 |
-
)";
|
90 |
-
$wpdb->query($sql);
|
91 |
|
92 |
return;
|
93 |
|
94 |
}
|
95 |
|
96 |
-
function init_ajax_currencies_actions(){
|
97 |
-
add_action('wp_ajax_wcml_update_currency', array($this,'update_currency_exchange_rate'));
|
98 |
-
add_action('wp_ajax_wcml_delete_currency', array($this,'delete_currency_exchange_rate'));
|
99 |
-
add_action('wp_ajax_wcml_update_currency_lang', array($this,'wcml_update_currency_lang'));
|
100 |
-
add_action('wp_ajax_wcml_update_default_currency', array($this,'wcml_update_default_currency'));
|
101 |
|
102 |
$this->set_default_currencies_languages();
|
103 |
}
|
104 |
-
|
105 |
function raw_price_filter($price, $product_id = false) {
|
106 |
|
107 |
$price = $this->convert_price_amount($price, $this->get_client_currency());
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
return $price;
|
110 |
|
111 |
}
|
@@ -136,9 +180,22 @@ class WCML_WC_MultiCurrency{
|
|
136 |
|
137 |
if(isset($exchange_rates[$currency]) && is_numeric($amount)){
|
138 |
$amount = $amount * $exchange_rates[$currency];
|
|
|
|
|
139 |
if(in_array($currency, $this->currencies_without_cents)){
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
|
|
142 |
}else{
|
143 |
$amount = 0;
|
144 |
}
|
@@ -146,6 +203,45 @@ class WCML_WC_MultiCurrency{
|
|
146 |
return $amount;
|
147 |
|
148 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
function price_currency_filter($currency){
|
151 |
|
@@ -159,19 +255,17 @@ class WCML_WC_MultiCurrency{
|
|
159 |
}
|
160 |
|
161 |
function get_exchange_rates(){
|
162 |
-
|
163 |
if(empty($this->exchange_rates)){
|
164 |
global $wpdb;
|
165 |
|
166 |
$this->exchange_rates = array(get_option('woocommerce_currency') => 1);
|
167 |
-
|
168 |
-
$currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` DESC", OBJECT);
|
169 |
-
|
170 |
$woo_currencies = get_woocommerce_currencies();
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
175 |
}
|
176 |
}
|
177 |
}
|
@@ -179,116 +273,39 @@ class WCML_WC_MultiCurrency{
|
|
179 |
return $this->exchange_rates;
|
180 |
}
|
181 |
|
182 |
-
|
183 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_update_currency')){
|
184 |
-
die('Invalid nonce');
|
185 |
-
}
|
186 |
-
|
187 |
-
global $wpdb;
|
188 |
-
$return = array();
|
189 |
-
if($_POST['currency_id'] == 0){
|
190 |
-
$wpdb->insert($wpdb->prefix .'icl_currencies', array(
|
191 |
-
'code' => $_POST['currency_code'],
|
192 |
-
'value' => (double) $_POST['currency_value'],
|
193 |
-
'changed' => date('Y-m-d H:i:s')
|
194 |
-
)
|
195 |
-
);
|
196 |
-
$return['id'] = $wpdb->insert_id;
|
197 |
-
global $sitepress,$woocommerce_wpml;
|
198 |
-
$active_languages = $sitepress->get_active_languages();
|
199 |
-
$settings = $woocommerce_wpml->get_settings();
|
200 |
-
$return['languages'] ='';
|
201 |
-
foreach($active_languages as $language){
|
202 |
-
if(!isset($settings['currencies_languages'][$_POST['currency_code']][$language['code']])){
|
203 |
-
$settings['currencies_languages'][$_POST['currency_code']][$language['code']] = 1;
|
204 |
-
}
|
205 |
-
}
|
206 |
-
$woocommerce_wpml->update_settings($settings);
|
207 |
-
} else {
|
208 |
-
$wpdb->update(
|
209 |
-
$wpdb->prefix .'icl_currencies',
|
210 |
-
array(
|
211 |
-
'code' => $_POST['currency_code'],
|
212 |
-
'value' => (double) $_POST['currency_value'],
|
213 |
-
'changed' => date('Y-m-d H:i:s')
|
214 |
-
),
|
215 |
-
array( 'id' => $_POST['currency_id'] )
|
216 |
-
);
|
217 |
-
}
|
218 |
-
|
219 |
-
$return['symbol'] = sprintf(__(' (%s)','wpml-wcml'),get_woocommerce_currency_symbol($_POST['currency_code']));;
|
220 |
-
|
221 |
-
echo json_encode($return);
|
222 |
-
die();
|
223 |
-
}
|
224 |
-
|
225 |
-
function delete_currency_exchange_rate(){
|
226 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_delete_currency')){
|
227 |
-
die('Invalid nonce');
|
228 |
-
}
|
229 |
-
global $wpdb,$woocommerce_wpml;
|
230 |
-
$wpdb->query($wpdb->prepare("DELETE FROM ". $wpdb->prefix ."icl_currencies WHERE id = %d", $_POST['currency_id']));
|
231 |
-
|
232 |
-
$settings = $woocommerce_wpml->get_settings();
|
233 |
-
unset($settings['currencies_languages'][$_POST['code']]);
|
234 |
-
$woocommerce_wpml->update_settings($settings);
|
235 |
-
|
236 |
-
die();
|
237 |
-
}
|
238 |
-
|
239 |
-
function wcml_update_currency_lang(){
|
240 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_update_currency_lang')){
|
241 |
-
die('Invalid nonce');
|
242 |
-
}
|
243 |
-
global $woocommerce_wpml;
|
244 |
-
|
245 |
-
$settings = $woocommerce_wpml->get_settings();
|
246 |
-
$settings['currencies_languages'][$_POST['code']][$_POST['lang']] = $_POST['value'];
|
247 |
-
|
248 |
-
$woocommerce_wpml->update_settings($settings);
|
249 |
-
die();
|
250 |
-
}
|
251 |
-
|
252 |
-
function wcml_update_default_currency(){
|
253 |
-
if(!wp_verify_nonce($_REQUEST['wcml_nonce'], 'wcml_update_default_currency')){
|
254 |
-
die('Invalid nonce');
|
255 |
-
}
|
256 |
-
global $woocommerce_wpml;
|
257 |
-
|
258 |
-
$settings = $woocommerce_wpml->get_settings();
|
259 |
-
$settings['default_currencies'][$_POST['lang']] = $_POST['code'];
|
260 |
-
|
261 |
-
$woocommerce_wpml->update_settings($settings);
|
262 |
-
die();
|
263 |
-
}
|
264 |
-
|
265 |
function set_default_currencies_languages(){
|
266 |
global $woocommerce_wpml,$sitepress,$wpdb;
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
$settings = $woocommerce_wpml->get_settings();
|
269 |
$wc_currency = get_option('woocommerce_currency');
|
270 |
|
271 |
-
|
272 |
-
|
273 |
-
foreach
|
274 |
-
|
275 |
-
|
276 |
-
$settings['currencies_languages'][$code][$language['code']] = 1;
|
277 |
}
|
278 |
}
|
279 |
}
|
280 |
|
281 |
-
|
282 |
if(!isset($settings['default_currencies'][$language['code']])){
|
283 |
$settings['default_currencies'][$language['code']] = false;
|
284 |
}
|
285 |
|
286 |
-
if(!isset($settings['
|
287 |
-
$settings['
|
288 |
}
|
289 |
}
|
290 |
|
291 |
-
|
292 |
|
293 |
}
|
294 |
|
@@ -297,8 +314,11 @@ class WCML_WC_MultiCurrency{
|
|
297 |
}
|
298 |
|
299 |
function get_client_currency(){
|
300 |
-
global $woocommerce;
|
301 |
-
|
|
|
|
|
|
|
302 |
|
303 |
}
|
304 |
|
@@ -380,7 +400,7 @@ class WCML_WC_MultiCurrency{
|
|
380 |
foreach($results as $row){
|
381 |
$currencies[$row->currency] = $row->c;
|
382 |
}
|
383 |
-
|
384 |
return $currencies;
|
385 |
|
386 |
|
@@ -433,9 +453,17 @@ class WCML_WC_MultiCurrency{
|
|
433 |
");
|
434 |
|
435 |
$this->reports_currency = isset($_COOKIE['_wcml_reports_currency']) ? $_COOKIE['_wcml_reports_currency'] : get_option('woocommerce_currency');
|
|
|
|
|
|
|
|
|
|
|
436 |
|
437 |
add_filter('woocommerce_currency_symbol', array($this, '_set_reports_currency_symbol'));
|
438 |
|
|
|
|
|
|
|
439 |
/* for WC 2.0.x - start */
|
440 |
add_filter('woocommerce_reports_sales_overview_order_totals_join', array($this, 'reports_filter_by_currency_join'));
|
441 |
add_filter('woocommerce_reports_sales_overview_order_totals_where', array($this, 'reports_filter_by_currency_where'));
|
@@ -544,10 +572,14 @@ class WCML_WC_MultiCurrency{
|
|
544 |
?>
|
545 |
|
546 |
<select id="dropdown_shop_report_currency">
|
|
|
|
|
|
|
547 |
<?php foreach($orders_currencies as $currency => $count): ?>
|
548 |
<option value="<?php echo $currency ?>" <?php selected( $currency, $this->reports_currency ); ?>><?php
|
549 |
printf("%s (%s)", $currencies[$currency], get_woocommerce_currency_symbol($currency)) ?></option>
|
550 |
<?php endforeach; ?>
|
|
|
551 |
</select>
|
552 |
|
553 |
<?php
|
@@ -568,6 +600,27 @@ class WCML_WC_MultiCurrency{
|
|
568 |
return $currency;
|
569 |
}
|
570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
function woocommerce_product_options_custom_pricing(){
|
572 |
global $pagenow,$sitepress;
|
573 |
|
@@ -590,7 +643,7 @@ class WCML_WC_MultiCurrency{
|
|
590 |
}
|
591 |
|
592 |
function custom_pricing_output($post_id = false){
|
593 |
-
global $wpdb,$woocommerce;
|
594 |
|
595 |
$custom_prices = array();
|
596 |
$is_variation = false;
|
6 |
//
|
7 |
|
8 |
class WCML_WC_MultiCurrency{
|
9 |
+
|
10 |
private $client_currency;
|
11 |
|
12 |
private $exchange_rates = array();
|
78 |
|
79 |
|
80 |
static function install(){
|
81 |
+
global $wpdb, $woocommerce_wpml;
|
82 |
|
83 |
+
if(empty($woocommerce_wpml->settings['multi_currency']['set_up'])){
|
84 |
+
$woocommerce_wpml->settings['multi_currency']['set_up'] = 1;
|
85 |
+
$woocommerce_wpml->update_settings();
|
86 |
+
}
|
|
|
|
|
|
|
|
|
87 |
|
88 |
return;
|
89 |
|
90 |
}
|
91 |
|
92 |
+
function init_ajax_currencies_actions(){
|
|
|
|
|
|
|
|
|
93 |
|
94 |
$this->set_default_currencies_languages();
|
95 |
}
|
96 |
+
|
97 |
function raw_price_filter($price, $product_id = false) {
|
98 |
|
99 |
$price = $this->convert_price_amount($price, $this->get_client_currency());
|
100 |
|
101 |
+
$price = $this->apply_rounding_rules($price);
|
102 |
+
|
103 |
+
return $price;
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
function apply_rounding_rules($price){
|
108 |
+
global $woocommerce_wpml;
|
109 |
+
|
110 |
+
$currency = $this->get_client_currency();
|
111 |
+
$currency_options = $woocommerce_wpml->settings['currency_options'][$currency];
|
112 |
+
|
113 |
+
if($currency_options['rounding'] != 'disabled'){
|
114 |
+
|
115 |
+
if($currency_options['rounding_increment'] > 1){
|
116 |
+
$price = $price / $currency_options['rounding_increment'];
|
117 |
+
}
|
118 |
+
|
119 |
+
switch($currency_options['rounding']){
|
120 |
+
case 'up':
|
121 |
+
$rounded_price = ceil($price);
|
122 |
+
break;
|
123 |
+
case 'down':
|
124 |
+
$rounded_price = floor($price);
|
125 |
+
break;
|
126 |
+
case 'nearest':
|
127 |
+
if(version_compare(PHP_VERSION, '5.3.0') >= 0){
|
128 |
+
$rounded_price = round($price, 0, PHP_ROUND_HALF_UP);
|
129 |
+
}else{
|
130 |
+
if($price - floor($price) < 0.5){
|
131 |
+
$rounded_price = floor($price);
|
132 |
+
}else{
|
133 |
+
$rounded_price = ceil($price);
|
134 |
+
}
|
135 |
+
}
|
136 |
+
break;
|
137 |
+
}
|
138 |
+
|
139 |
+
if($rounded_price > 0){
|
140 |
+
$price = $rounded_price;
|
141 |
+
}
|
142 |
+
|
143 |
+
if($currency_options['rounding_increment'] > 1){
|
144 |
+
$price = $price * $currency_options['rounding_increment'];
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
if($currency_options['auto_subtract'] && $currency_options['auto_subtract'] < $price){
|
150 |
+
$price = $price - $currency_options['auto_subtract'];
|
151 |
+
}
|
152 |
+
|
153 |
return $price;
|
154 |
|
155 |
}
|
180 |
|
181 |
if(isset($exchange_rates[$currency]) && is_numeric($amount)){
|
182 |
$amount = $amount * $exchange_rates[$currency];
|
183 |
+
|
184 |
+
// exception - currencies_without_cents
|
185 |
if(in_array($currency, $this->currencies_without_cents)){
|
186 |
+
|
187 |
+
if(version_compare(PHP_VERSION, '5.3.0') >= 0){
|
188 |
+
$amount = round($amount, 0, PHP_ROUND_HALF_UP);
|
189 |
+
}else{
|
190 |
+
if($amount - floor($amount) < 0.5){
|
191 |
+
$amount = floor($amount);
|
192 |
+
}else{
|
193 |
+
$amount = ceil($amount);
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
}
|
198 |
+
|
199 |
}else{
|
200 |
$amount = 0;
|
201 |
}
|
203 |
return $amount;
|
204 |
|
205 |
}
|
206 |
+
|
207 |
+
// convert back to default currency
|
208 |
+
function unconvert_price_amount($amount, $currency = false){
|
209 |
+
|
210 |
+
if(empty($currency)){
|
211 |
+
$currency = $this->get_client_currency();
|
212 |
+
}
|
213 |
+
|
214 |
+
if($currency != get_option('woocommerce_currency')){
|
215 |
+
|
216 |
+
$exchange_rates = $this->get_exchange_rates();
|
217 |
+
|
218 |
+
if(isset($exchange_rates[$currency]) && is_numeric($amount)){
|
219 |
+
$amount = $amount / $exchange_rates[$currency];
|
220 |
+
|
221 |
+
// exception - currencies_without_cents
|
222 |
+
if(in_array($currency, $this->currencies_without_cents)){
|
223 |
+
|
224 |
+
if(version_compare(PHP_VERSION, '5.3.0') >= 0){
|
225 |
+
$amount = round($amount, 0, PHP_ROUND_HALF_UP);
|
226 |
+
}else{
|
227 |
+
if($amount - floor($amount) < 0.5){
|
228 |
+
$amount = floor($amount);
|
229 |
+
}else{
|
230 |
+
$amount = ceil($amount);
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
}else{
|
237 |
+
$amount = 0;
|
238 |
+
}
|
239 |
+
|
240 |
+
}
|
241 |
+
|
242 |
+
return $amount;
|
243 |
+
|
244 |
+
}
|
245 |
|
246 |
function price_currency_filter($currency){
|
247 |
|
255 |
}
|
256 |
|
257 |
function get_exchange_rates(){
|
258 |
+
global $woocommerce_wpml;
|
259 |
if(empty($this->exchange_rates)){
|
260 |
global $wpdb;
|
261 |
|
262 |
$this->exchange_rates = array(get_option('woocommerce_currency') => 1);
|
|
|
|
|
|
|
263 |
$woo_currencies = get_woocommerce_currencies();
|
264 |
|
265 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
266 |
+
foreach($currencies as $code => $currency){
|
267 |
+
if(!empty($woo_currencies[$code])){
|
268 |
+
$this->exchange_rates[$code] = $currency['rate'];
|
269 |
}
|
270 |
}
|
271 |
}
|
273 |
return $this->exchange_rates;
|
274 |
}
|
275 |
|
276 |
+
//@todo - move to multi-currency-support.class.php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
function set_default_currencies_languages(){
|
278 |
global $woocommerce_wpml,$sitepress,$wpdb;
|
279 |
+
|
280 |
+
if(empty($woocommerce_wpml->multi_currency_support)){
|
281 |
+
require_once WCML_PLUGIN_PATH . '/inc/multi-currency-support.class.php';
|
282 |
+
$woocommerce_wpml->multi_currency_support = new WCML_Multi_Currency_Support;
|
283 |
+
$woocommerce_wpml->multi_currency_support->init();
|
284 |
+
}
|
285 |
+
|
286 |
$settings = $woocommerce_wpml->get_settings();
|
287 |
$wc_currency = get_option('woocommerce_currency');
|
288 |
|
289 |
+
$active_languages = $sitepress->get_active_languages();
|
290 |
+
foreach ($woocommerce_wpml->multi_currency_support->get_currency_codes() as $code) {
|
291 |
+
foreach($active_languages as $language){
|
292 |
+
if(!isset($settings['currency_options'][$code]['languages'][$language['code']])){
|
293 |
+
$settings['currency_options'][$code]['languages'][$language['code']] = 1;
|
|
|
294 |
}
|
295 |
}
|
296 |
}
|
297 |
|
298 |
+
foreach($active_languages as $language){
|
299 |
if(!isset($settings['default_currencies'][$language['code']])){
|
300 |
$settings['default_currencies'][$language['code']] = false;
|
301 |
}
|
302 |
|
303 |
+
if(!isset($settings['currency_options'][$wc_currency]['languages'][$language['code']])){
|
304 |
+
$settings['currency_options'][$wc_currency]['languages'][$language['code']] = 1;
|
305 |
}
|
306 |
}
|
307 |
|
308 |
+
$woocommerce_wpml->update_settings($settings);
|
309 |
|
310 |
}
|
311 |
|
314 |
}
|
315 |
|
316 |
function get_client_currency(){
|
317 |
+
global $woocommerce, $woocommerce_wpml;
|
318 |
+
|
319 |
+
$currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
|
320 |
+
|
321 |
+
return $currency;
|
322 |
|
323 |
}
|
324 |
|
400 |
foreach($results as $row){
|
401 |
$currencies[$row->currency] = $row->c;
|
402 |
}
|
403 |
+
|
404 |
return $currencies;
|
405 |
|
406 |
|
453 |
");
|
454 |
|
455 |
$this->reports_currency = isset($_COOKIE['_wcml_reports_currency']) ? $_COOKIE['_wcml_reports_currency'] : get_option('woocommerce_currency');
|
456 |
+
//validation
|
457 |
+
$orders_currencies = $this->get_orders_currencies();
|
458 |
+
if(!isset($orders_currencies[$this->reports_currency])){
|
459 |
+
$this->reports_currency = !empty($orders_currencies) ? key($orders_currencies) : false;
|
460 |
+
}
|
461 |
|
462 |
add_filter('woocommerce_currency_symbol', array($this, '_set_reports_currency_symbol'));
|
463 |
|
464 |
+
add_filter('woocommerce_report_sales_by_category_get_products_in_category', array($this, '_use_categories_in_all_languages'), 10, 2);
|
465 |
+
|
466 |
+
|
467 |
/* for WC 2.0.x - start */
|
468 |
add_filter('woocommerce_reports_sales_overview_order_totals_join', array($this, 'reports_filter_by_currency_join'));
|
469 |
add_filter('woocommerce_reports_sales_overview_order_totals_where', array($this, 'reports_filter_by_currency_where'));
|
572 |
?>
|
573 |
|
574 |
<select id="dropdown_shop_report_currency">
|
575 |
+
<?php if(empty($orders_currencies)): ?>
|
576 |
+
<option value=""><?php _e('Currrency - no orders found', 'wpml-wcml') ?></option>
|
577 |
+
<?php else: ?>
|
578 |
<?php foreach($orders_currencies as $currency => $count): ?>
|
579 |
<option value="<?php echo $currency ?>" <?php selected( $currency, $this->reports_currency ); ?>><?php
|
580 |
printf("%s (%s)", $currencies[$currency], get_woocommerce_currency_symbol($currency)) ?></option>
|
581 |
<?php endforeach; ?>
|
582 |
+
<?php endif; ?>
|
583 |
</select>
|
584 |
|
585 |
<?php
|
600 |
return $currency;
|
601 |
}
|
602 |
|
603 |
+
function _use_categories_in_all_languages($product_ids, $category_id){
|
604 |
+
global $sitepress;
|
605 |
+
|
606 |
+
$category_term = get_term($category_id, 'product_cat');
|
607 |
+
|
608 |
+
if(!is_wp_error($category_term)){
|
609 |
+
$trid = $sitepress->get_element_trid($category_term->term_taxonomy_id, 'tax_product_cat');
|
610 |
+
$translations = $sitepress->get_element_translations($trid, 'tax_product_cat', true);
|
611 |
+
|
612 |
+
foreach($translations as $translation){
|
613 |
+
if($translation->term_id != $category_id){
|
614 |
+
$term_ids = get_term_children( $translation->term_id, 'product_cat' );
|
615 |
+
$term_ids[] = $translation->term_id;
|
616 |
+
$product_ids = array_merge(array_unique($product_ids), get_objects_in_term( $term_ids, 'product_cat' ));
|
617 |
+
}
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
return $product_ids;
|
622 |
+
}
|
623 |
+
|
624 |
function woocommerce_product_options_custom_pricing(){
|
625 |
global $pagenow,$sitepress;
|
626 |
|
643 |
}
|
644 |
|
645 |
function custom_pricing_output($post_id = false){
|
646 |
+
global $wpdb,$woocommerce,$woocommerce_wpml;
|
647 |
|
648 |
$custom_prices = array();
|
649 |
$is_variation = false;
|
inc/orders.class.php
CHANGED
@@ -11,6 +11,9 @@ class WCML_Orders{
|
|
11 |
|
12 |
add_action('init', array($this, 'init'));
|
13 |
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
function init(){
|
@@ -22,6 +25,9 @@ class WCML_Orders{
|
|
22 |
|
23 |
add_filter('the_comments', array($this, 'get_filtered_comments'));
|
24 |
add_filter('gettext',array($this, 'filtered_woocommerce_new_order_note_data'),10,3);
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
function filtered_woocommerce_new_order_note_data($translations, $text, $domain ){
|
@@ -45,23 +51,65 @@ class WCML_Orders{
|
|
45 |
}
|
46 |
|
47 |
function get_filtered_comments($comments){
|
48 |
-
global $sitepress_settings
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
-
}
|
59 |
-
|
|
|
60 |
|
61 |
return $comments;
|
62 |
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
// Fix for shipping update on the checkout page.
|
66 |
function fix_shipping_update($amount){
|
67 |
global $sitepress, $post;
|
@@ -103,4 +151,9 @@ class WCML_Orders{
|
|
103 |
return $parameters;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
11 |
|
12 |
add_action('init', array($this, 'init'));
|
13 |
|
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(){
|
25 |
|
26 |
add_filter('the_comments', array($this, 'get_filtered_comments'));
|
27 |
add_filter('gettext',array($this, 'filtered_woocommerce_new_order_note_data'),10,3);
|
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 ){
|
51 |
}
|
52 |
|
53 |
function get_filtered_comments($comments){
|
54 |
+
global $sitepress_settings, $wpdb, $current_user;
|
55 |
+
|
56 |
+
if(!empty($current_user) && !is_null($current_user->data)){
|
57 |
+
|
58 |
+
$user_language = get_user_meta( $current_user->data->ID, 'icl_admin_language', true );
|
59 |
+
|
60 |
+
foreach($comments as $key=>$comment){
|
61 |
+
$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));
|
62 |
+
if($comment_string_id){
|
63 |
+
$comment_string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $comment_string_id, $user_language));
|
64 |
+
if($comment_string){
|
65 |
+
$comments[$key]->comment_content = $comment_string;
|
66 |
+
}
|
67 |
}
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
|
72 |
return $comments;
|
73 |
|
74 |
}
|
75 |
|
76 |
+
function woocommerce_order_get_items($items){
|
77 |
+
if(isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order'){
|
78 |
+
global $sitepress_settings;
|
79 |
+
foreach($items as $index=>$item){
|
80 |
+
foreach($item as $key=>$item_data){
|
81 |
+
if($key == 'product_id'){
|
82 |
+
$tr_product_id = icl_object_id($item_data,'product',false,$sitepress_settings['admin_default_language']);
|
83 |
+
if(!is_null($tr_product_id)){
|
84 |
+
$items[$index][$key] = $tr_product_id;
|
85 |
+
$items[$index]['name'] = get_the_title($tr_product_id);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
if($key == 'variation_id'){
|
89 |
+
$tr_variation_id = icl_object_id($item_data,'product_variation',false,$sitepress_settings['admin_default_language']);
|
90 |
+
if(!is_null($tr_variation_id)){
|
91 |
+
$items[$index][$key] = $tr_variation_id;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
if (substr($key, 0, 3) == 'pa_') {
|
96 |
+
global $wpdb;
|
97 |
+
//attr is taxonomy
|
98 |
+
$default_term = get_term_by('slug', $item_data, $key);
|
99 |
+
$tr_id = icl_object_id($default_term->term_id, $key, false, $sitepress_settings['admin_default_language']);
|
100 |
+
|
101 |
+
if(!is_null($tr_id)){
|
102 |
+
$translated_slug = $wpdb->get_var($wpdb->prepare("
|
103 |
+
SELECT t.slug FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $key));
|
104 |
+
$items[$index][$key] = $translated_slug;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
return $items;
|
111 |
+
}
|
112 |
+
|
113 |
// Fix for shipping update on the checkout page.
|
114 |
function fix_shipping_update($amount){
|
115 |
global $sitepress, $post;
|
151 |
return $parameters;
|
152 |
}
|
153 |
|
154 |
+
function switch_to_current(){
|
155 |
+
global $sitepress,$woocommerce_wpml;
|
156 |
+
$woocommerce_wpml->emails->change_email_language($sitepress->get_current_language());
|
157 |
+
}
|
158 |
+
|
159 |
}
|
inc/products.class.php
CHANGED
@@ -52,9 +52,11 @@ class WCML_Products{
|
|
52 |
}else{
|
53 |
add_filter('woocommerce_json_search_found_products', array($this, 'filter_found_products_by_language'));
|
54 |
}
|
|
|
|
|
55 |
add_action('woocommerce_email',array($this,'wcml_refresh_text_domain'));
|
56 |
-
add_action('wp_ajax_woocommerce_update_shipping_method',array($this,'wcml_refresh_text_domain'));
|
57 |
-
add_action('wp_ajax_nopriv_woocommerce_update_shipping_method',array($this,'wcml_refresh_text_domain'));
|
58 |
add_filter('wpml_link_to_translation',array($this,'_filter_link_to_translation'));
|
59 |
|
60 |
add_filter('woocommerce_upsell_crosssell_search_products', array($this, 'filter_woocommerce_upsell_crosssell_posts_by_language'));
|
@@ -66,6 +68,8 @@ class WCML_Products{
|
|
66 |
add_action('updated_post_meta', array($this,'register_product_name_and_attribute_strings'), 100, 4);
|
67 |
add_action('added_post_meta', array($this,'register_product_name_and_attribute_strings'), 100, 4);
|
68 |
|
|
|
|
|
69 |
//add translation manager filters
|
70 |
add_filter('wpml_tm_save_post_trid_value', array($this,'wpml_tm_save_post_trid_value'),10,2);
|
71 |
add_filter('wpml_tm_save_post_lang_value', array($this,'wpml_tm_save_post_lang_value'),10,2);
|
@@ -78,6 +82,9 @@ class WCML_Products{
|
|
78 |
//add filter when add term on product page
|
79 |
add_filter('wpml_create_term_lang',array($this,'product_page_add_language_info_to_term'));
|
80 |
|
|
|
|
|
|
|
81 |
|
82 |
//save taxonomy in WPML interface
|
83 |
add_action('wp_ajax_wpml_tt_save_term_translation', array($this, 'update_taxonomy_in_variations'),7);
|
@@ -85,7 +92,7 @@ class WCML_Products{
|
|
85 |
// Hooks for translating product attribute values
|
86 |
add_filter('woocommerce_variation_option_name', array($this, 'translate_variation_term_name'));
|
87 |
add_filter('woocommerce_attribute', array($this, 'translate_attribute_terms'));
|
88 |
-
add_action('wp_ajax_woocommerce_remove_variation', array($this,'remove_variation_ajax'),9);
|
89 |
//WooCommerce subscription
|
90 |
add_filter('woocommerce_users_subscriptions',array($this, 'woocommerce_users_subscriptions'),10,2);
|
91 |
|
@@ -93,22 +100,6 @@ class WCML_Products{
|
|
93 |
add_action('woocommerce_get_cart_item_from_session', array($this, 'translate_cart_contents'), 10, 3);
|
94 |
add_action('woocommerce_cart_loaded_from_session', array($this, 'translate_cart_subtotal'));
|
95 |
add_action('woocommerce_before_calculate_totals',array($this,'woocommerce_calculate_totals'));
|
96 |
-
|
97 |
-
if(isset($_POST['action'])){
|
98 |
-
if(isset($_POST['product']) && $_POST['action'] == 'apply' && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_test_actions')){
|
99 |
-
if($_POST['test_action']!='to_translation'){
|
100 |
-
$this->product_test_content_action($_POST['product'],$_POST['test_action']);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
if(isset($_POST['action_bottom']) && wp_verify_nonce($_POST['wcml_nonce'], 'wcml_test_actions')){
|
106 |
-
if(isset($_POST['product']) && $_POST['action_bottom'] == 'apply'){
|
107 |
-
if($_POST['test_action_bottom']!='to_translation'){
|
108 |
-
$this->product_test_content_action($_POST['product'],$_POST['test_action_bottom']);
|
109 |
-
}
|
110 |
-
}
|
111 |
-
}
|
112 |
|
113 |
if(defined('WPSEO_VERSION') && defined('WPSEO_PATH') && isset($_GET['tab']) && $_GET['tab'] == 'products'){
|
114 |
require WPSEO_PATH . 'admin/class-metabox.php';
|
@@ -123,7 +114,9 @@ class WCML_Products{
|
|
123 |
|
124 |
function wc_cart_widget_actions(){
|
125 |
add_action('wp_ajax_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),9);
|
|
|
126 |
add_action('wp_ajax_nopriv_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),9);
|
|
|
127 |
if(!is_admin()){
|
128 |
wp_enqueue_script('wcml-scripts', WCML_PLUGIN_URL . '/assets/js/cart_widget.js', array('jquery'), WCML_VERSION);
|
129 |
}
|
@@ -146,14 +139,10 @@ class WCML_Products{
|
|
146 |
* return array;
|
147 |
*/
|
148 |
function get_product_list($page = 1,$limit = 20){
|
149 |
-
$
|
150 |
-
$
|
151 |
-
$args['post_status'] = array('publish','future','draft','pending','private');
|
152 |
-
$args['suppress_filters'] = false;
|
153 |
-
|
154 |
-
$args['posts_per_page'] = -1;
|
155 |
|
156 |
-
return $this->display_hierarchical(
|
157 |
}
|
158 |
|
159 |
function display_hierarchical($products, $pagenum, $per_page){
|
@@ -175,9 +164,9 @@ class WCML_Products{
|
|
175 |
}
|
176 |
|
177 |
if ( 0 == $product->post_parent ){
|
178 |
-
$top_level_products[] = $product;
|
179 |
}else{
|
180 |
-
$children_products[$product->post_parent][] = $product;
|
181 |
}
|
182 |
}
|
183 |
|
@@ -185,19 +174,19 @@ class WCML_Products{
|
|
185 |
$start = ( $pagenum - 1 ) * $per_page;
|
186 |
$end = $start + $per_page;
|
187 |
|
188 |
-
foreach ( $top_level_products as $
|
189 |
if ( $count >= $end )
|
190 |
break;
|
191 |
|
192 |
if ( $count >= $start ) {
|
193 |
-
$output_products[] = $
|
194 |
|
195 |
-
if ( isset( $children_products[$
|
196 |
-
foreach($children_products[$
|
197 |
-
$output_products[] = $children;
|
198 |
$count++;
|
199 |
}
|
200 |
-
unset($children_products[$
|
201 |
}
|
202 |
}
|
203 |
|
@@ -275,22 +264,7 @@ class WCML_Products{
|
|
275 |
break;
|
276 |
}
|
277 |
|
278 |
-
$this->
|
279 |
-
|
280 |
-
//duplicate product attrs
|
281 |
-
$orig_product_attrs = $this->get_product_atributes($product_id);
|
282 |
-
add_post_meta($tr_product_id,'_product_attributes',$orig_product_attrs);
|
283 |
-
|
284 |
-
$this->sync_default_product_attr($product_id, $tr_product_id, $language['code']);
|
285 |
-
//sync media
|
286 |
-
$this->sync_thumbnail_id($product_id, $tr_product_id,$language['code']);
|
287 |
-
$this->sync_product_gallery($product_id);
|
288 |
-
|
289 |
-
//sync taxonomies
|
290 |
-
$this->sync_product_taxonomies($product_id,$tr_product_id,$language['code']);
|
291 |
-
|
292 |
-
//duplicate variations
|
293 |
-
$this->sync_product_variations($product_id,$tr_product_id,$language['code']);
|
294 |
}
|
295 |
break;
|
296 |
case 'clean':
|
@@ -537,7 +511,9 @@ class WCML_Products{
|
|
537 |
$this->duplicate_product_post_meta($original_product_id, $tr_product_id, $data);
|
538 |
|
539 |
}
|
540 |
-
|
|
|
|
|
541 |
//get "_product_attributes" from original product
|
542 |
$orig_product_attrs = $this->get_product_atributes($original_product_id);
|
543 |
$trnsl_labels = get_option('wcml_custom_attr_translations');
|
@@ -567,6 +543,8 @@ class WCML_Products{
|
|
567 |
// synchronize post variations
|
568 |
$this->sync_product_variations($original_product_id, $tr_product_id, $language, $data);
|
569 |
|
|
|
|
|
570 |
//save images texts
|
571 |
if(isset($data['images'])){
|
572 |
foreach($data['images'] as $key=>$image){
|
@@ -619,14 +597,46 @@ class WCML_Products{
|
|
619 |
|
620 |
}
|
621 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
function is_variable_product($product_id){
|
623 |
global $wpdb;
|
624 |
-
$
|
625 |
-
$
|
626 |
|
|
|
627 |
return $is_variable_product;
|
628 |
}
|
629 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
630 |
|
631 |
function sync_product_taxonomies($original_product_id,$tr_product_id,$lang){
|
632 |
global $sitepress,$wpdb;
|
@@ -665,7 +675,11 @@ class WCML_Products{
|
|
665 |
}
|
666 |
|
667 |
function get_product_atributes($product_id){
|
668 |
-
|
|
|
|
|
|
|
|
|
669 |
}
|
670 |
|
671 |
//duplicate product post meta
|
@@ -697,6 +711,15 @@ class WCML_Products{
|
|
697 |
$file_paths_array[md5($file_path)] = $file_path;
|
698 |
}
|
699 |
$meta_value = $file_paths_array;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
700 |
}else{
|
701 |
$meta_value = $data[$key.'_'.$lang];
|
702 |
}
|
@@ -762,11 +785,13 @@ class WCML_Products{
|
|
762 |
update_post_meta($trnsl_product_id,$key,$meta_value);
|
763 |
}
|
764 |
}else{
|
|
|
765 |
$meta_value = apply_filters('wcml_meta_value_before_add',$meta_value,$key);
|
766 |
update_post_meta($trnsl_product_id, $key, $meta_value);
|
767 |
}
|
768 |
}
|
769 |
}
|
|
|
770 |
|
771 |
do_action('wcml_after_duplicate_product_post_meta',$original_product_id, $trnsl_product_id, $data);
|
772 |
}
|
@@ -784,7 +809,7 @@ class WCML_Products{
|
|
784 |
$translations = $sitepress->get_element_translations($trid,'post_product',true);
|
785 |
foreach($translations as $translation){
|
786 |
$duplicated_ids = '';
|
787 |
-
if (
|
788 |
foreach($gallery_ids as $image_id){
|
789 |
$duplicated_id = icl_object_id($image_id,'attachment',false,$translation->language_code);
|
790 |
if(!is_null($duplicated_id)){
|
@@ -799,7 +824,7 @@ class WCML_Products{
|
|
799 |
|
800 |
function get_translation_flags($active_languages,$default_language,$slang = false){
|
801 |
foreach($active_languages as $language){
|
802 |
-
if ($default_language != $language['code'] && (($slang && $slang == $language['code']) || !$slang) && (current_user_can('
|
803 |
echo '<img src="'. ICL_PLUGIN_URL .'/res/flags/'. $language['code'] .'.png" width="18" height="12" class="flag_img" />';
|
804 |
}
|
805 |
}
|
@@ -810,7 +835,7 @@ class WCML_Products{
|
|
810 |
global $wpdb;
|
811 |
|
812 |
foreach ($active_languages as $language) {
|
813 |
-
if ($default_language != $language['code'] && (($slang && $slang == $language['code']) || !$slang) && (current_user_can('
|
814 |
if (isset($product_translations[$language['code']])) {
|
815 |
$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));
|
816 |
if(!$tr_status){
|
@@ -844,10 +869,9 @@ class WCML_Products{
|
|
844 |
|
845 |
//sync product variations
|
846 |
function sync_product_variations($product_id,$tr_product_id,$lang,$data = false,$trbl = false){
|
847 |
-
global $wpdb,$sitepress,$sitepress_settings, $woocommerce_wpml;
|
848 |
|
849 |
$is_variable_product = $this->is_variable_product($product_id);
|
850 |
-
|
851 |
if($is_variable_product){
|
852 |
$get_all_post_variations = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts
|
853 |
WHERE post_status IN ('publish','private') AND post_type = 'product_variation' AND post_parent = %d ORDER BY ID",$product_id));
|
@@ -862,6 +886,10 @@ class WCML_Products{
|
|
862 |
update_post_meta($product_id,$price_key,$min_max_price);
|
863 |
}
|
864 |
|
|
|
|
|
|
|
|
|
865 |
foreach ($get_all_post_variations as $k => $post_data) {
|
866 |
|
867 |
// Find if this has already been duplicated
|
@@ -933,15 +961,53 @@ class WCML_Products{
|
|
933 |
|
934 |
//sync file_paths
|
935 |
if(!$woocommerce_wpml->settings['file_path_sync'] && isset($data['variations_file_paths'][$variation_id])){
|
936 |
-
$file_paths = explode("\n",$data['variations_file_paths'][$variation_id]);
|
937 |
$file_paths_array = array();
|
|
|
|
|
938 |
foreach($file_paths as $file_path){
|
939 |
$file_paths_array[md5($file_path)] = $file_path;
|
940 |
}
|
941 |
update_post_meta($variation_id,'_file_paths',$file_paths_array);
|
942 |
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
$orig_file_path = maybe_unserialize(get_post_meta($post_data->ID,'_file_paths',true));
|
944 |
update_post_meta($variation_id,'_file_paths',$orig_file_path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
945 |
}
|
946 |
|
947 |
}
|
@@ -992,7 +1058,7 @@ class WCML_Products{
|
|
992 |
|
993 |
// adjust the global attribute slug in the custom field
|
994 |
$attid = null;
|
995 |
-
|
996 |
if (substr($meta_key, 0, 10) == 'attribute_') {
|
997 |
$tax = substr($meta_key, 10);
|
998 |
|
@@ -1013,15 +1079,12 @@ class WCML_Products{
|
|
1013 |
}else{
|
1014 |
if(isset($original_product_attr[$tax])){
|
1015 |
if(isset($tr_product_attr[$tax])){
|
1016 |
-
$values_arrs = explode('|',$original_product_attr[$tax]['value']);
|
1017 |
-
$values_arrs_tr = explode('|',$tr_product_attr[$tax]['value']);
|
1018 |
foreach($values_arrs as $key=>$value){
|
1019 |
-
$
|
1020 |
-
$
|
1021 |
-
|
1022 |
-
if($value == $meta_value && isset($values_arrs_tr[$key])){
|
1023 |
-
$meta_value = trim($values_arrs_tr[$key]);
|
1024 |
-
$meta_value = str_replace(' ','-',$meta_value);
|
1025 |
}
|
1026 |
}
|
1027 |
}else{
|
@@ -1045,8 +1108,40 @@ class WCML_Products{
|
|
1045 |
}
|
1046 |
|
1047 |
}
|
|
|
|
|
1048 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1049 |
}
|
|
|
1050 |
}
|
1051 |
|
1052 |
function sync_thumbnail_id($orig_post_id,$trnsl_post_id,$lang){
|
@@ -1100,7 +1195,7 @@ class WCML_Products{
|
|
1100 |
add_action('admin_notices', array($this, 'inf_editing_product_in_non_default_lang'));
|
1101 |
}
|
1102 |
|
1103 |
-
if($woocommerce_wpml->settings['trnsl_interface'] && $pagenow == 'post.php' && isset($_GET['post']) && $default_lang!=$prod_lang && get_post_type($_GET['post'])=='product'){
|
1104 |
if((!isset($_GET['action'])) || (isset($_GET['action']) && !in_array($_GET['action'],array('trash','delete')))){
|
1105 |
$prid = icl_object_id($_GET['post'],'product',true,$default_lang);
|
1106 |
wp_redirect(admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$prid)); exit;
|
@@ -1309,6 +1404,10 @@ class WCML_Products{
|
|
1309 |
global $wpdb, $pagenow, $sitepress, $sitepress_settings,$woocommerce_wpml;
|
1310 |
$default_language = $sitepress->get_default_language();
|
1311 |
$current_language = $sitepress->get_current_language();
|
|
|
|
|
|
|
|
|
1312 |
|
1313 |
//trnsl_interface option
|
1314 |
if (!$woocommerce_wpml->settings['trnsl_interface'] && $default_language != $current_language) {
|
@@ -1333,7 +1432,6 @@ class WCML_Products{
|
|
1333 |
|
1334 |
// exceptions
|
1335 |
$ajax_call = (!empty($_POST['icl_ajx_action']) && $_POST['icl_ajx_action'] == 'make_duplicates');
|
1336 |
-
$duplicated_post_id = icl_object_id($post_id, 'product', false, $default_language);
|
1337 |
if (empty($duplicated_post_id) || isset($_POST['autosave'])) {
|
1338 |
return;
|
1339 |
}
|
@@ -1360,18 +1458,18 @@ class WCML_Products{
|
|
1360 |
|
1361 |
update_post_meta($post_id,'_wcml_custom_prices_status',$_REQUEST['_wcml_custom_prices'][$post_id]);
|
1362 |
|
1363 |
-
$currencies = $
|
1364 |
|
1365 |
if($_REQUEST['_wcml_custom_prices'][$post_id] == 1){
|
1366 |
-
foreach($currencies as $currency){
|
1367 |
-
$sale_price = $_REQUEST['_custom_sale_price'][$
|
1368 |
-
$regular_price = $_REQUEST['_custom_regular_price'][$
|
1369 |
|
1370 |
-
$date_from = strtotime($_REQUEST['_custom_sale_price_dates_from'][$
|
1371 |
-
$date_to = strtotime($_REQUEST['_custom_sale_price_dates_to'][$
|
1372 |
-
$schedule = $_REQUEST['_wcml_schedule'][$
|
1373 |
|
1374 |
-
$pr_price = $this->update_custom_prices($post_id,$regular_price,$sale_price,$schedule,$date_from,$date_to,$
|
1375 |
}
|
1376 |
}
|
1377 |
}
|
@@ -1383,14 +1481,12 @@ class WCML_Products{
|
|
1383 |
//media sync
|
1384 |
update_post_meta($post_id, '_wpml_media_duplicate', 1);
|
1385 |
update_post_meta($post_id, '_wpml_media_featured', 1);
|
1386 |
-
//sync product gallery
|
1387 |
-
$this->sync_product_gallery($duplicated_post_id);
|
1388 |
|
1389 |
// pick posts to sync
|
1390 |
$posts = array();
|
1391 |
$translations = $sitepress->get_element_translations($language_details->trid, 'post_product');
|
1392 |
foreach ($translations as $translation) {
|
1393 |
-
if ($translation->
|
1394 |
$duplicated_post_id = $translation->element_id;
|
1395 |
} else {
|
1396 |
$posts[$translation->element_id] = $translation;
|
@@ -1404,6 +1500,18 @@ class WCML_Products{
|
|
1404 |
|
1405 |
// Filter upsell products, crosell products and default attributes for translations
|
1406 |
$this->duplicate_product_post_meta($duplicated_post_id,$post_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1407 |
$original_product_upsell_ids = get_post_meta($duplicated_post_id, '_upsell_ids', TRUE);
|
1408 |
if(!empty($original_product_upsell_ids)){
|
1409 |
$unserialized_upsell_ids = maybe_unserialize($original_product_upsell_ids);
|
@@ -1463,9 +1571,11 @@ class WCML_Products{
|
|
1463 |
|
1464 |
update_post_meta($post_id, '_product_attributes', $orig_product_attrs);
|
1465 |
|
|
|
|
|
1466 |
// synchronize post variations
|
1467 |
$this->sync_product_variations($duplicated_post_id,$post_id,$lang);
|
1468 |
-
|
1469 |
}
|
1470 |
|
1471 |
$this->sync_product_variations_custom_prices($duplicated_post_id);
|
@@ -1516,7 +1626,7 @@ class WCML_Products{
|
|
1516 |
}
|
1517 |
|
1518 |
function sync_product_variations_custom_prices($product_id){
|
1519 |
-
global $wpdb;
|
1520 |
$is_variable_product = $this->is_variable_product($product_id);
|
1521 |
|
1522 |
if($is_variable_product){
|
@@ -1533,43 +1643,43 @@ class WCML_Products{
|
|
1533 |
|
1534 |
update_post_meta($post_data->ID,'_wcml_custom_prices_status',$_REQUEST['_wcml_custom_prices'][$post_data->ID]);
|
1535 |
|
1536 |
-
$currencies = $
|
1537 |
|
1538 |
if($_REQUEST['_wcml_custom_prices'][$post_data->ID] == 1){
|
1539 |
-
foreach($currencies as $currency){
|
1540 |
-
$sale_price = $_REQUEST['_custom_variation_sale_price'][$
|
1541 |
-
$regular_price = $_REQUEST['_custom_variation_regular_price'][$
|
1542 |
|
1543 |
-
$date_from = strtotime($_REQUEST['_custom_sale_price_dates_from'][$
|
1544 |
-
$date_to = strtotime($_REQUEST['_custom_sale_price_dates_to'][$
|
1545 |
-
$schedule = $_REQUEST['_wcml_schedule'][$
|
1546 |
|
1547 |
-
$price = $this->update_custom_prices($post_data->ID,$regular_price,$sale_price,$schedule,$date_from,$date_to,$
|
1548 |
|
1549 |
-
if(!isset($min_max_prices['_min_variation_price_'.$
|
1550 |
-
$min_max_prices['_min_variation_price_'.$
|
1551 |
-
$min_max_prices['_min_price_variation_id_'.$
|
1552 |
}
|
1553 |
|
1554 |
-
if(!isset($min_max_prices['_max_variation_price_'.$
|
1555 |
-
$min_max_prices['_max_variation_price_'.$
|
1556 |
-
$min_max_prices['_max_price_variation_id_'.$
|
1557 |
}
|
1558 |
|
1559 |
-
if(!isset($min_max_prices['_min_variation_regular_price_'.$
|
1560 |
-
$min_max_prices['_min_variation_regular_price_'.$
|
1561 |
}
|
1562 |
|
1563 |
-
if(!isset($min_max_prices['_max_variation_regular_price_'.$
|
1564 |
-
$min_max_prices['_max_variation_regular_price_'.$
|
1565 |
}
|
1566 |
|
1567 |
-
if(!isset($min_max_prices['_min_variation_sale_price_'.$
|
1568 |
-
$min_max_prices['_min_variation_sale_price_'.$
|
1569 |
}
|
1570 |
|
1571 |
-
if(!isset($min_max_prices['_max_variation_sale_price_'.$
|
1572 |
-
$min_max_prices['_max_variation_sale_price_'.$
|
1573 |
}
|
1574 |
}
|
1575 |
}
|
@@ -1675,7 +1785,7 @@ class WCML_Products{
|
|
1675 |
}
|
1676 |
}
|
1677 |
|
1678 |
-
if(!$woocommerce_wpml->settings['file_path_sync'] && $product_type == 'variable'){
|
1679 |
$contents[] = 'variations';
|
1680 |
}
|
1681 |
|
@@ -1715,7 +1825,7 @@ class WCML_Products{
|
|
1715 |
$product_type = $type;
|
1716 |
}
|
1717 |
|
1718 |
-
if(!$woocommerce_wpml->settings['file_path_sync'] && $product_type == 'variable'){
|
1719 |
$contents[] = __('Variations','wpml-wcml');
|
1720 |
}
|
1721 |
|
@@ -1961,7 +2071,7 @@ class WCML_Products{
|
|
1961 |
|
1962 |
function product_variations_box($product_id, $lang, $is_duplicate_product = false)
|
1963 |
{
|
1964 |
-
global $sitepress, $woocommerce_wpml,$wpdb;
|
1965 |
|
1966 |
$default_language = $sitepress->get_default_language();
|
1967 |
$template_data = array();
|
@@ -1982,9 +2092,29 @@ class WCML_Products{
|
|
1982 |
if (!$woocommerce_wpml->settings['file_path_sync']) {
|
1983 |
global $wpdb;
|
1984 |
$is_downloable = $wpdb->get_results($wpdb->prepare("SELECT pm.meta_value FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS pm ON p.id=pm.post_id WHERE p.post_parent = %d AND p.post_type = 'product_variation' AND pm.meta_key='_downloadable' AND pm.meta_value = 'yes'", $product_id));
|
|
|
|
|
|
|
|
|
1985 |
|
1986 |
-
|
|
|
1987 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1988 |
}
|
1989 |
|
1990 |
$is_product_has_variations = $wpdb->get_var($wpdb->prepare("SELECT count(id) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation'",$product_id));
|
@@ -2005,7 +2135,7 @@ class WCML_Products{
|
|
2005 |
}
|
2006 |
|
2007 |
function product_images_box($product_id,$lang, $is_duplicate_product = false ) {
|
2008 |
-
global $sitepress;
|
2009 |
$default_language = $sitepress->get_default_language();
|
2010 |
if($default_language != $lang){
|
2011 |
$product_id = icl_object_id($product_id, 'product', false, $lang);
|
@@ -2029,7 +2159,7 @@ class WCML_Products{
|
|
2029 |
$prod_image = icl_object_id($prod_image, 'attachment', false, $lang);
|
2030 |
$images_texs = array();
|
2031 |
if(!is_null($prod_image)){
|
2032 |
-
|
2033 |
$images_texs['title'] = $attachment_data->post_title;
|
2034 |
$images_texs['caption'] = $attachment_data->post_excerpt;
|
2035 |
$images_texs['description'] = $attachment_data->post_content;
|
@@ -2069,12 +2199,32 @@ class WCML_Products{
|
|
2069 |
$template_data['translation_exist'] = false;
|
2070 |
}
|
2071 |
|
2072 |
-
$custom_box_html = apply_filters('wcml_custom_box_html','',$template_data);
|
2073 |
-
|
2074 |
include WCML_PLUGIN_PATH . '/menu/sub/custom-box.php';
|
2075 |
|
2076 |
}
|
2077 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2078 |
|
2079 |
function product_images_ids($product_id){
|
2080 |
global $wpdb;
|
@@ -2242,23 +2392,8 @@ class WCML_Products{
|
|
2242 |
}
|
2243 |
|
2244 |
$lang = $sitepress->get_language_for_element($tr_product_id,'post_product');
|
2245 |
-
$this->duplicate_product_post_meta($original_product_id,$tr_product_id);
|
2246 |
-
|
2247 |
-
//duplicate product attrs
|
2248 |
-
$orig_product_attrs = $this->get_product_atributes($original_product_id);
|
2249 |
-
add_post_meta($tr_product_id,'_product_attributes',$orig_product_attrs);
|
2250 |
-
|
2251 |
-
$this->sync_default_product_attr($original_product_id, $tr_product_id, $lang);
|
2252 |
-
//sync media
|
2253 |
-
$this->sync_thumbnail_id($original_product_id, $tr_product_id,$lang);
|
2254 |
-
$this->sync_product_gallery($original_product_id);
|
2255 |
-
|
2256 |
-
//sync taxonomies
|
2257 |
-
$this->sync_product_taxonomies($original_product_id,$tr_product_id,$lang);
|
2258 |
-
|
2259 |
-
//duplicate variations
|
2260 |
-
$this->sync_product_variations($original_product_id,$tr_product_id,$lang);
|
2261 |
|
|
|
2262 |
}
|
2263 |
|
2264 |
function translate_cart_contents($item, $values, $key) {
|
@@ -2290,7 +2425,7 @@ class WCML_Products{
|
|
2290 |
$translations = $sitepress->get_element_translations($trid, 'post_product_variation');
|
2291 |
if($translations){
|
2292 |
foreach($translations as $translation){
|
2293 |
-
if(
|
2294 |
wp_delete_post($translation->element_id,true);
|
2295 |
}
|
2296 |
}
|
@@ -2386,36 +2521,7 @@ class WCML_Products{
|
|
2386 |
//delete 'attribute_' at the beginning
|
2387 |
$taxonomy = substr($attr_key, 10, strlen($attr_key)-1 );
|
2388 |
}
|
2389 |
-
|
2390 |
-
if(taxonomy_exists($taxonomy)){
|
2391 |
-
$term = get_term_by('slug',$attribute,$taxonomy);
|
2392 |
-
$trnsl_term_id = icl_object_id($term->term_id,$taxonomy,true,$current_language);
|
2393 |
-
|
2394 |
-
$cart->cart_contents[$key]['variation'][$attr_key] = get_term($trnsl_term_id,$taxonomy)->slug;
|
2395 |
-
}else{
|
2396 |
-
$orig_product_attributes = get_post_meta($cart_item['product_id'], '_product_attributes', true);
|
2397 |
-
$unserialized_orig_product_attributes = maybe_unserialize($orig_product_attributes);
|
2398 |
-
foreach($unserialized_orig_product_attributes as $orig_attr_key => $orig_product_attribute){
|
2399 |
-
$orig_attr_key = urldecode($orig_attr_key);
|
2400 |
-
if($taxonomy == $orig_attr_key){
|
2401 |
-
$values = explode('|',$orig_product_attribute['value']);
|
2402 |
-
foreach($values as $key_id => $value){
|
2403 |
-
if(trim($value," ") == $attribute){
|
2404 |
-
$attr_key_id = $key_id;
|
2405 |
-
}
|
2406 |
-
}
|
2407 |
-
}
|
2408 |
-
}
|
2409 |
-
|
2410 |
-
$trnsl_product_attributes = get_post_meta($tr_product_id, '_product_attributes', true);
|
2411 |
-
$unserialized_trnsl_product_attributes = maybe_unserialize($trnsl_product_attributes);
|
2412 |
-
$taxonomy = sanitize_title($taxonomy);
|
2413 |
-
$trnsl_attr_values = explode('|',$unserialized_trnsl_product_attributes[$taxonomy]['value']);
|
2414 |
-
|
2415 |
-
if(isset($trnsl_attr_values[$attr_key_id])){
|
2416 |
-
$cart->cart_contents[$key]['variation'][$attr_key] = trim($trnsl_attr_values[$attr_key_id]);
|
2417 |
-
}
|
2418 |
-
}
|
2419 |
}
|
2420 |
}
|
2421 |
}
|
@@ -2428,13 +2534,13 @@ class WCML_Products{
|
|
2428 |
}
|
2429 |
|
2430 |
if(!is_null($tr_product_id)){
|
2431 |
-
$
|
2432 |
-
$
|
|
|
2433 |
$new_cart_data[$new_key] = $cart->cart_contents[$key];
|
2434 |
-
|
2435 |
}
|
2436 |
-
|
2437 |
-
$new_cart_data = apply_filters('wcml_update_cart_lang_switch', $new_cart_data, $cart->cart_contents,$key, $new_key);
|
2438 |
}
|
2439 |
$cart->cart_contents = $new_cart_data;
|
2440 |
|
@@ -2443,6 +2549,39 @@ class WCML_Products{
|
|
2443 |
return $cart;
|
2444 |
}
|
2445 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2446 |
function wcml_coupon_loaded($coupons_data){
|
2447 |
global $sitepress;
|
2448 |
|
@@ -2492,7 +2631,7 @@ class WCML_Products{
|
|
2492 |
|
2493 |
|
2494 |
function set_price_config() {
|
2495 |
-
global $sitepress, $iclTranslationManagement
|
2496 |
|
2497 |
$all_products_taxonomies = get_taxonomies(array('object_type'=>array('product')),'objects');
|
2498 |
foreach($all_products_taxonomies as $tax_key => $tax){
|
@@ -2523,6 +2662,7 @@ class WCML_Products{
|
|
2523 |
);
|
2524 |
|
2525 |
$save = false;
|
|
|
2526 |
foreach ($keys as $key) {
|
2527 |
$iclTranslationManagement->settings['custom_fields_readonly_config'][] = $key;
|
2528 |
if (!isset($sitepress_settings['translation-management']['custom_fields_translation'][$key]) ||
|
@@ -2530,17 +2670,18 @@ class WCML_Products{
|
|
2530 |
$wpml_settings['translation-management']['custom_fields_translation'][$key] = 1;
|
2531 |
$save = true;
|
2532 |
}
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
|
|
2542 |
}
|
2543 |
-
|
2544 |
|
2545 |
}
|
2546 |
|
@@ -2548,6 +2689,7 @@ class WCML_Products{
|
|
2548 |
$sitepress->save_settings($wpml_settings);
|
2549 |
}
|
2550 |
}
|
|
|
2551 |
|
2552 |
|
2553 |
function woocommerce_duplicate_product($new_id, $post){
|
@@ -2563,4 +2705,53 @@ class WCML_Products{
|
|
2563 |
}
|
2564 |
}
|
2565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2566 |
}
|
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,'wcml_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'));
|
61 |
|
62 |
add_filter('woocommerce_upsell_crosssell_search_products', array($this, 'filter_woocommerce_upsell_crosssell_posts_by_language'));
|
68 |
add_action('updated_post_meta', array($this,'register_product_name_and_attribute_strings'), 100, 4);
|
69 |
add_action('added_post_meta', array($this,'register_product_name_and_attribute_strings'), 100, 4);
|
70 |
|
71 |
+
add_filter('wcml_custom_box_html',array($this,'downloadable_files_box'),10,3);
|
72 |
+
|
73 |
//add translation manager filters
|
74 |
add_filter('wpml_tm_save_post_trid_value', array($this,'wpml_tm_save_post_trid_value'),10,2);
|
75 |
add_filter('wpml_tm_save_post_lang_value', array($this,'wpml_tm_save_post_lang_value'),10,2);
|
82 |
//add filter when add term on product page
|
83 |
add_filter('wpml_create_term_lang',array($this,'product_page_add_language_info_to_term'));
|
84 |
|
85 |
+
//quick & bulk edit
|
86 |
+
add_action('woocommerce_product_quick_edit_save',array($this,'woocommerce_product_quick_edit_save'));
|
87 |
+
add_action('woocommerce_product_bulk_edit_save',array($this,'woocommerce_product_quick_edit_save'));
|
88 |
|
89 |
//save taxonomy in WPML interface
|
90 |
add_action('wp_ajax_wpml_tt_save_term_translation', array($this, 'update_taxonomy_in_variations'),7);
|
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'));
|
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);
|
98 |
|
100 |
add_action('woocommerce_get_cart_item_from_session', array($this, 'translate_cart_contents'), 10, 3);
|
101 |
add_action('woocommerce_cart_loaded_from_session', array($this, 'translate_cart_subtotal'));
|
102 |
add_action('woocommerce_before_calculate_totals',array($this,'woocommerce_calculate_totals'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
if(defined('WPSEO_VERSION') && defined('WPSEO_PATH') && isset($_GET['tab']) && $_GET['tab'] == 'products'){
|
105 |
require WPSEO_PATH . 'admin/class-metabox.php';
|
114 |
|
115 |
function wc_cart_widget_actions(){
|
116 |
add_action('wp_ajax_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),9);
|
117 |
+
add_action('wp_ajax_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),9);
|
118 |
add_action('wp_ajax_nopriv_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),9);
|
119 |
+
add_action('wp_ajax_nopriv_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),9);
|
120 |
if(!is_admin()){
|
121 |
wp_enqueue_script('wcml-scripts', WCML_PLUGIN_URL . '/assets/js/cart_widget.js', array('jquery'), WCML_VERSION);
|
122 |
}
|
139 |
* return array;
|
140 |
*/
|
141 |
function get_product_list($page = 1,$limit = 20){
|
142 |
+
global $wpdb,$sitepress;
|
143 |
+
$products = $wpdb->get_results($wpdb->prepare("SELECT p.ID,p.post_parent 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()));
|
|
|
|
|
|
|
|
|
144 |
|
145 |
+
return $this->display_hierarchical($products,$page,$limit);
|
146 |
}
|
147 |
|
148 |
function display_hierarchical($products, $pagenum, $per_page){
|
164 |
}
|
165 |
|
166 |
if ( 0 == $product->post_parent ){
|
167 |
+
$top_level_products[] = $product->ID;
|
168 |
}else{
|
169 |
+
$children_products[$product->post_parent][] = $product->ID;
|
170 |
}
|
171 |
}
|
172 |
|
174 |
$start = ( $pagenum - 1 ) * $per_page;
|
175 |
$end = $start + $per_page;
|
176 |
|
177 |
+
foreach ( $top_level_products as $product_id ) {
|
178 |
if ( $count >= $end )
|
179 |
break;
|
180 |
|
181 |
if ( $count >= $start ) {
|
182 |
+
$output_products[] = get_post($product_id);
|
183 |
|
184 |
+
if ( isset( $children_products[$product_id] ) ){
|
185 |
+
foreach($children_products[$product_id] as $children){
|
186 |
+
$output_products[] = get_post($children);
|
187 |
$count++;
|
188 |
}
|
189 |
+
unset($children_products[$product_id]);
|
190 |
}
|
191 |
}
|
192 |
|
264 |
break;
|
265 |
}
|
266 |
|
267 |
+
$this->sync_product_data($product_id, $tr_product_id, $language['code']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
break;
|
270 |
case 'clean':
|
511 |
$this->duplicate_product_post_meta($original_product_id, $tr_product_id, $data);
|
512 |
|
513 |
}
|
514 |
+
|
515 |
+
do_action('wcml_update_extra_fields',$tr_product_id,$data);
|
516 |
+
|
517 |
//get "_product_attributes" from original product
|
518 |
$orig_product_attrs = $this->get_product_atributes($original_product_id);
|
519 |
$trnsl_labels = get_option('wcml_custom_attr_translations');
|
543 |
// synchronize post variations
|
544 |
$this->sync_product_variations($original_product_id, $tr_product_id, $language, $data);
|
545 |
|
546 |
+
$this->sync_grouped_products($original_product_id, $tr_product_id, $language);
|
547 |
+
|
548 |
//save images texts
|
549 |
if(isset($data['images'])){
|
550 |
foreach($data['images'] as $key=>$image){
|
597 |
|
598 |
}
|
599 |
|
600 |
+
function sync_product_data($original_product_id,$tr_product_id,$lang){
|
601 |
+
|
602 |
+
$this->duplicate_product_post_meta($original_product_id,$tr_product_id);
|
603 |
+
|
604 |
+
//duplicate product attrs
|
605 |
+
$orig_product_attrs = $this->get_product_atributes($original_product_id);
|
606 |
+
add_post_meta($tr_product_id,'_product_attributes',$orig_product_attrs);
|
607 |
+
|
608 |
+
$this->sync_default_product_attr($original_product_id, $tr_product_id, $lang);
|
609 |
+
//sync media
|
610 |
+
$this->sync_thumbnail_id($original_product_id, $tr_product_id,$lang);
|
611 |
+
$this->sync_product_gallery($original_product_id);
|
612 |
+
|
613 |
+
//sync taxonomies
|
614 |
+
$this->sync_product_taxonomies($original_product_id,$tr_product_id,$lang);
|
615 |
+
|
616 |
+
//duplicate variations
|
617 |
+
$this->sync_product_variations($original_product_id,$tr_product_id,$lang);
|
618 |
+
|
619 |
+
$this->sync_grouped_products($original_product_id,$tr_product_id,$lang);
|
620 |
+
}
|
621 |
+
|
622 |
+
|
623 |
function is_variable_product($product_id){
|
624 |
global $wpdb;
|
625 |
+
$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'");
|
626 |
+
$get_variation_term_taxonomy_ids = apply_filters('wcml_variation_term_taxonomy_ids',(array)$get_variation_term_taxonomy_ids);
|
627 |
|
628 |
+
$is_variable_product = $wpdb->get_var($wpdb->prepare("SELECT count(object_id) FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN (".join(',',$get_variation_term_taxonomy_ids).")",$product_id));
|
629 |
return $is_variable_product;
|
630 |
}
|
631 |
|
632 |
+
function is_grouped_product($product_id){
|
633 |
+
global $wpdb;
|
634 |
+
$get_variation_term_taxonomy_id = $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 = 'grouped'");
|
635 |
+
$is_grouped_product = $wpdb->get_var($wpdb->prepare("SELECT count(object_id) FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d ",$product_id,$get_variation_term_taxonomy_id));
|
636 |
+
|
637 |
+
return $is_grouped_product;
|
638 |
+
}
|
639 |
+
|
640 |
|
641 |
function sync_product_taxonomies($original_product_id,$tr_product_id,$lang){
|
642 |
global $sitepress,$wpdb;
|
675 |
}
|
676 |
|
677 |
function get_product_atributes($product_id){
|
678 |
+
$attributes = get_post_meta($product_id,'_product_attributes',true);
|
679 |
+
if(!is_array($attributes)){
|
680 |
+
$attributes = array();
|
681 |
+
}
|
682 |
+
return $attributes;
|
683 |
}
|
684 |
|
685 |
//duplicate product post meta
|
711 |
$file_paths_array[md5($file_path)] = $file_path;
|
712 |
}
|
713 |
$meta_value = $file_paths_array;
|
714 |
+
}elseif($key == '_downloadable_files'){
|
715 |
+
$file_paths_array = array();
|
716 |
+
foreach($data[$key.'_'.$lang] as $file_path){
|
717 |
+
$key_file = md5($file_path['file'].$file_path['name']);
|
718 |
+
$file_paths_array[$key_file]['name'] = $file_path['name'];
|
719 |
+
$file_paths_array[$key_file]['file'] = $file_path['file'];
|
720 |
+
}
|
721 |
+
$meta_value = $file_paths_array;
|
722 |
+
|
723 |
}else{
|
724 |
$meta_value = $data[$key.'_'.$lang];
|
725 |
}
|
785 |
update_post_meta($trnsl_product_id,$key,$meta_value);
|
786 |
}
|
787 |
}else{
|
788 |
+
if(isset($settings['translation-management']['custom_fields_translation'][$key]) && $settings['translation-management']['custom_fields_translation'][$key] == 1){
|
789 |
$meta_value = apply_filters('wcml_meta_value_before_add',$meta_value,$key);
|
790 |
update_post_meta($trnsl_product_id, $key, $meta_value);
|
791 |
}
|
792 |
}
|
793 |
}
|
794 |
+
}
|
795 |
|
796 |
do_action('wcml_after_duplicate_product_post_meta',$original_product_id, $trnsl_product_id, $data);
|
797 |
}
|
809 |
$translations = $sitepress->get_element_translations($trid,'post_product',true);
|
810 |
foreach($translations as $translation){
|
811 |
$duplicated_ids = '';
|
812 |
+
if ($translation->language_code != $sitepress->get_default_language()) {
|
813 |
foreach($gallery_ids as $image_id){
|
814 |
$duplicated_id = icl_object_id($image_id,'attachment',false,$translation->language_code);
|
815 |
if(!is_null($duplicated_id)){
|
824 |
|
825 |
function get_translation_flags($active_languages,$default_language,$slang = false){
|
826 |
foreach($active_languages as $language){
|
827 |
+
if ($default_language != $language['code'] && (($slang && $slang == $language['code']) || !$slang) && (current_user_can('wpml_operate_woocommerce_multilingual') || wpml_check_user_is_translator($default_language,$language['code'])) && (!isset($_POST['translation_status_lang']) || (isset($_POST['translation_status_lang']) && ($_POST['translation_status_lang'] == $language['code']) || $_POST['translation_status_lang']==''))){
|
828 |
echo '<img src="'. ICL_PLUGIN_URL .'/res/flags/'. $language['code'] .'.png" width="18" height="12" class="flag_img" />';
|
829 |
}
|
830 |
}
|
835 |
global $wpdb;
|
836 |
|
837 |
foreach ($active_languages as $language) {
|
838 |
+
if ($default_language != $language['code'] && (($slang && $slang == $language['code']) || !$slang) && (current_user_can('wpml_operate_woocommerce_multilingual') || wpml_check_user_is_translator($default_language,$language['code'])) && (!isset($_POST['translation_status_lang']) || (isset($_POST['translation_status_lang']) && ($_POST['translation_status_lang'] == $language['code']) || $_POST['translation_status_lang']==''))) {
|
839 |
if (isset($product_translations[$language['code']])) {
|
840 |
$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));
|
841 |
if(!$tr_status){
|
869 |
|
870 |
//sync product variations
|
871 |
function sync_product_variations($product_id,$tr_product_id,$lang,$data = false,$trbl = false){
|
872 |
+
global $wpdb,$sitepress,$sitepress_settings, $woocommerce_wpml,$woocommerce;
|
873 |
|
874 |
$is_variable_product = $this->is_variable_product($product_id);
|
|
|
875 |
if($is_variable_product){
|
876 |
$get_all_post_variations = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts
|
877 |
WHERE post_status IN ('publish','private') AND post_type = 'product_variation' AND post_parent = %d ORDER BY ID",$product_id));
|
886 |
update_post_meta($product_id,$price_key,$min_max_price);
|
887 |
}
|
888 |
|
889 |
+
|
890 |
+
$all_taxs = get_object_taxonomies( 'product_variation' );
|
891 |
+
|
892 |
+
|
893 |
foreach ($get_all_post_variations as $k => $post_data) {
|
894 |
|
895 |
// Find if this has already been duplicated
|
961 |
|
962 |
//sync file_paths
|
963 |
if(!$woocommerce_wpml->settings['file_path_sync'] && isset($data['variations_file_paths'][$variation_id])){
|
|
|
964 |
$file_paths_array = array();
|
965 |
+
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
966 |
+
$file_paths = explode("\n",$data['variations_file_paths'][$variation_id]);
|
967 |
foreach($file_paths as $file_path){
|
968 |
$file_paths_array[md5($file_path)] = $file_path;
|
969 |
}
|
970 |
update_post_meta($variation_id,'_file_paths',$file_paths_array);
|
971 |
}else{
|
972 |
+
|
973 |
+
foreach($data['variations_file_paths'][$variation_id] as $file_path){
|
974 |
+
$key = md5($file_path['file'].$file_path['name']);
|
975 |
+
$file_paths_array[$key]['name'] = $file_path['name'];
|
976 |
+
$file_paths_array[$key]['file'] = $file_path['file'];
|
977 |
+
}
|
978 |
+
update_post_meta($variation_id,'_downloadable_files',$file_paths_array);
|
979 |
+
|
980 |
+
}
|
981 |
+
}elseif($woocommerce_wpml->settings['file_path_sync']){
|
982 |
+
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
983 |
$orig_file_path = maybe_unserialize(get_post_meta($post_data->ID,'_file_paths',true));
|
984 |
update_post_meta($variation_id,'_file_paths',$orig_file_path);
|
985 |
+
}else{
|
986 |
+
$orig_file_path = maybe_unserialize(get_post_meta($post_data->ID,'_downloadable_files',true));
|
987 |
+
update_post_meta($variation_id,'_downloadable_files',$orig_file_path);
|
988 |
+
}
|
989 |
+
}
|
990 |
+
|
991 |
+
// sync taxonomies
|
992 |
+
if ( !empty( $all_taxs ) ) {
|
993 |
+
foreach ( $all_taxs as $tt ) {
|
994 |
+
$terms = get_the_terms( $post_data->ID, $tt );
|
995 |
+
if ( !empty( $terms ) ) {
|
996 |
+
$tax_sync = array();
|
997 |
+
foreach ( $terms as $term ) {
|
998 |
+
if ( $sitepress->is_translated_taxonomy($tt) ) {
|
999 |
+
$term_id = icl_object_id( $term->term_id, $tt, false, $lang );
|
1000 |
+
} else {
|
1001 |
+
$term_id = $term->term_id;
|
1002 |
+
}
|
1003 |
+
if ( $term_id ) {
|
1004 |
+
$tax_sync[ ] = intval( $term_id );
|
1005 |
+
}
|
1006 |
+
}
|
1007 |
+
//set the fourth parameter in 'true' because we need to add new terms, instead of replacing all
|
1008 |
+
wp_set_object_terms( $variation_id, $tax_sync, $tt, true );
|
1009 |
+
}
|
1010 |
+
}
|
1011 |
}
|
1012 |
|
1013 |
}
|
1058 |
|
1059 |
// adjust the global attribute slug in the custom field
|
1060 |
$attid = null;
|
1061 |
+
|
1062 |
if (substr($meta_key, 0, 10) == 'attribute_') {
|
1063 |
$tax = substr($meta_key, 10);
|
1064 |
|
1079 |
}else{
|
1080 |
if(isset($original_product_attr[$tax])){
|
1081 |
if(isset($tr_product_attr[$tax])){
|
1082 |
+
$values_arrs = array_map('trim', explode('|',$original_product_attr[$tax]['value']));
|
1083 |
+
$values_arrs_tr = array_map('trim',explode('|',$tr_product_attr[$tax]['value']));
|
1084 |
foreach($values_arrs as $key=>$value){
|
1085 |
+
$value_sanitized = sanitize_title($value);
|
1086 |
+
if($value_sanitized == urldecode($meta_value) && isset($values_arrs_tr[$key])){
|
1087 |
+
$meta_value = $values_arrs_tr[$key];
|
|
|
|
|
|
|
1088 |
}
|
1089 |
}
|
1090 |
}else{
|
1108 |
}
|
1109 |
|
1110 |
}
|
1111 |
+
}
|
1112 |
+
}
|
1113 |
|
1114 |
+
function sync_grouped_products($product_id,$tr_product_id,$lang){
|
1115 |
+
global $wpdb;
|
1116 |
+
$parent_id = wp_get_post_parent_id($product_id);
|
1117 |
+
if($this->is_grouped_product($product_id)){
|
1118 |
+
$grouped_ids = get_posts( 'post_parent=' . $product_id . '&post_type=product&orderby=menu_order&order=ASC&fields=ids&post_status=publish&numberposts=-1' );
|
1119 |
+
$trnsl_grouped_ids = array();
|
1120 |
+
foreach($grouped_ids as $id){
|
1121 |
+
$tr_id = icl_object_id($id,get_post_type($id),false,$lang);
|
1122 |
+
if(!is_null($tr_id)){
|
1123 |
+
$trnsl_grouped_ids[] =$tr_id;
|
1124 |
+
$wpdb->update(
|
1125 |
+
$wpdb->posts,
|
1126 |
+
array(
|
1127 |
+
'post_parent' => $tr_product_id
|
1128 |
+
),
|
1129 |
+
array( 'id' => $tr_id )
|
1130 |
+
);
|
1131 |
+
}
|
1132 |
+
}
|
1133 |
+
update_option('_transient_wc_product_children_ids_'.$tr_product_id,$trnsl_grouped_ids);
|
1134 |
+
}elseif($parent_id && get_post_type($product_id) == 'product'){
|
1135 |
+
$tr_parent_id = icl_object_id($parent_id,'product',false,$lang);
|
1136 |
+
if(!is_null($tr_parent_id)){
|
1137 |
+
$grouped_ids = maybe_unserialize(get_option('_transient_wc_product_children_ids_'.$tr_parent_id));
|
1138 |
+
if(!in_array($tr_product_id,$grouped_ids)){
|
1139 |
+
$grouped_ids[] = $tr_product_id;
|
1140 |
+
update_option('_transient_wc_product_children_ids_'.$tr_parent_id,$grouped_ids);
|
1141 |
+
}
|
1142 |
+
}
|
1143 |
}
|
1144 |
+
|
1145 |
}
|
1146 |
|
1147 |
function sync_thumbnail_id($orig_post_id,$trnsl_post_id,$lang){
|
1195 |
add_action('admin_notices', array($this, 'inf_editing_product_in_non_default_lang'));
|
1196 |
}
|
1197 |
|
1198 |
+
if($woocommerce_wpml->settings['trnsl_interface'] && $pagenow == 'post.php' && !is_ajax() && isset($_GET['post']) && $default_lang!=$prod_lang && get_post_type($_GET['post'])=='product'){
|
1199 |
if((!isset($_GET['action'])) || (isset($_GET['action']) && !in_array($_GET['action'],array('trash','delete')))){
|
1200 |
$prid = icl_object_id($_GET['post'],'product',true,$default_lang);
|
1201 |
wp_redirect(admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$prid)); exit;
|
1404 |
global $wpdb, $pagenow, $sitepress, $sitepress_settings,$woocommerce_wpml;
|
1405 |
$default_language = $sitepress->get_default_language();
|
1406 |
$current_language = $sitepress->get_current_language();
|
1407 |
+
$duplicated_post_id = icl_object_id($post_id, 'product', false, $default_language);
|
1408 |
+
|
1409 |
+
//sync product gallery
|
1410 |
+
$this->sync_product_gallery($duplicated_post_id);
|
1411 |
|
1412 |
//trnsl_interface option
|
1413 |
if (!$woocommerce_wpml->settings['trnsl_interface'] && $default_language != $current_language) {
|
1432 |
|
1433 |
// exceptions
|
1434 |
$ajax_call = (!empty($_POST['icl_ajx_action']) && $_POST['icl_ajx_action'] == 'make_duplicates');
|
|
|
1435 |
if (empty($duplicated_post_id) || isset($_POST['autosave'])) {
|
1436 |
return;
|
1437 |
}
|
1458 |
|
1459 |
update_post_meta($post_id,'_wcml_custom_prices_status',$_REQUEST['_wcml_custom_prices'][$post_id]);
|
1460 |
|
1461 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
1462 |
|
1463 |
if($_REQUEST['_wcml_custom_prices'][$post_id] == 1){
|
1464 |
+
foreach($currencies as $code => $currency){
|
1465 |
+
$sale_price = $_REQUEST['_custom_sale_price'][$code];
|
1466 |
+
$regular_price = $_REQUEST['_custom_regular_price'][$code];
|
1467 |
|
1468 |
+
$date_from = strtotime($_REQUEST['_custom_sale_price_dates_from'][$code]);
|
1469 |
+
$date_to = strtotime($_REQUEST['_custom_sale_price_dates_to'][$code]);
|
1470 |
+
$schedule = $_REQUEST['_wcml_schedule'][$code];
|
1471 |
|
1472 |
+
$pr_price = $this->update_custom_prices($post_id,$regular_price,$sale_price,$schedule,$date_from,$date_to,$code);
|
1473 |
}
|
1474 |
}
|
1475 |
}
|
1481 |
//media sync
|
1482 |
update_post_meta($post_id, '_wpml_media_duplicate', 1);
|
1483 |
update_post_meta($post_id, '_wpml_media_featured', 1);
|
|
|
|
|
1484 |
|
1485 |
// pick posts to sync
|
1486 |
$posts = array();
|
1487 |
$translations = $sitepress->get_element_translations($language_details->trid, 'post_product');
|
1488 |
foreach ($translations as $translation) {
|
1489 |
+
if ($translation->language_code == $default_language) {
|
1490 |
$duplicated_post_id = $translation->element_id;
|
1491 |
} else {
|
1492 |
$posts[$translation->element_id] = $translation;
|
1500 |
|
1501 |
// Filter upsell products, crosell products and default attributes for translations
|
1502 |
$this->duplicate_product_post_meta($duplicated_post_id,$post_id);
|
1503 |
+
|
1504 |
+
//sync product parent
|
1505 |
+
$tr_parent_id = icl_object_id(wp_get_post_parent_id($duplicated_post_id),'product',false,$lang);
|
1506 |
+
$wpdb->update(
|
1507 |
+
$wpdb->posts,
|
1508 |
+
array(
|
1509 |
+
'post_parent' => is_null($tr_parent_id)?0:$tr_parent_id
|
1510 |
+
),
|
1511 |
+
array( 'id' => $post_id )
|
1512 |
+
);
|
1513 |
+
|
1514 |
+
|
1515 |
$original_product_upsell_ids = get_post_meta($duplicated_post_id, '_upsell_ids', TRUE);
|
1516 |
if(!empty($original_product_upsell_ids)){
|
1517 |
$unserialized_upsell_ids = maybe_unserialize($original_product_upsell_ids);
|
1571 |
|
1572 |
update_post_meta($post_id, '_product_attributes', $orig_product_attrs);
|
1573 |
|
1574 |
+
|
1575 |
+
|
1576 |
// synchronize post variations
|
1577 |
$this->sync_product_variations($duplicated_post_id,$post_id,$lang);
|
1578 |
+
$this->sync_grouped_products($duplicated_post_id,$post_id,$lang);
|
1579 |
}
|
1580 |
|
1581 |
$this->sync_product_variations_custom_prices($duplicated_post_id);
|
1626 |
}
|
1627 |
|
1628 |
function sync_product_variations_custom_prices($product_id){
|
1629 |
+
global $wpdb,$woocommerce_wpml;
|
1630 |
$is_variable_product = $this->is_variable_product($product_id);
|
1631 |
|
1632 |
if($is_variable_product){
|
1643 |
|
1644 |
update_post_meta($post_data->ID,'_wcml_custom_prices_status',$_REQUEST['_wcml_custom_prices'][$post_data->ID]);
|
1645 |
|
1646 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
1647 |
|
1648 |
if($_REQUEST['_wcml_custom_prices'][$post_data->ID] == 1){
|
1649 |
+
foreach($currencies as $code => $currency){
|
1650 |
+
$sale_price = $_REQUEST['_custom_variation_sale_price'][$code][$post_data->ID];
|
1651 |
+
$regular_price = $_REQUEST['_custom_variation_regular_price'][$code][$post_data->ID];
|
1652 |
|
1653 |
+
$date_from = strtotime($_REQUEST['_custom_sale_price_dates_from'][$code][$post_data->ID]);
|
1654 |
+
$date_to = strtotime($_REQUEST['_custom_sale_price_dates_to'][$code][$post_data->ID]);
|
1655 |
+
$schedule = $_REQUEST['_wcml_schedule'][$code][$post_data->ID];
|
1656 |
|
1657 |
+
$price = $this->update_custom_prices($post_data->ID,$regular_price,$sale_price,$schedule,$date_from,$date_to,$code);
|
1658 |
|
1659 |
+
if(!isset($min_max_prices['_min_variation_price_'.$code]) || ($price && $price < $min_max_prices['_min_variation_price_'.$code])){
|
1660 |
+
$min_max_prices['_min_variation_price_'.$code] = $price;
|
1661 |
+
$min_max_prices['_min_price_variation_id_'.$code] = $post_data->ID;
|
1662 |
}
|
1663 |
|
1664 |
+
if(!isset($min_max_prices['_max_variation_price_'.$code]) || ($price && $price > $min_max_prices['_max_variation_price_'.$code])){
|
1665 |
+
$min_max_prices['_max_variation_price_'.$code] = $price;
|
1666 |
+
$min_max_prices['_max_price_variation_id_'.$code] = $post_data->ID;
|
1667 |
}
|
1668 |
|
1669 |
+
if(!isset($min_max_prices['_min_variation_regular_price_'.$code]) || ($regular_price && $regular_price < $min_max_prices['_min_variation_regular_price_'.$code])){
|
1670 |
+
$min_max_prices['_min_variation_regular_price_'.$code] = $regular_price;
|
1671 |
}
|
1672 |
|
1673 |
+
if(!isset($min_max_prices['_max_variation_regular_price_'.$code]) || ($regular_price && $regular_price > $min_max_prices['_max_variation_regular_price_'.$code])){
|
1674 |
+
$min_max_prices['_max_variation_regular_price_'.$code] = $regular_price;
|
1675 |
}
|
1676 |
|
1677 |
+
if(!isset($min_max_prices['_min_variation_sale_price_'.$code]) || ($sale_price && $sale_price < $min_max_prices['_min_variation_sale_price_'.$code])){
|
1678 |
+
$min_max_prices['_min_variation_sale_price_'.$code] = $sale_price;
|
1679 |
}
|
1680 |
|
1681 |
+
if(!isset($min_max_prices['_max_variation_sale_price_'.$code]) || ($sale_price && $sale_price > $min_max_prices['_max_variation_sale_price_'.$code])){
|
1682 |
+
$min_max_prices['_max_variation_sale_price_'.$code] = $sale_price;
|
1683 |
}
|
1684 |
}
|
1685 |
}
|
1785 |
}
|
1786 |
}
|
1787 |
|
1788 |
+
if(!$woocommerce_wpml->settings['file_path_sync'] && isset($product_type) && $product_type == 'variable'){
|
1789 |
$contents[] = 'variations';
|
1790 |
}
|
1791 |
|
1825 |
$product_type = $type;
|
1826 |
}
|
1827 |
|
1828 |
+
if(!$woocommerce_wpml->settings['file_path_sync'] && isset($product_type) && $product_type == 'variable'){
|
1829 |
$contents[] = __('Variations','wpml-wcml');
|
1830 |
}
|
1831 |
|
2071 |
|
2072 |
function product_variations_box($product_id, $lang, $is_duplicate_product = false)
|
2073 |
{
|
2074 |
+
global $sitepress, $woocommerce_wpml,$wpdb,$woocommerce;
|
2075 |
|
2076 |
$default_language = $sitepress->get_default_language();
|
2077 |
$template_data = array();
|
2092 |
if (!$woocommerce_wpml->settings['file_path_sync']) {
|
2093 |
global $wpdb;
|
2094 |
$is_downloable = $wpdb->get_results($wpdb->prepare("SELECT pm.meta_value FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS pm ON p.id=pm.post_id WHERE p.post_parent = %d AND p.post_type = 'product_variation' AND pm.meta_key='_downloadable' AND pm.meta_value = 'yes'", $product_id));
|
2095 |
+
$template_data['all_file_paths'] = $this->get_product_content_translation($product_id, 'variations_file_paths', $lang);
|
2096 |
+
|
2097 |
+
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '>')){
|
2098 |
+
$variations = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation'",is_null($trn_product_id)?$product_id:$trn_product_id));
|
2099 |
|
2100 |
+
foreach($variations as $variation){
|
2101 |
+
$files = maybe_unserialize(get_post_meta($variation->ID,'_downloadable_files',true));
|
2102 |
|
2103 |
+
if($files){
|
2104 |
+
if(is_null($trn_product_id)){
|
2105 |
+
$template_data['all_file_paths']['count'] = count($files);
|
2106 |
+
}else{
|
2107 |
+
$template_data['all_file_paths']['count'] = count(maybe_unserialize(get_post_meta(icl_object_id($variation->ID, 'product_variation', false, $sitepress->get_default_language()),'_downloadable_files',true)));
|
2108 |
+
}
|
2109 |
+
foreach($files as $file){
|
2110 |
+
$variables = array();
|
2111 |
+
$variables['value'] = $file['file'];
|
2112 |
+
$variables['label'] = $file['name'];
|
2113 |
+
$template_data['all_file_paths'][$variation->ID][] = $variables;
|
2114 |
+
}
|
2115 |
+
}
|
2116 |
+
}
|
2117 |
+
}
|
2118 |
}
|
2119 |
|
2120 |
$is_product_has_variations = $wpdb->get_var($wpdb->prepare("SELECT count(id) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation'",$product_id));
|
2135 |
}
|
2136 |
|
2137 |
function product_images_box($product_id,$lang, $is_duplicate_product = false ) {
|
2138 |
+
global $sitepress,$wpdb;
|
2139 |
$default_language = $sitepress->get_default_language();
|
2140 |
if($default_language != $lang){
|
2141 |
$product_id = icl_object_id($product_id, 'product', false, $lang);
|
2159 |
$prod_image = icl_object_id($prod_image, 'attachment', false, $lang);
|
2160 |
$images_texs = array();
|
2161 |
if(!is_null($prod_image)){
|
2162 |
+
$attachment_data = $wpdb->get_row($wpdb->prepare("SELECT post_title,post_excerpt,post_content FROM $wpdb->posts WHERE ID = %d", $prod_image));
|
2163 |
$images_texs['title'] = $attachment_data->post_title;
|
2164 |
$images_texs['caption'] = $attachment_data->post_excerpt;
|
2165 |
$images_texs['description'] = $attachment_data->post_content;
|
2199 |
$template_data['translation_exist'] = false;
|
2200 |
}
|
2201 |
|
|
|
|
|
2202 |
include WCML_PLUGIN_PATH . '/menu/sub/custom-box.php';
|
2203 |
|
2204 |
}
|
2205 |
|
2206 |
+
function downloadable_files_box($html,$data,$lang){
|
2207 |
+
if($data['product_content'] == '_downloadable_files'){
|
2208 |
+
$files = maybe_unserialize(get_post_meta($data['tr_product_id'],'_downloadable_files',true));
|
2209 |
+
$data['count'] = count(maybe_unserialize(get_post_meta($data['product_id'],'_downloadable_files',true)));
|
2210 |
+
if($files){
|
2211 |
+
foreach($files as $file){
|
2212 |
+
$variables = array();
|
2213 |
+
$variables['value'] = $file['file'];
|
2214 |
+
$variables['label'] = $file['name'];
|
2215 |
+
$data['files_data'][] = $variables;
|
2216 |
+
}
|
2217 |
+
}else{
|
2218 |
+
$data['files_data'] = array();
|
2219 |
+
}
|
2220 |
+
|
2221 |
+
ob_start();
|
2222 |
+
include WCML_PLUGIN_PATH . '/menu/sub/downloadable-files-box.php';
|
2223 |
+
|
2224 |
+
return ob_get_clean();
|
2225 |
+
}
|
2226 |
+
}
|
2227 |
+
|
2228 |
|
2229 |
function product_images_ids($product_id){
|
2230 |
global $wpdb;
|
2392 |
}
|
2393 |
|
2394 |
$lang = $sitepress->get_language_for_element($tr_product_id,'post_product');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2395 |
|
2396 |
+
$this->sync_product_data($original_product_id, $tr_product_id, $lang);
|
2397 |
}
|
2398 |
|
2399 |
function translate_cart_contents($item, $values, $key) {
|
2425 |
$translations = $sitepress->get_element_translations($trid, 'post_product_variation');
|
2426 |
if($translations){
|
2427 |
foreach($translations as $translation){
|
2428 |
+
if($translation->language_code != $sitepress->get_default_language()){
|
2429 |
wp_delete_post($translation->element_id,true);
|
2430 |
}
|
2431 |
}
|
2521 |
//delete 'attribute_' at the beginning
|
2522 |
$taxonomy = substr($attr_key, 10, strlen($attr_key)-1 );
|
2523 |
}
|
2524 |
+
$cart->cart_contents[$key]['variation'][$attr_key] = $this->get_cart_attribute_translation($taxonomy,$attribute,$cart_item['product_id'],$tr_product_id,$current_language);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2525 |
}
|
2526 |
}
|
2527 |
}
|
2534 |
}
|
2535 |
|
2536 |
if(!is_null($tr_product_id)){
|
2537 |
+
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', array(), $cart->cart_contents[$key]['product_id'], $cart->cart_contents[$key]['variation_id']);
|
2538 |
+
$new_key = $woocommerce->cart->generate_cart_id( $cart->cart_contents[$key]['product_id'], $cart->cart_contents[$key]['variation_id'], $cart->cart_contents[$key]['variation'], $cart_item_data );
|
2539 |
+
$cart->cart_contents = apply_filters('wcml_update_cart_contents_lang_switch',$cart->cart_contents,$key, $new_key,$current_language);
|
2540 |
$new_cart_data[$new_key] = $cart->cart_contents[$key];
|
2541 |
+
$new_cart_data = apply_filters('wcml_cart_contents', $new_cart_data, $cart->cart_contents,$key, $new_key);
|
2542 |
}
|
2543 |
+
|
|
|
2544 |
}
|
2545 |
$cart->cart_contents = $new_cart_data;
|
2546 |
|
2549 |
return $cart;
|
2550 |
}
|
2551 |
|
2552 |
+
function get_cart_attribute_translation($taxonomy,$attribute,$product_id,$tr_product_id,$current_language){
|
2553 |
+
|
2554 |
+
if(taxonomy_exists($taxonomy)){
|
2555 |
+
$term = get_term_by('slug',$attribute,$taxonomy);
|
2556 |
+
$trnsl_term_id = icl_object_id($term->term_id,$taxonomy,true,$current_language);
|
2557 |
+
|
2558 |
+
return get_term($trnsl_term_id,$taxonomy)->slug;
|
2559 |
+
}else{
|
2560 |
+
$orig_product_attributes = get_post_meta($product_id, '_product_attributes', true);
|
2561 |
+
$unserialized_orig_product_attributes = maybe_unserialize($orig_product_attributes);
|
2562 |
+
foreach($unserialized_orig_product_attributes as $orig_attr_key => $orig_product_attribute){
|
2563 |
+
$orig_attr_key = urldecode($orig_attr_key);
|
2564 |
+
if($taxonomy == $orig_attr_key){
|
2565 |
+
$values = explode('|',$orig_product_attribute['value']);
|
2566 |
+
foreach($values as $key_id => $value){
|
2567 |
+
if(trim($value," ") == $attribute){
|
2568 |
+
$attr_key_id = $key_id;
|
2569 |
+
}
|
2570 |
+
}
|
2571 |
+
}
|
2572 |
+
}
|
2573 |
+
|
2574 |
+
$trnsl_product_attributes = get_post_meta($tr_product_id, '_product_attributes', true);
|
2575 |
+
$unserialized_trnsl_product_attributes = maybe_unserialize($trnsl_product_attributes);
|
2576 |
+
$taxonomy = sanitize_title($taxonomy);
|
2577 |
+
$trnsl_attr_values = explode('|',$unserialized_trnsl_product_attributes[$taxonomy]['value']);
|
2578 |
+
|
2579 |
+
if(isset($trnsl_attr_values[$attr_key_id])){
|
2580 |
+
return trim($trnsl_attr_values[$attr_key_id]);
|
2581 |
+
}
|
2582 |
+
}
|
2583 |
+
}
|
2584 |
+
|
2585 |
function wcml_coupon_loaded($coupons_data){
|
2586 |
global $sitepress;
|
2587 |
|
2631 |
|
2632 |
|
2633 |
function set_price_config() {
|
2634 |
+
global $sitepress, $iclTranslationManagement, $sitepress_settings, $wpdb, $woocommerce_wpml;
|
2635 |
|
2636 |
$all_products_taxonomies = get_taxonomies(array('object_type'=>array('product')),'objects');
|
2637 |
foreach($all_products_taxonomies as $tax_key => $tax){
|
2662 |
);
|
2663 |
|
2664 |
$save = false;
|
2665 |
+
if (isset($iclTranslationManagement) && $iclTranslationManagement instanceof TranslationManagement ) {
|
2666 |
foreach ($keys as $key) {
|
2667 |
$iclTranslationManagement->settings['custom_fields_readonly_config'][] = $key;
|
2668 |
if (!isset($sitepress_settings['translation-management']['custom_fields_translation'][$key]) ||
|
2670 |
$wpml_settings['translation-management']['custom_fields_translation'][$key] = 1;
|
2671 |
$save = true;
|
2672 |
}
|
2673 |
+
|
2674 |
+
if(!empty($woocommerce_wpml->multi_currency_support)){
|
2675 |
+
foreach($woocommerce_wpml->multi_currency_support->get_currency_codes() as $code){
|
2676 |
+
$new_key = $key.'_'.$code;
|
2677 |
+
$iclTranslationManagement->settings['custom_fields_readonly_config'][] = $new_key;
|
2678 |
+
if (!isset($sitepress_settings['translation-management']['custom_fields_translation'][$new_key]) ||
|
2679 |
+
$wpml_settings['translation-management']['custom_fields_translation'][$new_key] != 0) {
|
2680 |
+
$wpml_settings['translation-management']['custom_fields_translation'][$new_key] = 0;
|
2681 |
+
$save = true;
|
2682 |
+
}
|
2683 |
}
|
2684 |
+
}
|
2685 |
|
2686 |
}
|
2687 |
|
2689 |
$sitepress->save_settings($wpml_settings);
|
2690 |
}
|
2691 |
}
|
2692 |
+
}
|
2693 |
|
2694 |
|
2695 |
function woocommerce_duplicate_product($new_id, $post){
|
2705 |
}
|
2706 |
}
|
2707 |
|
2708 |
+
|
2709 |
+
function woocommerce_restore_order_stock_quantity($stock_change,$item_id){
|
2710 |
+
global $sitepress;
|
2711 |
+
|
2712 |
+
$order_id = absint( $_POST['order_id'] );
|
2713 |
+
$order = new WC_Order( $order_id );
|
2714 |
+
$order_items = $order->get_items();
|
2715 |
+
$_product = $order->get_product_from_item( $order_items[$item_id] );
|
2716 |
+
$language_details = $sitepress->get_element_language_details($_product->post->ID, 'post_'.$_product->post->post_type);
|
2717 |
+
$translations = $sitepress->get_element_translations($language_details->trid, 'post_'.$_product->post->post_type);
|
2718 |
+
|
2719 |
+
foreach ($translations as $translation) {
|
2720 |
+
if($translation->element_id != $_product->post->ID){
|
2721 |
+
$prod = get_product($translation->element_id);
|
2722 |
+
$prod->increase_stock( $stock_change );
|
2723 |
+
}
|
2724 |
+
}
|
2725 |
+
|
2726 |
+
return $stock_change;
|
2727 |
+
}
|
2728 |
+
|
2729 |
+
|
2730 |
+
function woocommerce_product_quick_edit_save($product){
|
2731 |
+
global $sitepress;
|
2732 |
+
$default_language = $sitepress->get_default_language();
|
2733 |
+
$lang = $sitepress->get_language_for_element($product->id,'post_product');
|
2734 |
+
|
2735 |
+
if($lang == $default_language){
|
2736 |
+
$trid = $sitepress->get_element_trid($product->id, 'post_product');
|
2737 |
+
if ($trid) {
|
2738 |
+
$translations = $sitepress->get_element_translations($trid, 'post_product');
|
2739 |
+
if($translations){
|
2740 |
+
foreach($translations as $translation){
|
2741 |
+
if($translation->language_code != $default_language){
|
2742 |
+
$this->sync_product_data($product->id,$translation->element_id,$translation->language_code);
|
2743 |
+
}
|
2744 |
+
}
|
2745 |
+
}
|
2746 |
+
}
|
2747 |
+
}else{
|
2748 |
+
$original_product_id = icl_object_id($product->id, 'product', false, $default_language);
|
2749 |
+
if(is_null($original_product_id)){
|
2750 |
+
return;
|
2751 |
+
}
|
2752 |
+
|
2753 |
+
$this->sync_product_data($original_product_id,$product->id,$lang);
|
2754 |
+
}
|
2755 |
+
}
|
2756 |
+
|
2757 |
}
|
inc/reports.class.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class WCML_Reports{
|
5 |
+
|
6 |
+
public $tab;
|
7 |
+
public $report;
|
8 |
+
|
9 |
+
function __construct(){
|
10 |
+
|
11 |
+
add_action('init', array($this, 'init'));
|
12 |
+
|
13 |
+
}
|
14 |
+
|
15 |
+
function init(){
|
16 |
+
|
17 |
+
$this->tab = isset($_GET['tab']) ? $_GET['tab'] : 'orders';
|
18 |
+
$this->report = isset($_GET['report']) ? $_GET['report'] : '';
|
19 |
+
|
20 |
+
add_filter('woocommerce_reports_get_order_report_query', array($this, 'filter_reports_query'), 0);
|
21 |
+
|
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 |
+
|
31 |
+
$current_language = $sitepress->get_current_language();
|
32 |
+
$active_languages = $sitepress->get_active_languages();
|
33 |
+
|
34 |
+
if($this->tab == 'orders' && $this->report == 'sales_by_product'){
|
35 |
+
|
36 |
+
$sparkline_query = strpos( $query[ 'select'], 'sparkline_value' ) !== false;
|
37 |
+
|
38 |
+
if(
|
39 |
+
|
40 |
+
$sparkline_query ||
|
41 |
+
isset( $query[ 'order_by' ] ) && ( $query[ 'order_by' ] == 'ORDER BY order_item_qty DESC' || $query[ 'order_by' ] == 'ORDER BY order_item_total DESC' )
|
42 |
+
|
43 |
+
){
|
44 |
+
|
45 |
+
|
46 |
+
$query[ 'select' ] .= " , order_language.meta_value AS order_language , translations.trid";
|
47 |
+
|
48 |
+
$query[ 'join' ] .= " LEFT JOIN {$wpdb->postmeta} order_language ON posts.ID = order_language.post_id";
|
49 |
+
$query[ 'where' ] .= " AND order_language.meta_key = 'wpml_language' ";
|
50 |
+
|
51 |
+
$query[ 'join' ] .= " LEFT JOIN {$wpdb->prefix}icl_translations translations ON translations.element_id = order_item_meta__product_id.meta_value";
|
52 |
+
$query[ 'where' ] .= " AND translations.element_type = 'post_product' ";
|
53 |
+
|
54 |
+
if(!$sparkline_query){
|
55 |
+
$limit = str_replace('LIMIT ', '', trim($query[ 'limit' ]));
|
56 |
+
$query[ 'limit' ] = sprintf(" LIMIT %d ", $limit * count($active_languages));
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
if($sparkline_query){
|
61 |
+
preg_match("#order_item_meta__product_id\.meta_value = '([0-9]+)'#", $query[ 'where' ], $matches);
|
62 |
+
$product_id = $matches[1];
|
63 |
+
$trid = $sitepress->get_element_trid($product_id, 'post_product');
|
64 |
+
$translations = $sitepress->get_element_translations($trid, 'post_product', true);
|
65 |
+
$product_ids = array();
|
66 |
+
foreach($translations as $translation){
|
67 |
+
$product_ids[] = $translation->element_id;
|
68 |
+
}
|
69 |
+
|
70 |
+
$query[ 'where' ] = str_replace("order_item_meta__product_id.meta_value = '{$product_id}'", "order_item_meta__product_id.meta_value IN(" . join(',', $product_ids) . ")", $query[ 'where' ]);
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
}elseif(
|
76 |
+
$query[ 'select' ] == 'SELECT SUM( order_item_meta__line_total.meta_value) as order_item_amount' || //sales for the selected items
|
77 |
+
$query[ 'select' ] == 'SELECT SUM( order_item_meta__qty.meta_value) as order_item_count' || //purchases for the selected items
|
78 |
+
$query[ 'select' ] == 'SELECT SUM( order_item_meta__qty.meta_value) as order_item_count, posts.post_date as post_date, order_item_meta__product_id.meta_value as product_id' || //Get orders and dates in range - main chart: order_item_counts
|
79 |
+
$query[ 'select' ] == 'SELECT SUM( order_item_meta__line_total.meta_value) as order_item_amount, posts.post_date as post_date, order_item_meta__product_id.meta_value as product_id' //Get orders and dates in range - main chart: order_item_amounts
|
80 |
+
|
81 |
+
){
|
82 |
+
|
83 |
+
preg_match("#order_item_meta__product_id_array\.meta_value IN \(([^\)]+)\)#", $query[ 'where' ], $matches);
|
84 |
+
$product_ids = array();
|
85 |
+
$exp = array_map('trim', explode(',', $matches[1]));
|
86 |
+
foreach($exp as $e){
|
87 |
+
$product_ids[] = trim($e, "'");
|
88 |
+
}
|
89 |
+
$all_product_ids = array();
|
90 |
+
foreach($product_ids as $product_id){
|
91 |
+
$trid = $sitepress->get_element_trid($product_id, 'post_product');
|
92 |
+
$translations = $sitepress->get_element_translations($trid, 'post_product', true);
|
93 |
+
foreach($translations as $translation){
|
94 |
+
$all_product_ids[] = $translation->element_id;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
$query[ 'where' ] = preg_replace("#order_item_meta__product_id_array\.meta_value IN \(([^\)]+)\)#", "order_item_meta__product_id_array.meta_value IN (" . join(',', $all_product_ids) . ")", $query[ 'where' ]);
|
99 |
+
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
return $query;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
function combine_report_by_languages($results){
|
110 |
+
global $sitepress, $wpdb;
|
111 |
+
|
112 |
+
if(is_array($results) && isset($results['0']->order_item_qty)){
|
113 |
+
$mode = 'top_sellers';
|
114 |
+
}elseif(is_array($results) && isset($results['0']->order_item_total)){
|
115 |
+
$mode = 'top_earners';
|
116 |
+
}elseif(isset($results['0']->sparkline_value)){
|
117 |
+
$mode = 'top_sellers_spark';
|
118 |
+
}else{
|
119 |
+
return $results;
|
120 |
+
}
|
121 |
+
|
122 |
+
if(!isset($results['0']->trid)) return $results;
|
123 |
+
|
124 |
+
$current_language = $sitepress->get_current_language();
|
125 |
+
|
126 |
+
$combined_results = array();
|
127 |
+
|
128 |
+
foreach($results as $k => $row){
|
129 |
+
|
130 |
+
switch($mode){
|
131 |
+
case 'top_sellers':
|
132 |
+
case 'top_earners':
|
133 |
+
$key = $row->trid;
|
134 |
+
break;
|
135 |
+
case 'top_sellers_spark':
|
136 |
+
$key = $row->trid . '#' . substr($row->post_date, 0, 10);
|
137 |
+
break;
|
138 |
+
}
|
139 |
+
|
140 |
+
if($row->order_language == $current_language){
|
141 |
+
|
142 |
+
$combined_results[$key] = $row;
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
}
|
147 |
+
|
148 |
+
foreach($results as $k => $row){
|
149 |
+
|
150 |
+
if($row->order_language != $current_language){
|
151 |
+
|
152 |
+
switch($mode){
|
153 |
+
case 'top_sellers':
|
154 |
+
case 'top_earners':
|
155 |
+
$key = $row->trid;
|
156 |
+
break;
|
157 |
+
case 'top_sellers_spark':
|
158 |
+
$key = $row->trid . '#' . substr($row->post_date, 0, 10);
|
159 |
+
break;
|
160 |
+
}
|
161 |
+
|
162 |
+
if(isset($combined_results[$key])){
|
163 |
+
|
164 |
+
switch($mode){
|
165 |
+
case 'top_sellers':
|
166 |
+
$combined_results[$key]->order_item_qty += $row->order_item_qty;
|
167 |
+
break;
|
168 |
+
case 'top_earners':
|
169 |
+
$combined_results[$key]->order_item_total += $row->order_item_total;
|
170 |
+
break;
|
171 |
+
case 'top_sellers_spark':
|
172 |
+
$combined_results[$key]->sparkline_value += $row->sparkline_value;
|
173 |
+
break;
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
}else{
|
178 |
+
|
179 |
+
$default_product_id = icl_object_id($row->product_id, 'product', false, $current_language);
|
180 |
+
|
181 |
+
if($default_product_id){
|
182 |
+
$combined_results[$key] = new stdClass();
|
183 |
+
$combined_results[$key]->product_id = $default_product_id;
|
184 |
+
|
185 |
+
switch($mode){
|
186 |
+
case 'top_sellers':
|
187 |
+
$combined_results[$key]->order_item_qty = $row->order_item_qty;
|
188 |
+
break;
|
189 |
+
case 'top_earners':
|
190 |
+
$combined_results[$key]->order_item_total = $row->order_item_total;
|
191 |
+
break;
|
192 |
+
case 'top_sellers_spark':
|
193 |
+
$combined_results[$key]->sparkline_value = $row->sparkline_value;
|
194 |
+
$combined_results[$key]->post_date = $row->post_date;
|
195 |
+
break;
|
196 |
+
}
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
switch($mode){
|
208 |
+
case 'top_sellers':
|
209 |
+
usort($combined_results, array(__CLASS__, '_order_by_quantity'));
|
210 |
+
array_slice($combined_results, 0, 12);
|
211 |
+
break;
|
212 |
+
case 'top_earners':
|
213 |
+
usort($combined_results, array(__CLASS__, '_order_by_total'));
|
214 |
+
array_slice($combined_results, 0, 12);
|
215 |
+
break;
|
216 |
+
case 'top_sellers_spark':
|
217 |
+
break;
|
218 |
+
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
foreach($combined_results as $k => $row){
|
223 |
+
unset($combined_results[$k]->trid, $combined_results[$k]->order_language);
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
return $combined_results;
|
228 |
+
}
|
229 |
+
|
230 |
+
static function _order_by_quantity($a, $b){
|
231 |
+
return $a->order_item_qty < $b->order_item_qty;
|
232 |
+
}
|
233 |
+
|
234 |
+
static function _order_by_total($a, $b){
|
235 |
+
return $a->order_item_total < $b->order_item_total;
|
236 |
+
}
|
237 |
+
|
238 |
+
|
239 |
+
|
240 |
+
}
|
inc/requests.class.php
CHANGED
@@ -14,6 +14,16 @@ class WCML_Requests{
|
|
14 |
if(isset($_POST['general_options']) && check_admin_referer('general_options', 'general_options_nonce') && wp_verify_nonce($_POST['wcml_nonce'], 'general_options')){
|
15 |
|
16 |
$woocommerce_wpml->settings['enable_multi_currency'] = $_POST['multi_currency'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
$woocommerce_wpml->update_settings();
|
19 |
|
@@ -56,6 +66,7 @@ class WCML_Requests{
|
|
56 |
$woocommerce_wpml->update_settings();
|
57 |
|
58 |
$new_value = $_POST['wcml_file_path_sync'] == 0?2:$_POST['wcml_file_path_sync'];
|
|
|
59 |
$sitepress_settings['translation-management']['custom_fields_translation']['_file_paths'] = $new_value;
|
60 |
$sitepress->save_settings($sitepress_settings);
|
61 |
}
|
14 |
if(isset($_POST['general_options']) && check_admin_referer('general_options', 'general_options_nonce') && wp_verify_nonce($_POST['wcml_nonce'], 'general_options')){
|
15 |
|
16 |
$woocommerce_wpml->settings['enable_multi_currency'] = $_POST['multi_currency'];
|
17 |
+
|
18 |
+
|
19 |
+
$woocommerce_wpml->update_settings();
|
20 |
+
|
21 |
+
}
|
22 |
+
if(isset($_POST['currency_switcher_options']) && check_admin_referer('currency_switcher_options', 'currency_switcher_options_nonce') && wp_verify_nonce($_POST['wcml_nonce'], 'general_options')){
|
23 |
+
|
24 |
+
if(isset($_POST['currency_switcher_style'])) $woocommerce_wpml->settings['currency_switcher_style'] = $_POST['currency_switcher_style'];
|
25 |
+
if(isset($_POST['wcml_curr_sel_orientation'])) $woocommerce_wpml->settings['wcml_curr_sel_orientation'] = $_POST['wcml_curr_sel_orientation'];
|
26 |
+
if(isset($_POST['wcml_curr_template'])) $woocommerce_wpml->settings['wcml_curr_template'] = $_POST['wcml_curr_template'];
|
27 |
|
28 |
$woocommerce_wpml->update_settings();
|
29 |
|
66 |
$woocommerce_wpml->update_settings();
|
67 |
|
68 |
$new_value = $_POST['wcml_file_path_sync'] == 0?2:$_POST['wcml_file_path_sync'];
|
69 |
+
$sitepress_settings['translation-management']['custom_fields_translation']['_downloadable_files'] = $new_value;
|
70 |
$sitepress_settings['translation-management']['custom_fields_translation']['_file_paths'] = $new_value;
|
71 |
$sitepress->save_settings($sitepress_settings);
|
72 |
}
|
inc/store-pages.class.php
CHANGED
@@ -10,6 +10,7 @@ class WCML_Store_Pages{
|
|
10 |
}
|
11 |
|
12 |
function init(){
|
|
|
13 |
if(!is_admin()){
|
14 |
add_filter('pre_get_posts', array($this, 'shop_page_query'), 9);
|
15 |
add_filter('icl_ls_languages', array($this, 'translate_ls_shop_url'));
|
@@ -20,11 +21,17 @@ class WCML_Store_Pages{
|
|
20 |
$this->create_missing_store_pages();
|
21 |
}
|
22 |
|
23 |
-
// table rate shipping support
|
24 |
-
if(defined('TABLE_RATE_SHIPPING_VERSION')){
|
25 |
add_filter('woocommerce_table_rate_query_rates_args', array($this, 'default_shipping_class_id'));
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
}
|
30 |
|
@@ -59,11 +66,14 @@ class WCML_Store_Pages{
|
|
59 |
}
|
60 |
|
61 |
function default_shipping_class_id($args){
|
62 |
-
global $sitepress;
|
63 |
if($sitepress->get_current_language() != $sitepress->get_default_language() && !empty($args['shipping_class_id'])){
|
64 |
|
65 |
$args['shipping_class_id'] = icl_object_id($args['shipping_class_id'], 'product_shipping_class', false, $sitepress->get_default_language());
|
66 |
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
return $args;
|
@@ -77,11 +87,7 @@ class WCML_Store_Pages{
|
|
77 |
if ( ! $q->is_main_query() )
|
78 |
return;
|
79 |
|
80 |
-
$front_page_id
|
81 |
-
$shop_page_id = woocommerce_get_page_id('shop');
|
82 |
-
$shop_page = get_post( woocommerce_get_page_id('shop') );
|
83 |
-
|
84 |
-
if (!empty($shop_page) && $q->get('page_id') !== $front_page_id && $shop_page_id == $q->get('page_id')) {
|
85 |
$q->set( 'post_type', 'product' );
|
86 |
$q->set( 'page_id', '' );
|
87 |
if ( isset( $q->query['paged'] ) )
|
@@ -93,9 +99,9 @@ class WCML_Store_Pages{
|
|
93 |
|
94 |
$q->is_page = true;
|
95 |
|
96 |
-
$wp_post_types['product']->ID = $shop_page->ID;
|
97 |
-
$wp_post_types['product']->post_title = $shop_page->post_title;
|
98 |
-
$wp_post_types['product']->post_name
|
99 |
|
100 |
// Fix conditional functions
|
101 |
$q->is_singular = false;
|
@@ -110,10 +116,11 @@ class WCML_Store_Pages{
|
|
110 |
*/
|
111 |
function translate_ls_shop_url($languages) {
|
112 |
global $sitepress;
|
113 |
-
$shop_id =
|
114 |
-
$front_id = icl_object_id(
|
115 |
foreach ($languages as &$language) {
|
116 |
// shop page
|
|
|
117 |
if (is_post_type_archive('product')) {
|
118 |
if ($front_id == $shop_id) {
|
119 |
$url = $sitepress->language_url($language['language_code']);
|
@@ -122,11 +129,6 @@ class WCML_Store_Pages{
|
|
122 |
}
|
123 |
$language['url'] = $url;
|
124 |
}
|
125 |
-
// brand page
|
126 |
-
if (is_tax('product_brand')) {
|
127 |
-
$translated_id = icl_object_id( get_queried_object_id(), 'product_brand', true, $language['language_code'] );
|
128 |
-
$language['url'] = get_term_link( $translated_id, 'product_brand' );
|
129 |
-
}
|
130 |
}
|
131 |
return $languages;
|
132 |
}
|
@@ -178,23 +180,29 @@ class WCML_Store_Pages{
|
|
178 |
'woocommerce_myaccount_page_id'
|
179 |
));
|
180 |
|
181 |
-
|
|
|
|
|
|
|
182 |
foreach ($miss_lang['codes'] as $mis_lang) {
|
183 |
$args = array();
|
184 |
|
185 |
foreach ($check_pages as $page) {
|
|
|
|
|
186 |
$orig_id = get_option($page);
|
187 |
$trnsl_id = icl_object_id($orig_id, 'page', false, $mis_lang);
|
188 |
-
|
|
|
189 |
$orig_page = get_post($orig_id);
|
190 |
unload_textdomain('wpml-wcml');
|
191 |
$sitepress->switch_lang($mis_lang);
|
192 |
$woocommerce_wpml->load_locale();
|
193 |
-
$args['post_title'] = __($orig_page->post_title,'wpml-wcml');
|
194 |
$args['post_type'] = $orig_page->post_type;
|
195 |
$args['post_content'] = $orig_page->post_content;
|
196 |
$args['post_excerpt'] = $orig_page->post_excerpt;
|
197 |
-
$args['post_status'] = $orig_page->post_status;
|
198 |
$args['menu_order'] = $orig_page->menu_order;
|
199 |
$args['ping_status'] = $orig_page->ping_status;
|
200 |
$args['comment_status'] = $orig_page->comment_status;
|
@@ -202,6 +210,10 @@ class WCML_Store_Pages{
|
|
202 |
$args['post_parent'] = is_null($post_parent)?0:$post_parent;
|
203 |
$new_page_id = wp_insert_post($args);
|
204 |
|
|
|
|
|
|
|
|
|
205 |
$trid = $sitepress->get_element_trid($orig_id, 'post_' . $orig_page->post_type);
|
206 |
$sitepress->set_element_language_details($new_page_id, 'post_' . $orig_page->post_type, $trid, $mis_lang);
|
207 |
if(!is_null($trnsl_id)){
|
@@ -211,6 +223,7 @@ class WCML_Store_Pages{
|
|
211 |
}
|
212 |
}
|
213 |
}
|
|
|
214 |
unload_textdomain('wpml-wcml');
|
215 |
$sitepress->switch_lang($current_language);
|
216 |
$woocommerce_wpml->load_locale();
|
@@ -279,6 +292,42 @@ class WCML_Store_Pages{
|
|
279 |
function get_checkout_page_url(){
|
280 |
return get_permalink(icl_object_id(get_option('woocommerce_checkout_page_id'), 'page', true));
|
281 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
|
284 |
}
|
10 |
}
|
11 |
|
12 |
function init(){
|
13 |
+
global $woocommerce_wpml;
|
14 |
if(!is_admin()){
|
15 |
add_filter('pre_get_posts', array($this, 'shop_page_query'), 9);
|
16 |
add_filter('icl_ls_languages', array($this, 'translate_ls_shop_url'));
|
21 |
$this->create_missing_store_pages();
|
22 |
}
|
23 |
|
24 |
+
// table rate shipping support
|
25 |
+
if(defined('TABLE_RATE_SHIPPING_VERSION') && $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
|
26 |
add_filter('woocommerce_table_rate_query_rates_args', array($this, 'default_shipping_class_id'));
|
27 |
}
|
28 |
|
29 |
+
$this->front_page_id = get_option('page_on_front');
|
30 |
+
$this->shop_page_id = woocommerce_get_page_id('shop');
|
31 |
+
$this->shop_page = get_post( woocommerce_get_page_id('shop') );
|
32 |
+
|
33 |
+
|
34 |
+
$this->localize_flat_rates_shipping_classes();
|
35 |
|
36 |
}
|
37 |
|
66 |
}
|
67 |
|
68 |
function default_shipping_class_id($args){
|
69 |
+
global $sitepress, $woocommerce_wpml;
|
70 |
if($sitepress->get_current_language() != $sitepress->get_default_language() && !empty($args['shipping_class_id'])){
|
71 |
|
72 |
$args['shipping_class_id'] = icl_object_id($args['shipping_class_id'], 'product_shipping_class', false, $sitepress->get_default_language());
|
73 |
|
74 |
+
// use unfiltred cart price to compare against limits of different shipping methods
|
75 |
+
$args['price'] = $woocommerce_wpml->multi_currency->unconvert_price_amount($args['price']);
|
76 |
+
|
77 |
}
|
78 |
|
79 |
return $args;
|
87 |
if ( ! $q->is_main_query() )
|
88 |
return;
|
89 |
|
90 |
+
if (!empty($this->shop_page) && $q->get('page_id') !== $this->front_page_id && $this->shop_page_id == $q->get('page_id')) {
|
|
|
|
|
|
|
|
|
91 |
$q->set( 'post_type', 'product' );
|
92 |
$q->set( 'page_id', '' );
|
93 |
if ( isset( $q->query['paged'] ) )
|
99 |
|
100 |
$q->is_page = true;
|
101 |
|
102 |
+
$wp_post_types['product']->ID = $this->shop_page->ID;
|
103 |
+
$wp_post_types['product']->post_title = $this->shop_page->post_title;
|
104 |
+
$wp_post_types['product']->post_name = $this->shop_page->post_name;
|
105 |
|
106 |
// Fix conditional functions
|
107 |
$q->is_singular = false;
|
116 |
*/
|
117 |
function translate_ls_shop_url($languages) {
|
118 |
global $sitepress;
|
119 |
+
$shop_id = $this->shop_page_id;
|
120 |
+
$front_id = icl_object_id($this->front_page_id, 'page');
|
121 |
foreach ($languages as &$language) {
|
122 |
// shop page
|
123 |
+
// obsolete?
|
124 |
if (is_post_type_archive('product')) {
|
125 |
if ($front_id == $shop_id) {
|
126 |
$url = $sitepress->language_url($language['language_code']);
|
129 |
}
|
130 |
$language['url'] = $url;
|
131 |
}
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
return $languages;
|
134 |
}
|
180 |
'woocommerce_myaccount_page_id'
|
181 |
));
|
182 |
|
183 |
+
if(in_array($sitepress->get_default_language(), $miss_lang['codes'])){
|
184 |
+
$miss_lang['codes'] = array_merge(array($sitepress->get_default_language()), array_diff($miss_lang['codes'], array($sitepress->get_default_language())));
|
185 |
+
}
|
186 |
+
|
187 |
foreach ($miss_lang['codes'] as $mis_lang) {
|
188 |
$args = array();
|
189 |
|
190 |
foreach ($check_pages as $page) {
|
191 |
+
|
192 |
+
|
193 |
$orig_id = get_option($page);
|
194 |
$trnsl_id = icl_object_id($orig_id, 'page', false, $mis_lang);
|
195 |
+
|
196 |
+
if ($orig_id && (is_null($trnsl_id) || get_post_status($trnsl_id) != 'publish')) {
|
197 |
$orig_page = get_post($orig_id);
|
198 |
unload_textdomain('wpml-wcml');
|
199 |
$sitepress->switch_lang($mis_lang);
|
200 |
$woocommerce_wpml->load_locale();
|
201 |
+
$args['post_title'] = __($orig_page->post_title, 'wpml-wcml');
|
202 |
$args['post_type'] = $orig_page->post_type;
|
203 |
$args['post_content'] = $orig_page->post_content;
|
204 |
$args['post_excerpt'] = $orig_page->post_excerpt;
|
205 |
+
$args['post_status'] = get_post_status($trnsl_id) != 'publish' ? 'publish' : $orig_page->post_status;
|
206 |
$args['menu_order'] = $orig_page->menu_order;
|
207 |
$args['ping_status'] = $orig_page->ping_status;
|
208 |
$args['comment_status'] = $orig_page->comment_status;
|
210 |
$args['post_parent'] = is_null($post_parent)?0:$post_parent;
|
211 |
$new_page_id = wp_insert_post($args);
|
212 |
|
213 |
+
if(get_post_status($trnsl_id) == 'trash' && $mis_lang == $sitepress->get_default_language()){
|
214 |
+
update_option($page, $new_page_id);
|
215 |
+
}
|
216 |
+
|
217 |
$trid = $sitepress->get_element_trid($orig_id, 'post_' . $orig_page->post_type);
|
218 |
$sitepress->set_element_language_details($new_page_id, 'post_' . $orig_page->post_type, $trid, $mis_lang);
|
219 |
if(!is_null($trnsl_id)){
|
223 |
}
|
224 |
}
|
225 |
}
|
226 |
+
|
227 |
unload_textdomain('wpml-wcml');
|
228 |
$sitepress->switch_lang($current_language);
|
229 |
$woocommerce_wpml->load_locale();
|
292 |
function get_checkout_page_url(){
|
293 |
return get_permalink(icl_object_id(get_option('woocommerce_checkout_page_id'), 'page', true));
|
294 |
}
|
295 |
+
|
296 |
+
function localize_flat_rates_shipping_classes(){
|
297 |
+
global $woocommerce;
|
298 |
+
|
299 |
+
if(is_ajax() && isset($_POST['action']) && $_POST['action'] == 'woocommerce_update_order_review'){
|
300 |
+
$woocommerce->shipping->load_shipping_methods();
|
301 |
+
$shipping_methods = $woocommerce->shipping->get_shipping_methods();
|
302 |
+
foreach($shipping_methods as $method){
|
303 |
+
if(isset($method->flat_rate_option)){
|
304 |
+
add_filter('option_' . $method->flat_rate_option, array($this, 'translate_shipping_classs'));
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
function translate_shipping_classs($rates){
|
314 |
+
|
315 |
+
if(is_array($rates)){
|
316 |
+
foreach($rates as $shipping_class => $value){
|
317 |
+
$term = get_term_by('slug', $shipping_class, 'product_shipping_class');
|
318 |
+
if($term && !is_wp_error($term)){
|
319 |
+
$translated_term_id = icl_object_id($term->term_id, 'product_shipping_class', true);
|
320 |
+
if($translated_term_id != $term->term_id){
|
321 |
+
$term = get_term_by('id', $translated_term_id, 'product_shipping_class');
|
322 |
+
unset($rates[$shipping_class]);
|
323 |
+
$rates[$term->slug] = $value;
|
324 |
+
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
}
|
329 |
+
return $rates;
|
330 |
+
}
|
331 |
|
332 |
|
333 |
}
|
inc/terms.class.php
CHANGED
@@ -22,15 +22,15 @@ class WCML_Terms{
|
|
22 |
add_filter('option_rewrite_rules', array($this, 'rewrite_rules_filter'), 3, 1); // high priority
|
23 |
|
24 |
add_filter('term_link', array($this, 'translate_category_base'), 0, 3); // high priority
|
25 |
-
add_filter('term_link', array($this, 'translate_brand_link'), 10, 3);
|
26 |
|
27 |
add_filter('get_term', array($this, 'clean_term'), 14, 2);
|
28 |
add_filter('wp_get_object_terms', array($sitepress, 'get_terms_filter'));
|
29 |
|
30 |
add_action('icl_save_term_translation', array($this,'save_wc_term_meta'), 100,4);
|
31 |
|
32 |
-
add_action('created_term', array(
|
33 |
-
add_action('edit_term', array(
|
34 |
add_action('wp_ajax_wcml_update_term_translated_warnings', array('WCML_Terms', 'wcml_update_term_translated_warnings'));
|
35 |
add_action('wp_ajax_wcml_ingore_taxonomy_translation', array('WCML_Terms', 'wcml_ingore_taxonomy_translation'));
|
36 |
add_action('wp_ajax_wcml_uningore_taxonomy_translation', array('WCML_Terms', 'wcml_uningore_taxonomy_translation'));
|
@@ -52,6 +52,7 @@ class WCML_Terms{
|
|
52 |
add_filter('get_terms',array($this,'filter_coupons_terms'),10,3);
|
53 |
|
54 |
add_filter('woocommerce_attribute',array($this, 'hide_language_suffix'));
|
|
|
55 |
}
|
56 |
|
57 |
function admin_menu_setup(){
|
@@ -205,11 +206,11 @@ class WCML_Terms{
|
|
205 |
}
|
206 |
|
207 |
function translate_category_base($termlink, $term, $taxonomy){
|
208 |
-
global $sitepress_settings, $sitepress, $wp_rewrite, $wpdb;
|
209 |
static $no_recursion_flag;
|
210 |
|
211 |
// handles product categories, product tags and attributes
|
212 |
-
|
213 |
$wc_taxonomies = wc_get_attribute_taxonomies();
|
214 |
foreach($wc_taxonomies as $k => $v){
|
215 |
$wc_taxonomies_wc_format[] = 'pa_' . $v->attribute_name;
|
@@ -220,6 +221,7 @@ class WCML_Terms{
|
|
220 |
$cache_key = 'termlink#' . $taxonomy .'#' . $term->term_id;
|
221 |
if($link = wp_cache_get($cache_key, 'terms')){
|
222 |
$termlink = $link;
|
|
|
223 |
}else{
|
224 |
|
225 |
$no_recursion_flag = false;
|
@@ -243,25 +245,20 @@ class WCML_Terms{
|
|
243 |
}else{
|
244 |
$base = _x($base_sl, 'slug', 'woocommerce');
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
unset($l10n['woocommerce']);
|
256 |
-
remove_filter('plugin_locale', array($this, '_switch_wc_locale'));
|
257 |
-
$this->_tmp_locale_val = false;
|
258 |
-
$woocommerce->load_plugin_textdomain();
|
259 |
|
260 |
}
|
261 |
}else{
|
262 |
|
263 |
-
$string_identifier =
|
264 |
-
|
265 |
if($term_language->language_code != $strings_language){
|
266 |
$base_translated = $wpdb->get_var("
|
267 |
SELECT t.value
|
@@ -284,7 +281,7 @@ class WCML_Terms{
|
|
284 |
$wp_rewrite->extra_permastructs[$taxonomy]['struct'] = str_replace($base, $base_translated, $wp_rewrite->extra_permastructs[$taxonomy]['struct']);
|
285 |
$no_recursion_flag = true;
|
286 |
$termlink = get_term_link($term, $taxonomy);
|
287 |
-
|
288 |
$wp_rewrite->extra_permastructs[$taxonomy]['struct'] = $buff;
|
289 |
|
290 |
}
|
@@ -293,7 +290,7 @@ class WCML_Terms{
|
|
293 |
}
|
294 |
|
295 |
$no_recursion_flag = false;
|
296 |
-
|
297 |
wp_cache_add($cache_key, $termlink, 'terms', 0);
|
298 |
}
|
299 |
|
@@ -302,12 +299,14 @@ class WCML_Terms{
|
|
302 |
return $termlink;
|
303 |
}
|
304 |
|
|
|
305 |
function translate_brand_link($url, $term, $taxonomy) {
|
306 |
global $sitepress;
|
307 |
if ($taxonomy == 'product_brand')
|
308 |
$url = $sitepress->convert_url($url);
|
309 |
return $url;
|
310 |
-
|
|
|
311 |
|
312 |
function clean_term($terms) {
|
313 |
global $sitepress;
|
@@ -431,11 +430,31 @@ class WCML_Terms{
|
|
431 |
|
432 |
}
|
433 |
|
434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
global $wp_taxonomies;
|
436 |
if(in_array('product', $wp_taxonomies[$taxonomy]->object_type) || in_array('product_variation', $wp_taxonomies[$taxonomy]->object_type)){
|
437 |
self::update_terms_translated_status($taxonomy);
|
438 |
}
|
|
|
439 |
}
|
440 |
|
441 |
static function wcml_update_term_translated_warnings(){
|
@@ -614,27 +633,27 @@ class WCML_Terms{
|
|
614 |
|
615 |
if(isset( $attribute_taxonomies_arr ) && in_array($taxonomy, $attribute_taxonomies_arr)){
|
616 |
|
617 |
-
|
618 |
|
619 |
-
|
620 |
-
|
621 |
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
|
626 |
-
|
627 |
-
|
628 |
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
|
634 |
-
|
635 |
|
636 |
-
|
637 |
-
|
638 |
|
639 |
}
|
640 |
|
@@ -802,8 +821,10 @@ class WCML_Terms{
|
|
802 |
function shipping_terms($terms, $post_id, $taxonomy){
|
803 |
if(!is_admin() && get_post_type($post_id) == 'product' && $taxonomy == 'product_shipping_class'){
|
804 |
global $sitepress;
|
805 |
-
remove_filter('get_the_terms',array($this,'shipping_terms'));
|
806 |
-
|
|
|
|
|
807 |
}
|
808 |
|
809 |
return $terms;
|
@@ -823,7 +844,7 @@ class WCML_Terms{
|
|
823 |
return $terms;
|
824 |
}
|
825 |
|
826 |
-
|
827 |
global $wp_taxonomies;
|
828 |
|
829 |
foreach($wp_taxonomies as $key=>$taxonomy_obj){
|
@@ -845,6 +866,6 @@ class WCML_Terms{
|
|
845 |
$terms_string = implode(', ', $terms);
|
846 |
}
|
847 |
return $terms_string;
|
848 |
-
}
|
849 |
|
850 |
}
|
22 |
add_filter('option_rewrite_rules', array($this, 'rewrite_rules_filter'), 3, 1); // high priority
|
23 |
|
24 |
add_filter('term_link', array($this, 'translate_category_base'), 0, 3); // high priority
|
25 |
+
//add_filter('term_link', array($this, 'translate_brand_link'), 10, 3);
|
26 |
|
27 |
add_filter('get_term', array($this, 'clean_term'), 14, 2);
|
28 |
add_filter('wp_get_object_terms', array($sitepress, 'get_terms_filter'));
|
29 |
|
30 |
add_action('icl_save_term_translation', array($this,'save_wc_term_meta'), 100,4);
|
31 |
|
32 |
+
add_action('created_term', array($this, 'translated_terms_status_update'), 10,3);
|
33 |
+
add_action('edit_term', array($this, 'translated_terms_status_update'), 10,3);
|
34 |
add_action('wp_ajax_wcml_update_term_translated_warnings', array('WCML_Terms', 'wcml_update_term_translated_warnings'));
|
35 |
add_action('wp_ajax_wcml_ingore_taxonomy_translation', array('WCML_Terms', 'wcml_ingore_taxonomy_translation'));
|
36 |
add_action('wp_ajax_wcml_uningore_taxonomy_translation', array('WCML_Terms', 'wcml_uningore_taxonomy_translation'));
|
52 |
add_filter('get_terms',array($this,'filter_coupons_terms'),10,3);
|
53 |
|
54 |
add_filter('woocommerce_attribute',array($this, 'hide_language_suffix'));
|
55 |
+
|
56 |
}
|
57 |
|
58 |
function admin_menu_setup(){
|
206 |
}
|
207 |
|
208 |
function translate_category_base($termlink, $term, $taxonomy){
|
209 |
+
global $sitepress_settings, $sitepress, $wp_rewrite, $wpdb, $woocommerce;
|
210 |
static $no_recursion_flag;
|
211 |
|
212 |
// handles product categories, product tags and attributes
|
213 |
+
|
214 |
$wc_taxonomies = wc_get_attribute_taxonomies();
|
215 |
foreach($wc_taxonomies as $k => $v){
|
216 |
$wc_taxonomies_wc_format[] = 'pa_' . $v->attribute_name;
|
221 |
$cache_key = 'termlink#' . $taxonomy .'#' . $term->term_id;
|
222 |
if($link = wp_cache_get($cache_key, 'terms')){
|
223 |
$termlink = $link;
|
224 |
+
|
225 |
}else{
|
226 |
|
227 |
$no_recursion_flag = false;
|
245 |
}else{
|
246 |
$base = _x($base_sl, 'slug', 'woocommerce');
|
247 |
|
248 |
+
$mo_file = $woocommerce->plugin_path() . '/i18n/languages/woocommerce-' . $sitepress->get_locale($term_language->language_code) .'.mo';
|
249 |
+
if(file_exists($mo_file)){
|
250 |
+
$mo = new MO();
|
251 |
+
$mo->import_from_file( $mo_file );
|
252 |
+
$base_translated = $mo->translate($base_sl, 'slug');
|
253 |
+
}else{
|
254 |
+
$base_translated = $base_sl;
|
255 |
+
}
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
}
|
258 |
}else{
|
259 |
|
260 |
+
$string_identifier = $taxonomy == 'product_tag' || $taxonomy == 'product_cat' ? $taxonomy : 'attribute';
|
261 |
+
//
|
262 |
if($term_language->language_code != $strings_language){
|
263 |
$base_translated = $wpdb->get_var("
|
264 |
SELECT t.value
|
281 |
$wp_rewrite->extra_permastructs[$taxonomy]['struct'] = str_replace($base, $base_translated, $wp_rewrite->extra_permastructs[$taxonomy]['struct']);
|
282 |
$no_recursion_flag = true;
|
283 |
$termlink = get_term_link($term, $taxonomy);
|
284 |
+
|
285 |
$wp_rewrite->extra_permastructs[$taxonomy]['struct'] = $buff;
|
286 |
|
287 |
}
|
290 |
}
|
291 |
|
292 |
$no_recursion_flag = false;
|
293 |
+
|
294 |
wp_cache_add($cache_key, $termlink, 'terms', 0);
|
295 |
}
|
296 |
|
299 |
return $termlink;
|
300 |
}
|
301 |
|
302 |
+
/*
|
303 |
function translate_brand_link($url, $term, $taxonomy) {
|
304 |
global $sitepress;
|
305 |
if ($taxonomy == 'product_brand')
|
306 |
$url = $sitepress->convert_url($url);
|
307 |
return $url;
|
308 |
+
}
|
309 |
+
*/
|
310 |
|
311 |
function clean_term($terms) {
|
312 |
global $sitepress;
|
430 |
|
431 |
}
|
432 |
|
433 |
+
function translated_terms_status_update($term_id, $tt_id, $taxonomy){
|
434 |
+
|
435 |
+
if ( isset( $_POST['product_cat_thumbnail_id'] ) ){
|
436 |
+
global $sitepress,$sitepress_settings;
|
437 |
+
|
438 |
+
if($sitepress_settings['sync_taxonomy_parents'] && $sitepress->get_language_for_element($tt_id,'tax_'.$taxonomy) == $sitepress->get_default_language()){
|
439 |
+
$trid = $sitepress->get_element_trid($tt_id,'tax_'.$taxonomy);
|
440 |
+
$translations = $sitepress->get_element_translations($trid,'tax_'.$taxonomy);
|
441 |
+
|
442 |
+
foreach($translations as $translation){
|
443 |
+
if($translation->language_code != $sitepress->get_default_language()){
|
444 |
+
if(isset($_POST['display_type'])){
|
445 |
+
update_woocommerce_term_meta( $translation->term_id, 'display_type', esc_attr( $_POST['display_type'] ) );
|
446 |
+
}
|
447 |
+
update_woocommerce_term_meta( $translation->term_id, 'thumbnail_id', icl_object_id(esc_attr( $_POST['product_cat_thumbnail_id'] ),'attachment',true,$translation->language_code));
|
448 |
+
}
|
449 |
+
}
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
global $wp_taxonomies;
|
454 |
if(in_array('product', $wp_taxonomies[$taxonomy]->object_type) || in_array('product_variation', $wp_taxonomies[$taxonomy]->object_type)){
|
455 |
self::update_terms_translated_status($taxonomy);
|
456 |
}
|
457 |
+
|
458 |
}
|
459 |
|
460 |
static function wcml_update_term_translated_warnings(){
|
633 |
|
634 |
if(isset( $attribute_taxonomies_arr ) && in_array($taxonomy, $attribute_taxonomies_arr)){
|
635 |
|
636 |
+
$wcml_settings = $woocommerce_wpml->get_settings();
|
637 |
|
638 |
+
// get term language
|
639 |
+
$term_language = $sitepress->get_element_language_details($tt_id, 'tax_' . $taxonomy);
|
640 |
|
641 |
+
if($term_language->language_code != $sitepress->get_default_language()){
|
642 |
+
// get term in the default language
|
643 |
+
$term_id = icl_object_id($term_id, $taxonomy, false, $sitepress->get_default_language());
|
644 |
|
645 |
+
//does it belong to any posts (variations)
|
646 |
+
$objects = get_objects_in_term($term_id, $taxonomy);
|
647 |
|
648 |
+
if(!isset($wcml_settings['variations_needed'][$taxonomy])){
|
649 |
+
$wcml_settings['variations_needed'][$taxonomy] = 0;
|
650 |
+
}
|
651 |
+
$wcml_settings['variations_needed'][$taxonomy] += count($objects);
|
652 |
|
653 |
+
$woocommerce_wpml->update_settings($wcml_settings);
|
654 |
|
655 |
+
}
|
656 |
+
}
|
657 |
|
658 |
}
|
659 |
|
821 |
function shipping_terms($terms, $post_id, $taxonomy){
|
822 |
if(!is_admin() && get_post_type($post_id) == 'product' && $taxonomy == 'product_shipping_class'){
|
823 |
global $sitepress;
|
824 |
+
remove_filter('get_the_terms',array($this,'shipping_terms'), 10, 3);
|
825 |
+
$terms = get_the_terms(icl_object_id($post_id,'product',true,$sitepress->get_default_language()),'product_shipping_class');
|
826 |
+
add_filter('get_the_terms',array($this,'shipping_terms'), 10, 3);
|
827 |
+
return $terms;
|
828 |
}
|
829 |
|
830 |
return $terms;
|
844 |
return $terms;
|
845 |
}
|
846 |
|
847 |
+
function wcml_delete_term($term, $tt_id, $taxonomy, $deleted_term){
|
848 |
global $wp_taxonomies;
|
849 |
|
850 |
foreach($wp_taxonomies as $key=>$taxonomy_obj){
|
866 |
$terms_string = implode(', ', $terms);
|
867 |
}
|
868 |
return $terms_string;
|
869 |
+
}
|
870 |
|
871 |
}
|
inc/upgrade.class.php
CHANGED
@@ -6,7 +6,8 @@ class WCML_Upgrade{
|
|
6 |
|
7 |
'2.9.9.1',
|
8 |
'3.1',
|
9 |
-
'3.2'
|
|
|
10 |
|
11 |
);
|
12 |
|
@@ -259,7 +260,28 @@ class WCML_Upgrade{
|
|
259 |
|
260 |
}
|
261 |
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
|
265 |
|
6 |
|
7 |
'2.9.9.1',
|
8 |
'3.1',
|
9 |
+
'3.2',
|
10 |
+
'3.3'
|
11 |
|
12 |
);
|
13 |
|
260 |
|
261 |
}
|
262 |
|
263 |
+
function upgrade_3_3(){
|
264 |
+
global $wpdb, $woocommerce_wpml;
|
265 |
+
|
266 |
+
woocommerce_wpml::set_up_capabilities();
|
267 |
+
|
268 |
+
$currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` ASC", OBJECT);
|
269 |
+
if($currencies)
|
270 |
+
foreach($this->currencies as $currency){
|
271 |
+
|
272 |
+
$woocommerce_wpml->settings['currency_options'][$currency->code]['rate'] = $currency->value;
|
273 |
+
$woocommerce_wpml->settings['currency_options'][$currency->code]['updated'] = $currency->changed;
|
274 |
+
$woocommerce_wpml->settings['currency_options'][$currency->code]['position'] = 'left';
|
275 |
+
$woocommerce_wpml->settings['currency_options'][$currency->code]['languages'] = $woocommerce_wpml->settings['currencies_languages'];
|
276 |
+
unset($woocommerce_wpml->settings['currencies_languages']);
|
277 |
+
|
278 |
+
$woocommerce_wpml->update_settings();
|
279 |
+
|
280 |
+
}
|
281 |
+
|
282 |
+
$wpdb->query("DROP TABLE `{$wpdb->prefix}icl_currencies`");
|
283 |
+
|
284 |
+
}
|
285 |
|
286 |
|
287 |
|
inc/wc-strings.class.php
CHANGED
@@ -23,7 +23,9 @@ class WCML_WC_Strings{
|
|
23 |
|
24 |
add_filter('woocommerce_gateway_title', array($this, 'translate_gateway_title'), 10, 2);
|
25 |
add_filter('woocommerce_gateway_description', array($this, 'translate_gateway_description'), 10, 2);
|
26 |
-
|
|
|
|
|
27 |
//translate attribute label
|
28 |
add_filter('woocommerce_attribute_label',array($this,'translated_attribute_label'),10,2);
|
29 |
add_filter('woocommerce_cart_item_name',array($this,'translated_cart_item_name'),10,3);
|
@@ -31,6 +33,7 @@ class WCML_WC_Strings{
|
|
31 |
add_filter('woocommerce_countries_tax_or_vat', array($this, 'register_tax_label'));
|
32 |
|
33 |
if(is_admin() && $pagenow == 'options-permalink.php'){
|
|
|
34 |
add_action('admin_footer', array($this, 'show_custom_url_base_language_requirement'));
|
35 |
}
|
36 |
|
@@ -41,12 +44,13 @@ class WCML_WC_Strings{
|
|
41 |
add_filter('woocommerce_rate_label',array($this,'translate_woocommerce_rate_label'));
|
42 |
|
43 |
|
|
|
44 |
}
|
45 |
|
46 |
function translated_attribute_label($label, $name){
|
47 |
global $sitepress;
|
48 |
|
49 |
-
if(is_admin()){
|
50 |
global $wpdb,$sitepress_settings;
|
51 |
if($sitepress_settings['admin_default_language'] == $sitepress_settings['st']['strings_language']){
|
52 |
return $label;
|
@@ -72,10 +76,20 @@ class WCML_WC_Strings{
|
|
72 |
}
|
73 |
|
74 |
function translated_cart_item_name($title, $values, $cart_item_key){
|
75 |
-
|
|
|
76 |
if($values){
|
77 |
-
$tr_product_id = icl_object_id($values['product_id'],'product',true
|
78 |
-
$title = get_the_title($tr_product_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
return $title;
|
81 |
}
|
@@ -90,7 +104,7 @@ class WCML_WC_Strings{
|
|
90 |
}
|
91 |
|
92 |
|
93 |
-
function translate_query_var_for_product($public_query_vars){
|
94 |
global $wpdb, $sitepress, $sitepress_settings;
|
95 |
|
96 |
if($sitepress->get_current_language() != $sitepress_settings['st']['strings_language']){
|
@@ -105,8 +119,9 @@ class WCML_WC_Strings{
|
|
105 |
'URL slug: ' . $product_permalink, $product_permalink, $sitepress->get_current_language()));
|
106 |
|
107 |
if(isset($_GET[$translated_slug])){
|
108 |
-
$
|
109 |
unset($_GET[$translated_slug]);
|
|
|
110 |
}
|
111 |
|
112 |
}
|
@@ -172,6 +187,30 @@ class WCML_WC_Strings{
|
|
172 |
}
|
173 |
return $description;
|
174 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
function register_tax_label($label){
|
177 |
global $sitepress;
|
@@ -235,5 +274,12 @@ class WCML_WC_Strings{
|
|
235 |
return $label;
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
}
|
23 |
|
24 |
add_filter('woocommerce_gateway_title', array($this, 'translate_gateway_title'), 10, 2);
|
25 |
add_filter('woocommerce_gateway_description', array($this, 'translate_gateway_description'), 10, 2);
|
26 |
+
add_action( 'woocommerce_thankyou_bacs', array( $this, 'translate_bacs_instructions' ),9 );
|
27 |
+
add_action( 'woocommerce_thankyou_cheque', array( $this, 'translate_cheque_instructions' ),9 );
|
28 |
+
add_action( 'woocommerce_thankyou_cod', array( $this, 'translate_cod_instructions' ),9 );
|
29 |
//translate attribute label
|
30 |
add_filter('woocommerce_attribute_label',array($this,'translated_attribute_label'),10,2);
|
31 |
add_filter('woocommerce_cart_item_name',array($this,'translated_cart_item_name'),10,3);
|
33 |
add_filter('woocommerce_countries_tax_or_vat', array($this, 'register_tax_label'));
|
34 |
|
35 |
if(is_admin() && $pagenow == 'options-permalink.php'){
|
36 |
+
add_filter('gettext_with_context', array($this, 'category_base_in_strings_language'), 99, 3);
|
37 |
add_action('admin_footer', array($this, 'show_custom_url_base_language_requirement'));
|
38 |
}
|
39 |
|
44 |
add_filter('woocommerce_rate_label',array($this,'translate_woocommerce_rate_label'));
|
45 |
|
46 |
|
47 |
+
|
48 |
}
|
49 |
|
50 |
function translated_attribute_label($label, $name){
|
51 |
global $sitepress;
|
52 |
|
53 |
+
if(is_admin() && !wpml_is_ajax()){
|
54 |
global $wpdb,$sitepress_settings;
|
55 |
if($sitepress_settings['admin_default_language'] == $sitepress_settings['st']['strings_language']){
|
56 |
return $label;
|
76 |
}
|
77 |
|
78 |
function translated_cart_item_name($title, $values, $cart_item_key){
|
79 |
+
|
80 |
+
$parent = $values['data']->post->post_parent;
|
81 |
if($values){
|
82 |
+
$tr_product_id = icl_object_id( $values['product_id'], 'product', true );
|
83 |
+
$title = get_the_title($tr_product_id);
|
84 |
+
|
85 |
+
if($parent){
|
86 |
+
$tr_parent = icl_object_id( $parent, 'product', true );
|
87 |
+
$title = get_the_title( $tr_parent ) . ' → ' . $title;
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
$title = sprintf( '<a href="%s">%s</a>', $values['data']->get_permalink(), $title );
|
92 |
+
|
93 |
}
|
94 |
return $title;
|
95 |
}
|
104 |
}
|
105 |
|
106 |
|
107 |
+
function translate_query_var_for_product($public_query_vars){
|
108 |
global $wpdb, $sitepress, $sitepress_settings;
|
109 |
|
110 |
if($sitepress->get_current_language() != $sitepress_settings['st']['strings_language']){
|
119 |
'URL slug: ' . $product_permalink, $product_permalink, $sitepress->get_current_language()));
|
120 |
|
121 |
if(isset($_GET[$translated_slug])){
|
122 |
+
$buff = $_GET[$translated_slug];
|
123 |
unset($_GET[$translated_slug]);
|
124 |
+
$_GET[$product_permalink] = $buff;
|
125 |
}
|
126 |
|
127 |
}
|
187 |
}
|
188 |
return $description;
|
189 |
}
|
190 |
+
|
191 |
+
function translate_bacs_instructions(){
|
192 |
+
$this->translate_payment_instructions('bacs');
|
193 |
+
}
|
194 |
+
|
195 |
+
function translate_cheque_instructions(){
|
196 |
+
$this->translate_payment_instructions('cheque');
|
197 |
+
}
|
198 |
+
|
199 |
+
function translate_cod_instructions(){
|
200 |
+
$this->translate_payment_instructions('cod');
|
201 |
+
}
|
202 |
+
|
203 |
+
function translate_payment_instructions($id){
|
204 |
+
if (function_exists('icl_translate')) {
|
205 |
+
$gateways = WC()->payment_gateways();
|
206 |
+
foreach($gateways->payment_gateways as $key => $gateway){
|
207 |
+
if($gateway->id == $id){
|
208 |
+
WC_Payment_Gateways::instance()->payment_gateways[$key]->instructions = icl_translate('woocommerce', $gateway->id .'_gateway_instructions', $gateway->instructions);
|
209 |
+
break;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}
|
214 |
|
215 |
function register_tax_label($label){
|
216 |
global $sitepress;
|
274 |
return $label;
|
275 |
}
|
276 |
|
277 |
+
function category_base_in_strings_language($text, $original_value, $context){
|
278 |
+
if($context == 'slug' && ($original_value == 'product-category' || $original_value == 'product-tag')){
|
279 |
+
$text = $original_value;
|
280 |
+
}
|
281 |
+
return $text;
|
282 |
+
}
|
283 |
+
|
284 |
|
285 |
}
|
inc/woocommerce-2.0-backward-compatibility.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
global $woocommerce;
|
4 |
|
5 |
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
6 |
|
@@ -54,8 +54,8 @@ if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '
|
|
54 |
}
|
55 |
add_filter('woocommerce_available_shipping_methods', 'wcml_wc_2_0_backward_compatibility_register_shipping_methods');
|
56 |
|
57 |
-
if(isset($
|
58 |
-
add_filter('woocommerce_available_shipping_methods', array($
|
59 |
}
|
60 |
|
61 |
add_filter('woocommerce_in_cart_product_title',array($this->strings, 'translated_cart_item_name'), 10, 3);
|
1 |
<?php
|
2 |
|
3 |
+
global $woocommerce, $woocommerce_wpml;
|
4 |
|
5 |
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
6 |
|
54 |
}
|
55 |
add_filter('woocommerce_available_shipping_methods', 'wcml_wc_2_0_backward_compatibility_register_shipping_methods');
|
56 |
|
57 |
+
if(isset($woocommerce_wpml->multi_currency_support)){
|
58 |
+
add_filter('woocommerce_available_shipping_methods', array($woocommerce_wpml->multi_currency_support, 'shipping_taxes_filter'));
|
59 |
}
|
60 |
|
61 |
add_filter('woocommerce_in_cart_product_title',array($this->strings, 'translated_cart_item_name'), 10, 3);
|
locale/{wpml-wcml-ko_KO.mo → wpml-wcml-ko_KR.mo}
RENAMED
File without changes
|
locale/wpml-wcml-ru_RU.mo
CHANGED
Binary file
|
locale/{wpml-wcml-vn.mo → wpml-wcml-vi.mo}
RENAMED
File without changes
|
menu/plugins.php
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
<div class="wrap">
|
2 |
<div id="icon-wpml" class="icon32"><br /></div>
|
3 |
<h2><?php _e('WooCommerce Multilingual', 'wpml-wcml') ?></h2>
|
@@ -13,26 +14,31 @@
|
|
13 |
<div class="wcml-section-content">
|
14 |
<ul>
|
15 |
<?php if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '2.0.5', '<')) : ?>
|
16 |
-
<li><i class="icon-warning-sign"></i> <?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML</a> versions prior 2.0.5.', 'wpml-wcml'), 'http://wpml.org/'); ?> <a href="http://wpml.org/shop/account/" target="_blank"><?php _e('Update WPML', 'wpml-wcml'); ?></a></li>
|
17 |
<?php elseif (defined('ICL_SITEPRESS_VERSION')) : ?>
|
18 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
|
|
|
|
|
|
|
|
|
|
19 |
<?php else : ?>
|
20 |
-
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML</strong>'); ?> <a href="http://wpml.org" target="_blank"><?php _e('Get WPML', 'wpml-wcml'); ?></a></li>
|
21 |
<?php endif; ?>
|
22 |
<?php if (defined('WPML_MEDIA_VERSION')) : ?>
|
23 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML Media</strong>'); ?></li>
|
24 |
<?php else : ?>
|
25 |
-
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML Media</strong>'); ?> <a href="http://wpml.org" target="_blank"><?php _e('Get WPML Media', 'wpml-wcml'); ?></a></li>
|
26 |
<?php endif; ?>
|
27 |
<?php if (defined('WPML_TM_VERSION')) : ?>
|
28 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML Translation Management</strong>'); ?></li>
|
29 |
<?php else : ?>
|
30 |
-
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML Translation Management</strong>'); ?> <a href="http://wpml.org" target="_blank"><?php _e('Get WPML Translation Management', 'wpml-wcml'); ?></a></li>
|
31 |
<?php endif; ?>
|
32 |
<?php if (defined('WPML_ST_VERSION')) : ?>
|
33 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML String Translation</strong>'); ?></li>
|
34 |
<?php else : ?>
|
35 |
-
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML String Translation</strong>'); ?> <a href="http://wpml.org" target="_blank"><?php _e('Get WPML String Translation', 'wpml-wcml'); ?></a></li>
|
36 |
<?php endif; ?>
|
37 |
<?php
|
38 |
global $woocommerce;
|
1 |
+
<?php global $woocommerce_wpml, $sitepress; ?>
|
2 |
<div class="wrap">
|
3 |
<div id="icon-wpml" class="icon32"><br /></div>
|
4 |
<h2><?php _e('WooCommerce Multilingual', 'wpml-wcml') ?></h2>
|
14 |
<div class="wcml-section-content">
|
15 |
<ul>
|
16 |
<?php if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '2.0.5', '<')) : ?>
|
17 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('WooCommerce Multilingual is enabled but not effective. It is not compatible with <a href="%s">WPML</a> versions prior 2.0.5.', 'wpml-wcml'), $woocommerce_wpml->generate_tracking_link('http://wpml.org/')); ?> <a href="<?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/shop/account/',false,'account') ?>" target="_blank"><?php _e('Update WPML', 'wpml-wcml'); ?></a></li>
|
18 |
<?php elseif (defined('ICL_SITEPRESS_VERSION')) : ?>
|
19 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
20 |
+
<?php if($sitepress->setup()): ?>
|
21 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s is set up.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
22 |
+
<?php else: ?>
|
23 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('%s is not set up.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
24 |
+
<?php endif; ?>
|
25 |
<?php else : ?>
|
26 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML</strong>'); ?> <a href="<?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/') ?>" target="_blank"><?php _e('Get WPML', 'wpml-wcml'); ?></a></li>
|
27 |
<?php endif; ?>
|
28 |
<?php if (defined('WPML_MEDIA_VERSION')) : ?>
|
29 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML Media</strong>'); ?></li>
|
30 |
<?php else : ?>
|
31 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML Media</strong>'); ?> <a href="<?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/') ?>" target="_blank"><?php _e('Get WPML Media', 'wpml-wcml'); ?></a></li>
|
32 |
<?php endif; ?>
|
33 |
<?php if (defined('WPML_TM_VERSION')) : ?>
|
34 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML Translation Management</strong>'); ?></li>
|
35 |
<?php else : ?>
|
36 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML Translation Management</strong>'); ?> <a href="<?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/') ?>" target="_blank"><?php _e('Get WPML Translation Management', 'wpml-wcml'); ?></a></li>
|
37 |
<?php endif; ?>
|
38 |
<?php if (defined('WPML_ST_VERSION')) : ?>
|
39 |
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML String Translation</strong>'); ?></li>
|
40 |
<?php else : ?>
|
41 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('%s plugin is either not installed or not active.', 'wpml-wcml'), '<strong>WPML String Translation</strong>'); ?> <a href="<?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/') ?>" target="_blank"><?php _e('Get WPML String Translation', 'wpml-wcml'); ?></a></li>
|
42 |
<?php endif; ?>
|
43 |
<?php
|
44 |
global $woocommerce;
|
menu/sub/currency-switcher-options.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $woocommerce_wpml;
|
3 |
+
$settings = $woocommerce_wpml->get_settings();
|
4 |
+
$currency_switcher_style = isset($settings['currency_switcher_style'])?$settings['currency_switcher_style']:false;
|
5 |
+
?>
|
6 |
+
|
7 |
+
<div id="currency-switcher" <?php if ( $settings['enable_multi_currency'] != WCML_MULTI_CURRENCIES_INDEPENDENT ):?>style="display:none"<?php endif;?>>
|
8 |
+
|
9 |
+
<div class="wcml-section-header">
|
10 |
+
<h3>
|
11 |
+
<?php _e('Currency switcher options', 'wpml-wcml'); ?>
|
12 |
+
<i class="icon-question-sign js-display-tooltip" data-header="<?php _e('Currency switcher', 'wpml-wcml') ?>" data-content="<?php _e('You can customize currency switcher on front-end', 'wpml-wcml') ?>"></i>
|
13 |
+
</h3>
|
14 |
+
</div>
|
15 |
+
|
16 |
+
<div class="wcml-section-content">
|
17 |
+
<div class="wcml-section-content-inner">
|
18 |
+
<h4><?php _e('Currency order', 'wpml-wcml'); ?></h4>
|
19 |
+
<?php
|
20 |
+
$wc_currencies = get_woocommerce_currencies();
|
21 |
+
|
22 |
+
if(!isset($settings['currencies_order'])){
|
23 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currency_codes();
|
24 |
+
}else{
|
25 |
+
$currencies = $settings['currencies_order'];
|
26 |
+
}
|
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>
|
34 |
+
<input type="hidden" id="wcml_currencies_order_order_nonce" value="<?php echo wp_create_nonce('set_currencies_order_nonce') ?>" />
|
35 |
+
<p class="explanation-text"><?php _e('Drag the currencies to change their order', 'wpml-wcml') ?></p>
|
36 |
+
</div>
|
37 |
+
<div class="wcml-section-content-inner">
|
38 |
+
<h4><?php _e('Currency switcher style', 'wpml-wcml'); ?></h4>
|
39 |
+
<ul class="wcml_curr_style">
|
40 |
+
<li>
|
41 |
+
<label for="wcml_curr_sel_stype">
|
42 |
+
<input type="radio" name="currency_switcher_style" value="dropdown" <?php if(!$currency_switcher_style || $currency_switcher_style == 'dropdown'):?>checked="checked"<?php endif?> />
|
43 |
+
<?php echo __('Drop-down menu', 'wpml-wcml') ?>
|
44 |
+
</label>
|
45 |
+
</li>
|
46 |
+
<li>
|
47 |
+
<label for="wcml_curr_sel_orientation">
|
48 |
+
<input type="radio" name="currency_switcher_style" value="list" <?php if($currency_switcher_style == 'list'):?>checked="checked"<?php endif?> />
|
49 |
+
<?php echo __('List of currencies', 'wpml-wcml') ?>
|
50 |
+
</label>
|
51 |
+
<select id="wcml_curr_sel_orientation" name="wcml_curr_sel_orientation" <?php if($currency_switcher_style != 'list'): ?>style="display: none;"<?php endif;?>>
|
52 |
+
<option value="vertical"><?php _e('Vertical', 'wpml-wcml') ?></option>
|
53 |
+
<option value="horizontal" <?php if(isset($settings['wcml_curr_sel_orientation']) && $settings['wcml_curr_sel_orientation'] == 'horizontal'): ?>selected="selected"<?php endif;?>><?php _e('Horizontal', 'wpml-wcml') ?></option>
|
54 |
+
</select>
|
55 |
+
</li>
|
56 |
+
</ul>
|
57 |
+
</div>
|
58 |
+
<div class="wcml-section-content-inner">
|
59 |
+
<h4><?php _e('Available parameters', 'wpml-wcml'); ?></h4>
|
60 |
+
<span class="explanation-text"><?php _e('%name%, %symbol%, %code%', 'wpml-wcml'); ?></span>
|
61 |
+
<h4><?php _e('Template for currency switcher', 'wpml-wcml'); ?></h4>
|
62 |
+
<input type="text" name="wcml_curr_template" value="<?php echo isset($settings['wcml_curr_template'])?$settings['wcml_curr_template']:''; ?>" />
|
63 |
+
<span class="explanation-text"><?php _e('Default: %name% (%symbol%) - %code%', 'wpml-wcml'); ?></span>
|
64 |
+
<input type="hidden" id="currency_switcher_default" value="%name% (%symbol%) - %code%" />
|
65 |
+
<div id="wcml_curr_sel_preview_wrap">
|
66 |
+
<p><strong><?php _e('Currency switcher preview', 'wpml-wcml')?></strong></p>
|
67 |
+
<input type="hidden" id="wcml_currencies_switcher_preview_nonce" value="<?php echo wp_create_nonce('wcml_currencies_switcher_preview') ?>" />
|
68 |
+
<div id="wcml_curr_sel_preview">
|
69 |
+
<?php echo $woocommerce_wpml->multi_currency_support->currency_switcher(); ?>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
<p class="button-wrap general_option_btn">
|
75 |
+
<input type='submit' name="currency_switcher_options" value='<?php _e('Save', 'wpml-wcml'); ?>' class='button-secondary' />
|
76 |
+
<?php wp_nonce_field('currency_switcher_options', 'currency_switcher_options_nonce'); ?>
|
77 |
+
</p>
|
78 |
+
|
79 |
+
</div>
|
menu/sub/custom-box.php
CHANGED
@@ -5,6 +5,6 @@
|
|
5 |
|
6 |
<table id="<?php echo $product_content.'_'.$lang ?>" class="widefat custom_fields_block js-table">
|
7 |
<tbody>
|
8 |
-
<?php echo
|
9 |
</tbody>
|
10 |
</table>
|
5 |
|
6 |
<table id="<?php echo $product_content.'_'.$lang ?>" class="widefat custom_fields_block js-table">
|
7 |
<tbody>
|
8 |
+
<?php echo apply_filters('wcml_custom_box_html','',$template_data,$lang); ?>
|
9 |
</tbody>
|
10 |
</table>
|
menu/sub/custom-currency-options.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$currency_name = $wc_currencies[$code];
|
3 |
+
$currency_symbol = get_woocommerce_currency_symbol($code);
|
4 |
+
?>
|
5 |
+
<table id="wcml_currency_options_<?php echo $code ?>" class="wcml_currency_options_popup">
|
6 |
+
<tr>
|
7 |
+
<td>
|
8 |
+
<h4><?php printf(__('Currency options for %s', 'wpml-wcml'), '<strong>' . $currency_name . ' (' . $currency_symbol . ')</strong>') ?></h4>
|
9 |
+
<hr />
|
10 |
+
<table>
|
11 |
+
|
12 |
+
<tr>
|
13 |
+
<td align="right"><?php _e('Exchange Rate', 'wpml-wcml') ?></td>
|
14 |
+
<td>
|
15 |
+
<?php printf("1 %s = %s %s", $wc_currency, '<input name="currency_options[' . $code . '][rate]" type="number" style="width:50px" step="0.01" value="' . $currency['rate'] . '" />', $code) ?>
|
16 |
+
</td>
|
17 |
+
</tr>
|
18 |
+
<tr>
|
19 |
+
<td> </td>
|
20 |
+
<td><small><i><?php printf(__('Set on %s', 'wpml-wcml'), date('F j, Y, H:i', strtotime($currency['updated']))); ?></i></small></td>
|
21 |
+
</tr>
|
22 |
+
|
23 |
+
<tr>
|
24 |
+
<td colspan="2"><hr /></td>
|
25 |
+
</tr>
|
26 |
+
<tr>
|
27 |
+
<td align="right"><?php _e('Currency Position', 'wpml-wcml') ?></td>
|
28 |
+
<td>
|
29 |
+
<select name="currency_options[<?php echo $code ?>][position]">
|
30 |
+
<option value="left" <?php selected('left', $currency['position'], 1); ?>><?php
|
31 |
+
echo $post_str['left'] = sprintf(__('Left (%s99.99)', 'wpml-wcml'),
|
32 |
+
$currency_symbol); ?></option>
|
33 |
+
<option value="right" <?php selected('right', $currency['position'], 1); ?>><?php
|
34 |
+
echo $post_str['right'] = sprintf(__('Right (99.99%s)', 'wpml-wcml'),
|
35 |
+
$currency_symbol); ?></option>
|
36 |
+
<option value="left_space" <?php selected('left_space', $currency['position'], 1); ?>><?php
|
37 |
+
echo $post_str['left_space'] = sprintf(__('Left with space (%s 99.99)', 'wpml-wcml'),
|
38 |
+
$currency_symbol); ?></option>
|
39 |
+
<option value="right_space" <?php selected('right_space', $currency['position'], 1); ?>><?php
|
40 |
+
echo $post_str['right_space'] = sprintf(__('Right with space (99.99 %s)', 'wpml-wcml'),
|
41 |
+
$currency_symbol); ?></option>
|
42 |
+
</select>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
<tr>
|
46 |
+
<td align="right"><?php _e('Thousand Separator', 'wpml-wcml') ?></td>
|
47 |
+
<td><input name="currency_options[<?php echo $code ?>][thousand_sep]" type="text" style="width:50px;" value="<?php echo esc_attr($currency['thousand_sep']) ?>" /></td>
|
48 |
+
</tr>
|
49 |
+
<tr>
|
50 |
+
<td align="right"><?php _e('Decimal Separator', 'wpml-wcml') ?></td>
|
51 |
+
<td><input name="currency_options[<?php echo $code ?>][decimal_sep]" type="text" style="width:50px;" value="<?php echo esc_attr($currency['decimal_sep']) ?>" /></td>
|
52 |
+
</tr>
|
53 |
+
<tr>
|
54 |
+
<td align="right"><?php _e('Number of Decimals', 'wpml-wcml') ?></td>
|
55 |
+
<td><input name="currency_options[<?php echo $code ?>][num_decimals]" type="number" style="width:50px;" value="<?php echo esc_attr($currency['num_decimals']) ?>" min="0" step="1" /></td>
|
56 |
+
</tr>
|
57 |
+
|
58 |
+
<tr>
|
59 |
+
<td colspan="2"><hr /></td>
|
60 |
+
</tr>
|
61 |
+
<tr>
|
62 |
+
<td align="right"><?php _e('Rounding to the nearest integer', 'wpml-wcml') ?></td>
|
63 |
+
<td>
|
64 |
+
<select name="currency_options[<?php echo $code ?>][rounding]">
|
65 |
+
<option value="disabled" <?php selected('disabled', $currency['rounding']) ?> ><?php _e('disabled', 'wpml-wcml') ?></option>
|
66 |
+
<option value="up" <?php selected('up', $currency['rounding']) ?>><?php _e('up', 'wpml-wcml') ?></option>
|
67 |
+
<option value="down" <?php selected('down', $currency['rounding']) ?>><?php _e('down', 'wpml-wcml') ?></option>
|
68 |
+
<option value="down" <?php selected('nearest', $currency['rounding']) ?>><?php _e('nearest', 'wpml-wcml') ?></option>
|
69 |
+
</select>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<tr>
|
73 |
+
<td align="right"><?php _e('Increment for nearest integer', 'wpml-wcml') ?></td>
|
74 |
+
<td>
|
75 |
+
<select name="currency_options[<?php echo $code ?>][rounding_increment]">
|
76 |
+
<option value="1" <?php selected('1', $currency['rounding_increment']) ?> >1</option>
|
77 |
+
<option value="10" <?php selected('10', $currency['rounding_increment']) ?>>10</option>
|
78 |
+
<option value="100" <?php selected('100', $currency['rounding_increment']) ?>>100</option>
|
79 |
+
<option value="1000" <?php selected('1000', $currency['rounding_increment']) ?>>1000</option>
|
80 |
+
</select>
|
81 |
+
</td>
|
82 |
+
</tr>
|
83 |
+
<tr>
|
84 |
+
<td align="right"><?php _e('Autosubtract amount', 'wpml-wcml') ?></td>
|
85 |
+
<td>
|
86 |
+
<input name="currency_options[<?php echo $code ?>][auto_subtract]" value="<?php echo $currency['auto_subtract'] ?>" type="number" value="0" style="width:50px;" />
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
</table>
|
90 |
+
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
|
94 |
+
|
95 |
+
<tr>
|
96 |
+
<td colspan="2" align="right">
|
97 |
+
<input type="button" class="button-secondary currency_options_cancel" value="<?php esc_attr_e('Cancel', 'wpml-wcml') ?>" data-currency="<?php echo $code ?>" />
|
98 |
+
<input type="submit" class="button-primary currency_options_save" value="<?php esc_attr_e('Save', 'wpml-wcml') ?>" data-currency="<?php echo $code ?>" />
|
99 |
+
<br /><br />
|
100 |
+
</td>
|
101 |
+
</tr>
|
102 |
+
</table>
|
menu/sub/custom-prices.php
CHANGED
@@ -8,9 +8,15 @@ if($is_variation){
|
|
8 |
<?php }else{
|
9 |
$html_id = '';
|
10 |
}
|
|
|
|
|
11 |
?>
|
12 |
<div class="wcml_custom_prices_block">
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
<div class="wcml_custom_prices_options_block">
|
15 |
|
16 |
<input type="radio" name="_wcml_custom_prices[<?php echo $post_id; ?>]" id="wcml_custom_prices_auto[<?php echo $post_id ?>]" value="0" class="wcml_custom_prices_input"<?php echo $checked ?> />
|
@@ -33,27 +39,27 @@ if($is_variation){
|
|
33 |
|
34 |
<div class="wcml_custom_prices_manually_block">
|
35 |
|
36 |
-
<?php
|
37 |
$wc_currencies = get_woocommerce_currencies();
|
38 |
|
39 |
-
foreach($currencies as $currency){
|
40 |
|
41 |
$regular_price = '';
|
42 |
$sale_price = '';
|
43 |
|
44 |
if(isset($custom_prices['_wcml_custom_prices_status'])){
|
45 |
|
46 |
-
if(isset($custom_prices['_regular_price_'.$
|
47 |
-
$regular_price = $custom_prices['_regular_price_'.$
|
48 |
}
|
49 |
|
50 |
-
if(isset($custom_prices['_sale_price_'.$
|
51 |
-
$sale_price = $custom_prices['_sale_price_'.$
|
52 |
}
|
53 |
} ?>
|
54 |
<div class="currency_blck">
|
55 |
<label>
|
56 |
-
<?php echo $wc_currencies[$
|
57 |
</label>
|
58 |
|
59 |
<?php if($regular_price == ''): ?>
|
@@ -61,7 +67,7 @@ if($is_variation){
|
|
61 |
<?php endif; ?>
|
62 |
|
63 |
<?php if($is_variation){
|
64 |
-
$custom_id = '['.$
|
65 |
|
66 |
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
67 |
$wc_input_type = 'number';
|
@@ -70,16 +76,16 @@ if($is_variation){
|
|
70 |
}
|
71 |
?>
|
72 |
<p>
|
73 |
-
<label><?php echo __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
74 |
<input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_regular_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" />
|
75 |
</p>
|
76 |
|
77 |
<p>
|
78 |
-
<label><?php echo __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
79 |
<input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_sale_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" />
|
80 |
</p>
|
81 |
<?php }else{
|
82 |
-
$custom_id = '['.$
|
83 |
|
84 |
$wc_input = array();
|
85 |
|
@@ -93,22 +99,22 @@ if($is_variation){
|
|
93 |
$wc_input['type_val'] = 'price';
|
94 |
}
|
95 |
|
96 |
-
woocommerce_wp_text_input( array( 'id' => '_custom_regular_price'.$custom_id, 'value'=>$regular_price ,'class' => 'wc_input_price wcml_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
97 |
|
98 |
-
woocommerce_wp_text_input( array( 'id' => '_custom_sale_price'.$custom_id, 'value'=>$sale_price , 'class' => 'wc_input_price wcml_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
99 |
} ?>
|
100 |
<div class="wcml_schedule">
|
101 |
<label><?php _e('Schedule','wpml-wcml') ?></label>
|
102 |
<div class="wcml_schedule_options">
|
103 |
-
<?php $checked = (!isset($custom_prices['_wcml_schedule_'.$
|
104 |
|
105 |
-
<input type="radio" name="_wcml_schedule[<?php echo $
|
106 |
-
<label for="wcml_schedule_auto[<?php echo $
|
107 |
|
108 |
-
<?php $checked = isset($custom_prices['_wcml_schedule_'.$
|
109 |
|
110 |
-
<input type="radio" name="_wcml_schedule[<?php echo $
|
111 |
-
<label for="wcml_schedule_manually[<?php echo $
|
112 |
<span class="block_actions">(
|
113 |
<a href="javascript:void(0);" class="wcml_schedule_manually_block_show"><?php _e('Schedule','wpml-wcml') ?></a>
|
114 |
<a href="javascript:void(0);" class="wcml_schedule_manually_block_hide"><?php _e('Collapse','wpml-wcml') ?></a>
|
@@ -117,8 +123,8 @@ if($is_variation){
|
|
117 |
|
118 |
<div class="wcml_schedule_dates">
|
119 |
<?php
|
120 |
-
$sale_price_dates_from = (isset($custom_prices['_sale_price_dates_from_'.$
|
121 |
-
$sale_price_dates_to = (isset($custom_prices['_sale_price_dates_to_'.$
|
122 |
?>
|
123 |
<input type="text" class="short custom_sale_price_dates_from" name="_custom_sale_price_dates_from<?php echo $custom_id; ?>" id="_custom_sale_price_dates_from<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_from ) ?>" placeholder="<?php echo _x( 'From…', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
124 |
<input type="text" class="short custom_sale_price_dates_to" name="_custom_sale_price_dates_to<?php echo $custom_id; ?>" id="_custom_sale_price_dates_to<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_to ) ?>" placeholder="<?php echo _x( 'To…', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
@@ -145,42 +151,43 @@ if($is_variation){
|
|
145 |
|
146 |
$regular_price = get_post_meta($post_id,'_regular_price',true);
|
147 |
if($regular_price){
|
148 |
-
$regular_price = $regular_price*$currency
|
149 |
}
|
150 |
|
151 |
$sale_price = get_post_meta($post_id,'_sale_price',true);
|
152 |
if($sale_price){
|
153 |
-
$sale_price = $sale_price*$currency
|
154 |
}
|
155 |
} ?>
|
156 |
|
157 |
-
<label><?php echo $wc_currencies[$
|
158 |
|
159 |
<?php
|
160 |
if($is_variation){ ?>
|
161 |
<p>
|
162 |
-
<label><?php echo __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
163 |
-
<input type="number" size="5" name="_readonly_regular_price" class="wc_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency
|
164 |
</p>
|
165 |
|
166 |
<p>
|
167 |
-
<label><?php echo __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
168 |
-
<input type="number" size="5" name="_readonly_sale_price" class="wc_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency
|
169 |
</p>
|
170 |
<?php
|
171 |
|
172 |
}else{
|
173 |
|
174 |
-
$wc_input['custom_attributes'] = array( 'readonly' => 'readonly', 'rel'=> $currency
|
175 |
|
176 |
-
woocommerce_wp_text_input( array( 'id' => '_readonly_regular_price', 'value'=>$regular_price, 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
177 |
|
178 |
-
woocommerce_wp_text_input( array( 'id' => '_readonly_sale_price', 'value'=>$sale_price, 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($
|
179 |
}
|
180 |
|
181 |
} ?>
|
182 |
|
183 |
</div>
|
|
|
184 |
</div>
|
185 |
<?php if($is_variation){ ?>
|
186 |
</td></tr>
|
8 |
<?php }else{
|
9 |
$html_id = '';
|
10 |
}
|
11 |
+
|
12 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
13 |
?>
|
14 |
<div class="wcml_custom_prices_block">
|
15 |
+
<?php if(empty($currencies)): ?>
|
16 |
+
<div class="custom_prices_message_block">
|
17 |
+
<label><?php _e('Multi-currency is enabled but no secondary currencies have been set','wpml-wcml')?></label>
|
18 |
+
</div>
|
19 |
+
<?php else: ?>
|
20 |
<div class="wcml_custom_prices_options_block">
|
21 |
|
22 |
<input type="radio" name="_wcml_custom_prices[<?php echo $post_id; ?>]" id="wcml_custom_prices_auto[<?php echo $post_id ?>]" value="0" class="wcml_custom_prices_input"<?php echo $checked ?> />
|
39 |
|
40 |
<div class="wcml_custom_prices_manually_block">
|
41 |
|
42 |
+
<?php
|
43 |
$wc_currencies = get_woocommerce_currencies();
|
44 |
|
45 |
+
foreach($currencies as $currency_code => $currency){
|
46 |
|
47 |
$regular_price = '';
|
48 |
$sale_price = '';
|
49 |
|
50 |
if(isset($custom_prices['_wcml_custom_prices_status'])){
|
51 |
|
52 |
+
if(isset($custom_prices['_regular_price_'.$currency_code][0])){
|
53 |
+
$regular_price = $custom_prices['_regular_price_'.$currency_code][0];
|
54 |
}
|
55 |
|
56 |
+
if(isset($custom_prices['_sale_price_'.$currency_code][0])){
|
57 |
+
$sale_price = $custom_prices['_sale_price_'.$currency_code][0];
|
58 |
}
|
59 |
} ?>
|
60 |
<div class="currency_blck">
|
61 |
<label>
|
62 |
+
<?php echo $wc_currencies[$currency_code].sprintf(__(' (%s)','wpml-wcml'),get_woocommerce_currency_symbol($currency_code)) ?>
|
63 |
</label>
|
64 |
|
65 |
<?php if($regular_price == ''): ?>
|
67 |
<?php endif; ?>
|
68 |
|
69 |
<?php if($is_variation){
|
70 |
+
$custom_id = '['.$currency_code.']['.$post_id.']';
|
71 |
|
72 |
if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
73 |
$wc_input_type = 'number';
|
76 |
}
|
77 |
?>
|
78 |
<p>
|
79 |
+
<label><?php echo __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
|
80 |
<input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_regular_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" />
|
81 |
</p>
|
82 |
|
83 |
<p>
|
84 |
+
<label><?php echo __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
|
85 |
<input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_sale_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" />
|
86 |
</p>
|
87 |
<?php }else{
|
88 |
+
$custom_id = '['.$currency_code.']';
|
89 |
|
90 |
$wc_input = array();
|
91 |
|
99 |
$wc_input['type_val'] = 'price';
|
100 |
}
|
101 |
|
102 |
+
woocommerce_wp_text_input( array( 'id' => '_custom_regular_price'.$custom_id, 'value'=>$regular_price ,'class' => 'wc_input_price wcml_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
|
103 |
|
104 |
+
woocommerce_wp_text_input( array( 'id' => '_custom_sale_price'.$custom_id, 'value'=>$sale_price , 'class' => 'wc_input_price wcml_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
|
105 |
} ?>
|
106 |
<div class="wcml_schedule">
|
107 |
<label><?php _e('Schedule','wpml-wcml') ?></label>
|
108 |
<div class="wcml_schedule_options">
|
109 |
+
<?php $checked = (!isset($custom_prices['_wcml_schedule_'.$currency_code]) || (isset($custom_prices['_wcml_schedule_'.$currency_code]) && $custom_prices['_wcml_schedule_'.$currency_code][0] == 0))?'checked="checked"':' '; ?>
|
110 |
|
111 |
+
<input type="radio" name="_wcml_schedule[<?php echo $currency_code.']'.$html_id; ?>" id="wcml_schedule_auto[<?php echo $currency_code.']'.$html_id ?>" value="0" class="wcml_schedule_input"<?php echo $checked ?> />
|
112 |
+
<label for="wcml_schedule_auto[<?php echo $currency_code.']'.$html_id ?>"><?php _e('Same as default currency','wpml-wcml')?></label>
|
113 |
|
114 |
+
<?php $checked = isset($custom_prices['_wcml_schedule_'.$currency_code]) && $custom_prices['_wcml_schedule_'.$currency_code][0] == 1?'checked="checked"':' '; ?>
|
115 |
|
116 |
+
<input type="radio" name="_wcml_schedule[<?php echo $currency_code.']'.$html_id ?>" value="1" id="wcml_schedule_manually[<?php echo $currency_code.']'.$html_id ?>" class="wcml_schedule_input" <?php echo $checked ?> />
|
117 |
+
<label for="wcml_schedule_manually[<?php echo $currency_code.']'.$html_id ?>"><?php _e('Set dates','wpml-wcml') ?>
|
118 |
<span class="block_actions">(
|
119 |
<a href="javascript:void(0);" class="wcml_schedule_manually_block_show"><?php _e('Schedule','wpml-wcml') ?></a>
|
120 |
<a href="javascript:void(0);" class="wcml_schedule_manually_block_hide"><?php _e('Collapse','wpml-wcml') ?></a>
|
123 |
|
124 |
<div class="wcml_schedule_dates">
|
125 |
<?php
|
126 |
+
$sale_price_dates_from = (isset($custom_prices['_sale_price_dates_from_'.$currency_code]) && $custom_prices['_sale_price_dates_from_'.$currency_code][0] != '') ? date_i18n( 'Y-m-d', $custom_prices['_sale_price_dates_from_'.$currency_code][0] ) : '';
|
127 |
+
$sale_price_dates_to = (isset($custom_prices['_sale_price_dates_to_'.$currency_code]) && $custom_prices['_sale_price_dates_to_'.$currency_code][0] != '') ? date_i18n( 'Y-m-d', $custom_prices['_sale_price_dates_to_'.$currency_code][0] ) : '';
|
128 |
?>
|
129 |
<input type="text" class="short custom_sale_price_dates_from" name="_custom_sale_price_dates_from<?php echo $custom_id; ?>" id="_custom_sale_price_dates_from<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_from ) ?>" placeholder="<?php echo _x( 'From…', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
130 |
<input type="text" class="short custom_sale_price_dates_to" name="_custom_sale_price_dates_to<?php echo $custom_id; ?>" id="_custom_sale_price_dates_to<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_to ) ?>" placeholder="<?php echo _x( 'To…', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
|
151 |
|
152 |
$regular_price = get_post_meta($post_id,'_regular_price',true);
|
153 |
if($regular_price){
|
154 |
+
$regular_price = $regular_price*$currency['rate'];
|
155 |
}
|
156 |
|
157 |
$sale_price = get_post_meta($post_id,'_sale_price',true);
|
158 |
if($sale_price){
|
159 |
+
$sale_price = $sale_price*$currency['rate'];
|
160 |
}
|
161 |
} ?>
|
162 |
|
163 |
+
<label><?php echo $wc_currencies[$currency_code].sprintf(__(' (%s)','wpml-wcml'),get_woocommerce_currency_symbol($currency_code)) ?></label>
|
164 |
|
165 |
<?php
|
166 |
if($is_variation){ ?>
|
167 |
<p>
|
168 |
+
<label><?php echo __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
|
169 |
+
<input type="number" size="5" name="_readonly_regular_price" class="wc_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency['rate'] ?>" />
|
170 |
</p>
|
171 |
|
172 |
<p>
|
173 |
+
<label><?php echo __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
|
174 |
+
<input type="number" size="5" name="_readonly_sale_price" class="wc_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency['rate'] ?>" />
|
175 |
</p>
|
176 |
<?php
|
177 |
|
178 |
}else{
|
179 |
|
180 |
+
$wc_input['custom_attributes'] = array( 'readonly' => 'readonly', 'rel'=> $currency['rate'] ) ;
|
181 |
|
182 |
+
woocommerce_wp_text_input( array( 'id' => '_readonly_regular_price', 'value'=>$regular_price, 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
|
183 |
|
184 |
+
woocommerce_wp_text_input( array( 'id' => '_readonly_sale_price', 'value'=>$sale_price, 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
|
185 |
}
|
186 |
|
187 |
} ?>
|
188 |
|
189 |
</div>
|
190 |
+
<?php endif; ?>
|
191 |
</div>
|
192 |
<?php if($is_variation){ ?>
|
193 |
</td></tr>
|
menu/sub/downloadable-files-box.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<tr>
|
2 |
+
<td>
|
3 |
+
<?php for($i=0;$i<$data['count'];$i++): ?>
|
4 |
+
<?php if($data['original']): ?>
|
5 |
+
<input type="text" value="<?php echo $data['files_data'][$i]['label']; ?>" class="" disabled="disabled">
|
6 |
+
<input type="text" value="<?php echo $data['files_data'][$i]['value']; ?>" class="" disabled="disabled">
|
7 |
+
<?php else: ?>
|
8 |
+
<div>
|
9 |
+
<input type="text" value="<?php echo isset($data['files_data'][$i])?$data['files_data'][$i]['label']:''; ?>" name='<?php echo $data['product_content'].'_'.$data['lang'].'['.$i.'][name]'; ?>' class="wcml_file_paths_name" placeholder="<?php esc_attr_e('Enter translation for name', 'wpml-wcml') ?>">
|
10 |
+
<input type="text" value="<?php echo isset($data['files_data'][$i])?$data['files_data'][$i]['value']:''; ?>" name='<?php echo $data['product_content'].'_'.$data['lang'].'['.$i.'][file]'; ?>' class="wcml_file_paths_file" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"/>
|
11 |
+
<button type="button" class="button-secondary wcml_file_paths_button"><?php _e('Choose a file', 'wpml-wcml') ?></button>
|
12 |
+
</div>
|
13 |
+
<?php endif; ?>
|
14 |
+
<?php endfor; ?>
|
15 |
+
</td>
|
16 |
+
</tr>
|
menu/sub/images_box.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<button id="prod_images_link_<?php echo $lang ?>" class="button-secondary js-table-toggle prod_images_link<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" data-text-opened="<?php _e('Collapse','wpml-wcml'); ?>" data-text-closed="<?php _e('Expand','wpml-wcml'); ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>>
|
2 |
-
<span><?php _e('Expand','wpml-wcml'); ?></span>
|
3 |
-
<i class="icon-caret-down"></i>
|
4 |
-
</button>
|
5 |
-
|
6 |
-
<table id="prod_images_<?php echo $lang ?>" class="widefat prod_images js-table">
|
7 |
-
<tbody>
|
8 |
-
<tr>
|
9 |
-
<?php if($template_data['original']): ?>
|
10 |
-
<td></td>
|
11 |
-
<?php if(!isset($template_data['empty_images'])): ?>
|
12 |
-
<?php foreach($template_data['images_thumbnails'] as $prod_image): ?>
|
13 |
-
<td>
|
14 |
-
<?php echo wp_get_attachment_image( $prod_image , 'thumbnail'); ?>
|
15 |
-
</td>
|
16 |
-
<?php endforeach; ?>
|
17 |
-
<?php endif; ?>
|
18 |
-
<?php endif; ?>
|
19 |
-
</tr>
|
20 |
-
<?php if(isset($template_data['empty_images'])): ?>
|
21 |
-
<tr>
|
22 |
-
<td><?php _e('Please set images for product','wpml-wcml'); ?></td>
|
23 |
-
</tr>
|
24 |
-
<?php elseif(isset($template_data['empty_translation'])): ?>
|
25 |
-
<tr>
|
26 |
-
<td><?php _e('Please save translation before translate images texts','wpml-wcml'); ?></td>
|
27 |
-
</tr>
|
28 |
-
<?php else: ?>
|
29 |
-
<?php $texts = array('title','caption','description'); ?>
|
30 |
-
<?php foreach($texts as $text): ?>
|
31 |
-
<tr>
|
32 |
-
<td>
|
33 |
-
<?php if($text == 'title'): ?>
|
34 |
-
<?php _e('Title','wpml-wcml'); ?>
|
35 |
-
<?php elseif($text == 'caption'): ?>
|
36 |
-
<?php _e('Caption','wpml-wcml'); ?>
|
37 |
-
<?php else: ?>
|
38 |
-
<?php _e('Description','wpml-wcml'); ?>
|
39 |
-
<?php endif; ?>
|
40 |
-
</td>
|
41 |
-
<?php foreach($template_data['images_data'] as $key=>$image_data): ?>
|
42 |
-
<?php if(!empty($image_data)): ?>
|
43 |
-
<td>
|
44 |
-
<?php if($template_data['original']): ?>
|
45 |
-
<input type="text" value="<?php echo $image_data[$text]?>" readonly="readonly"/>
|
46 |
-
<?php else: ?>
|
47 |
-
<input type="text" name="images[<?php echo $key ?>][<?php echo $text; ?>]" value="<?php echo $image_data[$text]?>" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"/>
|
48 |
-
<?php endif; ?>
|
49 |
-
</td>
|
50 |
-
<?php endif; ?>
|
51 |
-
<?php endforeach; ?>
|
52 |
-
</tr>
|
53 |
-
<?php endforeach; ?>
|
54 |
-
<?php endif; ?>
|
55 |
-
</tbody>
|
56 |
-
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu/sub/products.php
CHANGED
@@ -37,7 +37,7 @@ $button_labels = array(
|
|
37 |
<h3><?php _e('WooCommerce Products','wpml-wcml'); ?></h3>
|
38 |
<span style="display:none" id="wcml_product_update_button_label"><?php echo $button_labels['update'] ?></span>
|
39 |
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
|
40 |
-
|
41 |
<select class="wcml_product_category">
|
42 |
<option value="0"><?php _e('Any category', 'wpml-wcml'); ?></option>
|
43 |
<?php
|
@@ -78,6 +78,8 @@ $button_labels = array(
|
|
78 |
<?php endif; ?>
|
79 |
<?php endforeach; ?>
|
80 |
</select>
|
|
|
|
|
81 |
<input type="text" class="wcml_product_name" placeholder="<?php _e('Search', 'wpml-wcml'); ?>" value="<?php echo isset($_GET['s'])?$_GET['s']:''; ?>"/>
|
82 |
<input type="hidden" value="<?php echo admin_url('admin.php?page=wpml-wcml&tab=products'); ?>" class="wcml_products_admin_url" />
|
83 |
<input type="hidden" value="<?php echo $pagination_url; ?>" class="wcml_pagination_url" />
|
@@ -86,19 +88,7 @@ $button_labels = array(
|
|
86 |
<?php if($search): ?>
|
87 |
<button type="button" value="reset" class="button-secondary wcml_reset_search"><?php _e('Reset', 'wpml-wcml'); ?></button>
|
88 |
<?php endif;?>
|
89 |
-
|
90 |
-
<?php if(current_user_can('wpml_manage_woocommerce_multilingual')): ?>
|
91 |
-
<div class="wcml_product_actions">
|
92 |
-
<p>
|
93 |
-
<select name="test_action">
|
94 |
-
<?php /* <option value="duplicate"><?php _e('Duplicate for testing', 'wpml-wcml'); ?></option> */ ?>
|
95 |
-
<option value="clean"><?php _e('Cleanup test content', 'wpml-wcml'); ?></option>
|
96 |
-
<option value="to_translation"><?php _e('Send to translation', 'wpml-wcml'); ?></option>
|
97 |
-
</select>
|
98 |
-
<button type="submit" name="action" value="apply" class="button-secondary wcml_action_top"><?php _e('Apply', 'wpml-wcml'); ?></button>
|
99 |
-
</p>
|
100 |
-
</div>
|
101 |
-
<?php endif; ?>
|
102 |
|
103 |
<?php if($products): ?>
|
104 |
<div class="wcml_product_pagination">
|
@@ -111,17 +101,16 @@ $button_labels = array(
|
|
111 |
<a class="last-page <?php echo $pn==$last?'disabled':''; ?>" href="<?php echo $pagination_url.$last; ?>" title="<?php _e('Go to the last page', 'wpml-wcml'); ?>">»</a>
|
112 |
<?php endif; ?>
|
113 |
<?php if(isset($_GET['prid']) || ($lm && isset($last)) && $last > 1): ?>
|
114 |
-
<a href="<?php echo $pagination_url; ?>
|
115 |
<?php endif; ?>
|
116 |
</div>
|
117 |
<?php endif; ?>
|
118 |
<input type="hidden" class="icl_def_language" value="<?php echo $default_language ?>" />
|
119 |
-
<input type="hidden" id="upd_product_nonce" value="<?php echo wp_create_nonce('update_product_actions'); ?>" />
|
120 |
-
<?php wp_nonce_field('wcml_test_actions', 'wcml_nonce'); ?>
|
121 |
<table class="widefat fixed wcml_products" cellspacing="0">
|
122 |
<thead>
|
123 |
<tr>
|
124 |
-
<th scope="col" width="
|
125 |
<th scope="col" width="5%"><?php _e('Type', 'wpml-wcml') ?></th>
|
126 |
<th scope="col" width="20%"><?php _e('Product', 'wpml-wcml') ?></th>
|
127 |
<th scope="col" width="73%"><?php echo $woocommerce_wpml->products->get_translation_flags($active_languages,$default_language,isset($_GET['slang']) && $_GET['slang'] != "all"?$_GET['slang']:false); ?></th>
|
@@ -205,6 +194,9 @@ $button_labels = array(
|
|
205 |
<?php unset($attributes[$key]); ?>
|
206 |
<?php endif; ?>
|
207 |
<?php endforeach; ?>
|
|
|
|
|
|
|
208 |
</tr>
|
209 |
</thead>
|
210 |
<tbody>
|
@@ -316,9 +308,9 @@ $button_labels = array(
|
|
316 |
<h3><?php _e('Original content:', 'wpml-wcml') ?></h3>
|
317 |
<?php
|
318 |
if($product_content == 'content'){
|
319 |
-
$original_content = $product->post_content;
|
320 |
}else{
|
321 |
-
$original_content = $product->post_excerpt;
|
322 |
}
|
323 |
?>
|
324 |
<textarea class="wcml_original_content"><?php echo $original_content; ?></textarea>
|
@@ -361,6 +353,7 @@ $button_labels = array(
|
|
361 |
<?php endif; ?>
|
362 |
</td>
|
363 |
<?php endforeach; ?>
|
|
|
364 |
<?php
|
365 |
foreach ($attributes as $attr_key=>$attribute): ?>
|
366 |
<td>
|
@@ -416,30 +409,10 @@ $button_labels = array(
|
|
416 |
<a class="last-page <?php echo $pn==$last?'disabled':''; ?>" href="<?php echo $pagination_url.$last; ?>" title="<?php _e('Go to the last page', 'wpml-wcml'); ?>">»</a>
|
417 |
<?php endif; ?>
|
418 |
<?php if(isset($_GET['prid']) || ($lm && isset($last)) && $last > 1): ?>
|
419 |
-
<a href="<?php echo $pagination_url; ?>
|
420 |
<?php endif; ?>
|
421 |
</div>
|
422 |
<div class="clr"></div>
|
423 |
-
|
424 |
-
<?php if(current_user_can('wpml_manage_woocommerce_multilingual')): ?>
|
425 |
-
<div class="wcml_product_actions">
|
426 |
-
<select name="test_action_bottom">
|
427 |
-
<?php /*<option value="duplicate"><?php _e('Duplicate for testing', 'wpml-wcml'); ?></option> */ ?>
|
428 |
-
<option value="clean"><?php _e('Cleanup test content', 'wpml-wcml'); ?></option>
|
429 |
-
<option value="to_translation"><?php _e('Send to translation', 'wpml-wcml'); ?></option>
|
430 |
-
</select>
|
431 |
-
<button type="submit" name="action_bottom" value="apply" class="button-secondary wcml_action_bottom"><?php _e('Apply', 'wpml-wcml'); ?></button>
|
432 |
-
</div>
|
433 |
-
<?php endif; ?>
|
434 |
-
|
435 |
<?php endif;?>
|
436 |
|
437 |
-
</form>
|
438 |
-
<?php if($products): ?>
|
439 |
-
<form method="post" name="translation-dashboard-filter" action="admin.php?page=<?php echo WPML_TM_FOLDER ?>/menu/main.php&sm=dashboard" >
|
440 |
-
<input type="hidden" name="icl_tm_action" value="dashboard_filter" />
|
441 |
-
<input type="hidden" name="filter[icl_selected_posts]" value="" class="icl_selected_posts" />
|
442 |
-
<button type="submit" name="filter[type]" value="product" class="wcml_send_to_trnsl none"><?php _e('Send products to translation', 'wpml-wcml'); ?></button>
|
443 |
-
<div class="clr"></div>
|
444 |
-
</form>
|
445 |
-
<?php endif;?>
|
37 |
<h3><?php _e('WooCommerce Products','wpml-wcml'); ?></h3>
|
38 |
<span style="display:none" id="wcml_product_update_button_label"><?php echo $button_labels['update'] ?></span>
|
39 |
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
|
40 |
+
<div class="wcml_prod_filters">
|
41 |
<select class="wcml_product_category">
|
42 |
<option value="0"><?php _e('Any category', 'wpml-wcml'); ?></option>
|
43 |
<?php
|
78 |
<?php endif; ?>
|
79 |
<?php endforeach; ?>
|
80 |
</select>
|
81 |
+
</div>
|
82 |
+
<div>
|
83 |
<input type="text" class="wcml_product_name" placeholder="<?php _e('Search', 'wpml-wcml'); ?>" value="<?php echo isset($_GET['s'])?$_GET['s']:''; ?>"/>
|
84 |
<input type="hidden" value="<?php echo admin_url('admin.php?page=wpml-wcml&tab=products'); ?>" class="wcml_products_admin_url" />
|
85 |
<input type="hidden" value="<?php echo $pagination_url; ?>" class="wcml_pagination_url" />
|
88 |
<?php if($search): ?>
|
89 |
<button type="button" value="reset" class="button-secondary wcml_reset_search"><?php _e('Reset', 'wpml-wcml'); ?></button>
|
90 |
<?php endif;?>
|
91 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
<?php if($products): ?>
|
94 |
<div class="wcml_product_pagination">
|
101 |
<a class="last-page <?php echo $pn==$last?'disabled':''; ?>" href="<?php echo $pagination_url.$last; ?>" title="<?php _e('Go to the last page', 'wpml-wcml'); ?>">»</a>
|
102 |
<?php endif; ?>
|
103 |
<?php if(isset($_GET['prid']) || ($lm && isset($last)) && $last > 1): ?>
|
104 |
+
<a href="<?php echo $pagination_url; ?>1"><?php _e('Show all products', 'wpml-wcml'); ?></a>
|
105 |
<?php endif; ?>
|
106 |
</div>
|
107 |
<?php endif; ?>
|
108 |
<input type="hidden" class="icl_def_language" value="<?php echo $default_language ?>" />
|
109 |
+
<input type="hidden" id="upd_product_nonce" value="<?php echo wp_create_nonce('update_product_actions'); ?>" />
|
|
|
110 |
<table class="widefat fixed wcml_products" cellspacing="0">
|
111 |
<thead>
|
112 |
<tr>
|
113 |
+
<th scope="col" width="15"><input type="checkbox" value="" class="wcml_check_all"/></th>
|
114 |
<th scope="col" width="5%"><?php _e('Type', 'wpml-wcml') ?></th>
|
115 |
<th scope="col" width="20%"><?php _e('Product', 'wpml-wcml') ?></th>
|
116 |
<th scope="col" width="73%"><?php echo $woocommerce_wpml->products->get_translation_flags($active_languages,$default_language,isset($_GET['slang']) && $_GET['slang'] != "all"?$_GET['slang']:false); ?></th>
|
194 |
<?php unset($attributes[$key]); ?>
|
195 |
<?php endif; ?>
|
196 |
<?php endforeach; ?>
|
197 |
+
<?php
|
198 |
+
do_action('wcml_extra_titles',$product_id);
|
199 |
+
?>
|
200 |
</tr>
|
201 |
</thead>
|
202 |
<tbody>
|
308 |
<h3><?php _e('Original content:', 'wpml-wcml') ?></h3>
|
309 |
<?php
|
310 |
if($product_content == 'content'){
|
311 |
+
$original_content = apply_filters('the_content', $product->post_content);
|
312 |
}else{
|
313 |
+
$original_content = apply_filters('the_content', $product->post_excerpt);
|
314 |
}
|
315 |
?>
|
316 |
<textarea class="wcml_original_content"><?php echo $original_content; ?></textarea>
|
353 |
<?php endif; ?>
|
354 |
</td>
|
355 |
<?php endforeach; ?>
|
356 |
+
<?php do_action('wcml_gui_additional_box',$product_id,$key,$is_duplicate_product); ?>
|
357 |
<?php
|
358 |
foreach ($attributes as $attr_key=>$attribute): ?>
|
359 |
<td>
|
409 |
<a class="last-page <?php echo $pn==$last?'disabled':''; ?>" href="<?php echo $pagination_url.$last; ?>" title="<?php _e('Go to the last page', 'wpml-wcml'); ?>">»</a>
|
410 |
<?php endif; ?>
|
411 |
<?php if(isset($_GET['prid']) || ($lm && isset($last)) && $last > 1): ?>
|
412 |
+
<a href="<?php echo $pagination_url; ?>1"><?php _e('Show all products', 'wpml-wcml'); ?></a>
|
413 |
<?php endif; ?>
|
414 |
</div>
|
415 |
<div class="clr"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
<?php endif;?>
|
417 |
|
418 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu/sub/settings.php
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
<div class="wcml-section">
|
2 |
<div class="wcml-section-header">
|
3 |
<h3>
|
@@ -7,29 +9,35 @@
|
|
7 |
</div>
|
8 |
<div class="wcml-section-content">
|
9 |
<ul>
|
10 |
-
<?php if (defined('ICL_SITEPRESS_VERSION')) : ?>
|
11 |
-
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and
|
|
|
|
|
|
|
|
|
|
|
12 |
<?php endif; ?>
|
13 |
<?php if (defined('WPML_MEDIA_VERSION')) : ?>
|
14 |
-
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and
|
15 |
<?php endif; ?>
|
16 |
<?php if (defined('WPML_TM_VERSION')) : ?>
|
17 |
-
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and
|
18 |
<?php endif; ?>
|
19 |
<?php if (defined('WPML_ST_VERSION')) : ?>
|
20 |
-
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and
|
21 |
<?php endif; ?>
|
22 |
<?php
|
23 |
global $woocommerce;
|
24 |
if (class_exists('Woocommerce')) : ?>
|
25 |
-
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and
|
26 |
<?php endif; ?>
|
27 |
</ul>
|
28 |
</div> <!-- .wcml-section-content -->
|
29 |
|
30 |
</div> <!-- .wcml-section -->
|
31 |
-
|
32 |
-
|
|
|
33 |
<div class="wcml-section">
|
34 |
<div class="wcml-section-header">
|
35 |
<h3>
|
@@ -39,7 +47,9 @@
|
|
39 |
</div>
|
40 |
|
41 |
<div class="wcml-section-content">
|
42 |
-
<?php if($sitepress->get_default_language() != 'en'
|
|
|
|
|
43 |
<p><i class="icon-warning-sign"></i><strong><?php _e('Attention required: probable problem with URLs in different languages', 'wpml-wcml') ?></strong></p>
|
44 |
|
45 |
<p><?php _e("Your site's default language is not English and the strings language is also not English. This may lead to problems with your site's URLs in different languages.", 'wpml-wcml') ?></p>
|
@@ -52,20 +62,35 @@
|
|
52 |
<p class="submit">
|
53 |
<input type="hidden" id="wcml_fix_strings_language_nonce" value="<?php echo wp_create_nonce('wcml_fix_strings_language') ?>" />
|
54 |
<input id="wcml_fix_strings_language" type="button" class="button-primary" value="<?php esc_attr_e('Run fix', 'wpml-wcml') ?>" />
|
55 |
-
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
<?php endif; ?>
|
57 |
|
58 |
<?php if(!empty($woocommerce_wpml->dependencies->xml_config_errors)): ?>
|
59 |
-
<p><i class="icon-warning-sign"></i
|
|
|
|
|
|
|
|
|
|
|
60 |
<ul>
|
61 |
<?php foreach($woocommerce_wpml->dependencies->xml_config_errors as $error): ?>
|
62 |
<li><?php echo $error ?></li>
|
63 |
<?php endforeach; ?>
|
64 |
</ul>
|
65 |
-
|
66 |
-
|
67 |
<?php endif; ?>
|
68 |
-
|
69 |
</div>
|
70 |
|
71 |
</div>
|
@@ -285,10 +310,9 @@
|
|
285 |
<i class="icon-question-sign js-display-tooltip" data-header="<?php _e('Currency management', 'wpml-wcml') ?>" data-content="<?php _e('This will let you enable the multi-currency mode where users can see prices according to their currency preference and configured exchange rate.', 'wpml-wcml') ?>"></i>
|
286 |
</h3>
|
287 |
</div>
|
288 |
-
|
289 |
<div class="wcml-section-content">
|
290 |
|
291 |
-
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="general_options">
|
292 |
<?php wp_nonce_field('general_options', 'wcml_nonce'); ?>
|
293 |
|
294 |
<ul id="general_options">
|
@@ -298,15 +322,15 @@
|
|
298 |
<li>
|
299 |
<input type="radio" name="multi_currency" id="multi_currency_disabled" value="<?php echo WCML_MULTI_CURRENCIES_DISABLED ?>" <?php
|
300 |
echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_DISABLED) ?> />
|
301 |
-
<label for="multi_currency_disabled"><?php _e("No multi-currency",'wpml-wcml'); ?></label>
|
302 |
</li>
|
303 |
<li>
|
304 |
<input type="radio" name="multi_currency" id="multi_currency_independent" value="<?php echo WCML_MULTI_CURRENCIES_INDEPENDENT ?>" <?php
|
305 |
echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_INDEPENDENT) ?> />
|
306 |
<label for="multi_currency_independent">
|
307 |
-
<?php _e("Multiple currencies, independent of languages",'wpml-wcml'); ?>
|
308 |
-
|
309 |
-
<a href="http://wpml.org
|
310 |
</label>
|
311 |
</li>
|
312 |
</ul>
|
@@ -318,13 +342,22 @@
|
|
318 |
|
319 |
|
320 |
<div id="multi-currency-per-language-details" <?php if ( $woocommerce_wpml->settings['enable_multi_currency'] != WCML_MULTI_CURRENCIES_INDEPENDENT ):?>style="display:none"<?php endif;?>>
|
|
|
321 |
<?php
|
322 |
$wc_currencies = get_woocommerce_currencies();
|
323 |
$wc_currency = get_option('woocommerce_currency');
|
324 |
$active_languages = $sitepress->get_active_languages();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
?>
|
326 |
<p>
|
327 |
-
<?php printf(__(
|
328 |
</p>
|
329 |
<input type="hidden" id="update_currency_lang_nonce" value="<?php echo wp_create_nonce('wcml_update_currency_lang'); ?>"/>
|
330 |
<table class="widefat currency_table" id="currency-table">
|
@@ -335,55 +368,44 @@
|
|
335 |
</tr>
|
336 |
</thead>
|
337 |
<tbody>
|
338 |
-
<?php
|
339 |
-
|
340 |
-
$currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` ASC", OBJECT);
|
341 |
-
$exists_codes = $wpdb->get_col("SELECT code FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` ASC"); ?>
|
342 |
<tr>
|
343 |
<td class="currency_code">
|
344 |
-
<span class="code_val"><?php echo $wc_currencies[$wc_currency]; ?><?php printf(__(' (%s)','wpml-wcml'),
|
345 |
-
<
|
346 |
-
<option value="<?php echo $wc_currency; ?>" selected="selected"><?php echo $wc_currency; ?></option>
|
347 |
-
</select>
|
348 |
-
<div class="currency_value">
|
349 |
-
<span><?php _e( 'default', 'wpml-wcml' ); ?></span>
|
350 |
-
</div>
|
351 |
</td>
|
352 |
-
|
353 |
<td class="currency-actions"></td>
|
|
|
354 |
</tr>
|
355 |
-
<?php
|
356 |
-
unset($wc_currencies[$wc_currency]);
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
<
|
370 |
-
|
371 |
-
|
372 |
-
<input type="text" value="<?php echo $currency->value; ?>"/>
|
373 |
-
<span class="curr_val_code"><?php echo $currency->code; ?></span>
|
374 |
-
</span>
|
375 |
</div>
|
376 |
-
|
377 |
</td>
|
|
|
378 |
<td class="currency-actions">
|
379 |
<div class="currency_action_update">
|
380 |
-
<a href="javascript:void(0);" title="<?php esc_attr(_e('Edit', 'wpml-wcml')); ?>" class="edit_currency">
|
381 |
<i class="icon-edit" title="<?php esc_attr(_e('Edit', 'wpml-wcml')); ?>"></i>
|
382 |
</a>
|
383 |
<i class="icon-ok-circle save_currency"></i>
|
384 |
</div>
|
385 |
<div class="currency_action_delete">
|
386 |
-
<a href="javascript:void(0);" title="<?php esc_attr(_e('Delete', 'wpml-wcml')); ?>" class="delete_currency">
|
387 |
<i class="icon-trash" title="<?php esc_attr(_e('Delete', 'wpml-wcml')); ?>"></i>
|
388 |
</a>
|
389 |
<i class="icon-remove-circle cancel_currency"></i>
|
@@ -418,47 +440,48 @@
|
|
418 |
<td class="currency_languages">
|
419 |
<div class="wcml_onof_buttons">
|
420 |
<ul>
|
421 |
-
<li <?php echo $woocommerce_wpml->settings['
|
422 |
-
<li <?php echo $woocommerce_wpml->settings['
|
423 |
</ul>
|
424 |
</div>
|
425 |
</td>
|
426 |
<?php endforeach; ?>
|
427 |
</tr>
|
428 |
-
<?php foreach ($currencies as $
|
429 |
-
<tr>
|
430 |
<?php foreach($active_languages as $language): ?>
|
431 |
<td class="currency_languages">
|
432 |
<div class="wcml_onof_buttons">
|
433 |
<ul>
|
434 |
-
<li <?php echo $
|
435 |
-
<li <?php echo $
|
436 |
</ul>
|
437 |
</div>
|
438 |
</td>
|
439 |
<?php endforeach; ?>
|
440 |
</tr>
|
441 |
<?php endforeach; ?>
|
442 |
-
<tr class="default_currency">
|
443 |
-
<input type="hidden" id="wcml_update_default_currency_nonce" value="<?php echo wp_create_nonce('wcml_update_default_currency'); ?>"/>
|
444 |
<?php foreach($active_languages as $language): ?>
|
445 |
<td class="currency_languages">
|
446 |
<select rel="<?php echo $language['code']; ?>">
|
447 |
-
<option value="0" <?php
|
448 |
-
<?php if($woocommerce_wpml->settings['
|
449 |
-
<option value="<?php echo $wc_currency; ?>" <?php
|
450 |
<?php endif; ?>
|
451 |
-
<?php foreach($
|
452 |
-
<?php if($woocommerce_wpml->settings['
|
453 |
-
<option value="<?php echo $
|
454 |
<?php endif; ?>
|
455 |
<?php endforeach; ?>
|
456 |
</select>
|
457 |
</td>
|
458 |
<?php endforeach; ?>
|
459 |
</tr>
|
460 |
-
|
461 |
-
|
|
|
|
|
462 |
</div>
|
463 |
</div>
|
464 |
|
@@ -467,11 +490,10 @@
|
|
467 |
<tr class="edit-mode js-table-row">
|
468 |
<td class="currency_code" data-message="<?php _e( 'Please fill field', 'wpml-wcml' ); ?>">
|
469 |
<span class="code_val"></span>
|
470 |
-
<
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
<option value="<?php echo $key; ?>"><?php echo $currency_name; ?></option>
|
475 |
<?php endif; ?>
|
476 |
<?php endforeach; ?>
|
477 |
</select>
|
@@ -483,7 +505,6 @@
|
|
483 |
<span class="curr_val_code"></span>
|
484 |
</span>
|
485 |
</div>
|
486 |
-
<span class="currency_changed"></span>
|
487 |
</td>
|
488 |
<td class="currency-actions">
|
489 |
<div class="currency_action_update">
|
@@ -493,7 +514,7 @@
|
|
493 |
<i class="icon-ok-circle save_currency" style="display:inline"></i>
|
494 |
</div>
|
495 |
<div class="currency_action_delete">
|
496 |
-
<a href="javascript:void(0);" title="Delete" class="delete_currency" style="display:none">
|
497 |
<i class="icon-trash" alt="Delete"></i>
|
498 |
</a>
|
499 |
<i class="icon-remove-circle cancel_currency" style="display:inline"></i>
|
@@ -508,8 +529,8 @@
|
|
508 |
<td class="currency_languages">
|
509 |
<div class="wcml_onof_buttons">
|
510 |
<ul>
|
511 |
-
<li><a class="off_btn" href="javascript:void(0);"
|
512 |
-
<li class="on"><a class="on_btn" href="javascript:void(0);"
|
513 |
</ul>
|
514 |
</div>
|
515 |
</td>
|
@@ -518,8 +539,10 @@
|
|
518 |
</table>
|
519 |
|
520 |
<input type="hidden" value="<?php echo WCML_PLUGIN_URL; ?>" class="wcml_plugin_url" />
|
521 |
-
<input type="hidden" id="
|
522 |
<input type="hidden" id="del_currency_nonce" value="<?php echo wp_create_nonce('wcml_delete_currency'); ?>" />
|
|
|
|
|
523 |
|
524 |
<p class="wcml_add_currency button-wrap">
|
525 |
<button type="button" class="button-secondary">
|
@@ -527,7 +550,7 @@
|
|
527 |
<?php _e('Add currency','wpml-wcml'); ?>
|
528 |
</button>
|
529 |
</p>
|
530 |
-
|
531 |
<?php // backward compatibility ?>
|
532 |
<?php
|
533 |
$posts = $wpdb->get_results($wpdb->prepare("
|
@@ -566,11 +589,11 @@
|
|
566 |
echo '<th rowspan="2"> </th>';
|
567 |
echo '</tr>';
|
568 |
echo '<tr>';
|
569 |
-
foreach($currencies as $currency){
|
570 |
-
echo '<th>' . $
|
571 |
}
|
572 |
-
foreach($currencies as $currency){
|
573 |
-
echo '<th>' . $
|
574 |
}
|
575 |
echo '</tr>';
|
576 |
echo '</thead>';
|
@@ -580,20 +603,20 @@
|
|
580 |
echo '<tr>';
|
581 |
echo '<td><a href="' . get_edit_post_link($post->post_id) . '">' . apply_filters('the_title', $post->post_title) . '</a></td>';
|
582 |
|
583 |
-
foreach($currencies as $currency){
|
584 |
echo '<td>';
|
585 |
-
if(isset($rates['_price'][$
|
586 |
-
echo '<input name="posts[' . $post->post_id . '][_price][' . $
|
587 |
}else{
|
588 |
_e('n/a', 'wpml-wcml');
|
589 |
}
|
590 |
echo '</td>';
|
591 |
}
|
592 |
|
593 |
-
foreach($currencies as $currency){
|
594 |
echo '<td>';
|
595 |
-
if(isset($rates['_sale_price'][$
|
596 |
-
echo '<input name="posts[' . $post->post_id . '][_sale_price][' . $
|
597 |
}else{
|
598 |
_e('n/a', 'wpml-wcml');
|
599 |
}
|
@@ -611,24 +634,20 @@
|
|
611 |
|
612 |
|
613 |
}
|
614 |
-
?>
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
</div>
|
620 |
-
<p class="button-wrap">
|
621 |
<input type='submit' name="general_options" value='<?php _e('Save', 'wpml-wcml'); ?>' class='button-secondary' />
|
622 |
<?php wp_nonce_field('general_options', 'general_options_nonce'); ?>
|
623 |
</p>
|
624 |
-
|
625 |
-
|
|
|
|
|
|
|
626 |
</form>
|
627 |
-
|
628 |
-
</div> <!-- .wcml-section-content -->
|
629 |
-
|
630 |
</div> <!-- .wcml-section -->
|
631 |
<input type="hidden" id="wcml_warn_message" value="<?php esc_attr_e('The changes you made will be lost if you navigate away from this page.','wpml-wcml');?>"/>
|
|
|
632 |
<div class="troubleshoot_link_block">
|
633 |
<a href="admin.php?page=<?php echo basename(WCML_PLUGIN_PATH) ?>/menu/sub/troubleshooting.php"><?php _e('Troubleshooting page','wpml-wcml'); ?></a>
|
634 |
</div>
|
1 |
+
<?php global $sitepress_settings, $sitepress; ?>
|
2 |
+
|
3 |
<div class="wcml-section">
|
4 |
<div class="wcml-section-header">
|
5 |
<h3>
|
9 |
</div>
|
10 |
<div class="wcml-section-content">
|
11 |
<ul>
|
12 |
+
<?php if (defined('ICL_SITEPRESS_VERSION')) : ?>
|
13 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
14 |
+
<?php if($sitepress->setup()): ?>
|
15 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s is set up.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
16 |
+
<?php else: ?>
|
17 |
+
<li><i class="icon-warning-sign"></i> <?php printf(__('%s is not set up.', 'wpml-wcml'), '<strong>WPML</strong>'); ?></li>
|
18 |
+
<?php endif; ?>
|
19 |
<?php endif; ?>
|
20 |
<?php if (defined('WPML_MEDIA_VERSION')) : ?>
|
21 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML Media</strong>'); ?></li>
|
22 |
<?php endif; ?>
|
23 |
<?php if (defined('WPML_TM_VERSION')) : ?>
|
24 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML Translation Management</strong>'); ?></li>
|
25 |
<?php endif; ?>
|
26 |
<?php if (defined('WPML_ST_VERSION')) : ?>
|
27 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WPML String Translation</strong>'); ?></li>
|
28 |
<?php endif; ?>
|
29 |
<?php
|
30 |
global $woocommerce;
|
31 |
if (class_exists('Woocommerce')) : ?>
|
32 |
+
<li><i class="icon-ok"></i> <?php printf(__('%s plugin is installed and active.', 'wpml-wcml'), '<strong>WooCommerce</strong>'); ?></li>
|
33 |
<?php endif; ?>
|
34 |
</ul>
|
35 |
</div> <!-- .wcml-section-content -->
|
36 |
|
37 |
</div> <!-- .wcml-section -->
|
38 |
+
|
39 |
+
|
40 |
+
<?php if($sitepress->get_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)): ?>
|
41 |
<div class="wcml-section">
|
42 |
<div class="wcml-section-header">
|
43 |
<h3>
|
47 |
</div>
|
48 |
|
49 |
<div class="wcml-section-content">
|
50 |
+
<?php if($sitepress->get_default_language() != 'en'): ?>
|
51 |
+
|
52 |
+
<?php if($sitepress_settings['st']['strings_language'] != 'en'): ?>
|
53 |
<p><i class="icon-warning-sign"></i><strong><?php _e('Attention required: probable problem with URLs in different languages', 'wpml-wcml') ?></strong></p>
|
54 |
|
55 |
<p><?php _e("Your site's default language is not English and the strings language is also not English. This may lead to problems with your site's URLs in different languages.", 'wpml-wcml') ?></p>
|
62 |
<p class="submit">
|
63 |
<input type="hidden" id="wcml_fix_strings_language_nonce" value="<?php echo wp_create_nonce('wcml_fix_strings_language') ?>" />
|
64 |
<input id="wcml_fix_strings_language" type="button" class="button-primary" value="<?php esc_attr_e('Run fix', 'wpml-wcml') ?>" />
|
65 |
+
</p>
|
66 |
+
|
67 |
+
<?php else: ?>
|
68 |
+
<p><?php _e("Your site's default language is not English. There are some settings that require careful attention.", 'wpml-wcml') ?> </p>
|
69 |
+
<?php endif; ?>
|
70 |
+
|
71 |
+
<p><?php printf(__("Please review the %sguide for running WooCommerce multilingual with default language other than English%s.", 'wpml-wcml'), '<a href="http://wpml.org/?page_id=355545">', '</a>') ?> </p>
|
72 |
+
|
73 |
+
<?php if($sitepress_settings['st']['strings_language'] == 'en'): ?>
|
74 |
+
<p class="submit">
|
75 |
+
<input id="wcml_dimiss_non_default_language_warning" type="button" class="button-primary" value="<?php esc_attr_e('Dismiss', 'wpml-wcml') ?>" />
|
76 |
+
</p>
|
77 |
+
<?php endif; ?>
|
78 |
+
|
79 |
<?php endif; ?>
|
80 |
|
81 |
<?php if(!empty($woocommerce_wpml->dependencies->xml_config_errors)): ?>
|
82 |
+
<p><i class="icon-warning-sign"></i>
|
83 |
+
<strong><?php _e('Some settings from the WooCommerce Multilingual wpml-config.xml file have been overwritten.', 'wpml-wcml'); ?></strong>
|
84 |
+
</p>
|
85 |
+
<p><?php printf(__('You should check WPML configuration files added by other plugins or manual settings on the %sMultilingual Content Setup%s section.', 'wpml-wcml'),
|
86 |
+
'<a href="' . admin_url('?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=mcsetup') . '">' , '</a>') ?>
|
87 |
+
</p>
|
88 |
<ul>
|
89 |
<?php foreach($woocommerce_wpml->dependencies->xml_config_errors as $error): ?>
|
90 |
<li><?php echo $error ?></li>
|
91 |
<?php endforeach; ?>
|
92 |
</ul>
|
|
|
|
|
93 |
<?php endif; ?>
|
|
|
94 |
</div>
|
95 |
|
96 |
</div>
|
310 |
<i class="icon-question-sign js-display-tooltip" data-header="<?php _e('Currency management', 'wpml-wcml') ?>" data-content="<?php _e('This will let you enable the multi-currency mode where users can see prices according to their currency preference and configured exchange rate.', 'wpml-wcml') ?>"></i>
|
311 |
</h3>
|
312 |
</div>
|
313 |
+
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="general_options">
|
314 |
<div class="wcml-section-content">
|
315 |
|
|
|
316 |
<?php wp_nonce_field('general_options', 'wcml_nonce'); ?>
|
317 |
|
318 |
<ul id="general_options">
|
322 |
<li>
|
323 |
<input type="radio" name="multi_currency" id="multi_currency_disabled" value="<?php echo WCML_MULTI_CURRENCIES_DISABLED ?>" <?php
|
324 |
echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_DISABLED) ?> />
|
325 |
+
<label for="multi_currency_disabled"><?php _e("No multi-currency.",'wpml-wcml'); ?></label>
|
326 |
</li>
|
327 |
<li>
|
328 |
<input type="radio" name="multi_currency" id="multi_currency_independent" value="<?php echo WCML_MULTI_CURRENCIES_INDEPENDENT ?>" <?php
|
329 |
echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_INDEPENDENT) ?> />
|
330 |
<label for="multi_currency_independent">
|
331 |
+
<?php _e("Multiple currencies, independent of languages.",'wpml-wcml'); ?>
|
332 |
+
|
333 |
+
<a href=" <?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/','multi-currency-support-woocommerce','documentation') ?>"><?php _e('Learn more', 'wpl-wcml') ?></a>.
|
334 |
</label>
|
335 |
</li>
|
336 |
</ul>
|
342 |
|
343 |
|
344 |
<div id="multi-currency-per-language-details" <?php if ( $woocommerce_wpml->settings['enable_multi_currency'] != WCML_MULTI_CURRENCIES_INDEPENDENT ):?>style="display:none"<?php endif;?>>
|
345 |
+
<div class="currencies-table-content">
|
346 |
<?php
|
347 |
$wc_currencies = get_woocommerce_currencies();
|
348 |
$wc_currency = get_option('woocommerce_currency');
|
349 |
$active_languages = $sitepress->get_active_languages();
|
350 |
+
|
351 |
+
switch(get_option('woocommerce_currency_pos')){
|
352 |
+
case 'left': $positioned_price = sprintf('%s99.99', get_woocommerce_currency_symbol($wc_currency)); break;
|
353 |
+
case 'right': $positioned_price = sprintf('99.99%s', get_woocommerce_currency_symbol($wc_currency)); break;
|
354 |
+
case 'left_space': $positioned_price = sprintf('%s 99.99', get_woocommerce_currency_symbol($wc_currency)); break;
|
355 |
+
case 'right_space': $positioned_price = sprintf('99.99 %s', get_woocommerce_currency_symbol($wc_currency)); break;
|
356 |
+
}
|
357 |
+
|
358 |
?>
|
359 |
<p>
|
360 |
+
<?php printf(__("Your store's base currency is %s (%s). To change it, go to the %s page.", 'wpml-wcml'), $wc_currencies[$wc_currency],get_woocommerce_currency_symbol($wc_currency),'<a href="'. admin_url(sprintf('admin.php?page=%s&tab=general', version_compare($woocommerce->version, '2.1', '<') ? 'woocommerce_settings' : 'wc-settings')) .'">WooCommerce settings</a>'); ?>
|
361 |
</p>
|
362 |
<input type="hidden" id="update_currency_lang_nonce" value="<?php echo wp_create_nonce('wcml_update_currency_lang'); ?>"/>
|
363 |
<table class="widefat currency_table" id="currency-table">
|
368 |
</tr>
|
369 |
</thead>
|
370 |
<tbody>
|
|
|
|
|
|
|
|
|
371 |
<tr>
|
372 |
<td class="currency_code">
|
373 |
+
<span class="code_val"><?php echo $wc_currencies[$wc_currency]; ?><?php printf(__(' (%s)','wpml-wcml'), $positioned_price); ?></span>
|
374 |
+
<div class="currency_value"><span><?php _e( 'default', 'wpml-wcml' ); ?></span></div>
|
|
|
|
|
|
|
|
|
|
|
375 |
</td>
|
|
|
376 |
<td class="currency-actions"></td>
|
377 |
+
|
378 |
</tr>
|
379 |
+
<?php
|
380 |
+
unset($wc_currencies[$wc_currency]);
|
381 |
+
$currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
|
382 |
+
foreach ($currencies as $code => $currency) :
|
383 |
+
switch($currency['position']){
|
384 |
+
case 'left': $positioned_price = sprintf('%s99.99', get_woocommerce_currency_symbol($code)); break;
|
385 |
+
case 'right': $positioned_price = sprintf('99.99%s', get_woocommerce_currency_symbol($code)); break;
|
386 |
+
case 'left_space': $positioned_price = sprintf('%s 99.99', get_woocommerce_currency_symbol($code)); break;
|
387 |
+
case 'right_space': $positioned_price = sprintf('99.99 %s', get_woocommerce_currency_symbol($code)); break;
|
388 |
+
}
|
389 |
+
?>
|
390 |
+
<tr id="currency_row_<?php echo $code ?>">
|
391 |
+
<td class="currency_code">
|
392 |
+
<?php include WCML_PLUGIN_PATH . '/menu/sub/custom-currency-options.php'; ?>
|
393 |
+
<span class="code_val"><?php echo $wc_currencies[$code]; ?><?php printf(__(' (%s)','wpml-wcml'), $positioned_price); ?></span>
|
394 |
+
<div class="currency_value">
|
395 |
+
<span><?php printf('1 %s = %s %s', $wc_currency, $currency['rate'], $code); ?></span>
|
|
|
|
|
|
|
396 |
</div>
|
397 |
+
|
398 |
</td>
|
399 |
+
|
400 |
<td class="currency-actions">
|
401 |
<div class="currency_action_update">
|
402 |
+
<a href="javascript:void(0);" title="<?php esc_attr(_e('Edit', 'wpml-wcml')); ?>" class="edit_currency" data-currency="<?php echo $code ?>">
|
403 |
<i class="icon-edit" title="<?php esc_attr(_e('Edit', 'wpml-wcml')); ?>"></i>
|
404 |
</a>
|
405 |
<i class="icon-ok-circle save_currency"></i>
|
406 |
</div>
|
407 |
<div class="currency_action_delete">
|
408 |
+
<a href="javascript:void(0);" title="<?php esc_attr(_e('Delete', 'wpml-wcml')); ?>" class="delete_currency" data-currency="<?php echo $code ?>" >
|
409 |
<i class="icon-trash" title="<?php esc_attr(_e('Delete', 'wpml-wcml')); ?>"></i>
|
410 |
</a>
|
411 |
<i class="icon-remove-circle cancel_currency"></i>
|
440 |
<td class="currency_languages">
|
441 |
<div class="wcml_onof_buttons">
|
442 |
<ul>
|
443 |
+
<li <?php echo $woocommerce_wpml->settings['currency_options'][$wc_currency]['languages'][$language['code']] == 0 ?'class="on"':''; ?> ><a class="off_btn" href="javascript:void(0);" data-language="<?php echo $language['code']; ?>" data-currency="<?php echo $wc_currency; ?>" ><?php _e( 'OFF', 'wpml-wcml' ); ?></a></li>
|
444 |
+
<li <?php echo $woocommerce_wpml->settings['currency_options'][$wc_currency]['languages'][$language['code']] == 1 ?'class="on"':''; ?> ><a class="on_btn" href="javascript:void(0);" data-language="<?php echo $language['code']; ?>" data-currency="<?php echo $wc_currency ?>"><?php _e( 'ON', 'wpml-wcml' ); ?></a></li>
|
445 |
</ul>
|
446 |
</div>
|
447 |
</td>
|
448 |
<?php endforeach; ?>
|
449 |
</tr>
|
450 |
+
<?php foreach ($currencies as $code => $currency) : ?>
|
451 |
+
<tr id="currency_row_langs_<?php echo $code ?>">
|
452 |
<?php foreach($active_languages as $language): ?>
|
453 |
<td class="currency_languages">
|
454 |
<div class="wcml_onof_buttons">
|
455 |
<ul>
|
456 |
+
<li <?php echo $currency['languages'][$language['code']] == 0 ?'class="on"':''; ?> ><a class="off_btn" href="javascript:void(0);" data-language="<?php echo $language['code']; ?>" data-currency="<?php echo $code; ?>"><?php _e( 'OFF', 'wpml-wcml' ); ?></a></li>
|
457 |
+
<li <?php echo $currency['languages'][$language['code']] == 1 ?'class="on"':''; ?> ><a class="on_btn" href="javascript:void(0);" data-language="<?php echo $language['code']; ?>" data-currency="<?php echo $code; ?>"><?php _e( 'ON', 'wpml-wcml' ); ?></a></li>
|
458 |
</ul>
|
459 |
</div>
|
460 |
</td>
|
461 |
<?php endforeach; ?>
|
462 |
</tr>
|
463 |
<?php endforeach; ?>
|
464 |
+
<tr class="default_currency">
|
|
|
465 |
<?php foreach($active_languages as $language): ?>
|
466 |
<td class="currency_languages">
|
467 |
<select rel="<?php echo $language['code']; ?>">
|
468 |
+
<option value="0" <?php selected('0', $woocommerce_wpml->settings['default_currencies'][$language['code']]); ?>><?php _e('Keep', 'wpml-wcml'); ?></option>
|
469 |
+
<?php if($woocommerce_wpml->settings['currency_options'][$wc_currency]['languages'][$language['code']] == 1): ?>
|
470 |
+
<option value="<?php echo $wc_currency; ?>" <?php selected($wc_currency, $woocommerce_wpml->settings['default_currencies'][$language['code']]); ?>><?php echo $wc_currency; ?></option>
|
471 |
<?php endif; ?>
|
472 |
+
<?php foreach($currencies as $code2 => $currency2): ?>
|
473 |
+
<?php if($woocommerce_wpml->settings['currency_options'][$code2]['languages'][$language['code']] == 1): ?>
|
474 |
+
<option value="<?php echo $code2; ?>" <?php selected($code2, $woocommerce_wpml->settings['default_currencies'][$language['code']]); ?>><?php echo $code2; ?></option>
|
475 |
<?php endif; ?>
|
476 |
<?php endforeach; ?>
|
477 |
</select>
|
478 |
</td>
|
479 |
<?php endforeach; ?>
|
480 |
</tr>
|
481 |
+
</tbody>
|
482 |
+
</table>
|
483 |
+
<input type="hidden" id="wcml_update_default_currency_nonce" value="<?php echo wp_create_nonce('wcml_update_default_currency'); ?>"/>
|
484 |
+
|
485 |
</div>
|
486 |
</div>
|
487 |
|
490 |
<tr class="edit-mode js-table-row">
|
491 |
<td class="currency_code" data-message="<?php _e( 'Please fill field', 'wpml-wcml' ); ?>">
|
492 |
<span class="code_val"></span>
|
493 |
+
<select name="code" style="display:block">
|
494 |
+
<?php foreach($wc_currencies as $wc_code=>$currency_name): ?>
|
495 |
+
<?php if(empty($currencies[$wc_code])): ?>
|
496 |
+
<option value="<?php echo $wc_code; ?>"><?php echo $currency_name; ?></option>
|
|
|
497 |
<?php endif; ?>
|
498 |
<?php endforeach; ?>
|
499 |
</select>
|
505 |
<span class="curr_val_code"></span>
|
506 |
</span>
|
507 |
</div>
|
|
|
508 |
</td>
|
509 |
<td class="currency-actions">
|
510 |
<div class="currency_action_update">
|
514 |
<i class="icon-ok-circle save_currency" style="display:inline"></i>
|
515 |
</div>
|
516 |
<div class="currency_action_delete">
|
517 |
+
<a href="javascript:void(0);" title="Delete" class="delete_currency" data-currency="" style="display:none">
|
518 |
<i class="icon-trash" alt="Delete"></i>
|
519 |
</a>
|
520 |
<i class="icon-remove-circle cancel_currency" style="display:inline"></i>
|
529 |
<td class="currency_languages">
|
530 |
<div class="wcml_onof_buttons">
|
531 |
<ul>
|
532 |
+
<li><a class="off_btn" href="javascript:void(0);" data-language="<?php echo $language['code']; ?>"><?php _e( 'OFF', 'wpml-wcml' ); ?></a></li>
|
533 |
+
<li class="on"><a class="on_btn" href="javascript:void(0);" data-language="<?php echo $language['code']; ?>"><?php _e( 'ON', 'wpml-wcml' ); ?></a></li>
|
534 |
</ul>
|
535 |
</div>
|
536 |
</td>
|
539 |
</table>
|
540 |
|
541 |
<input type="hidden" value="<?php echo WCML_PLUGIN_URL; ?>" class="wcml_plugin_url" />
|
542 |
+
<input type="hidden" id="new_currency_nonce" value="<?php echo wp_create_nonce('wcml_new_currency'); ?>" />
|
543 |
<input type="hidden" id="del_currency_nonce" value="<?php echo wp_create_nonce('wcml_delete_currency'); ?>" />
|
544 |
+
<input type="hidden" id="currencies_list_nonce" value="<?php echo wp_create_nonce('wcml_currencies_list'); ?>" />
|
545 |
+
</div>
|
546 |
|
547 |
<p class="wcml_add_currency button-wrap">
|
548 |
<button type="button" class="button-secondary">
|
550 |
<?php _e('Add currency','wpml-wcml'); ?>
|
551 |
</button>
|
552 |
</p>
|
553 |
+
|
554 |
<?php // backward compatibility ?>
|
555 |
<?php
|
556 |
$posts = $wpdb->get_results($wpdb->prepare("
|
589 |
echo '<th rowspan="2"> </th>';
|
590 |
echo '</tr>';
|
591 |
echo '<tr>';
|
592 |
+
foreach($currencies as $code => $currency){
|
593 |
+
echo '<th>' . $code . '</th>';
|
594 |
}
|
595 |
+
foreach($currencies as $code => $currency){
|
596 |
+
echo '<th>' . $code . '</th>';
|
597 |
}
|
598 |
echo '</tr>';
|
599 |
echo '</thead>';
|
603 |
echo '<tr>';
|
604 |
echo '<td><a href="' . get_edit_post_link($post->post_id) . '">' . apply_filters('the_title', $post->post_title) . '</a></td>';
|
605 |
|
606 |
+
foreach($currencies as $code => $currency){
|
607 |
echo '<td>';
|
608 |
+
if(isset($rates['_price'][$code])){
|
609 |
+
echo '<input name="posts[' . $post->post_id . '][_price][' . $code . ']" size="3" value="' . round($rates['_price'][$code],3) . '">';
|
610 |
}else{
|
611 |
_e('n/a', 'wpml-wcml');
|
612 |
}
|
613 |
echo '</td>';
|
614 |
}
|
615 |
|
616 |
+
foreach($currencies as $code => $currency){
|
617 |
echo '<td>';
|
618 |
+
if(isset($rates['_sale_price'][$code])){
|
619 |
+
echo '<input name="posts[' . $post->post_id . '][_sale_price][' . $code . ']" size="3" value="' . round($rates['_sale_price'][$code],3) . '">';
|
620 |
}else{
|
621 |
_e('n/a', 'wpml-wcml');
|
622 |
}
|
634 |
|
635 |
|
636 |
}
|
637 |
+
?>
|
638 |
+
<p class="button-wrap general_option_btn">
|
|
|
|
|
|
|
|
|
|
|
639 |
<input type='submit' name="general_options" value='<?php _e('Save', 'wpml-wcml'); ?>' class='button-secondary' />
|
640 |
<?php wp_nonce_field('general_options', 'general_options_nonce'); ?>
|
641 |
</p>
|
642 |
+
</div>
|
643 |
+
</div> <!-- .wcml-section-content -->
|
644 |
+
<div class="wcml-section">
|
645 |
+
<?php include WCML_PLUGIN_PATH . '/menu/sub/currency-switcher-options.php'; ?>
|
646 |
+
</div>
|
647 |
</form>
|
|
|
|
|
|
|
648 |
</div> <!-- .wcml-section -->
|
649 |
<input type="hidden" id="wcml_warn_message" value="<?php esc_attr_e('The changes you made will be lost if you navigate away from this page.','wpml-wcml');?>"/>
|
650 |
+
<input type="hidden" id="wcml_warn_disable_language_massage" value="<?php esc_attr_e('At least one currency must be enabled for this language!','wpml-wcml');?>"/>
|
651 |
<div class="troubleshoot_link_block">
|
652 |
<a href="admin.php?page=<?php echo basename(WCML_PLUGIN_PATH) ?>/menu/sub/troubleshooting.php"><?php _e('Troubleshooting page','wpml-wcml'); ?></a>
|
653 |
</div>
|
menu/sub/troubleshooting.php
CHANGED
@@ -6,6 +6,7 @@ if(get_option('wcml_products_to_sync') === false ){
|
|
6 |
|
7 |
$prod_with_variations = $woocommerce_wpml->troubleshooting->wcml_count_products_with_variations();
|
8 |
$prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
|
9 |
?>
|
10 |
<div class="wrap wcml_trblsh">
|
11 |
<div id="icon-wpml" class="icon32"><br /></div>
|
@@ -40,11 +41,21 @@ $prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
40 |
</label>
|
41 |
</li>
|
42 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
<li>
|
44 |
<button type="button" class="button-secondary" id="wcml_trbl"><?php _e('Start', 'wpml-wcml') ?></button>
|
45 |
<input id="count_prod_variat" type="hidden" value="<?php echo $prod_with_variations; ?>"/>
|
46 |
<input id="count_prod" type="hidden" value="<?php echo $prod_count; ?>"/>
|
|
|
47 |
<input id="sync_galerry_page" type="hidden" value="0"/>
|
|
|
48 |
<span class="wcml_spinner"></span>
|
49 |
</li>
|
50 |
</ul>
|
@@ -65,6 +76,8 @@ $prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
65 |
sync_variations();
|
66 |
}else if(jQuery('#wcml_sync_gallery_images').is(':checked')){
|
67 |
sync_product_gallery();
|
|
|
|
|
68 |
}
|
69 |
});
|
70 |
});
|
@@ -86,6 +99,8 @@ $prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
86 |
sync_variations();
|
87 |
}else if(jQuery('#wcml_sync_gallery_images').is(':checked')){
|
88 |
sync_product_gallery();
|
|
|
|
|
89 |
}
|
90 |
}
|
91 |
});
|
@@ -106,6 +121,8 @@ $prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
106 |
});
|
107 |
if(jQuery('#wcml_sync_gallery_images').is(':checked')){
|
108 |
sync_product_gallery();
|
|
|
|
|
109 |
}else{
|
110 |
jQuery('#wcml_trbl').removeAttr('disabled');
|
111 |
jQuery('.wcml_spinner').hide();
|
@@ -138,9 +155,13 @@ $prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
138 |
},
|
139 |
success: function(response) {
|
140 |
if(jQuery('#count_prod').val() == 0){
|
|
|
|
|
|
|
141 |
jQuery('#wcml_trbl').removeAttr('disabled');
|
142 |
jQuery('.wcml_spinner').hide();
|
143 |
jQuery('#wcml_trbl').next().fadeOut();
|
|
|
144 |
jQuery('.gallery_status').html(0);
|
145 |
}else{
|
146 |
var left = jQuery('#count_prod').val()-5;
|
@@ -156,4 +177,35 @@ $prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
|
156 |
}
|
157 |
});
|
158 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
</script>
|
6 |
|
7 |
$prod_with_variations = $woocommerce_wpml->troubleshooting->wcml_count_products_with_variations();
|
8 |
$prod_count = $woocommerce_wpml->troubleshooting->wcml_count_products();
|
9 |
+
$prod_categories_count = $woocommerce_wpml->troubleshooting->wcml_count_product_categories();
|
10 |
?>
|
11 |
<div class="wrap wcml_trblsh">
|
12 |
<div id="icon-wpml" class="icon32"><br /></div>
|
41 |
</label>
|
42 |
</li>
|
43 |
<?php endif; ?>
|
44 |
+
<li>
|
45 |
+
<label>
|
46 |
+
<input type="checkbox" id="wcml_sync_categories" />
|
47 |
+
<?php _e('Sync products categories (display type, thumbnail):', 'wpml-wcml') ?>
|
48 |
+
<span class="cat_status"><?php echo $prod_categories_count; ?></span> <span><?php _e('left', 'wpml-wcml') ?></span>
|
49 |
+
</label>
|
50 |
+
|
51 |
+
</li>
|
52 |
<li>
|
53 |
<button type="button" class="button-secondary" id="wcml_trbl"><?php _e('Start', 'wpml-wcml') ?></button>
|
54 |
<input id="count_prod_variat" type="hidden" value="<?php echo $prod_with_variations; ?>"/>
|
55 |
<input id="count_prod" type="hidden" value="<?php echo $prod_count; ?>"/>
|
56 |
+
<input id="count_categories" type="hidden" value="<?php echo $prod_categories_count; ?>"/>
|
57 |
<input id="sync_galerry_page" type="hidden" value="0"/>
|
58 |
+
<input id="sync_category_page" type="hidden" value="0"/>
|
59 |
<span class="wcml_spinner"></span>
|
60 |
</li>
|
61 |
</ul>
|
76 |
sync_variations();
|
77 |
}else if(jQuery('#wcml_sync_gallery_images').is(':checked')){
|
78 |
sync_product_gallery();
|
79 |
+
}else if(jQuery('#wcml_sync_categories').is(':checked')){
|
80 |
+
sync_product_categories();
|
81 |
}
|
82 |
});
|
83 |
});
|
99 |
sync_variations();
|
100 |
}else if(jQuery('#wcml_sync_gallery_images').is(':checked')){
|
101 |
sync_product_gallery();
|
102 |
+
}else if(jQuery('#wcml_sync_categories').is(':checked')){
|
103 |
+
sync_product_categories();
|
104 |
}
|
105 |
}
|
106 |
});
|
121 |
});
|
122 |
if(jQuery('#wcml_sync_gallery_images').is(':checked')){
|
123 |
sync_product_gallery();
|
124 |
+
}else if(jQuery('#wcml_sync_categories').is(':checked')){
|
125 |
+
sync_product_categories();
|
126 |
}else{
|
127 |
jQuery('#wcml_trbl').removeAttr('disabled');
|
128 |
jQuery('.wcml_spinner').hide();
|
155 |
},
|
156 |
success: function(response) {
|
157 |
if(jQuery('#count_prod').val() == 0){
|
158 |
+
if(jQuery('#wcml_sync_categories').is(':checked')){
|
159 |
+
sync_product_categories();
|
160 |
+
}else{
|
161 |
jQuery('#wcml_trbl').removeAttr('disabled');
|
162 |
jQuery('.wcml_spinner').hide();
|
163 |
jQuery('#wcml_trbl').next().fadeOut();
|
164 |
+
}
|
165 |
jQuery('.gallery_status').html(0);
|
166 |
}else{
|
167 |
var left = jQuery('#count_prod').val()-5;
|
177 |
}
|
178 |
});
|
179 |
}
|
180 |
+
|
181 |
+
function sync_product_categories(){
|
182 |
+
jQuery.ajax({
|
183 |
+
type : "post",
|
184 |
+
url : ajaxurl,
|
185 |
+
data : {
|
186 |
+
action: "trbl_sync_categories",
|
187 |
+
wcml_nonce: "<?php echo wp_create_nonce('trbl_sync_categories'); ?>",
|
188 |
+
page: jQuery('#sync_category_page').val()
|
189 |
+
},
|
190 |
+
success: function(response) {
|
191 |
+
if(jQuery('#count_categories').val() == 0){
|
192 |
+
jQuery('#wcml_trbl').removeAttr('disabled');
|
193 |
+
jQuery('.wcml_spinner').hide();
|
194 |
+
jQuery('#wcml_trbl').next().fadeOut();
|
195 |
+
jQuery('.cat_status').html(0);
|
196 |
+
}else{
|
197 |
+
var left = jQuery('#count_categories').val()-5;
|
198 |
+
if(left < 0 ){
|
199 |
+
left = 0;
|
200 |
+
}else{
|
201 |
+
jQuery('#sync_category_page').val(parseInt(jQuery('#sync_category_page').val())+1)
|
202 |
+
}
|
203 |
+
jQuery('.cat_status').html(left);
|
204 |
+
jQuery('#count_categories').val(left);
|
205 |
+
sync_product_categories();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
});
|
209 |
+
}
|
210 |
+
|
211 |
</script>
|
menu/sub/variations_box.php
CHANGED
@@ -34,23 +34,39 @@
|
|
34 |
<tr>
|
35 |
<td><?php _e('Download URL','wpml-wcml'); ?></td>
|
36 |
<?php foreach($template_data['all_variations_ids'] as $variation_id): $file_paths = ''; ?>
|
37 |
-
<?php if(
|
38 |
echo '<td></td>';
|
39 |
continue;
|
40 |
}
|
41 |
-
if(get_post_meta($variation_id,'_downloadable',true) == 'yes'):
|
42 |
-
|
|
|
|
|
|
|
43 |
foreach($file_paths_array as $trn_file_paths){
|
44 |
$file_paths = $file_paths ? $file_paths . "\n" .$trn_file_paths : $trn_file_paths;
|
45 |
}
|
46 |
-
|
47 |
-
<td>
|
48 |
-
<?php if($template_data['original']): ?>
|
49 |
<textarea value="<?php echo $file_paths; ?>" class="wcml_file_paths_textarea" disabled="disabled"><?php echo $file_paths; ?></textarea>
|
50 |
<?php else: ?>
|
51 |
<textarea value="<?php echo $file_paths; ?>" name='<?php echo 'variations_file_paths['.$variation_id.']'; ?>' class="wcml_file_paths_textarea" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"><?php echo $file_paths; ?></textarea>
|
52 |
<button type="button" class="button-secondary wcml_file_paths"><?php _e('Choose a file', 'wpml-wcml') ?></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
<?php endif; ?>
|
|
|
|
|
|
|
54 |
</td>
|
55 |
<?php else: ?>
|
56 |
<td><?php _e('Variation is not downloadable','wpml-wcml'); ?></td>
|
34 |
<tr>
|
35 |
<td><?php _e('Download URL','wpml-wcml'); ?></td>
|
36 |
<?php foreach($template_data['all_variations_ids'] as $variation_id): $file_paths = ''; ?>
|
37 |
+
<?php if(isset($template_data['all_file_paths'][$variation_id]['not_translated'])){
|
38 |
echo '<td></td>';
|
39 |
continue;
|
40 |
}
|
41 |
+
if(get_post_meta($variation_id,'_downloadable',true) == 'yes'): ?>
|
42 |
+
<td>
|
43 |
+
<?php if(version_compare(preg_replace('#-(.+)$#', '', $woocommerce->version), '2.1', '<')){
|
44 |
+
$file_paths_array = maybe_unserialize($template_data['all_file_paths'][$variation_id]['value']);
|
45 |
+
if($file_paths_array)
|
46 |
foreach($file_paths_array as $trn_file_paths){
|
47 |
$file_paths = $file_paths ? $file_paths . "\n" .$trn_file_paths : $trn_file_paths;
|
48 |
}
|
49 |
+
if($template_data['original']): ?>
|
|
|
|
|
50 |
<textarea value="<?php echo $file_paths; ?>" class="wcml_file_paths_textarea" disabled="disabled"><?php echo $file_paths; ?></textarea>
|
51 |
<?php else: ?>
|
52 |
<textarea value="<?php echo $file_paths; ?>" name='<?php echo 'variations_file_paths['.$variation_id.']'; ?>' class="wcml_file_paths_textarea" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"><?php echo $file_paths; ?></textarea>
|
53 |
<button type="button" class="button-secondary wcml_file_paths"><?php _e('Choose a file', 'wpml-wcml') ?></button>
|
54 |
+
<?php endif;
|
55 |
+
}else{
|
56 |
+
for($i=0;$i<$template_data['all_file_paths']['count'];$i++): ?>
|
57 |
+
<?php if($template_data['original']): ?>
|
58 |
+
<input type="text" value="<?php echo $template_data['all_file_paths'][$variation_id][$i]['label']; ?>" class="" disabled="disabled">
|
59 |
+
<input type="text" value="<?php echo $template_data['all_file_paths'][$variation_id][$i]['value']; ?>" class="" disabled="disabled">
|
60 |
+
<?php else: ?>
|
61 |
+
<div>
|
62 |
+
<input type="text" value="<?php echo isset($template_data['all_file_paths'][$variation_id][$i])?$template_data['all_file_paths'][$variation_id][$i]['label']:''; ?>" name='<?php echo 'variations_file_paths['.$variation_id.']['.$i.'][name]'; ?>' class="wcml_file_paths_name" placeholder="<?php esc_attr_e('Enter translation for name', 'wpml-wcml') ?>">
|
63 |
+
<input type="text" value="<?php echo isset($template_data['all_file_paths'][$variation_id][$i])?$template_data['all_file_paths'][$variation_id][$i]['value']:''; ?>" name='<?php echo 'variations_file_paths['.$variation_id.']['.$i.'][file]'; ?>' class="wcml_file_paths_file" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"/>
|
64 |
+
<button type="button" class="button-secondary wcml_file_paths_button"><?php _e('Choose a file', 'wpml-wcml') ?></button>
|
65 |
+
</div>
|
66 |
<?php endif; ?>
|
67 |
+
<?php endfor; ?>
|
68 |
+
<?php }
|
69 |
+
?>
|
70 |
</td>
|
71 |
<?php else: ?>
|
72 |
<td><?php _e('Variation is not downloadable','wpml-wcml'); ?></td>
|
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: 3.
|
8 |
-
Stable tag: 3.
|
9 |
|
10 |
Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
|
11 |
|
@@ -15,7 +15,7 @@ This 'glue' plugin makes it possible to run fully multilingual e-commerce sites
|
|
15 |
|
16 |
= Features =
|
17 |
|
18 |
-
* Lets you different kinds of WooCommerce product types
|
19 |
* Central management for translating product categories, tags and custom attributes
|
20 |
* Automatically synchronizes product variations and images
|
21 |
* Keeps the same language through the checkout process
|
@@ -43,7 +43,7 @@ You will also need [WPML](http://wpml.org), together with the String Translation
|
|
43 |
|
44 |
WooCommerce Multilingual checks that the following versions of WPML and its components are active:
|
45 |
|
46 |
-
* WPML Multilingual CMS - 3.
|
47 |
* WPML String Translation - 2.0
|
48 |
* WPML Translation Managenet - 1.9
|
49 |
* WPML Media - 2.1
|
@@ -77,6 +77,61 @@ In order for the checkout and store pages to appear translated, you need to crea
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 3.2.1 =
|
81 |
* Fixed bug related to product category urls translaiton
|
82 |
* Fixed bug related to back-compatibility with WooCommerce 2.0.20
|
@@ -111,7 +166,7 @@ In order for the checkout and store pages to appear translated, you need to crea
|
|
111 |
* Fixed bug: language names not localized on products editor page
|
112 |
* Fixed bug: Can't set "Custom post type" to translate
|
113 |
* Fixed bug: Translation fields not visible - In certain circumstances (e.g. search) the translation fields corresponding to the translated languages were missing
|
114 |
-
* Fixed alignment for
|
115 |
* Fixed bug: Default selection not copied to duplicate products
|
116 |
* Fixed bug: Price doesn't change when change language on the cart page when set "I will manage the pricing in each currency myself"
|
117 |
* Resolved one compatibility issue with Woosidebars
|
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: 3.9
|
8 |
+
Stable tag: 3.3
|
9 |
|
10 |
Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
|
11 |
|
15 |
|
16 |
= Features =
|
17 |
|
18 |
+
* Lets you translate different kinds of WooCommerce product types
|
19 |
* Central management for translating product categories, tags and custom attributes
|
20 |
* Automatically synchronizes product variations and images
|
21 |
* Keeps the same language through the checkout process
|
43 |
|
44 |
WooCommerce Multilingual checks that the following versions of WPML and its components are active:
|
45 |
|
46 |
+
* WPML Multilingual CMS - 3.1.5
|
47 |
* WPML String Translation - 2.0
|
48 |
* WPML Translation Managenet - 1.9
|
49 |
* WPML Media - 2.1
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 3.3 =
|
81 |
+
* Performance improvements: optimized database queries
|
82 |
+
* Support rounding rules for converted prices
|
83 |
+
* More advanced GUI for Multi-currency options
|
84 |
+
* GUI for currency switchers (including widget)
|
85 |
+
* Added option to synchronize product category display type & thumbnail
|
86 |
+
* Performance improvement for WCML_Terms::translate_category_base (avoid switching locales)
|
87 |
+
* Send admin notifications to admin default language
|
88 |
+
* Dependencies update: WooCommerce Multilingual requires WPML 3.1.5
|
89 |
+
* Set language information for existing products when installing WCML the first time.
|
90 |
+
* Do not allow disabling all currencies for a language
|
91 |
+
* Removed 'clean up test content' and 'send to translation' dropdown on products editor page
|
92 |
+
* Message about overwritten settings in wpml-config made more explicit
|
93 |
+
* Lock 'Default variation' select field in product translations
|
94 |
+
* After change shipping method on cart page we will see not translated strings
|
95 |
+
* Fixed bug related to shipping cost calculation in multi-currency mode
|
96 |
+
* With php magic quotes on, products translations with quotes have backslashes
|
97 |
+
* Bug related to translation of grouped products � simple product not showing up on front end
|
98 |
+
* Stock actions on the order page don't work correct with translated products
|
99 |
+
* For Orders save attributes in default language and display them on order page in admin language
|
100 |
+
* Attribute Label appearing untranslated in backend order
|
101 |
+
* Memory issues on the Products tab when we have a large number of products
|
102 |
+
* 'product-category' not translated in the default language.
|
103 |
+
* 'WCML_Products' does not have a method 'translated_cart_item_name'
|
104 |
+
* Order completed emails sent in default currency
|
105 |
+
* Language suffix (e.g. @en) not hidden for product attributes on the front end
|
106 |
+
* Quick edit functionality issues fixed
|
107 |
+
* Fixed 'Call to undefined method WC_Session_Handler::get()'
|
108 |
+
* Fatal error when updating the order status to 'complete'
|
109 |
+
* Currency is not converted when you switch language until you refresh the page.
|
110 |
+
* �Super Admin� not able to see the WCML menu
|
111 |
+
* Checkout validation errors in default language instead of user language
|
112 |
+
* Fixes for compatibility with Tab manager: Can't translate �Additional Information� tab title
|
113 |
+
* Bug: SEO title & meta description changed to original
|
114 |
+
* Bug: 404 on 'view my order' on secondary language using 'language name added as a parameter'
|
115 |
+
* Bug: Permalink placeholders appear translated when using default language different than English
|
116 |
+
* Fixes for compatibility with Table Rate shipping: shipping classes not decoded correctly in multi-currency mode
|
117 |
+
* Bug: 'show all products' link on WCML products page points to the wrong page � no products
|
118 |
+
* Bug fix: product page redirecting to homepage when the product post type slug was identical in different languages and 'language added as a parameter' was set
|
119 |
+
* Bug fixes related to File paths functionality (WooComemrce 2.1.x)
|
120 |
+
* Bug: Product parents not synced between translations (grouped products)
|
121 |
+
* Bug: Grouped products title incomplete
|
122 |
+
* Bug: Db Error when saving translation of variable products with custom attributes
|
123 |
+
* Bug: WooCommerce translated product attributes with spaces not showing
|
124 |
+
* Bug: Deactivated currency still appears if you maintain the default currency for that language to 'Keep'.
|
125 |
+
* Bug: Incorrect shipping value on translated page
|
126 |
+
* Bug: Reports for products including only products in the current language (WooCommerce 2.1.x)
|
127 |
+
* Bug: WooCommerce translated product attributes with spaces not showing
|
128 |
+
* Bug: Problems creating translations for shop pages when existing pages were trashed
|
129 |
+
* Bug fix: Fatal error when Multi-currency is not enabled and 'Table Rate Shipping' plugin is active
|
130 |
+
* Fixed bug in compatibility with Tab Manager
|
131 |
+
* Bug fix: Cart strings falling to default language after updating chosen shipping method
|
132 |
+
* Bug fix: Reports not including selected product/category translations
|
133 |
+
|
134 |
+
|
135 |
= 3.2.1 =
|
136 |
* Fixed bug related to product category urls translaiton
|
137 |
* Fixed bug related to back-compatibility with WooCommerce 2.0.20
|
166 |
* Fixed bug: language names not localized on products editor page
|
167 |
* Fixed bug: Can't set "Custom post type" to translate
|
168 |
* Fixed bug: Translation fields not visible - In certain circumstances (e.g. search) the translation fields corresponding to the translated languages were missing
|
169 |
+
* Fixed alignment for 'Update/Save' button in the products translation editor
|
170 |
* Fixed bug: Default selection not copied to duplicate products
|
171 |
* Fixed bug: Price doesn't change when change language on the cart page when set "I will manage the pricing in each currency myself"
|
172 |
* Resolved one compatibility issue with Woosidebars
|
woocommerce_wpml.class.php
CHANGED
@@ -14,7 +14,6 @@ class woocommerce_wpml {
|
|
14 |
|
15 |
function __construct(){
|
16 |
add_action('plugins_loaded', array($this, 'init'), 2);
|
17 |
-
|
18 |
}
|
19 |
|
20 |
function init(){
|
@@ -34,10 +33,12 @@ class woocommerce_wpml {
|
|
34 |
global $sitepress,$pagenow;
|
35 |
|
36 |
if($this->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
|
37 |
-
|
38 |
-
$
|
39 |
require_once WCML_PLUGIN_PATH . '/inc/multi-currency.class.php';
|
40 |
-
$
|
|
|
|
|
41 |
}else{
|
42 |
add_shortcode('currency_switcher', '__return_empty_string');
|
43 |
}
|
@@ -51,6 +52,12 @@ class woocommerce_wpml {
|
|
51 |
$this->compatibility = new WCML_Compatibility();
|
52 |
$this->strings = new WCML_WC_Strings;
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
include WCML_PLUGIN_PATH . '/inc/woocommerce-2.0-backward-compatibility.php';
|
55 |
|
56 |
new WCML_Ajax_Setup;
|
@@ -85,17 +92,19 @@ class woocommerce_wpml {
|
|
85 |
remove_action( 'wp_before_admin_bar_render', array($sitepress, 'admin_language_switcher') );
|
86 |
}
|
87 |
|
88 |
-
if((($pagenow == 'post.php' && isset($_GET['post']) && get_post_type($_GET['post']) == 'product') || ($pagenow == 'post-new.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'product'))
|
89 |
&& !$this->settings['trnsl_interface'] && isset($_GET['lang']) && $_GET['lang'] != $sitepress->get_default_language()){
|
90 |
add_action('init', array($this, 'load_lock_fields_js'));
|
91 |
add_action( 'admin_footer', array($this,'hidden_label'));
|
92 |
}
|
|
|
|
|
93 |
|
94 |
}
|
95 |
|
96 |
function translate_product_slug(){
|
97 |
global $sitepress, $wpdb,$woocommerce, $sitepress_settings;
|
98 |
-
|
99 |
if(!defined('WOOCOMMERCE_VERSION') || (!isset($GLOBALS['ICL_Pro_Translation']) || is_null($GLOBALS['ICL_Pro_Translation']))){
|
100 |
return;
|
101 |
}
|
@@ -110,7 +119,7 @@ class woocommerce_wpml {
|
|
110 |
}
|
111 |
|
112 |
if(isset($sitepress_settings['posts_slug_translation']['types'])){
|
113 |
-
|
114 |
}
|
115 |
|
116 |
if(!empty($permalinks['product_base']) && isset($sitepress_settings['posts_slug_translation']['types'][$slug])){
|
@@ -133,13 +142,12 @@ class woocommerce_wpml {
|
|
133 |
$string_id = icl_register_string('WordPress', 'URL slug: ' . $slug, $slug);
|
134 |
}
|
135 |
foreach($active_languages as $language){
|
136 |
-
if($
|
137 |
$sitepress->switch_lang($language['code']);
|
138 |
-
$text = 'product';
|
139 |
$context = 'slug';
|
140 |
$domain = 'woocommerce';
|
141 |
$woocommerce->load_plugin_textdomain();
|
142 |
-
$string_text = _x( $
|
143 |
unload_textdomain($domain);
|
144 |
icl_add_string_translation($string_id,$language['code'],$string_text,ICL_STRING_TRANSLATION_COMPLETE,null);
|
145 |
$sitepress->switch_lang($current_language);
|
@@ -167,7 +175,8 @@ class woocommerce_wpml {
|
|
167 |
'is_term_order_synced' => 0,
|
168 |
'enable_multi_currency' => WCML_MULTI_CURRENCIES_DISABLED,
|
169 |
'dismiss_doc_main' => 0,
|
170 |
-
'trnsl_interface' => 1
|
|
|
171 |
);
|
172 |
|
173 |
if(empty($this->settings)){
|
@@ -190,6 +199,18 @@ class woocommerce_wpml {
|
|
190 |
update_option('_wcml_settings', $this->settings);
|
191 |
}
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
function load_locale(){
|
194 |
load_plugin_textdomain('wpml-wcml', false, WCML_LOCALE_PATH);
|
195 |
}
|
@@ -223,6 +244,8 @@ class woocommerce_wpml {
|
|
223 |
|
224 |
self::set_up_capabilities();
|
225 |
|
|
|
|
|
226 |
$this->settings['set_up'] = 1;
|
227 |
$this->update_settings();
|
228 |
|
@@ -236,9 +259,17 @@ class woocommerce_wpml {
|
|
236 |
public static function set_up_capabilities(){
|
237 |
|
238 |
$role = get_role( 'administrator' );
|
239 |
-
$role
|
240 |
-
|
|
|
|
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
$super_admins = get_super_admins();
|
243 |
foreach ($super_admins as $admin) {
|
244 |
$user = new WP_User( $admin );
|
@@ -253,6 +284,40 @@ class woocommerce_wpml {
|
|
253 |
|
254 |
}
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
function menu(){
|
257 |
if($this->dependencies->check()){
|
258 |
$top_page = apply_filters('icl_menu_main_page', basename(ICL_PLUGIN_PATH) .'/menu/languages.php');
|
@@ -312,7 +377,7 @@ class woocommerce_wpml {
|
|
312 |
}
|
313 |
wp_register_style('wpml-wcml', WCML_PLUGIN_URL . '/assets/css/management.css', array('toolset-font-awesome'), WCML_VERSION);
|
314 |
wp_register_style('cleditor', WCML_PLUGIN_URL . '/assets/css/jquery.cleditor.css', null, WCML_VERSION);
|
315 |
-
wp_register_script('wcml-tm-scripts', WCML_PLUGIN_URL . '/assets/js/scripts.js', array('jquery'), WCML_VERSION);
|
316 |
wp_register_script('jquery-cookie', WCML_PLUGIN_URL . '/assets/js/jquery.cookie.js', array('jquery'), WCML_VERSION);
|
317 |
wp_register_script('cleditor', WCML_PLUGIN_URL . '/assets/js/jquery.cleditor.min.js', array('jquery'), WCML_VERSION);
|
318 |
|
@@ -327,6 +392,14 @@ class woocommerce_wpml {
|
|
327 |
wp_enqueue_script('cleditor');
|
328 |
wp_enqueue_script('suggest');
|
329 |
wp_enqueue_script('wp-pointer');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
}
|
331 |
}
|
332 |
|
@@ -350,13 +423,26 @@ class woocommerce_wpml {
|
|
350 |
<?php }
|
351 |
}
|
352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
function documentation_links(){
|
354 |
global $post, $pagenow;
|
355 |
|
356 |
$get_post_type = get_post_type(@$post->ID);
|
357 |
|
358 |
if($get_post_type == 'product' && $pagenow == 'edit.php'){
|
359 |
-
$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="http://wpml.org/documentation/related-projects/woocommerce-multilingual
|
360 |
__('How to translate products', 'sitepress') . '<\/a>' . '<\/span>'
|
361 |
?>
|
362 |
<script type="text/javascript">
|
@@ -369,7 +455,7 @@ class woocommerce_wpml {
|
|
369 |
$pos = strpos($_GET['taxonomy'], 'pa_');
|
370 |
|
371 |
if($pos !== false && $pagenow == 'edit-tags.php'){
|
372 |
-
$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="http://wpml.org/documentation/related-projects/woocommerce-multilingual
|
373 |
__('How to translate attributes', 'sitepress') . '<\/a>' . '<\/span><br \/><br \/>'
|
374 |
?>
|
375 |
<script type="text/javascript">
|
@@ -381,7 +467,7 @@ class woocommerce_wpml {
|
|
381 |
|
382 |
if(isset($_GET['taxonomy']) && $_GET['taxonomy'] == 'product_cat'){
|
383 |
|
384 |
-
$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="http://wpml.org/documentation/related-projects/woocommerce-multilingual
|
385 |
__('How to translate product categories', 'sitepress') . '<\/a>' . '<\/span><br \/><br \/>'
|
386 |
?>
|
387 |
<script type="text/javascript">
|
@@ -407,7 +493,7 @@ class woocommerce_wpml {
|
|
407 |
<?php _e('Would you like to see a quick overview?', 'wpml-wcml'); ?>
|
408 |
</p>
|
409 |
<p>
|
410 |
-
<a class="button-primary" href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/" target="_blank"><?php _e('Learn how to turn your e-commerce site multilingual', 'wpml-wcml') ?></a>
|
411 |
<a class="button-secondary" href="<?php echo $url; ?>"><?php _e('Dismiss', 'wpml-wcml') ?></a>
|
412 |
</p>
|
413 |
</div>
|
14 |
|
15 |
function __construct(){
|
16 |
add_action('plugins_loaded', array($this, 'init'), 2);
|
|
|
17 |
}
|
18 |
|
19 |
function init(){
|
33 |
global $sitepress,$pagenow;
|
34 |
|
35 |
if($this->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
|
36 |
+
require_once WCML_PLUGIN_PATH . '/inc/multi-currency-support.class.php';
|
37 |
+
$this->multi_currency_support = new WCML_Multi_Currency_Support;
|
38 |
require_once WCML_PLUGIN_PATH . '/inc/multi-currency.class.php';
|
39 |
+
$this->multi_currency = new WCML_WC_MultiCurrency;
|
40 |
+
require_once WCML_PLUGIN_PATH . '/inc/currency-switcher.class.php';
|
41 |
+
$this->currency_switcher = new WCML_CurrencySwitcher;
|
42 |
}else{
|
43 |
add_shortcode('currency_switcher', '__return_empty_string');
|
44 |
}
|
52 |
$this->compatibility = new WCML_Compatibility();
|
53 |
$this->strings = new WCML_WC_Strings;
|
54 |
|
55 |
+
|
56 |
+
if(isset($_GET['page']) && $_GET['page'] == 'wc-reports'){
|
57 |
+
require_once WCML_PLUGIN_PATH . '/inc/reports.class.php';
|
58 |
+
$this->reports = new WCML_Reports;
|
59 |
+
}
|
60 |
+
|
61 |
include WCML_PLUGIN_PATH . '/inc/woocommerce-2.0-backward-compatibility.php';
|
62 |
|
63 |
new WCML_Ajax_Setup;
|
92 |
remove_action( 'wp_before_admin_bar_render', array($sitepress, 'admin_language_switcher') );
|
93 |
}
|
94 |
|
95 |
+
if((($pagenow == 'post.php' && isset($_GET['post']) && get_post_type($_GET['post']) == 'product') || (($pagenow == 'post-new.php' || $pagenow == 'edit.php') && isset($_GET['post_type']) && $_GET['post_type'] == 'product'))
|
96 |
&& !$this->settings['trnsl_interface'] && isset($_GET['lang']) && $_GET['lang'] != $sitepress->get_default_language()){
|
97 |
add_action('init', array($this, 'load_lock_fields_js'));
|
98 |
add_action( 'admin_footer', array($this,'hidden_label'));
|
99 |
}
|
100 |
+
|
101 |
+
add_action('wp_ajax_wcml_update_setting_ajx', array($this, 'update_setting_ajx'));
|
102 |
|
103 |
}
|
104 |
|
105 |
function translate_product_slug(){
|
106 |
global $sitepress, $wpdb,$woocommerce, $sitepress_settings;
|
107 |
+
|
108 |
if(!defined('WOOCOMMERCE_VERSION') || (!isset($GLOBALS['ICL_Pro_Translation']) || is_null($GLOBALS['ICL_Pro_Translation']))){
|
109 |
return;
|
110 |
}
|
119 |
}
|
120 |
|
121 |
if(isset($sitepress_settings['posts_slug_translation']['types'])){
|
122 |
+
$iclsettings['posts_slug_translation']['types'] = $sitepress_settings['posts_slug_translation']['types'];
|
123 |
}
|
124 |
|
125 |
if(!empty($permalinks['product_base']) && isset($sitepress_settings['posts_slug_translation']['types'][$slug])){
|
142 |
$string_id = icl_register_string('WordPress', 'URL slug: ' . $slug, $slug);
|
143 |
}
|
144 |
foreach($active_languages as $language){
|
145 |
+
if($language['code'] != $sitepress_settings['st']['strings_language']){
|
146 |
$sitepress->switch_lang($language['code']);
|
|
|
147 |
$context = 'slug';
|
148 |
$domain = 'woocommerce';
|
149 |
$woocommerce->load_plugin_textdomain();
|
150 |
+
$string_text = _x( $slug, $context, $domain );
|
151 |
unload_textdomain($domain);
|
152 |
icl_add_string_translation($string_id,$language['code'],$string_text,ICL_STRING_TRANSLATION_COMPLETE,null);
|
153 |
$sitepress->switch_lang($current_language);
|
175 |
'is_term_order_synced' => 0,
|
176 |
'enable_multi_currency' => WCML_MULTI_CURRENCIES_DISABLED,
|
177 |
'dismiss_doc_main' => 0,
|
178 |
+
'trnsl_interface' => 1,
|
179 |
+
'currency_options' => array()
|
180 |
);
|
181 |
|
182 |
if(empty($this->settings)){
|
199 |
update_option('_wcml_settings', $this->settings);
|
200 |
}
|
201 |
|
202 |
+
function update_setting_ajx(){
|
203 |
+
$data = $_POST;
|
204 |
+
$error = '';
|
205 |
+
$html = '';
|
206 |
+
if($data['nonce'] == wp_create_nonce('woocommerce_multilingual')){
|
207 |
+
$this->settings[$data['setting']] = $data['value'];
|
208 |
+
$this->update_settings();
|
209 |
+
}
|
210 |
+
echo json_encode(array('html' => $html, 'error'=> $error));
|
211 |
+
exit;
|
212 |
+
}
|
213 |
+
|
214 |
function load_locale(){
|
215 |
load_plugin_textdomain('wpml-wcml', false, WCML_LOCALE_PATH);
|
216 |
}
|
244 |
|
245 |
self::set_up_capabilities();
|
246 |
|
247 |
+
$this->set_language_information();
|
248 |
+
|
249 |
$this->settings['set_up'] = 1;
|
250 |
$this->update_settings();
|
251 |
|
259 |
public static function set_up_capabilities(){
|
260 |
|
261 |
$role = get_role( 'administrator' );
|
262 |
+
if($role){
|
263 |
+
$role->add_cap( 'wpml_manage_woocommerce_multilingual' );
|
264 |
+
$role->add_cap( 'wpml_operate_woocommerce_multilingual' );
|
265 |
+
}
|
266 |
|
267 |
+
$role = get_role( 'super_admin' );
|
268 |
+
if($role){
|
269 |
+
$role->add_cap( 'wpml_manage_woocommerce_multilingual' );
|
270 |
+
$role->add_cap( 'wpml_operate_woocommerce_multilingual' );
|
271 |
+
}
|
272 |
+
|
273 |
$super_admins = get_super_admins();
|
274 |
foreach ($super_admins as $admin) {
|
275 |
$user = new WP_User( $admin );
|
284 |
|
285 |
}
|
286 |
|
287 |
+
function set_language_information(){
|
288 |
+
global $sitepress,$wpdb;
|
289 |
+
|
290 |
+
$def_lang = $sitepress->get_default_language();
|
291 |
+
//set language info for products
|
292 |
+
$products = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type = 'product' AND post_status <> 'auto-draft'");
|
293 |
+
foreach($products as $product){
|
294 |
+
$exist = $sitepress->get_language_for_element($product->ID,'post_product');
|
295 |
+
if(!$exist)
|
296 |
+
$sitepress->set_element_language_details($product->ID, 'post_product',false,$def_lang);
|
297 |
+
}
|
298 |
+
|
299 |
+
//set language info for taxonomies
|
300 |
+
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_cat'");
|
301 |
+
foreach($terms as $term){
|
302 |
+
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_cat');
|
303 |
+
if(!$exist)
|
304 |
+
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_cat',false,$def_lang);
|
305 |
+
}
|
306 |
+
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_tag'");
|
307 |
+
foreach($terms as $term){
|
308 |
+
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_tag');
|
309 |
+
if(!$exist)
|
310 |
+
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_tag',false,$def_lang);
|
311 |
+
}
|
312 |
+
|
313 |
+
$terms = $wpdb->get_results("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'product_shipping_class'");
|
314 |
+
foreach($terms as $term){
|
315 |
+
$exist = $sitepress->get_language_for_element($term->term_taxonomy_id, 'tax_product_shipping_class');
|
316 |
+
if(!$exist)
|
317 |
+
$sitepress->set_element_language_details($term->term_taxonomy_id, 'tax_product_shipping_class',false,$def_lang);
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
function menu(){
|
322 |
if($this->dependencies->check()){
|
323 |
$top_page = apply_filters('icl_menu_main_page', basename(ICL_PLUGIN_PATH) .'/menu/languages.php');
|
377 |
}
|
378 |
wp_register_style('wpml-wcml', WCML_PLUGIN_URL . '/assets/css/management.css', array('toolset-font-awesome'), WCML_VERSION);
|
379 |
wp_register_style('cleditor', WCML_PLUGIN_URL . '/assets/css/jquery.cleditor.css', null, WCML_VERSION);
|
380 |
+
wp_register_script('wcml-tm-scripts', WCML_PLUGIN_URL . '/assets/js/scripts.js', array('jquery', 'jquery-ui-resizable'), WCML_VERSION);
|
381 |
wp_register_script('jquery-cookie', WCML_PLUGIN_URL . '/assets/js/jquery.cookie.js', array('jquery'), WCML_VERSION);
|
382 |
wp_register_script('cleditor', WCML_PLUGIN_URL . '/assets/js/jquery.cleditor.min.js', array('jquery'), WCML_VERSION);
|
383 |
|
392 |
wp_enqueue_script('cleditor');
|
393 |
wp_enqueue_script('suggest');
|
394 |
wp_enqueue_script('wp-pointer');
|
395 |
+
|
396 |
+
|
397 |
+
wp_localize_script('wcml-tm-scripts', 'wcml_settings',
|
398 |
+
array(
|
399 |
+
'nonce' => wp_create_nonce( 'woocommerce_multilingual' )
|
400 |
+
)
|
401 |
+
);
|
402 |
+
|
403 |
}
|
404 |
}
|
405 |
|
423 |
<?php }
|
424 |
}
|
425 |
|
426 |
+
function generate_tracking_link($link,$term=false,$content = false, $id = false){
|
427 |
+
$params = '?utm_source=wcml-admin&utm_medium=plugin&utm_term=';
|
428 |
+
$params .= $term?$term:'WPML';
|
429 |
+
$params .= '&utm_content=';
|
430 |
+
$params .= $content?$content:'required-plugins';
|
431 |
+
$params .= '&utm_campaign=WCML';
|
432 |
+
|
433 |
+
if($id){
|
434 |
+
$params .= $id;
|
435 |
+
}
|
436 |
+
return $link.$params;
|
437 |
+
}
|
438 |
+
|
439 |
function documentation_links(){
|
440 |
global $post, $pagenow;
|
441 |
|
442 |
$get_post_type = get_post_type(@$post->ID);
|
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">
|
455 |
$pos = strpos($_GET['taxonomy'], 'pa_');
|
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">
|
467 |
|
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">
|
493 |
<?php _e('Would you like to see a quick overview?', 'wpml-wcml'); ?>
|
494 |
</p>
|
495 |
<p>
|
496 |
+
<a class="button-primary" href="<?php echo $this->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/','woocommerce-multilingual','documentation'); ?>" target="_blank"><?php _e('Learn how to turn your e-commerce site multilingual', 'wpml-wcml') ?></a>
|
497 |
<a class="button-secondary" href="<?php echo $url; ?>"><?php _e('Dismiss', 'wpml-wcml') ?></a>
|
498 |
</p>
|
499 |
</div>
|
wpml-config.xml
CHANGED
@@ -6,7 +6,6 @@
|
|
6 |
<custom-field action="copy">_download_limit</custom-field>
|
7 |
<custom-field action="copy">_downloadable</custom-field>
|
8 |
<custom-field action="copy">_featured</custom-field>
|
9 |
-
<custom-field action="copy">_file_path</custom-field>
|
10 |
<custom-field action="copy">_manage_stock</custom-field>
|
11 |
<custom-field action="copy">_sale_price_dates_from</custom-field>
|
12 |
<custom-field action="copy">_sale_price_dates_to</custom-field>
|
@@ -38,6 +37,10 @@
|
|
38 |
<custom-field action="copy">_override_tab_layout</custom-field>
|
39 |
<custom-field action="translate">_product_tabs</custom-field>
|
40 |
<custom-field action="ignore">_wcml_custom_prices_status</custom-field>
|
|
|
|
|
|
|
|
|
41 |
</custom-fields>
|
42 |
<custom-types>
|
43 |
<custom-type translate="1">product</custom-type>
|
@@ -45,6 +48,7 @@
|
|
45 |
<custom-type translate="0">shop_coupon</custom-type>
|
46 |
<custom-type translate="0">shop_order</custom-type>
|
47 |
<custom-type translate="1">wc_product_tab</custom-type>
|
|
|
48 |
</custom-types>
|
49 |
<taxonomies>
|
50 |
<taxonomy translate="1">product_cat</taxonomy>
|
6 |
<custom-field action="copy">_download_limit</custom-field>
|
7 |
<custom-field action="copy">_downloadable</custom-field>
|
8 |
<custom-field action="copy">_featured</custom-field>
|
|
|
9 |
<custom-field action="copy">_manage_stock</custom-field>
|
10 |
<custom-field action="copy">_sale_price_dates_from</custom-field>
|
11 |
<custom-field action="copy">_sale_price_dates_to</custom-field>
|
37 |
<custom-field action="copy">_override_tab_layout</custom-field>
|
38 |
<custom-field action="translate">_product_tabs</custom-field>
|
39 |
<custom-field action="ignore">_wcml_custom_prices_status</custom-field>
|
40 |
+
<custom-field action="copy">_per_product_pricing_active</custom-field>
|
41 |
+
<custom-field action="copy">_product_addons</custom-field>
|
42 |
+
<custom-field action="copy">_product_addons_exclude_global</custom-field>
|
43 |
+
<custom-field action="copy">_pricing_rules</custom-field>
|
44 |
</custom-fields>
|
45 |
<custom-types>
|
46 |
<custom-type translate="1">product</custom-type>
|
48 |
<custom-type translate="0">shop_coupon</custom-type>
|
49 |
<custom-type translate="0">shop_order</custom-type>
|
50 |
<custom-type translate="1">wc_product_tab</custom-type>
|
51 |
+
<custom-type translate="0">global_product_addon</custom-type>
|
52 |
</custom-types>
|
53 |
<taxonomies>
|
54 |
<taxonomy translate="1">product_cat</taxonomy>
|
wpml-woocommerce.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php
|
2 |
/*
|
3 |
Plugin Name: WooCommerce Multilingual
|
4 |
Plugin URI: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
|
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: ICanLocalize
|
7 |
Author URI: http://wpml.org/
|
8 |
-
Version: 3.
|
9 |
*/
|
10 |
|
11 |
if(defined('WCML_VERSION')) return;
|
12 |
-
define('WCML_VERSION', '3.
|
13 |
define('WCML_PLUGIN_PATH', dirname(__FILE__));
|
14 |
define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
|
15 |
define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
|
1 |
+
<?php
|
2 |
/*
|
3 |
Plugin Name: WooCommerce Multilingual
|
4 |
Plugin URI: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
|
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: ICanLocalize
|
7 |
Author URI: http://wpml.org/
|
8 |
+
Version: 3.3
|
9 |
*/
|
10 |
|
11 |
if(defined('WCML_VERSION')) return;
|
12 |
+
define('WCML_VERSION', '3.3');
|
13 |
define('WCML_PLUGIN_PATH', dirname(__FILE__));
|
14 |
define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
|
15 |
define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
|