Order Management module
Learn more about the Order Management module.
The OrderManagement
module keeps the Digital River orders and WooCommerce orders in sync by managing the state of the orders.
Specifications
This module is responsible for handling different order lifecycle states. It will also enable users to download and view order invoices for their purchases.
Order Management methods
Order Manager class
This class is the module's entry point.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: string Description: Constructs the object by passing its dependencies |
name | Arg: - Return: string Description: Returns the name of the module |
init | Arg: - Return: void Description: Initializes the module, register necessary hooks, and initialize |
create | Arg: int $order_id Return: void Description: Syncs the |
get | Arg: String $order_id Return: Description: Gets a |
is_dr_order | Arg: Return: bool Description: Checks if a WooCommerce order has a |
checkout_id | Arg: int $order_id Return: string Description: Returns the ID of the checkout corresponding to the order which has its ID |
Order Container class
This class acts as a Dependency Injection container for providing dependencies to classes present in the OrderManagement
module.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Accepts a Dependency Injection container as an argument and assigns it to a container attribute |
define_services | Arg: - Return: void Description: Defines all the classes present within the module |
get | Arg: String $service_name Return: object Description: Retrieves a service from the container |
State Manager class
This class updates the WC_Order
status to reflect the corresponding Digital River order status.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Stores the |
init | Arg: - Return: void Description: Initializes the object and register necessary hooks |
statuses | Arg: array $order_statuses Return: array Description: Add statuses to the |
register_statuses | Arg: array $statuses Return: array Description: Add statuses to the |
transit | Arg: String $event, array $event_data Return: void Description: Uses |
handle_status_transition | Arg: int $order_id, string $status_from, string $status_to, \WC_Order $order Return: void Description: Handles status change for an order and is useful for a cancellation and refund |
Fulfiller class
This class handles automatic order fulfillment.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Constructs the object by passing its dependencies |
init | Arg: - Return: void Description: Registers necessary hooks if |
order | Arg: Return: void Description: Updates the |
fulfill | Arg: int $order_id, string $status_from, String $status_to, Return: void Description: Fulfills the order by calling the Digital River fulfillment API |
prepare_items | Arg: array $items Return: array Description: Prepares items before passing them to the Digital River fulfillment API |
Invoice Manager class
This class manages order invoices.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Constructs the object by passing its dependencies |
init | Arg: - Return: void Description: Initializes the object and registers necessary hooks |
associate_invoice | Arg: Return: void Description: Associates invoice file ID to WooCommerce Order |
invoice_event | Arg: string $event_name, array $event_data Return: void Description: Handles an invoice created from |
download_invoice_action | Arg: array $actions, Return: array Description: Adds a |
download_invoice | Arg: - Return: void Description: Gets the invoice file link and redirects to it |
State Transition Handler Classes
These three Handler classes are responsible for the order state transition.
Class | Description |
| This Handler is responsible for fulfilling orders. It calls Digital River API for fulfillment so that the order can be fulfilled and eventually be completed. |
| This Handler is responsible for order cancellation. An order can only be cancelled if it is in Note: The order can only be cancelled as a whole, no partial cancellation is available. |
| This Handler is responsible for order reversal. The refund can be generated only by the store admin by selecting Note: Only completed orders can be refunded. The refund will be performed on order-level, line-item or partial refunds are not available. |
State transition classes must implement the StateTransition
interface. Optionally, they can also extend theBaseTransition
class.
State Transition Interface
Method | Args, Returns, and Descriptions |
valid | Arg: string $status_to, string $status_from, \WC_Order $order Return: bool Description: Checks if the current transition is valid or not |
transit | Arg: WC_Order $order Return: void Description: Performs any in-transition activity such as calling Digital River API |
Last updated