Skip Navigation

[Résolu] Shortcode for displaying price of product not working as it should

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: Shortcode for displaying price of product not working as it should

Solution: If you want to display the WooCommerce Views price filed "views_woo_price", please make sure that you run the batch update manually once to calculate and update the price field value.

You can find proposed solution, in this case, with the following reply: => https://toolset.com/forums/topic/shortcode-for-displaying-price-of-product-not-working-as-it-should/#post-1077183

Relevant Documentation: https://toolset.com/documentation/user-guides/woocommerce-views-calculated-fields-and-batch-update/#when-do-you-need-to-update-calculated-fields

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 7 réponses, has 2 voix.

Last updated by Dido Il y a 3 années et 1 mois.

Assigned support staff: Minesh.

Auteur
Publications
#1076214

I am trying to: Diplay two different prices (€ 75 and € 15) on one page

Link to a page where the issue can be seen: homepage (but now in maintenance mode, so I am including screenshots)

I expected to see: the correct prices (€ 75 and € 15)

Instead, I got: twice € 75.
Also when the shortcode for the second product (id 2400) is tried on another page, I still get the price of the first product (id 2262) which is € 75.
Finally, I would like to have a way to display the euro sign in front of the price.

#1076215
15.JPG
75.JPG
voorkant.JPG

Forgot to include the screenshots. Here they are.

#1076228

And these are the shortcodes I used:
[types field='views_woo_price' item='2262'][/types]
[types field='views_woo_price' item='2400'][/types]

#1076233

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to display correct price could you please try to use the following shortcode. You should use id attribute instead of item attribute.

[types field='views_woo_price' id='2262'][/types]
[types field='views_woo_price' id='2400'][/types]

Additionally, to display the euro sign - you should use following:

€ [types field='views_woo_price' id='2262'][/types]

OR

€ [types field='views_woo_price' id='2400'][/types]
#1076265

Thanks for the quick reply. Unfortunately when testing this, using "id=" made no difference. Also, when I asked for a way to display the euro, I really meant a way to display the currency. This could be euro, but it could also be dollar or pound or whatever. Therefore "hardcoding" a sign is unfortunately not an option.

#1076271

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - can I have problem URL where you are trying to display the price and currency symbol with access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#1077183

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - When I visited the products with IDs 2262 and 2400 and when I check the views_woo_price field for both product the value was same 75. Then I go to WooCommerce Views and udpated the batch manually to calculate the fields.

Here is the guideline how you can update the batch manually:
https://toolset.com/documentation/user-guides/woocommerce-views-calculated-fields-and-batch-update/#when-do-you-need-to-update-calculated-fields

To display currency symbol I've added following shortcode to your current theme's functions.php file.

function func_show_currency_symbol( $atts ){
	
	// Get the country name:
	return get_woocommerce_currency_symbol();

}
add_shortcode( 'show_currency_symbol', 'func_show_currency_symbol' );

And displayed withing your sidebar widget as given under:

[show_currency_symbol]

I can see its working now here: hidden link

As we covered your original issues reported with this ticket, I would kindly urge you to create a new ticket with your each new question. This will help other users searching on the forum. However - for displaying translated price for each language please contact WPML support.

#1077622

I think I am going to use a currency converter plugin. Thank you very much for this solution!