Rebrand 2023 Learn more 

  • Commerce Cloud/
    Carts/
    Cart Management API/
    Cart Settings

    Cart Settings

    You can modify the cart expiry settings to set it to any number of days up to 365. Any existing carts default to the expiry of 7 days. To update cart settings in Commerce Manager, see Updating Cart setting.

    With cart settings, you can enable or disable your custom discounts. You can set the custom_discounts_enabled field to true to enable your custom discounts from external services.

    GET Get Cart Settings

    https://useast.api.elasticpath.com/v2/settings/cart
    

    Parameters

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API. Grant type must be client_credentials.

    Request examples

    Curl

    curl -X GET https://useast.api.elasticpath.com/v2/settings/cart \
         -H "Authorization: Bearer XXXX" \
         -H "Content-Type: application/json" \
    

    JavaScript SDK

    // Where `EPCC` is an authenticated client
    await EPCC.Settings.Cart();
    

    Response example

    200 OK

    {
        "data": {
            "type": "settings",
            "cart_expiry_days": 7,
            "discounts": {
                "custom_discounts_enabled": false
            }
        }
    }
    

    PUT Update Cart Settings

    https://useast.api.elasticpath.com/v2/settings/cart
    

    Parameters

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API. Grant type must be client_credentials.

    Body

    NameRequiredTypeDescription
    typeRequiredstringThe type is settings.
    cart_expiry_daysRequirednumberThe number of days in which the cart will expire.
    discounts.custom_discounts_enabledOptionalbooleanWhen true, custom discounts are enabled. Default is false. Note: This setting only affects the new empty carts while the existing active carts will not be affected.

    Request examples

    Curl

    curl -X PUT https://useast.api.elasticpath.com/v2/settings/cart \
         -H "Authorization: Bearer XXXX"
         -d $'{
            "data": {
               "type": "settings",
               "cart_expiry_days": 365
               "discounts": {
                    "custom_discounts_enabled": false
            }
          }
        }
    

    JavaScript SDK

    const data = {
        type: "settings",
        cart_expiry_days: 365,
    };
    
    
    // Where `EPCC` is an authenticated client
    await EPCC.Settings.UpdateCart(data);
    

    Response example

    200 OK

    {
        "data": {
            "type": "settings",
            "cart_expiry_days": 7,
            "discounts": {
                "custom_discounts_enabled": false
            }
        }
    }
    

    Error Response Examples

    You might encounter the following error response if cart_expiry_days is not set to less than or equal to 365.

    {
        "errors": [
            {
                "status": 400,
                "source": "data.cart_expiry_days",
                "title": "number_lte",
                "detail": "Must be less than or equal to 365",
                "meta": {
                    "value": 366
                }
            }
        ]
    }
    

    In this example, when discounts.custom_discounts_enabled is set to true and the existing cart has fixed discount promotion, the promotion will not be applied to the cart and the following error response is returned:

    {
        "errors": [
            {
                "status": 422,
                "title": "Could not apply EP promotion with the given code",
                "detail": "The cart is configured to use custom discounts",
                "meta": {
                    "code": "nike80"
                }
            }
        ]
    }
    
    Previous
    Delete a Cart