- Get Started
- Product
- Build
- User Guide
- Cloud
- Get Started
- Product
- Build
- Tools
- Reference
- User Guide
- Cloud
This documentation provides a reference to the addOrderLineItemsWorkflow. It belongs to the @medusajs/medusa/core-flows package.
This workflow adds line items to an order. This is useful when making edits to an order. It's used by other workflows, such as orderEditAddNewItemWorkflow.
You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around adding items to an order.
Source CodeWorkflow hook
Step conditioned by when
View step details
OrderAddLineItemWorkflowInput & AdditionalDataOrderAddLineItemWorkflowInput & AdditionalDataOrderAddLineItemWorkflowInputobjectAdditionalDataobjectadditional_data property accepted in HTTP
requests, that allows passing custom data and handle them in hooks.
Learn more in this documentation.OrderLineItemDTO[]OrderLineItemDTO[]original_totalBigNumberValueoriginal_subtotalBigNumberValueoriginal_tax_totalBigNumberValueitem_totalBigNumberValueitem_subtotalBigNumberValueitem_tax_totalBigNumberValuetotalBigNumberValuesubtotalBigNumberValuetax_totalBigNumberValuediscount_totalBigNumberValuediscount_tax_totalBigNumberValuerefundable_totalBigNumberValuerefundable_total_per_unitBigNumberValueraw_original_totalBigNumberRawValueraw_original_subtotalBigNumberRawValueraw_original_tax_totalBigNumberRawValueraw_item_totalBigNumberRawValueraw_item_subtotalBigNumberRawValueraw_item_tax_totalBigNumberRawValueraw_totalBigNumberRawValueraw_subtotalBigNumberRawValueraw_tax_totalBigNumberRawValueraw_discount_totalBigNumberRawValueraw_discount_tax_totalBigNumberRawValueraw_refundable_totalBigNumberRawValueraw_refundable_total_per_unitBigNumberRawValueidstringtitlestringrequires_shippingbooleanis_discountablebooleanis_giftcardbooleanis_tax_inclusivebooleanunit_pricenumberraw_unit_priceBigNumberRawValuequantitynumberraw_quantityBigNumberRawValuedetailOrderItemDTOcreated_atDateupdated_atDatesubtitlenull | stringOptionalthumbnailnull | stringOptionalvariant_idnull | stringOptionalproduct_idnull | stringOptionalproduct_titlenull | stringOptionalproduct_descriptionnull | stringOptionalproduct_subtitlenull | stringOptionalproduct_type_idnull | stringOptionalproduct_typenull | stringOptionalproduct_collectionnull | stringOptionalproduct_handlenull | stringOptionalvariant_skunull | stringOptionalvariant_barcodenull | stringOptionalvariant_titlenull | stringOptionalvariant_option_valuesnull | Record<string, unknown>Optionalcompare_at_unit_pricenumberOptionalmetadatanull | Record<string, unknown>OptionalHooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
Learn more about Hooks and Additional Data.
This hook is executed after the order is retrieved and before the line items are created. You can consume this hook to return any custom context useful for the prices retrieval of the variants to be added to the order.
For example, assuming you have the following custom pricing rule:
You can consume the setPricingContext hook to add the location_id context to the prices calculation:
1import { addOrderLineItemsWorkflow } from "@medusajs/medusa/core-flows";2import { StepResponse } from "@medusajs/workflows-sdk";3 4addOrderLineItemsWorkflow.hooks.setPricingContext((5 { order, variantIds, region, customerData, additional_data }, { container }6) => {7 return new StepResponse({8 location_id: "sloc_123", // Special price for in-store purchases9 });10});
The variants' prices will now be retrieved using the context you return.
Handlers consuming this hook accept the following input.
inputinputorderanyvariantIdsstring[]regionRegionDTOcustomerDataFindOrCreateCustomerOutputStepOutputadditional_dataRecord<string, unknown> | undefinedadditional_data property in HTTP requests.
Learn more in this documentation.