This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | - | 9:00 – 18:00 | 9:00 – 18:00 | 9:00 – 18:00 | 9:00 – 18:00 | 9:00 – 18:00 |
- | - | - | - | - | - | - |
Supporter timezone: America/Lima (GMT-05:00)
This topic contains 15 replies, has 2 voices.
Last updated by mads-kronborgA 2 years, 5 months ago.
Assisted by: Andreas W..
Author | Posts |
---|---|
July 17, 2021 at 12:31 am #9219771 | |
mads-kronborgA |
I am trying to use the default rate exchange having multiple currencies on variable subscription product. I set one secondary language with a fixed sign-up fee and leave the remaining secondary fields untouched. Link to a page where the issue can be seen: I expected to see pricing with an exchange rate calculated sign-up fee when I select e.g. GBP or USD. Instead, I got price without any sign-up fee for GBP and USD. Attached image of the Variations currency configuration. |
July 17, 2021 at 8:12 pm #9222707 | |
mads-kronborgA |
Solved it myself by altering the sign_up_fee_filter in woocommerce-multilingual/compatibility/class-wcml-wc-subscriptions.php Do you see any complications? public function subscriptions_product_sign_up_fee_filter( $subscription_sign_up_fee, $product ) { if ( $product && wcml_is_multi_currency_on() ) { $currency = $this->woocommerce_wpml->multi_currency->get_client_currency(); if ( $currency !== wcml_get_woocommerce_currency_option() ) { $product_id = $product->get_id(); if( $product instanceof WC_Product_Variable_Subscription ){ $product_id = $product->get_meta( '_min_price_variation_id', true ); } $original_product_id = $this->woocommerce_wpml->products->get_original_product_id( $product_id ); $tmp = get_post_meta( $original_product_id, '_subscription_sign_up_fee_' . $currency, true ); if ( $tmp && get_post_meta( $original_product_id, '_wcml_custom_prices_status', true ) ) { $subscription_sign_up_fee = $tmp; } else { $subscription_sign_up_fee = apply_filters( 'wcml_raw_price_amount', $subscription_sign_up_fee ); } } } return $subscription_sign_up_fee; } |
July 18, 2021 at 4:02 am #9223547 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, I am sorry to hear that you are running into issues with this feature. Please recreate the issue on the following test-site for further debugging and escalation towards our compatilbity team: One-Click-Login: Leave me a short notice once the issue has been recreated. Please do not imply any patches or fixes, we need the code as is. Further we would be thankful to know in detail how you solved the issue. Did you comment our a special line of code or comment out the whole function? Best regards |
July 21, 2021 at 8:35 am #9242765 | |
mads-kronborgA |
Hi Andreas, Thanks for getting back to me 🙂 To reproduce the subscription issue on the test environment, I need Woocommerce Subscriptions to be installed 😉 Below a diff towards your repo: --- a/compatibility/class-wcml-wc-subscriptions.php +++ b/compatibility/class-wcml-wc-subscriptions.php @@ -97,9 +97,10 @@ class WCML_WC_Subscriptions { } $original_product_id = $this->woocommerce_wpml->products->get_original_product_id( $product_id ); + $custom_sign_up_fee = get_post_meta( $original_product_id, '_subscription_sign_up_fee_' . $currency, true ); - if ( get_post_meta( $original_product_id, '_wcml_custom_prices_status', true ) ) { - $subscription_sign_up_fee = get_post_meta( $original_product_id, '_subscription_sign_up_fee_' . $currency, true ); + if ( $custom_sign_up_fee && get_post_meta( $original_product_id, '_wcml_custom_prices_status', true ) ) { + $subscription_sign_up_fee = $custom_sign_up_fee; } else { $subscription_sign_up_fee = apply_filters( 'wcml_raw_price_amount', $subscription_sign_up_fee ); } Best regards |
July 22, 2021 at 2:47 am #9248871 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello Mads, The plugin is installed. Please proceed and leave me a short notification if you are able to recreate the issue. In case the issue might not be replicable on the test-site please provide me admin access to your website for further debugging. The private reply form is enabled. Regarding: "I set one secondary language with a fixed sign-up fee and leave the remaining secondary fields untouched." The normal WPML workflow with WooCommerce includes that we always translate products from default language to second language. Product details by default are not editable on translated products. Best regards |
July 22, 2021 at 6:44 am #9249811 | |
mads-kronborgA |
There you go, I created "test subscription" in the test environment. The subscription shows without subscription fee when selecting MyAttribute: 'Option 1' and currency set to USD. The error is reproduced. |
July 23, 2021 at 6:28 am #9257933 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, I am not sure what happened here, but I can not connect to the sandbox anymore which for I created a new one and tried to recreate this issue. One-Click-Login: I have already everthing prepared. Please simply edit the product and let me know exactly what you do here. As far I understood you edit prices in second language manually? Best regards |
July 23, 2021 at 10:25 am #9259543 | |
mads-kronborgA |
I lost access to the sandbox as well, and now recreated the issue in the new one... I created all of the above for the test product in the sandbox. Then under a subscription variant, you need to set custom prices for only one of the currencies - see attached wp-admin screen shot. The subscription fee is now missing for Euro as the currency calculation will fail for the one without custom price specified, see attached store screen shot. The code diff I provided for your verification fixes the issue as far I can tell. Best regards |
July 23, 2021 at 4:39 pm #9261979 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, You have enabled the option to set a manual price for different currencies but did not provide a value for Euro. As far I can see this issue is solved as long we declare a custom price for "Euro". Would this not be a proper solution for you? If not, I understand right that you found a code fix that solved the issue for you? If so, please could you show me how you solved that? Best regards |
July 23, 2021 at 9:02 pm #9262719 | |
mads-kronborgA |
Hi, That would not be a solution because then I can’t use the features your plugin provides; exchange rate updates, rounding to nice looking prices, etc. for the currencies where I have no special concerns/deals. I know my initial question quickly turned into a proposed fix making WPML act as I expected in this corner case. I guess your test cases simply did not cover my use case. Meanwhile I have done more testing and all is working as expected with no regressions. Simply apply the code change I proposed above will as far as I can tell handle the issue. I would appreciate if you could verify that the my proposal can be merged to your code base. That way maintenance will be no hassle when updating your plugins… Best regards |
July 24, 2021 at 3:32 am #9264049 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, Thank you for your message. I was able to confirm that your fix solves the issue. Anyhow, your code suggestion will need to be reviewed by our developers to make sure that it does not cause issues with other features. The issue has been escalated to our compatilbity team now and I will be in contact once I do have more feedback for you. Best regards |
July 24, 2021 at 8:59 pm #9265623 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, Our compatilbity team has come to the conslusion that the reported issue will lead to a feature request which depends on many factors. In fact, the provided fix is not working as expected in second language and would need to be revised and adjusted by our development team. If there are enough feature requests of this kind, our development team will take this into consideration for implementation. Unfortunately I cannot give you any guarantees that it will happen. Until then, please keep applying the suggest workaround by adding a custom price for each currency when using WC Subscriptions. Best regards |
July 25, 2021 at 9:00 am #9266929 | |
mads-kronborgA |
A feature request?! The attached screenshot states that the developers had the very same expectations as I have to the exchange rate calculation feature... Subscription price and sales price gets calculated. But the subscription fee is left out... Can you point me to how you reproduced the issue with secondary language using my proposal? Than I might find the time to make a revised proposal... Best regards |
July 25, 2021 at 11:58 am #9267175 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, Thank you for your message. In fact, I also commented on the response that I believe that this should work right out of the box, as it also does if we use for example a variable product with custom prives and leave out values for one given currency. I have forwarded your message to the compatibility team and we will need to wait their response. We hope for your understanding and thank you for your patience. Best regards |
July 27, 2021 at 2:51 pm #9281121 | |
Andreas W. Supporter Languages: English (English ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, Thank you for your patience while our team has been reviewing the reported issue which in the meantime has been escalated towards our development team for implementation into WCML. Further, we would like to provide you with a fix for the provided workaround and another workaround suggestion from our compatilbity team: With the given workaround we had the following results: This happens because of the following line of the workaround: $tmp = get_post_meta( $original_product_id, 'subscription_sign_up_fee' . $currency, true ); The subscription_sign_up_fee key does not exist, so it will always be empty. Then it applies the filter to all values. We can fix by replacing with this: $tmp = get_post_meta( $original_product_id, '_subscription_sign_up_fee_' . $currency, true ); My colleague Diego also wrote an alternative workaround, that also worked well: public function subscriptions_product_sign_up_fee_filter( $subscription_sign_up_fee, $product ) { if ( $product && wcml_is_multi_currency_on() ) { $currency = $this->woocommerce_wpml->multi_currency->get_client_currency(); if ( $currency !== wcml_get_woocommerce_currency_option() ) { $product_id = $product->get_id(); if( $product instanceof WC_Product_Variable_Subscription ){ $product_id = $product->get_meta( '_min_price_variation_id', true ); } $original_product_id = $this->woocommerce_wpml->products->get_original_product_id( $product_id ); if ( get_post_meta( $original_product_id, '_wcml_custom_prices_status', true ) ) { $subscription_sign_up_fee = get_post_meta( $original_product_id, '_subscription_sign_up_fee_' . $currency, true ); //if empty, get the original value, then apply 'wcml_raw_price_amount' filter if (empty($subscription_sign_up_fee)) { $subscription_sign_up_fee = get_post_meta( $original_product_id, '_subscription_sign_up_fee', true ); $subscription_sign_up_fee = apply_filters( 'wcml_raw_price_amount', $subscription_sign_up_fee ); } } else { $subscription_sign_up_fee = apply_filters( 'wcml_raw_price_amount', $subscription_sign_up_fee ); } } } return $subscription_sign_up_fee; } Best regards |