Navigation überspringen

[Gelöst] Show price in view

This support ticket is created vor 3 Jahren, 10 Monaten. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

Dieses Thema enthält 7 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von maiS vor 3 Jahren, 10 Monaten.

Assistiert von: Jamal.

Author
Artikel
#1983457
Skærmbillede-2021-03-12-kl.-09.26.50.jpg

Hi there,
On my site: versteckter Link
I have a view that shows different infos about the camp. The bottom one is "Pris" (Price) and i would like to show the price of the camp - but as a dynamic source since every camp obviously has different prices.

On the content template you guys set in a shortcode. What i did was trying to copy this code and just paste it into the view where i want it, but nothing shows up.

Can you help?

Thanks

#1983837

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

You are using the legacy editor for Views and templates?

Rather than copy and paste an existing shortcode, while editing the output of the View use the Fields and Views button to insert the shortcode for that field in the place it is required.

Can you try that?

#1985115

Hi there,

I did copy the existing shortcode from the tempalte and set it into a classic field in the view. But it is not working. Do you have any suggestions or a guide on how to do it?

#1985489

What do you mean by every camp obviously has different prices? Is the price a custom field on the camp? Or does it come from the related product(Relationship: Camps Products)?
Can you give an example of a camp that has multiple prices? What price to choose from?
Or is each camp linked to only one product?

#1986853

Hi Jamal,

Oh sorry for explaining poorly.

So 1 camp has 1 price. But 2 camps can have different prices - so yes there is a relation between 1 camp and 1 product. Just like on the content template of each camp.

my question is: How do i show the price of the camp in the view? because it seems like i can not just copy the shortcode from the content template. It does not work when i do it however.

Thanks.

#1986915

The shortcode will not work with a simple copy-paste. Because the shortcode expect to find the data in the current post(In this case: the camp post). A shortcode can pull the data from the parent post in a One-to-many relationship, but it can't take it from a child post. This uses the item attribute https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Currently, the Camps<>Products relationship is a one-to-many relationship, so you can't get product's data inside the camp page using shortcode. But, you can pull the camp's data inside the product page, because the camp is a parent for the product.

In addition to that, the wpv-woo-product-price will only work inside product pages or product views. Check the context in the documentation https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-154347
versteckter Link

This being said, the only way, is to create a view that will pull the products linked to the camp, and display the price inside of it. The view needs to have a filter on the relationship related to the current post in the loop. Check this screenshot versteckter Link
I created the view here versteckter Link
And included it inside the page's view with a shortcode:

[wpv-view name="camps-product-price"]

It displays the price, but in blue. So, I'll let you fix the color of the price using CSS as you did before. versteckter Link

#1987273

Thank you so much! It works!

#1987281

My issue is resolved now. Thank you!