getCartDetailsById

Learn how to validate whether the cart contains a subscription product.

Use this global method to verify whether the cart contains a subscription product. If the cart contains a subscription product, do not allow customer credit as the payment method since subscription renewals require a primary payment method. If your store sells subscriptions, use this method to verify whether the cart contains subscription products before allowing the user to select the customer credit as a payment method.

Sending a request

This method accepts parameters in JSON string format. You need to pass the cartId to this method.

ParameterRequired/OptionalDescription

cartId

Required

The Salesforce ID for the cart object.

Request body example
“{
    "cartId":CartId
}”

Receiving a response

You'll see the following parameters in the response.

ParameterDescription

return

This global method returns a Boolean value where:

  • true–indicates the cart contains a subscription product.

  • false–indicates the cart does not contain a subscription product.

Response body example
return true;

Calling the global method from a custom component

Import the getCartDetailsByIdmethod into your custom component javascript file with digialriverv3 as the namespace as shown below.

Import example
import getCartDetailsById from 
"@salesforce/apex/digitalriverv3.DRB2B_CustomerCreditService.getCartDetailsById";

Call the global method from a custom JavaScript file by passing the cartId as shown below.

getCartDetails() {
        getCartDetailsById({cartId:this.webcartId })
            .then((result) => { 
              // implement here logic in case of success      
            })
            .catch((error) => {
             // implement here logic in case of error
            });
        }

Last updated