Woocommerce Set Price() On Each Variant

[Resolved] How to display min_variation_price in manually set price in second currency?

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.

This thread is resolved. Here is a description of the problem and solution.

Problem:How to display min_variation_price in manually set price in second currency?

Solution:In most cases this should need custom work so if you have a different case, please open a new ticket. And for this specific ticket, this code snippet worked for the user to display all his custom variation prices. https://wpml.org/forums/topic/how-to-display-min_variation_price-in-manually-set-price-in-second-currency/#post-847317

This topic contains 11 replies, has 3 voices.

Assigned support staff: Ahmed Ibrahim.

I am using the following to display prices as ‘From R$X’ rather than ‘R$X-R$XX’:

if ( $product->min_variation_price !== $product->max_variation_price ) <
$price .= ‘ ‘ . _x(‘From ‘, ‘min_price’, ‘cofi’) . ‘ ‘;
$price .= woocommerce_price($product->min_variation_price);
> else <
$price = woocommerce_price($product->get_price());

Works in the default currency but in the second currency ‘min_variation_price’ displays the automatically converted lowest variation price, not the manually set price.

Hello. Thank you for contacting WPML Support. I am happy to help you with this.

Can you tell me if you already checked the following? This will help narrow down the issue:

** IMPORTANT ** Please backup a working copy of site files and database before continuing.

A. Update all WPML plugins & WordPress core.

B. Minimal Set Up ( 1. All plugins except WPML disabled 2. and then Temporarily changing the theme to a default WordPress such as TwentyFifteen ).

C. If the issue is gone after Minimal Set Up steps above, activate each plugin one by one to find out which plugin is causing the issue.

Does the issue still persist when you do each step above?

Thank you in advance for the information above. This will help me come to a faster resolution.

Thanks Tia, but the auto response doesn’t help.

WordPress, WPML and plugins are all up to date, and I cannot run just WPML and Twenty Fifteen as it is in my theme and with WooCommerce that I am using woocommerce_price($product->min_variation_price);

But I deactivated all other plugins except WooCommerce and WPML plugins and the issue persists.

Can you tell me the file location of the code in the theme and the corresponding page in the frontend?

I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply.

The information you will enter is private which means only you and I can see and have access to it.

– Please make a backup of site files and database before providing us access.

– If needed, I will be using a plugin called ‘Duplicator’ (https://wordpress.org/plugins/duplicator) to make a local copy of the website for testing purposes and/or Adminer (https://wordpress.org/plugins/adminer/) to inspect the database. Once the problem is resolved I will delete the local site. Do I have your permission to move forward with either Duplicator or Adminer, if needed?

– If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:

Great, thank you! I will test this further and get back with you as soon as possible.

Hello. Just an update to let you know I am still looking into the issue but I expect to update you soon with the results. Thank you for your patience.

I have finished debugging. The issue needs further investigation.

I am going to escalate your ticket to 2nd Tier support where they can take a deeper look into the matter. Please give them time to respond.

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi, This is Ahmed Ibrahim from second tier support.

Does the update to WCML version 3.7.11 resolved your issue.

I can see that the prices for these two products listed below are coming from your the manually entered prices in the back-end.(see the attached screenshot for "Cofi Ideas").

Sorry Ahmed, I removed the code by accident. The issue is not resolved.

If you go back to to the product you will see it shows ‘From $59’ instead of ‘From $95’

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi, and thanks for your reply.

I see it now, I will investigate more and will come back to you.

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

I have checked your custom code and I think it should be modified to show you the correct values.

I have followed this funtion this function "get_price_html" at wp-content/plugins/woocommerce/includes/class-wc-product-variable.php:346

And I have updated your custom function to be like that:

This code worked correctly on my local environment. (see the attached screenshot). So please try it and let me know if that helps you.

Change original price in cart for WooCommerce product variation

December 2018

1.5k time

I tried using this to change the original price in the cart but no dice. I think it’s not working because the product I’m using is a variable product. The Product ID is 141 and the variation ID 142.

How to make it work

Вы должны необходимо заменить $cart_item[‘product_id’] на , $cart_item[‘variation_id’]чтобы сделать его работу для изменения продукта в вашем состоянии.

Эта функция изменит только дисплей, но не расчет:

Вот зацепили функция, которая изменит расчет корзины с ценой:

Код идет в function.php файле Вашего активного ребенка темы (или темы), или также в любой файл плагина.

Таким образом, вы получите, что:

Этот код проверяется объявление работает на WooCommerce версии 2.6.x и 3.0+

Leave a Reply

Your email address will not be published. Required fields are marked *