Orders

Order Processor

Overview

The Order Processor is a class designed to manage the process of creating an order for Toolstation. It uses Laravel's Pipeline to execute a series of tasks based on the payment type specified in the order. The tasks are organized in an array, each containing a sequence of steps required to process a Toolstation order.

Class Structure

OrderProcessor Class

  • Namespace: Toolstation\Orders\OrderProcessor
  • Extends: None
  • Uses: Illuminate\Pipeline\Pipeline

Properties

orderTasks (protected array): An array that defines order tasks for various payment types. Each payment type has an array of tasks to be completed during order processing.

Methods

processOrder(array $orderData): OrderData: The main method responsible for processing an order. It accepts an array of order details, creates an OrderData object, and then executes a series of tasks based on the payment type using Laravel's Pipeline. It returns the processed OrderData object.

Order Tasks

Order tasks are organized by payment types, and each payment type has a corresponding array of tasks to be executed during order processing. Here are some notable tasks:

  • SetupOrder: Initializes the order and sets up necessary configurations.
  • ValidateOrder: Validates the order data to ensure accuracy and completeness.
  • ProcessOrder: Executes the main processing logic for the order.
  • BalanceRelatedOrders: Manages related orders and ensures a balanced state.
  • AddOrderNotesAndAttributes: Adds notes and attributes to the order.
  • CompleteOrder: Finalizes the order processing and marks it as complete.

Pipeline Execution

The processOrder method uses Laravel's Pipeline to execute a series of tasks in a defined order. The order tasks are retrieved based on the payment type, and the OrderData object is passed through each task in sequence. The result is a processed OrderData object.


Copyright © 2026