Skip to main content

Merge Strategies

MergeOrdersStrategy

Merges both Orders. If the guest order contains items which are already in the existing Order, the guest Order quantity will replace that of the existing Order.

Signature
class MergeOrdersStrategy implements OrderMergeStrategy {
merge(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[];
}

merge

method
(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[]

UseExistingStrategy

The guest order is discarded and the existing order is used as the active order.

Signature
class UseExistingStrategy implements OrderMergeStrategy {
merge(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[];
}

merge

method
(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[]

UseGuestIfExistingEmptyStrategy

If the existing order is empty, then the guest order is used. Otherwise the existing order is used.

Signature
class UseGuestIfExistingEmptyStrategy implements OrderMergeStrategy {
merge(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[];
}

merge

method
(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[]

UseGuestStrategy

Any existing order is discarded and the guest order is set as the active order.

Signature
class UseGuestStrategy implements OrderMergeStrategy {
merge(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[];
}

merge

method
(ctx: RequestContext, guestOrder: Order, existingOrder: Order) => MergedOrderLine[]