 marioG-45
|
Hi Dražen,
Okay Waiting for the solution.
Thanks
|
 marioG-45
|
Hi Dražen,
Any update regarding the variable product?
Thanks
|
 Dražen
Supporter
Languages:
English (English )
Timezone:
Europe/Zagreb (GMT+02:00)
|
Hello,
There were holidays and weekend in Europe, so most of the team was OFF, so it is taking a while.
I will update you when I have some news, should be today or tomorrow.
Regards,
Drazen
|
 marioG-45
|
Hi Dražen,
I hope you are doing well.
Okay I'm waiting for the response. I hope I'll get the solution asap.
Thanks
|
 Dražen
Supporter
Languages:
English (English )
Timezone:
Europe/Zagreb (GMT+02:00)
|
Hello,
For the label, you should additional hook that reuses your code for the label:
add_filter( 'wcml_custom_prices_strings', 'set_labels_for_price_fields', 10, 2 );
and for saving value, the data for the variation is saved in a separate value - _POST["_custom_variation_purchase_cost"][$code][$post_id].
So finally working code on test site looks like this:
add_filter( 'wcml_custom_prices_fields', 'add_custom_price_fields', 10, 2 );
function add_custom_price_fields( $fields, $product_id ) {
// Add a new custom price field
$fields[] = '_purchase_cost';
return $fields;
}
add_filter( 'wcml_custom_prices_strings', 'set_labels_for_price_fields', 10, 2 );
add_filter( 'wcml_custom_prices_fields_labels', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $labels, $product_id ){
// Edit the label of a custom price field
$labels[ '_purchase_cost' ] = __( 'Purchase cost', 'woocommerce-multilingual' );
return $labels;
}
add_filter( 'wcml_update_custom_prices_values', 'add_purchase_cost_to_custom_prices', 10, 3 );
function add_purchase_cost_to_custom_prices( $custom_prices, $code, $post_id ) {
$type = get_post_type($post_id);
if ( 'product' == $type ) {
$purchase_cost = get_post_meta($post_id, '_purchase_cost' . '_' . $code, true);
if (isset($_POST["_custom_variation_purchase_cost"][$code])) {
$purchase_cost = $_POST["_custom_purchase_cost"][$code];
}
} elseif ( 'product_variation' == $type ) {
$purchase_cost = get_post_meta($post_id, '_purchase_cost' . '_' . $code, true);
if (isset($_POST["_custom_variation_purchase_cost"][$code])) {
$purchase_cost = $_POST["_custom_variation_purchase_cost"][$code][$post_id];
}
}
$custom_prices['_purchase_cost'] = $purchase_cost;
return $custom_prices;
}
Regards,
Drazen
|
 marioG-45
|
Hi Dražen,
Thanks for the update.
I'll test above code tomorrow and let you know.
Thanks
|
 Dražen
Supporter
Languages:
English (English )
Timezone:
Europe/Zagreb (GMT+02:00)
|
Hello,
sure.
You are free to see the test site, where it works fine:
- hidden link
Regards,
Drazen
|
 marioG-45
|
Hi Dražen,
I have noticed that on the test site you installed the below plugins as well, which I think its necessary.
Plugins:-
1. WooCommerce Multilingual & Multicurrency
2. WPML Multilingual CMS
3. WPML String Translation
On my staging site I have just installed WooCommerce Multilingual & Multicurrency and
now I have installed rest of the two plugin as well.
But for now I just want to work on English language I don't want to add any other languages on the site. So if those two plugin is necessary in that case I want to add any other language on my site which I don't want to add.
So now what happen is if I can't add any other language on site my setup will stay remaining and i can't see that purchase cost field in product.
See the screenshot:-
1. hidden link
2. hidden link
So could you please check it and let me know on urgent basis.
If you are available for call then we will meet on google meet and discuss.
Thanks
|
 Dražen
Supporter
Languages:
English (English )
Timezone:
Europe/Zagreb (GMT+02:00)
|
Hello,
We do not provide support over the phone or similar, it is only via forum/chats.
As for other plugins, you do not need them if you are using only WooCommerce Multilingual & Multicurrency.
For custom code, you will probably need to further adjust it to your custom environment / approach, but as you can see in test site it works fine. You can use that working code as example, but if you need further adjustments to your website / code I am afraid we can not help with custom coding and custom debugging, it is out of scope of our support.
For custom coding you can use service of WPML contractors:
- https://wpml.org/contractors/
Hope this makes sense.
Regards,
Drazen
|
 marioG-45
|
Hello,
Yes but in your testing site you added the two languages.
Could you please create one more testing site and add only multi currency plugin and test it?
So I can show you what exactly happing.
Thanks
|
 Dražen
Supporter
Languages:
English (English )
Timezone:
Europe/Zagreb (GMT+02:00)
|
Hello,
I have already before my reply, disabled plugins and confirmed it works fine without extra plugins and with only WooCommerce Multilingual & Multicurrency.
You are free to check.
Regards,
Drazen
|
 marioG-45
|
Hello
Okay let me check and get back to you.
Thanks
|
 Dražen
Supporter
Languages:
English (English )
Timezone:
Europe/Zagreb (GMT+02:00)
|
Hello,
Sure, but as said before, maybe you have not understood my reply, it is already like that on the test website, and it works fine:
hidden link
You are free to check it out.
Regards,
Drazen
|
 marioG-45
|
Hello,
Okay sure let me check and get back to you.
Thanks
|
 marioG-45
|
Hello,
I have just review the testing site which you provided. In that site I have noticed that for default currency the purchase cost field is not coming why?
Screenshot:- hidden link
Could you please check it and let me know.
Thanks
|