Skip Navigation

[Resolved] Split: Relationship between the custom field value and the product to buy

This support ticket is created 4 years, 7 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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by eugeneI 4 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#1605285

I'm sorry to bother you again, Waqar, but I'm stuck: Ok, I chose Adults, inserted another field in the form, called Students. The price would be different, but I can't figure out how to set up this payment thing. I use this guide, but I don't understand a few things:

https://toolset.com/documentation/user-guides/front-end-forms/using-cred-commerce-to-add-payments-to-forms/

1st: "The Custom field content you set for the field’s options must correspond with the Product IDs you want to offer as a choice." - but if I put 1 adult, 2 adults etc - each field would have the same ID as it's the same product, only the number of people is different and the form wouldn't let me use the same ID in every field. How do I set this up? I have tested it and only got an empty email - it only mentions the number of people and that's it, no prices etc.

2nd: If I choose Adults in the form setup, how do I choose another field - students?
I'm confused and I don't understand how to set it up, even after reading this "Using Forms Commerce to add payments to forms" 🙁

#1605771

Hi Eugene,

Thank you for waiting, while I reviewed how your booking form and the products are set up.

1st: "The Custom field content you set for the field’s options must correspond with the Product IDs you want to offer as a choice." - but if I put 1 adult, 2 adults etc - each field would have the same ID as it's the same product, only the number of people is different and the form wouldn't let me use the same ID in every field. How do I set this up? I have tested it and only got an empty email - it only mentions the number of people and that's it, no prices etc.

- WooCommerce stores each variation of a variable product with its own ID.

For example, the ID of your "Peterhof Palace and Fountain Park" product is 90, however, the 3 variations of that product have their own IDs too, which are 93, 94 & 95.
( screenshot: hidden link )

When you'd like to give users the option to choose from one of those variations, you'll use the product variation IDs as the select custom field's values.

2nd: If I choose Adults in the form setup, how do I choose another field - students?
I'm confused and I don't understand how to set it up, even after reading this "Using Forms Commerce to add payments to forms" 🙁

- It is important to understand how a Toolset Form can be used with WooCommerce's checkout.
( ref: https://toolset.com/documentation/user-guides/front-end-forms/using-cred-commerce-to-add-payments-to-forms/ )

Though a Toolset Form, you can add exactly one product (or a product's variation) into the WooCommerce cart and in a single quantity, through one form submission.

It doesn't support a built-in feature to allow visitors to choose more than one product variations and their quantities, at the same time.

Also, using a Toolset Form's integration is handy when your goal is to collect information from a user in a different post type, for example, "Bookings" post type and then when the form is submitted, one product is added in the cart.

But on your website, there is no post type like this and the booking form is set to add a new "Product" post, every time the form is submitted, which means that you'll end up with a lot of products which won't be used.

Based on these points, a simple option would be to remove the booking form from the single product pages and instead use the "wpv-woo-buy-options" shortcode:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-woo-buy-options

It will show the WooCommerce's default add to cart and product variation selection options and when a visitor will have added all the desired products and quantities in the cart, he/she can complete the checkout and fill personal details in the checkout form to complete the order.

If you'd like to continue using a Toolset Form that offers the option to select from multiple product variations and also set their quantities, then it will involve a fair deal of customization, using the "Toolset Forms Commerce API Hooks":
https://toolset.com/documentation/programmer-reference/cred-commerce-api/

Here is a good example to get you started in the right direction:
https://toolset.com/forums/topic/define-product-quantity-within-cred-form-2/#post-272938

I hope this helps and for more personalized assistance around custom code, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#1606017

Thank you Waqar, I'm starting to process and digest the information in the links you have sent me. Will keep this thread open if you don't mind as I believe I'll have the questions along the way.
Eugene

#1606559

You're very welcome Eugene.

Please feel free to let me know if you have any follow up questions.

And for each new question or concern, please start a new ticket.
( you can mention that it is related to what has been discussed in this ticket )

#1606999

Thank you for your suggestions. Unfortunately, after reading this I have understood that I will not be able to implement that because I have no idea about coding. I will have to be looking for other solutions then. Maybe I'll use the help of contractors if it's not too expensive - I have bought Toolset for a lot of money (for my business) to save on hiring people as the description said you can do it all yourself. Apparently not. Thank you for your time though