Workflows on shop triggers
This page is for developers and administrators who connect workflows to the shop. It maps each shop trigger to the events that fit there, walks through setting up the usual two workflows, and lists the mistakes that break a checkout.
Contents
- The trigger map
- Set up the shipping workflow
- Set up the payment workflow
- Several events on one trigger
- Events of your own
- Mistakes that break a checkout
The trigger map
| Trigger in Setup > Triggers | Operation point | What exists at that moment | Fits |
|---|---|---|---|
shop addtobasket before | pre_addtobasket | The product (object_id), chosen options, quantity | Refusing an item (for example a product that may not be sold to this customer) |
shop addtobasket after | post_addtobasket | The item is in the basket | Logging, recommendations |
shop updatebasket before / after | pre_updatebasket, post_updatebasket | Item ids and counts | Quantity limits |
shop confirmorder before | pre_confirmorder | The temporary order | Shipping (ezsimpleshipping or your own event), surcharges as order items |
shop checkout before | pre_checkout | The temporary order with its final total | Payment (ezpaymentgateway) |
shop checkout after | post_checkout | The placed order with its number; the mail has been sent | Reporting, exports to other systems, analytics |
Which triggers appear at all is decided by workflow.ini [OperationSettings]
(workflow.ini for the shop). Which event types may be put on a trigger is
decided by each event type: ezsimpleshipping only allows shop confirmorder before.
Set up the shipping workflow
- Set the amount:
ShippingCostandShippingDescriptioninsettings/override/workflow.ini.append.php. - Setup > Workflows, open a group, New workflow, name it "Shipping".
- Add the event Simple shipping, save.
- Setup > Triggers: for
shopconfirmorderbefore, choose "Shipping", save. - Place a test order: the confirmation page shows the shipping line.
Details and limits: Simple shipping event.
Set up the payment workflow
- Activate the gateway extension and set its provider file to test mode (paymentgateways.ini walkthrough).
- Setup > Workflows, New workflow, name it "Payment".
- Add the event Payment Gateway; in the event, select the gateways customers may use; save.
- Setup > Triggers: for
shopcheckoutbefore, choose "Payment", save. - Place a test order and complete the payment in the provider's test mode.
Details: Payment gateway event.
Several events on one trigger
A trigger has one workflow. To run several events at one point, add them to that workflow in order. Events run one
after the other; the next starts only when the previous accepted. On pre_checkout, put checks that may refuse an
order before the payment event, so that a customer is never charged for an order that a later event refuses.
To run an event only for some customers or products, wrap a second workflow in a multiplexer event (Multiplexer in the shop).
Events of your own
An event type is a class extending eZWorkflowEventType with an execute() method that returns a status: accepted,
rejected, show a template, redirect, or defer to cron. Generate one with Setup > RAD's workflow event wizard
(setup/workflowevent) and read Writing a workflow event type.
Restrict it to the triggers it understands with setTriggerTypes(), as eZSimpleShippingType does.
For an event on post_checkout, the process parameters carry order_id; fetch the order with eZOrder::fetch() and
read its number, items and totals. Never read card data: there is none to read, and there must not be.
Mistakes that break a checkout
| Mistake | Symptom |
|---|---|
Payment event on checkout after instead of before | Orders are placed and mailed before anyone pays |
Shipping event on checkout before | No shipping on the confirmation page; total changes after confirming |
| Simple shipping event and a shipping handler both active | Two independent shipping charges can appear; use one or the other |
| Workflow edited but not saved | Old behavior continues; check Setup > Triggers |
workflow.php cron part not running | Deferred processes never resume (Workflows) |
| No payment workflow at all | Every order is placed unpaid; the dashboard's "Next steps" warns about it |
Related pages
- Checkout and workflows
- Workflows
- Workflows, triggers and events
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.