cart icon indicating copy to clipboard operation
cart copied to clipboard

Feature Request: Handling for unfinished orders

Open dahaupt opened this issue 10 months ago • 2 comments

Feature Request

Related problem In our project, we offer special benefits that are only available for a first order. However, we have noticed that users can start an order, abandon the payment process, and leave the order in an unfinished state. This makes it difficult to reliably identify completed orders and ensure that the first-order benefits are only granted once.

Potential solution To solve this issue, it would be helpful if unfinished orders (e.g. orders with a canceled or abandoned payment) could be automatically removed from the system after a certain period. A possible implementation could be a Symfony command that runs via a cron job and removes such orders based on specific criteria (e.g., order status, payment status, and creation date).

Alternatively, instead of creating a new order when a user attempts another purchase, it might be worth considering finalizing an existing open order. This could help keep the system cleaner and prevent unnecessary abandoned orders from accumulating.

Current workaround As a workaround, we currently check for a successfully completed payment instead of a valid order. While this helps to correctly identify a first order, it does not remove unfinished orders from the system. This can lead to issues, for example, when displaying orders in the user account, where unfinished orders would still appear.

dahaupt avatar Mar 10 '25 13:03 dahaupt

I can see the problem when users simply leave the order process during the payment process with a payment provider. The order is then already stored in the database.

However, I can't find a general approach on how to solve this.

I think that continuing an order at a later point in time is a useful solution, but not one that I could just implement. In case of doubt, it would also be necessary to check the warehouse management in the event that products no longer exist or are no longer available in sufficient quantities. This is only possible if a user is logged in. It may be possible to offer a redirect to the payment provider for such an open payment. I would have to check that.

I also don't really like the approach of only deleting cancelled orders. I think such a task can be included in your own site package in individual cases.

What I could imagine, however, is providing a command that mark open orders as cancelled if they have exceeded a time window of e.g. one hour. Presumably no user will wait accordingly. Various payment providers may not even allow this. However, I have not tried this out.

However, this would then have to be a task in the corresponding payment provider extensions, which only handle orders with their own payment provider in this way, as an advance payment should not be marked as cancelled within an hour. The processing times here are usually longer, especially if the users do not use online banking.

This feature should be provided for which cart version?

extcode avatar Mar 10 '25 14:03 extcode

@extcode Thanks for your fast reply.

I agree that certain behaviors should be directly part of a payment provider extension. But I guess the logic will be identical across different payment provider extensions: Marking pending payments and related orders as cancelled, after a certain period of time.

Maybe it would be a good first starting point to add a status to orders (PENDING, COMPLETED, CANCELLED), which could be used to provide a console command in the extension which deletes not COMPLETED orders after a configurable period of time?

Regardless of which new functions are implemented, it is sufficient if those are only available in the latest version of the extension.

Feel free to ping me on Slack for further discussion.

dahaupt avatar Mar 11 '25 14:03 dahaupt