Skip to content

CartModule

Module in @evolve-framework/commercetools

The active cart on commercetools: cart, creating one, adding, updating and removing lines, discount codes, and the cart's B2B fields.

import { CartModule } from "@evolve-framework/commercetools";

Serves the Cart part of the GraphQL API: addressValidate, cart, cartBundleAdd, cartChangesAcknowledge, cartCreate, cartDiscountCodeAdd, cartDiscountCodeRemove, cartLineItemsAdd, cartLineItemsRemove, cartLineItemsUpdate, cartPaymentRemove, cartSetDeliveryRemarks, cartSetPurchaseOrderNumber, cartSetVatNumber, cartUpdate.

new CartModule(options: CartModuleOptions)
OptionTypeDescription
clientFactoryClientFactory

The commercetools client its requests to the project go through, built with ClientFactory.create.

customTypesCartCustomTypeKeys

Keys of the custom types this project has provisioned for a cart and a line item. Required: a missing one is a configuration error, and the framework has no key of its own to fall back on. The address key is needed only when a cart address carries a name.

minimumQuantityAttribute?string

The variant attribute holding a minimum order quantity. A line asking for less is refused as BELOW_MINIMUM_QUANTITY. Omit it when there is none.

maximumQuantityAttribute?string

The variant attribute holding a maximum per line. A line that would hold more is refused as ABOVE_MAXIMUM_QUANTITY. Omit it when there is none.

packSizeAttribute?string

The variant attribute holding a pack size. A line that would hold a quantity that is not a whole number of packs is refused as NOT_A_MULTIPLE_OF_PACK_SIZE. Omit it when nothing is sold in packs.

payments?PaymentRegistry

The payment providers checkout can use. Required for the availablePaymentMethods resolver to return anything.

vatNumberCheck?VatNumberCheck

How cartSetVatNumber checks a VAT number against the register, such as ViesClient.check from @evolve-framework/vies. Without one a number is stored unverified, and never makes a cart reverse-charged.

nameNewCarts?boolean

Name every cart created without one after the day it was made, through cartCreate or by adding the first line. Set it with MultipleCartModule: the name is written to the cart type's name field, and commercetools refuses the cart where the type has none.

Extends AbstractModule<CommercetoolsLoaderContext>.

The same module on medusa and sfcc.