Skip Navigation

[Resolved] Radiofield with specific options per product

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a radio field that displays specific options per product.

Solution: Use WooCommerce attributes to create variable products.

This support ticket is created 6 years 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)

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Pat 5 years, 12 months ago.

Assisted by: Christian Cox.

Author
Posts
#1183674

Pat

Hello,

I plan to develop a news site based on Toolset + WC. The aim is to sell excursions.

In the product page, I need to propose the choice of the departure location (could be between 1 and 5 different choices - only one choice permitted)

I need to be able to place an address on each option and the options are not the same from one to another excursion.
Another issue is that I do not want to create a specific new field for each product.

The idea is to define the option on the admin product page.
Last, I need to be able to use this field to make some sorting (ie : list all people that have chosen a specific location departure for a specific excursion).

So, the question is : how can I create a global radio field that could be used on all products and with options that are specific to each product?

I have thought of using a generic radio field and populate its options with another custom field content but I'm not sure if this is feasible and how to manage the fact that we can have between 1 to 5 different locations (no fix option number).

Let me know
Regards
Pat

#1183796

In the product page, I need to propose the choice of the departure location (could be between 1 and 5 different choices - only one choice permitted)
Hi Pat, what about Variable Products in WooCommerce? You can create a different variation for each departure location, and the variations can be different for each Product (Excursion).
https://docs.woocommerce.com/document/variable-product/

Last, I need to be able to use this field to make some sorting (ie : list all people that have chosen a specific location departure for a specific excursion).
Where would you like to see this sorted list - on the front-end of the site or in wp-admin?

#1184045

Pat

Hi Christian,

Thanks for your answer.
You're right, variable product could be an answer. I will investigate a little more and see if it's really the right answer.
Concerning the sorted list display, it should be both on admin and on frontend.
Regards
Pat

#1184048

Pat

OOoppps,
Just another point concerning the variable product solution : I need to get the info like (list all products bought by a user, or list all users having bought a product with this variation ...

So, I have 2 potential solutions :
- Use a WC Cred in conjunction with the product (but how can I manage a variable product in this case?)
- Use the variable product directly, but how can I get the needed info

Regards
Pat

#1184381

Concerning the sorted list display, it should be both on admin and on frontend.
I'm not sure if WooCommerce gives the ability to filter a list of Users who have ordered a specific product in wp-admin, that's something you would have to ask their support team about.

On the front-end, you can create a View of Orders in the status wc-completed. You can insert the billing name in the results, and include a conditional that filters only Users who purchased a specific Product ID. We offer the wpv-ordered-product-ids shortcode, which will return a list of Product IDs in the current Order, and you can use CONTAINS and ARRAY in the conditional like this:

[wpv-conditional if="( CONTAINS(ARRAY([wpv-ordered-product-ids]),12345) )"]
[wpv-post-field name="_billing_first_name"]
[wpv-post-field name="_billing_last_name"]
 [/wpv-conditional]

Replace 12345 with the numeric ID of the product variation you want to test.

#1185105

Pat

Hi Christian,

Sounds good, thanks for the info
What are all info that I can get thanks to shortcodes (products bought in this order, price, ...)
Let me know
Regards
Pat

#1185243

Our shortcodes specific to WooCommerce are listed in the documentation here:
https://toolset.com/documentation/user-guides/views-shortcodes/#woocommerce-views-2
In the context of a View of Orders, you can get product IDs with the wpv-ordered-product-ids shortcode. Then you could use those IDs to filter a nested View of Products. In the View of Products, you can display information about each Product, like the price, product meta, etc.

#1185256

Pat

Hi Christian,

Thanks for the info.
What about the product quantity in each order? How can I get it?
Regards
Pat

#1185268
#1186565

Pat

Hi Christian.
Thanks for your support.
Regards
Pat