Hi there, I am trying to send email notifications to fields included in forms submitted by the user once payment is completed. For example, a user adds multiple cred-connected items to their cart and checkouts out once paying for all these items. For the most part this works, however only the second form (post) receives the email notification despite two (or more) posts being created (where relevant). So if one day permit is purchased everything works as expected. When more than one permit is purchased only the user who has their details entered second will receive a notification. I noticed on investigating that the second post (day permits in this case) would display published but the first would retain the status of wc-pending suggesting there might be a bug here?
Post form settings is set to create posts with status 'pending payment' and the to change the post type to published once the payment status updates. However, this only happens to the last submitted form entry/post. The previously added items are not updated.
Is there any documentation that you are following?
I have reviewed the available documentation.
Is there a similar example that we can see?
Yes, you can add 'purchase multiple day passes' on the paarltrails.com site under memberships & permits.
I think we might be speaking past each other. At the moment I have a cred form that users completes. This add a designated product to the cart (product determined by cred form field). Once a user has added a product to their cart (they can/do) add another product to their cart using the cred for form. They then check out and pay for both products. No problems so far. The problem now arises that only the LAST CPT that was created by completing the cred form is set to published and receive the notification set up within the cred form settings. The first CPT (day permit in this case) remains with a 'wc-pending' status. In other words, I need all CPTs created through a single order to be updated, not only the last.
The "cred_commerce_after_payment_completed" hook will run once the payment is successfully completed and if you have the way to get the post ID of your previous form then you can use this hook to set the post status based on the post ID.
If this is not helpful then I will require a test site where I will require to review how user will navigate through the 1st and 2nd post and then I will be able to guide you in the right direction.
Thank you for this. This could definitely solve the problem. Before I go and make changes, please confirm that the expected behavior is that on checkout only the last item created by a cred form will see its status updated? For example, complete a cred form that creates a new CPT and sets the status to wc-pending. I then complete the form again for a second item which then generates a second CTP. Both products related to the cred form posts are in my basket. I then check out and pay for both items (both CPTs Id's are reflected on the WC order in DB). Now, only the last item added to the cart is updated to published. The first remains as is despite the reference to the WC order.
Toolset Forms commerce can only process one thing in the cart at a time (even though it doesn't prevent you from adding more than one thing), so I suggest you should go with the solution I shared and use the Form's commerce hook as workaround.