Skip Navigation

[Resolved] [wpv-woo-product-price] does not work through a many-to-many relationship

This support ticket is created 7 years, 1 month ago. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Minesh 7 years ago.

Assisted by: Minesh.

Author
Posts
#505293

My site hidden link links various custom post types with associated products.

In the first relationship type, a Vessel (custom post type) is the Parent and the Product is the Child. In this instance, the shortcode [wpv-woo-product-price] displays correctly for the child item when displayed through a view on a parent page. For an example, go to hidden link and scroll to the view named "Sail Leila". Here you will see the price displaying correctly, even if a variation or sale price is set.

The second relationship type is many-to-many and is between an Event (custom post type) and a Product. In this instance, the shortcode [wpv-woo-product-price] is not returning any value when used in a View showing Products on the Event page. For an example go to hidden link and look under "Sail From This Event". The view below it, names "Sail To This Event" uses the shortcode [wpv-post-field name="_regular_price" id='$product'], but this does not adjust to display variation prices or sale prices when necessary.

Could you please advise on how I can get the [wpv-woo-product-price] shortcode to work through the many-to-many relationship, or alternately, advise on how I can get the lowest price to display through the View, whether that be a sale price or the lowest variation price.

Thanks in Advance!

#505388

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I need to check on your install why only thtat view is not displaying the price.

*** 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.

#507282

Minesh
Supporter

Languages: English (English )

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

The field views_woo_price is null most likely because they are not yet calculated. This needs to be calculated first before its usable by Toolset:
=> https://toolset.com/documentation/woocommerce-views-calculated-fields-and-batch-update/#wcv-update-calculated

I manually calculated it and used shortcode:

[wpv-post-field name="views_woo_price" id="$product"]

Now - I can see the price with your products.

#507310

The solution you have provided appears is working ok, though I wonder if it is possible to show label that price to show the visitor when it is a sale price or show the variation in price (from min to max) for a variable product?

Such features were possible with the original shortcode of [wpv-woo-product-price]

#510292

Minesh
Supporter

Languages: English (English )

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

Sorry for delayed reply as the ticket was resolved and I didnt notice your further question.

views_woo_on_sale will return values of 1 (true) and 0 (false) if the product is on sale. For Variable products, this will be true if any of the Product Variants are on sale.

views_woo_price This will return the product’s normal price or, if it is currently on sale, the sale price. For Variable products, the lowest price for the Products variants will be returned.

So you can check using [wpv-conditional] shortcode if views_woo_on_sale set to true or not and based on that you should dipslay labels.

For example:

[wpv-conditional if="( '[wpv-post-field name="views_woo_on_sale " id="$product"]' eq '1' )"]
Product set for sale
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/woocommerce-views-calculated-fields-and-batch-update/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.