Skip Navigation

[Closed] current post data to another post type form

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 8 replies, has 2 voices.

Last updated by Waqar 1 year, 4 months ago.

Assisted by: Waqar.

Author
Posts
#2623127

On my custom post(type Product) page CRED post form creates new post(type Order) .
How to get current Product data into form and post it?

For example:
We are on my Sample Product page and composing order(filling CRED form).
Form fields like customer name, mail etc are there.
Wish to add automatically product name and price to order.

#2623155

Hi,

Thank you for contacting us and I'd be happy to assist.

To automatically populate the data in the form fields, you can use relevant Toolset shortcodes in the default value option in the form field settings.

For example, to get the current logged-in user's data, you can use the 'wpv-user' shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-user

Likewise, to get the data from the current product (whose single product page is being used), you can use the shortcodes like 'wpv-post-title', 'wpv-post-field' etc:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2623167

Can You give me a sample piece of code to populate my product SKU(custom field slug is 'prod-sku') in to form field 'tel-sku'.
Here is the row in my order form:

[cred_field field='tel-sku' placeholder='SKU' force_type='field' class='form-control' output='bootstrap']
#2623549

Yes, you'll include the field's value shortcode [types field='prod-sku'][/types] in the 'value' attribute like this:


[cred_field field='tel-sku' placeholder='SKU' force_type='field' class='form-control' output='bootstrap' value='[types field='prod-sku'][/types]']

Related documentation links:
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

#2624095

Thanks Waqar,

This works fine. Help me also to post some Product field values to Orders if checkbox checked.

#2624113

For example Product field Installation cost(field='installation') I wish to save into Order field Extras(field='extras') if customer checks checkbox.

#2624561

Glad I could help.

For something like this you can use the 'cred_save_data' hook:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This hook can be used to fire a custom function that executes when the form's data (order) has been saved to the database.

In your function, you can check if the checkbox has been checked or not. And if checked, you can get the required custom field values from the product and save them in the 'extras' field of the order itself.

#2625543

Looks good, but I am still processing.
Let's keep this ticket open for some time.

#2626513

Sure, please take your time and the ticket will stay open for a couple of weeks.

The topic ‘[Closed] current post data to another post type form’ is closed to new replies.