The custom widget alters the logic for pricing the shopping cart. This section describes how the pricing of the cart behaves when external pricing is enabled.

When a shopper views the product detail page for a specific product, the page displays the internal price that Oracle Commerce Cloud stores for the product. When the shopper modifies the shopping cart (adds or remove an item, or changes the quantity of an item), the custom widget makes a call to the external pricing service, and applies any external prices it receives to the items in the cart. Note that this means that the price of a product in the cart may differ from the price displayed on the product detail page.

After obtaining prices from the external pricing service, the storefront sends the current contents of the cart to the Oracle Commerce Cloud server to calculate pricing (for example, to apply promotions). This call includes externalPrice and externalPriceQuantity values for any products in the cart that have external prices.

The following shows an example of the data sent to the server:

{
  "shoppingCart": {
    "items": [
      {
        "productId": "xprod1003",
        "quantity": 3,
        "catRefId": "xsku1013",
        "stockStatus": true,
        "discountInfo": [],
        "externalPrice": "21.00",
        "externalPriceQuantity": "1",
        "invalid": false
      },
      {
        "productId": "xprod1002",
        "quantity": 5,
        "catRefId": "xsku1007",
        "stockStatus": true,
        "externalPrice": "18.00",
        "externalPriceQuantity": "-1",
        "invalid": false,
        "currentPrice": 0
      }
    ],
    "coupons": []
  }
}

In the example above, the cart contains two products, xprod1003 and xprod1002. The quantity of xprod1003 is 3, but only one of those items will have the external price applied to it ($21.00), because the externalPriceQuantity value for xprod1003 is 1. The other two items will have the internal price applied.

The quantity of xprod1002 is 5, and all of these items will have the external price applied ($18.00), because the externalPriceQuantity value for xprod1002 is -1.

When the server receives the data above, it performs a pricing operation, using the external prices for any items that have them, and applying internal prices to the rest. The repriced cart data is returned to the storefront for display.

The following example shows part of the data returned to the storefront after a pricing operation:

{
  "shoppingCart": {
    "numberOfItems": 8,
    "items": [
      {
        "onSale": false,
        "catRefId": "xsku1013",
        "shippingSurchargeValue": 0,
        "externalPrice": 21,
        "unitPrice": 36,
        "discountAmount": 0,
        "productId": "xprod1003",
        "externalPriceQuantity": 1,
        "rawTotalPrice": 93,
        "price": 93,
        "discountInfo": [],
        "listPrice": 36,
        "detailedItemPriceInfo": [
          {
            "amount": 21,
            "currencyCode": "USD",
            "tax": 0,
            "discounted": false,
            "orderDiscountShare": 0,
            "quantity": 1,
            "detailedUnitPrice": 21
          },
          {
            "amount": 72,
            "currencyCode": "USD",
            "tax": 0,
            "discounted": false,
            "orderDiscountShare": 0,
            "quantity": 2,
            "detailedUnitPrice": 36
          }
        ],
        "salePrice": 0,
        "quantity": 3
      },
      {
        "onSale": false,
        "catRefId": "xsku1007",
        "shippingSurchargeValue": 0,
        "externalPrice": 18,
        "unitPrice": 24,
        "discountAmount": 0,
        "productId": "xprod1002",
        "externalPriceQuantity": -1,
        "rawTotalPrice": 90,
        "price": 90,
        "discountInfo": [],
        "listPrice": 24,
        "detailedItemPriceInfo": [
          {
            "amount": 90,
            "currencyCode": "USD",
            "tax": 0,
            "discounted": false,
            "orderDiscountShare": 0,
            "quantity": 5,
            "detailedUnitPrice": 18
          }
        ],
        "salePrice": 0,
        "quantity": 5
      }
    ]
  },
  "discountInfo": {
    "orderCouponsMap": {},
    "orderDiscount": 0,
    "orderImplicitDiscountList": [],
    "unclaimedCouponsMap": {},
    "shippingDiscount": 0
  },
  "priceInfo": {
    "amount": 183,
    "total": 183,
    "shipping": 0,
    "totalWithoutTax": 183,
    "currencyCode": "USD",
    "shippingSurchargeValue": 0,
    "tax": 0,
    "subTotal": 183
  },
...

The response shows the effect of the external pricing. For example, the detailedItemPriceInfo object for xprod1003 shows that one item is priced at $21.00 (the external price) and the other two are priced at $36.00 each (the internal price). The total price of the three items is $93.00.


Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices