Skip Navigation

[Resolved] Conditional based on Product Category of item in Cart

This support ticket is created 6 years, 2 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1101759

Hello Christian,

The Cart can include product related to Booking OR Pack which means I'll add 2 views (1 for each CPT) with same filters that you advised

and as the customer can purchase a pack, so both views will display results.

from the frontend I can't get the id of the product in the cart so I can set conditional based on the product category so I could display the right view and hide the other.

the direct way to achieve that is if I have the id of that newly created Booking / Pack so I can have only 1 view for both CPTs with a post ID filter

I hope I explained it clearly now. Thank you so much for you patience 🙂

#1101779

Toolset doesn't offer any shortcodes or APIs for inspecting items in the shopping cart directly, so that's something you would need to get WooCommerce to help with. However, you could use a View like I was explaining. This is the simplest possible approach. Create a View that shows Bookings and Packs, filtered by post author, where the post author is the current User, and filtered by post status "Pending." Sort the View results by date in descending order. Limit the number of results to 1. Use a conditional to test the post type of that one result, and display different Views based on the post type.