Skip Navigation

[Gelöst] commerce forms – adding read only and invisible fields

This support ticket is created vor 5 Jahren, 1 Monat. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 5 Jahren, 1 Monat.

Assistiert von: Luo Yang.

Author
Artikel
#1356551

Tell us what you are trying to do?

Using woocommerce products and toolset commerce forms to complete orders.
When an order is placed, i need to have additional information stored along with the order.

I have a "bookings" post type set up, with custom fields, i need some of these custom fields to be invisible on the form to the customer.

Example of fields i need to be stored alongside each order or "booking" would be:

Supplier nett rate
Supplier name

etc

My aim would then be to produce a reporting section, with toolset, showing bookings sent, the nett rate value of each order etc, for working with the suppliers etc.

So, my question is, in summary:

How can i add custom fields from the "bookings" post type to the commerce form and have them remain invisible to the customer, as they contain information that i do not want customers to see, but that i need stored in each booking created.

Thank you in advance.

#1356567

Hello,

There isn't such kind of built-in feature within Toolset Forms plugin, you might consider custom codes, for example,

When user submit the post form and complete Woocommerce order, use action hook "cred_commerce_after_order_completed" to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_after_order_completed

In this PHP function, do these:
1) Get the new "bookings" post ID and Woocommerce Order post ID, see above document:
- $post_id: ID of the post that was created or edited with the form.
- $transaction_id: ID of the WooCommerce order associated with the buying process.

2) Get the custom fields values:
- Supplier nett rate
- Supplier name
https://codex.wordpress.org/Function_Reference/get_post_meta

3) Update custom fields values as what you want:
https://developer.wordpress.org/reference/functions/update_post_meta/

#1361125

I found a simpler solution to this issue, which doesn't involve writing code and messing around with php (At this stage, i'm a new toolset user and relatively new to coding, so was looking to avoid having to struggle with custom coding something).

#1361131

My issue is resolved now. Thank you!

#1361133

Can you share your simpler solution to this issue here? That will help other users too, thanks