1 min read
Cart extensions
The cart is where the products your customers plan to purchase are displayed.
You can use Cart extension points to apply promotions, add or remove items or add custom data to your customer's cart as they shop.
Extension Point: Get Cart
The Get Cart extension point allows you to interact with data in the cart.
FETCH
Use Fetch to get the cart response from your system. Any existing cart in the Poq database is ignored and the fetched cart response is sent to the app unaltered.
You can use this method when the cart entirely depends on a 3rd party, including add to cart and other functions.
Request
This request is sent by the Poq platform to your external system:
GET
{yourApi}
Accept: application/jsonAuthorization: {Authorization Header Value}
Response
The response below is a sample of what should be returned by your external system. Those fields marked Required must be included in your response.
200 OK
{ "cartItems": [ { "id": "", //required "productId": "", //required "brand": "", "color": "", "isInStock": true, //required "title": "", //required "thumbnailUrl": "", //required "quantity": 0, //required "variantId": "", //required "variantName": "", //required "price": { "now": 0, //required "was": 0, } } ], "total": { "now": 0, //required "was": 0, }, "customData": {}}
REPLACE
Use Replace to send your customer's cart data from your app to your external system. A new cart response is sent from your external system to the app, replacing the data originally there.
This can be used when cart functionality depends on the Poq database. Your external system enriches the data it holds with the data from your Poq app. The response completely replaces the platform cart response.
Request
This request is sent by your app to your external system. It contains the required Cart data, and some optional data:
POST
{yourApi}
Accept: application/jsonAuthorization: {Authorization Header Value}Currency-Code: {ISO 4217 Currency Code Value}
{ "cartItems": [ { "id": "", "productId": "", "brand": "", "color": "", "isInStock": true, "title": "", "thumbnailUrl": "", "quantity": 0, "variantId": "", "variantName": "", "price": { "now": 0, "was": 0, } } ], "total": { "now": 0, "was": 0, }, "customData": {}}
Response
The response below is a sample of what should be returned by your external system. Those fields marked Required must be included in your response.
200 OK
{ "cartItems": [ { "id": "", //required "productId": "", //required "brand": "", "color": "", "isInStock": true, //required "title": "", //required "thumbnailUrl": "", //required "quantity": 0, //required "variantId": "", //required "variantName": "", //required "price": { "now": 0, //required "was": 0, } } ], "total": { "now": 0, //required "was": 0, }, "customData": {}}
EXTEND
Use this to get data from your external system and add it to the existing data in the cart in your app.
You can use this when your cart functionality depends on the Poq database. Your exteranl system is used to enrich the data, it does not require Poq's data to do this. All properties contained in the 3rd party response will overwrite the same property in Poq's platform response, except customData
, which will be merged.
Request
This request is sent by your app to your external system. It does not contain any cart data, but requests data that can then be added to the cart in your app:
GET
{yourApi}
Accept: application/jsonAuthorization: {Authorization Header Value}Currency-Code: {ISO 4217 Currency Code Value}
Response
The response below is a sample of what could be returned by your external system. All fields in an Extend response are optional.
200 OK
{ "cartItems": [ { "id": "", "productId": "", "brand": "", "color": "", "isInStock": true, "title": "", "thumbnailUrl": "", "quantity": 0, "variantId": "", "variantName": "", "price": { "now": 0, "was": 0, } } ], "total": { "now": 0, "was": 0, }, "customData": {}}