Skip Navigation

[Resolved] Delete post when removing product from cart (without completing payment)

This support ticket is created 6 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 3 voices.

Last updated by Yann Bigant 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#632963

Hello,
I use a CRED form for logged-in users to create a custom post 'tour'.
Upon submission of the form, the 'tour' is set to draft, a product is loaded in the cart, and the user is taken to the cart page.

In the CRED Commerce options, when the user completes payment, the tour takes the status pending. That works.
I've set the post status to 'delete' (or move to trash) when the purchase is cancelled. But if I removes the product from the cart without completing checkout, the 'tour' is not deleted nor moved to trash (I tried both), it remains as draft.

The payment method used in BACS (transfer).

I have checked the documentation but cannot find the reason. Is 'Purchase cancelled' different than removing a product from the cart ? And if so, is it possible when removing a product from the cart to delete the associated post ?

Thank you,
Yann

#634376

Well, you cancel an order in the interface you manage it with, not by removing an item from a cart.

In WooCommerce that's done in the backend where you manage the orders.

CRED Commerce only works with WooCommerce and refers to the Order Status that you can see when you list all orders in the backend.
Whatever order status you see there, and can set in CRED, is the one referred to.

If WooCommerce would update the Order Status to cancelled if the Item is moved out of the cart, then CRED would react to that Order Status change and trigger its notifications or whatever it's supposed to do.

There is an issue with that BTW:
https://toolset.com/errata/cred-commerce-emails-sent-order-status-changes-instead-specific-order-status/

Whatever Order status happens, the notifications will be sent (this is not directly related to the issue you report but I want to let you know in case you planned to use that feature)

For now what you try to achieve depends mainly on what the Commerce Tool (in this case, WooCommerce) does when an item is removed from the cart manually.
It seems WooCommerce does nothing with the order.
Hence CRED cannot react to it.

#638266

Hello Beda,
Thanks for your answer. I understand better how it works now.

So I tracked in the Woocommerce backoffice what happens :
- when the form is submitted, a post is created as 'draft' (which is what I set), but no order is created.
- when the user proceeds to checkout, same, no order is created.
- when the user clicks on 'place order', then the order appears as 'On hold' in WC backoffice (and I've set the post to switch to 'pending')

If you say CRED Commerce can only react to WC order status changes, then right, nothing can be done because the corresponding order is not created while the draft post is itself already created.

The problems that remain for me in case a user submits the form but doesn't complete checkout are the following (and how I plan to deal with it) :

1. a draft is created but the payment is not complete and/or the cart is being emptied, leaving useless drafts hanging around
-> I will issue drafts to expire and get deleted within a day (or a week) if the order is not placed

2. but then, a draft could be deleted, while the cart not actually empty
-> the cart will be set to clear after a certain time as well

3. hide 'drafts' from the list of posts the user can see with conditional shortcodes. The user this way doesn't need to deal with them, they will be taken care automatically.

Thank you for the info on the notifications issue. I'm not setting these yet, but will do soon. Anyway, the fact that CRED Commerce emails are being sent on all status changes at the moment tells me that the way above is better.

If you see another piece of information that could improve this process, I welcome it !
Best,
Yann

#639369

Your information looks good to me. Feel free to open tickets for any new questions related to this functionality.

#639809

Ok, thanks to both of you.
Best,
Yann