Skip Navigation

[Resolved] Display old product price in WooCommerce..

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 6 replies, has 2 voices.

Last updated by thomasS-11 6 years, 10 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#278047

Hi.

How do i display the normal price on a product?
When i use [types field="views_woo_price" output="raw"][/types] from WooCommerce Views plugin, i get the Sale price on a product.. i would like to display the "old" price as well so the customer can see it in the product archive.

Further more, is it possible to do a mathematical calculation in a view loop?
I want to display the saving amoung in percentage, in it could be done with a mathmatical calculation.

Also, is it possible to make it conditional as well? so if the specific product is not on sale, it shouldnt show the percentage?

Thanks.

#278126

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

If you are going to display the regular price, which is using field slug "_regular_price", please try Views shortcode [wpv-post-field], like this:
[wpv-post-field name="_regular_price"]

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-post-field

#278157

Works like a charm! - can i do this with all fields?

How do i make a calculation? i.e. "sale_price / regular_price * 100" = SAVED AMOUNT IN %

Thanks again!

#278418

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Here is a shortcode can perform of calculation
https://toolset.com/forums/topic/calculation-not-working/#post-199963

Hope it help

#278494

Calculations are not correct at all?

Regular price is 150
Sale price is 25

[wpv-calculate]
[wpv-post-field name="_regular_price"]-[wpv-post-field name="_sale_price"]/[wpv-post-field name="_regular_price"]*100
[/wpv-calculate]

This calculation gives me 133..
It should give 83...

I have tried performing the exact same calculation on a calculator, and i get 83 as i should.. i dont know why views makes it 133..

#278717

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Are you going to Calculate as below?
(_regular_price - _sale_price) * 100 / _regular_price

Please try modify your codes as below:

[wpv-calculate]
([wpv-post-field name="_regular_price"]-[wpv-post-field name="_sale_price"])*100/[wpv-post-field name="_regular_price"]
[/wpv-calculate]
#278794

I dont know what i would do without you..