Order copies

The order copy object and the allowed CRUD operations on the related resource endpoint

Order copies generate asynchronously a copy of a source order and all of its associated line items, line item options, payment source (if stored within the customer wallet) and addresses.

They can be used standalone to allow orders editing (no matter their state) or generated recursively as part of a manually generated order subscription, in which case they are usually automatically placed according to the specified frequency.

You can set different options, based on how you want the order copy process to be performed:

  • place_target_order — the copied order is going to be placed at the end of the process (default for order subscriptions).

  • cancel_source_order — the source order is going to be cancelled at the end of the process.

Retriggering promotions

By default, order copies create frozen copies of the source order. That means that promotions and discounts line items are copied as is (without being recomputed). A recalculation occurs if the target order is edited (e.g. adding or removing line items) only.

To manage promotion recalculation differently you can leverage two specific attributes:

  • ignore_invalid_coupon — if an invalid (e.g. expired, single-use, etc.) coupon is associated with the source order, it's not copied with the target order (without blocking the copy process or throwing any errors).

  • apply_promotions — the promotion application is retriggered at the end of the copy process (i.e. the line items related to promotions are cancelled and recreated only if still valid).

If you need promotions to be recomputed and want to be certain to avoid possible errors about the coupon's copy (if any), make sure to set both of the attributes above to true. Please note that these options are available for order copies only (not for recurring order copies).

Skipping copy errors

By default, order copies that collect errors (e.g. one or more line items run out of stock) fail. You can override this behavior by setting the skip_errors attribute to true. This way, only a check on the correct target order's creation is performed, while any other error is ignored and the order copy is moved to completed.

Data model

Check the related ER diagram and explore the flowchart that illustrates how the order copy resource relates to the other API entities.

Last updated