[Resolved] crud commerce set/replace cart item data with postname or id
This support ticket is created 6 years, 3 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Are you aiming to do something like add additional fields to the WooCommerce Order when a product is added to the cart? (The typical example is when you are ordering a product that the customer can have engraved with a custom message, so that message is added as a field to the order.)
The title of this thread says "set/replace cart item data with postname or id", and I'm not sure what you mean by that.
i am submitting curd form through product "pay to author" .
"pay to author" is product name linked with form.
different post subscription submitted through same crud form.
if user subscribe to post "Firrst post" After successful payment when user see order details "pay to author" is shown as ordered product but should be post name for which he subscribed
then user subscribe to one other post. After successful payment when user see order details it still shows "pay to author" as ordered product.
because user subscribe to different posts so he get always "pay to author" as product in their woo order details because product linked to crud fo
i want to show additional information post title with order details sent to user.
Sorry, our messages crossed, I understand what you are aiming for.
Unfortunately, you cannot modify the details of the order created with a CRED Commerce form.
The process is built on top of WooCommerce, and involves:
- somewhere, you display a form to "publish" a post
- the form is linked to a WooCommerce product, and when the form is submitted the product is added to the WooCommerce cart
- the subsequent steps where order is submitted and payment processed is handled wholly by WooCommerce.
Toolset doesn't have any influence over the resulting order.
You can, however, send custom notifications that are triggered when the order is placed, when payment is completed etc., and the fields where you store the post title & post id are available in the notifications. So you can create a custom notification to send to the client (and to the site admin) that says "You have just paid for *this post*" and not simply the same product name each time.
I looked through the API for CRED Commerce (https://toolset.com/documentation/programmer-reference/cred-commerce-api/) and unfortunately I don't see a hook that would help you modify the order programmatically so that you can add custom fields to it. (The order ID is available as an argument with the cred_commerce_after_order_completed or cred_commerce_after_send_notifications hooks, but I think these will fire later than you require.)