Skip Navigation

[Resolved] Woocommerce add to cart and price not working in content template

This support ticket is created 7 years, 6 months 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
- 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: Asia/Hong_Kong (GMT+08:00)

Author
Posts
#519579
view-for-product-cart-button-and-price.jpg
Selecting-related-product-from-edit-event-page.JPG
Single-event_wrong-price-and-wrong-product.jpg

Hi 🙂

I'm trying to add price and add to cart button to a single event page (made with content template), this single event is a child of the product which price I want to show, and the product that should be added to cart, but it's not working, meaning I'm seeing same price and buying same product, from every single event page.

I'm sorry about the length of this, I have tried to explain in detailed points.

1. I created a content template for my custom post type "Events"

Single event page:
hidden link
Single event pages are built with a content template.

2. Then I created a parent/child relationship with products and events.

PARENT: PRODUCTS
CHILD: EVENTS

I don't know which one should be parent or child for this to work, I did it this way only because it is easier to select the related product from the "edit event" page, using the dropdown product search.
IMAGE: Selecting-related-product-from-edit-event-page.JPG

3. I created a product for each event.
Besides the shop, I also want the Event to be purchased from the single event page. (Meaning to purchase the product related to the current event - from the single event page)

- It is currently showing a price and a button on the single event page, but it's the same price (950 DKK) and the same product that will be added to cart, from every single event page.
I'm confused how to get the Product/Event relationship to work.

Price and button in content template:
The standard woocommerce fields didn't work, no data is displayed.
I created a view, but "Products" isn't a structured post type, so I can't make parent/child filters.
IMAGE: view-for-product-cart-button-and-price.jpg

Inserting view:
[wpv-view name="event-og-produkt-information" limit="1"]
This is just showing price and add to cart button for same product on all event pages.

---

Can you help me find out how to put product cart button and product price on the single event page, that will relate to the product set in post relationship?

Thank you for your time,
Best regards
Lykke

#519686

Dear Lykke,

You are using wrong filter in the screenshot:
hidden link
Please follow our document to setup the parent filter:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
It should be a "Post relationship filter":
Select posts that are children of the Post where this View is shown.

You can use [wpv-woo-buy-or-select] shortcode of Woocommerce Views plugin to display the "add to cart" button, see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-woo-buy-or-select

#520981

Thank you so much 🙂