Cancel unpaid orders

  • Posts: 85613
  • Thank you received: 14034
  • MODERATOR
1 month 1 week ago #371480

Hi Harald,

Yes, mass actions support date-based filters. You can create a mass action on the "order" table with:
- Trigger: "On cron"
- Filter 1: "Order status" set to "cancelled"
- Filter 2: "Column value" with the column `order_modified`, operator `<`, and value `{time}-864000`

The value `{time}-864000` means "current timestamp minus 864000 seconds (10 days)". This way, only cancelled orders that haven't been modified in the last 10 days will be matched.

You could also use the same approach to directly target "Pending" orders older than 10 days, by using "Order status" set to "pending" instead.

In the next version of HikaShop, the auto-cancel plugin will also have a new setting allowing you to select which order statuses to target, so you will be able to include "Pending" orders directly without a separate mass action.

Great to hear that the bot protection in 6.4.0 is working well with only 4 new bot orders.


German answer:

Hallo Harald,

Ja, Massenaktionen unterstützen datumsbasierte Filter. Sie können eine Massenaktion auf der Tabelle "order" erstellen mit:
- Trigger: "On cron"
- Filter 1: "Order status" auf "cancelled" gesetzt
- Filter 2: "Column value" mit der Spalte `order_modified`, Operator `<` und dem Wert `{time}-864000`

Der Wert `{time}-864000` bedeutet "aktueller Zeitstempel minus 864000 Sekunden (10 Tage)". So werden nur stornierte Bestellungen erfasst, die seit mindestens 10 Tagen nicht mehr geändert wurden.

Sie können den gleichen Ansatz auch direkt für "Ausstehend"-Bestellungen verwenden, indem Sie den "Order status" auf "pending" setzen.

In der nächsten Version von HikaShop wird das Auto-Cancel-Plugin auch eine neue Einstellung haben, mit der Sie auswählen können, welche Bestellstatus erfasst werden sollen. Damit können Sie dann "Ausstehend"-Bestellungen direkt einbeziehen, ohne eine separate Massenaktion zu benötigen.

Schön zu hören, dass der Bot-Schutz in 6.4.0 gut funktioniert mit nur 4 neuen Bot-Bestellungen.

The following user(s) said Thank You: haraldundandrea

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 2
  • Hikashop Business
1 month 5 days ago #371516

Hallo Nicolas,

ich habe noch Fragen zu der Massenaktion.

Ich finde keine passenden Trigger. Die einzigen die passen könnten sind "Bei HTTP-Anfrage (Webhook)" oder "Bei MCP-Anfrage".



Die Eingabe der Zeit macht noch Schwierigkeiten, {time}-864000 findet keine Bestellungen, '{time}-864000' führt beim Ausführen zur Fehlermeldung "Unsupported operand types: string - string". woran kann das liegen? Wie muss es richtig heißen?



Viele Grüße - Harald

Attachments:
Last edit: 1 month 5 days ago by haraldundandrea.

Please Log in or Create an account to join the conversation.

  • Posts: 85613
  • Thank you received: 14034
  • MODERATOR
1 month 5 days ago #371522

Hi Harald,

Regarding your questions:

1. Trigger

"On MCP request" and "On HTTP request (Webhook)" are not the right triggers for your case - they are called by external systems (AI/chatbot for MCP, manual HTTP calls for the webhook) and don't run automatically at regular intervals.

For a recurring task you need a time-based trigger like Hourly or Daily. These work via the HikaShop CRON URL: HikaShop provides a specific URL that needs to be called regularly so that time-based massactions and HikaShop plugins with a CRON trigger actually run. The URL and the details are in our documentation:

www.hikashop.com/support/documentation/5...n-configuration.html

Without such a regular call (via a server CRON on Linux, the Task Scheduler on Windows, or an external service like cron-job.org), the time-based triggers won't fire, even though they appear in the dropdown.

2. Filter finds no orders

The value {time}-864000 should work: {time} is replaced by the current Unix timestamp when the action runs, and the subtraction is then computed, so you get a timestamp from 10 days ago. If the massaction still doesn't find any orders, it's usually not the syntax but one of the following:

- There are simply no orders older than 10 days that also have the "Pending" status. First test with a shorter period like {time}-86400 (1 day), or without the time filter at all, to see if the status filter returns any hits on its own.
- "Pending" may not be the status your unpaid orders actually have. Depending on the payment method, unpaid orders are often created with the "Created" status rather than "Pending". Check the actual status of your old unpaid orders in the backend under "Orders" and adjust the filter accordingly.

3. Simpler alternative: the "Order auto cancel" plugin

The new HikaShop 6.4.1 release will be published in the next few days. It includes an updated "Order auto cancel" plugin that covers exactly your use case, without needing to configure a massaction yourself:

- You directly select in the plugin which order statuses should be cancelled (e.g. "Pending" and/or "Created").
- You specify after how many days an order should be cancelled automatically.

If the massaction configuration is too complex for you, I would recommend simply waiting for 6.4.1 and then enabling and configuring the plugin - that's much simpler.

german:

Hallo Harald,

zu Ihren Fragen:

1. Trigger

"Bei MCP-Anfrage" und "Bei HTTP-Anfrage (Webhook)" sind nicht die passenden Auslöser für Ihren Fall - die werden von externen Systemen aufgerufen (AI/Chatbot beim MCP, manuelle HTTP-Aufrufe beim Webhook) und laufen nicht automatisch in regelmäßigen Abständen.

Für einen wiederkehrenden Auftrag brauchen Sie einen zeitbasierten Auslöser wie Stündlich oder Täglich. Diese Auslöser funktionieren über die HikaShop-CRON-URL: HikaShop bietet eine spezielle URL, die regelmäßig aufgerufen werden muss, damit die zeitbasierten Massaktionen und die HikaShop-Plugins mit CRON-Trigger überhaupt ausgeführt werden. Die URL und die Details dazu finden Sie in unserer Dokumentation:

www.hikashop.com/support/documentation/5...n-configuration.html

Ohne einen solchen regelmäßigen Aufruf (per Server-CRON unter Linux, Aufgabenplanung unter Windows, oder über einen externen Dienst wie cron-job.org) laufen die zeitbasierten Auslöser nicht, auch wenn sie im Dropdown auswählbar sind.

2. Filter findet keine Bestellungen

Der Wert {time}-864000 sollte korrekt funktionieren: {time} wird beim Ausführen durch den aktuellen Unix-Zeitstempel ersetzt und anschließend die Subtraktion durchgeführt, sodass Sie einen Zeitstempel von vor 10 Tagen erhalten. Wenn die Massaktion trotzdem keine Bestellungen findet, liegt es meist nicht an der Syntax, sondern an einem der folgenden Punkte:

- Es gibt schlichtweg keine Bestellungen, die älter als 10 Tage sind UND den Status "Ausstehend" haben. Testen Sie zunächst mit einem kürzeren Zeitraum, z.B. {time}-86400 (1 Tag) oder ganz ohne Zeit-Filter, um zu sehen, ob der Statusfilter überhaupt Treffer liefert.
- "Ausstehend" ist eventuell nicht der Status, in dem Ihre unbezahlten Bestellungen liegen. Je nach Zahlungsart werden unbezahlte Bestellungen häufig mit dem Status "Erstellt" (created) angelegt, nicht "Ausstehend" (pending). Prüfen Sie im Backend unter "Bestellungen" den tatsächlichen Status Ihrer alten unbezahlten Bestellungen und passen Sie den Filter entsprechend an.

3. Einfachere Alternative: das Plugin "Order auto cancel"

Die neue Version HikaShop 6.4.1 wird in den nächsten Tagen veröffentlicht. Sie enthält ein aktualisiertes Plugin "Order auto cancel", das genau Ihren Anwendungsfall abdeckt, ohne dass Sie selbst eine Massaktion konfigurieren müssen:

- Sie wählen direkt im Plugin aus, welche Bestellstatus storniert werden sollen (z.B. "Ausstehend" und/oder "Erstellt").
- Sie geben an, nach wie vielen Tagen eine Bestellung automatisch storniert werden soll.

Wenn die Konfiguration der Massaktion für Sie zu komplex ist, empfehle ich Ihnen, einfach auf 6.4.1 zu warten und dann das Plugin zu aktivieren und zu konfigurieren - das ist deutlich einfacher.

The following user(s) said Thank You: haraldundandrea

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 2
  • Hikashop Business
1 month 4 days ago #371533

Hello Nicolas,

it has been my fault. I had forgotten to add some fields which should be displayed.

Now I have copied my older massaction to display pending orders and added the new filter and the trigger daily. The range I have set from 0 to 1000.

I have processed the massaction manually and got a list up to 10th of march.

After that I copied this massaction and changed the aktion to "delete the elements" and got the desired result.

With the massaction for displaying pending orders I still see now some orders from 11th of march up to now but older than 10 days.

I think this massaction should delete the next orders by itself tomorrow.

Thank you very much for your support and explenations.

I will set up the new version of the plugin aswell.

Greetings - Harald

P.S.: Now all wors/is fine, only real orders are left...

Last edit: 1 month 1 day ago by haraldundandrea.
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.445 seconds
Powered by Kunena Forum