--- displayed_sidebar: servicesSidebar --- import ParameterTypes from "@site/src/components/ParameterTypes" # CartService ## constructor ### Parameters ___ ## Properties `","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} /> ___ ## Accessors ### activeManager\_ #### Returns ___ ## Methods ### addLineItem Adds a line item to the cart. #### Parameters #### Returns #### Deprecated Use [addOrUpdateLineItems](services.CartService.mdx#addorupdatelineitems) instead. ___ ### addOrUpdateLineItems Adds or update one or multiple line items to the cart. It also update all existing items in the cart to have has\_shipping to false. Finally, the adjustments will be updated. #### Parameters #### Returns ___ ### addShippingMethod Adds the shipping method to the list of shipping methods associated with the cart. Shipping Methods are the ways that an order is shipped, whereas a Shipping Option is a possible way to ship an order. Shipping Methods may also have additional details in the data field such as an id for a package shop. #### Parameters `","description":"the fulmillment data for the method","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} /> #### Returns ___ ### adjustFreeShipping\_ Ensures shipping total on cart is correct in regards to a potential free shipping discount If a free shipping is present, we set shipping methods price to 0 if a free shipping was present, we set shipping methods to original amount #### Parameters #### Returns ___ ### applyDiscount Updates the cart's discounts. If discount besides free shipping is already applied, this will be overwritten Throws if discount regions does not include the cart region #### Parameters #### Returns ___ ### applyDiscounts Updates the cart's discounts. If discount besides free shipping is already applied, this will be overwritten Throws if discount regions does not include the cart region #### Parameters #### Returns ___ ### applyGiftCard\_ #### Parameters #### Returns ___ ### atomicPhase\_ Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created. #### Type Parameters #### Parameters Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} /> #### Returns ___ ### authorizePayment Authorizes a payment for a cart. Will authorize with chosen payment provider. This will return a payment object, that we will use to update our cart payment with. Additionally, if the payment does not require more or fails, we will set the payment on the cart. #### Parameters `","description":"object containing whatever is relevant for\n authorizing the payment with the payment provider. As an example,\n this could be IP address or similar for fraud handling.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} /> #### Returns ___ ### create Creates a cart. #### Parameters #### Returns ___ ### createOrFetchGuestCustomerFromEmail\_ Creates or fetches a user based on an email. #### Parameters #### Returns ___ ### createTaxLines #### Parameters #### Returns ___ ### decorateTotals #### Parameters #### Returns ___ ### decorateTotals\_ #### Parameters #### Returns #### Deprecated Use decorateTotals instead ___ ### delete Deletes a cart from the database. Completed carts cannot be deleted. #### Parameters #### Returns ___ ### deletePaymentSession Removes a payment session from the cart. #### Parameters #### Returns ___ ### deleteTaxLines #### Parameters #### Returns ___ ### findCustomShippingOption Finds the cart's custom shipping options based on the passed option id. throws if custom options is not empty and no shipping option corresponds to optionId #### Parameters #### Returns ___ ### getTotalsRelations #### Parameters #### Returns ___ ### getValidatedSalesChannel #### Parameters #### Returns ___ ### list #### Parameters #### Returns ___ ### onSalesChannelChange Remove the cart line item that does not belongs to the newly assigned sales channel #### Parameters #### Returns ___ ### refreshAdjustments\_ #### Parameters #### Returns ___ ### refreshPaymentSession Refreshes a payment session on a cart #### Parameters #### Returns ___ ### removeDiscount Removes a discount based on a discount code. #### Parameters #### Returns ___ ### removeLineItem Removes a line item from the cart. #### Parameters #### Returns ___ ### retrieve Gets a cart by id. #### Parameters #### Returns ___ ### retrieveLegacy #### Parameters #### Returns #### Deprecated ___ ### retrieveWithTotals #### Parameters #### Returns ___ ### setMetadata Dedicated method to set metadata for a cart. To ensure that plugins does not overwrite each others metadata fields, setMetadata is provided. #### Parameters #### Returns ___ ### setPaymentSession Selects a payment session for a cart and creates a payment object in the external provider system #### Parameters #### Returns ___ ### setPaymentSessions Creates, updates and sets payment sessions associated with the cart. The first time the method is called payment sessions will be created for each provider. Additional calls will ensure that payment sessions have correct amounts, currencies, etc. as well as make sure to filter payment sessions that are not available for the cart's region. #### Parameters #### Returns ___ ### setRegion\_ Set's the region of a cart. #### Parameters #### Returns ___ ### shouldRetryTransaction\_ #### Parameters ` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} /> #### Returns ___ ### transformQueryForTotals\_ #### Parameters #### Returns ___ ### update #### Parameters #### Returns ___ ### updateBillingAddress\_ Updates the cart's billing address. #### Parameters #### Returns ___ ### updateCustomerId\_ Sets the customer id of a cart #### Parameters #### Returns ___ ### updateLineItem Updates a cart's existing line item. #### Parameters #### Returns ___ ### updatePaymentSession Updates the currently selected payment session. #### Parameters `","description":"the data to update the payment session with","optional":false,"defaultValue":"","expandable":false,"children":[]}]} /> #### Returns ___ ### updateShippingAddress\_ Updates the cart's shipping address. #### Parameters #### Returns ___ ### updateUnitPrices\_ #### Parameters #### Returns ___ ### validateLineItem Check if line item's variant belongs to the cart's sales channel. #### Parameters #### Returns ___ ### validateLineItemShipping\_ Checks if a given line item has a shipping method that can fulfill it. Returns true if all products in the cart can be fulfilled with the current shipping methods. #### Parameters #### Returns ___ ### withTransaction #### Parameters #### Returns