VlocityDCShoppingCart

VlocityDCShoppingCart

vlocity-dc-shopping-cart is a web component to show the offers that are being added to cart.

Features
1.Shopping Cart Items
2.CRUD Operations

Constructor

new VlocityDCShoppingCart()

Properties:
Name Type Description
offer Offer offer object that you want to push into cart.
cartItems Array.<Offer> holds the all shopping cart items.
productBundle ProductBundle parent bundle which has all child offers.
loading Boolean set to False once shopping cart is loaded.
cartContextKey String Unique cart context key generated after adding offer to cart.
catalogCode String current catalog code.
Example
Sample Usage -

Include the component in your template simply by adding <vlocity-dc-shopping-cart> custom tag

<vlocity-dc-shopping-cart catalogCode="Phones" cartContextKey"abc123"></vlocity-dc-shopping-cart>
If catalogCode and cartContextKey passed via URL, then no need to pass via attributes.

--------------------------------------------------------------------------------------------------------------------------------------
 KEY INFO -

 events fired : vlocity-dc-refresh-edit-modal-content, vlocity-dc-route-navigation and vlocity-dc-sign-in

 events registered :

       | Event Name                            |        Event source component                                                                      |   Callback Function       | Description                                                  |
       |---------------------------------------|----------------------------------------------------------------------------------------------------|---------------------------|--------------------------------------------------------------|
       | vlocity-dc-delete-cart-offer          | vlocity-dc-shopping-offer-details                                                                  | deleteOfferFromCart       | delete offer from cart using basketAction="DeleteFromBasket" |
       | vlocity-dc-update-cart-offer          | vlocity-dc-shopping-offer-details                                                                  |   updateOfferInCart       | update offer to cart using basketAction="updateBasket"       |
       | vlocity-dc-open-edit-modal            | vlocity-dc-shopping-offer-details                                                                  |   configureEditModalData  | configure edit modal content                                 |
       | vlocity-dc-close-edit-modal           | vlocity-dc-edit-modal                                                                              |   closeEditModal          | close edit modal popup                                       |
       | vlocity-dc-remove-promo               | vlocity-dc-applied-promotion-list                                                                  |   removePromoFromCart     | remove the promotion from cart and applied promotion list    |
       | vlocity-dc-refresh-edit-modal-content | vlocity-dc-offer-group-sections                                                                    |   refreshEditModalContent | refresh content of edit modal popup                          |
       | vlocity-dc-promo-list-updated         | vlocity-dc-promotion-list                                                                          |   addToCart               | add selected promotion to cart                               |
       |                                       |                                                                                                    |                           |                                                              |
       |                                       | Mutiple Event Sources:                                                                             |                           |                                                              |
       |                                       |      | Component Name                        | Description                                         |                           |                                                              |
       | vlocity-dc-configure-offer            |      |---------------------------------------|-----------------------------------------------------|  updateOfferInCart        | update offer in cart                                         |
       |                                       |      | vlocity-dc-offer-attribute-config     | Event triggered on selection of offer config        |                           |                                                              |
       |                                       |      | vlocity-dc-offer-color-config         |                                                     |                           |                                                              |
       |                                       |      | vlocity-dc-offer-input-config         |                                                     |                           |                                                              |
       |                                       |                                              |                                                     |                           |                                                              |
       | vlocity-dc-checkout-cart              | vlocity-dc-totalbar                                                                                |   checkoutCart            | navigate to checkout phase                                   |
       |                                       |                                                                                                    |                           |                                                              |
       |                                       | Mutiple Event Sources:                                                                             |                           |                                                              |
       |                                       |      | Component Name                        | Description                                         |                           |                                                              |
       | vlocity-dc-checkout-success           |      |---------------------------------------|-----------------------------------------------------|                           |                                                              |
       |                                       |      | vlocity-dc-review-order               | Event triggered on phase success                    |                           |                                                              |
       |                                       |      | vlocity-dc-signin                     |                                                     |                           |                                                              |
       |                                       |      | vlocity-dc-update-billing-address     |                                                     |                           |                                                              |
       |                                       |                                              |                                                     |                           |                                                              |


 Dependency - vlocity-dc-shopping-cart has no dependency on parent component.

       | Parent Component | Expected Children Components        |
       |------------------|-------------------------------------|
       | none             | vlocity-dc-shopping-nested-offer    |
       |                  | vlocity-dc-shopping-offer-details   |

Sample with slots -

<vlocity-dc-shopping-cart>
   <span slot="{slot_name}">
     Custom HTML elements goes here
   </span>
</vlocity-dc-shopping-cart>

List of available slots -

| Slot names                        | Dynamic     | Description                           | Impact                 |
|-----------------------------------|-------------|---------------------------------------|------------------------|
| dc-shopping-cart-wrapper          | -           | Wrapper for component                 | Replaces template DOM  |
| dc-continue-btn                   | -           | Continue Button                       | Replace Button         |
| dc-sub-total-extra-column-title   | -           | new column in sub total section       | Adds new column        |
| dc-sub-total-extra-column-value   | -           | new column value in sub total section | Adds new column        |

Extends

  • LitElement

Members

(static, readonly) properties

Properties that will be available in the binding system
Properties:
Name Type Description
offer Object offer object that you want to push into cart.
cartItems Array holds the all shopping cart items.
productBundle Object parent bundle which has all child offers.
loading Boolean set to false once shopping cart is loaded.
cartContextKey String Unique cart context key generated after adding offer to cart.
catalogCode String current catalog code.

Methods

(async, static) addToCart(offer)

This function is used to fetch all the offers
Parameters:
Name Type Description
offer object An object containing current offer.

(static) addToCartGetInput(catalogCode)

This function is used to get addToCart input object
Parameters:
Name Type Description
catalogCode object An object containing current catalog.

(static) addToCartHandleFailure(error)

This function is used to handle addToCart failure
Parameters:
Name Type Description
error object Error Object from SDK call.

(static) addToCartPostHook(response)

A custom function to be used by customers for customisation, any custom action after fetch offers call is successfull can be written here
Parameters:
Name Type Description
response object SDK Response object.

(static) addToCartPreHook(input)

A custom function to be used by customers for customisation, any custom action prior to fetch offers call can be written here
Parameters:
Name Type Description
input object Current Input Object.

(static) addToCartPreSDKCalls(input)

This function is used to execute any action before addToCart SDK call is made.
Parameters:
Name Type Description
input object Current Input Object.

(static) addToCartProcessResponse(response)

This function is used to process addToCart response
Parameters:
Name Type Description
response object Response Object from SDK call.

(static) addToCartSdkCall(input)

This function is used to make SDK call for addToCart
Parameters:
Name Type Description
input object Current Input Object.

(static) configureEditModalData(heirachyPath)

this function gets the item for the modal poup based on the heirachy path.
Parameters:
Name Type Description
heirachyPath string heirarchy path of the product to be displayed.

(static) connectedCallback()

Invoked when vlocity-dc-shopping-cart component is added to the document’s DOM.

(async, static) createOrder()

Function to create order.

(static) createOrderGetInput()

Function to fetch the create order sdk call inputs

(static) createOrderHandleFailure()

A custom function to be used by customers for handling api failures

(static) createOrderPostHook()

A custom function to be used by customer's for customisation, any custom action after fetch offers call can be written here.

(static) createOrderPreHook()

A custom function to be used by customer's for customisation, any custom action prior to fetch offers call can be written here.

(static) createOrderPreSDKCalls()

This function is used to do any changes prior to sdk calls

(static) createOrderProcessResponse(response)

This function is used to process createOrder response
Parameters:
Name Type Description
response object Response Object from SDK call.

(static) createOrderSDKCall()

This function is used to do actual sdk calls

(async, static) deleteOfferFromCart(offer)

callback function for event vlocity-dc-delete-cart-offer.
Deleting offer from bundle with basketAction = "DeleteFromBasket" or basketAction = "DeleteChildProduct"
Parameters:
Name Type Description
offer Object offer that need to be deleted.

(static) deleteOfferFromCartGetInput(offer)

This function is used to get deleteOfferFromCart input object
Parameters:
Name Type Description
offer object An object denoting current offer to be deleted.

(static) deleteOfferFromCartHandleFailure(error)

This function is used to handle deleteOfferFromCart failure
Parameters:
Name Type Description
error object Error Object from SDK call.

(static) deleteOfferFromCartPostHook(response)

A custom function to be used by customers for customisation, any custom action after deleteOfferFromCart call is successfull can be written here
Parameters:
Name Type Description
response object SDK Response object.

(static) deleteOfferFromCartPreHook(input)

A custom function to be used by customers for customisation, any custom action prior to deleteOfferFromCart call can be written here
Parameters:
Name Type Description
input object Current Input Object.

(static) deleteOfferFromCartPreSDKCalls()

This function is used to execute any action before deleteOfferFromCart SDK call is made.

(static) deleteOfferFromCartProcessResponse(response)

This function is used to process deleteOfferFromCart response
Parameters:
Name Type Description
response object Response Object from SDK call.

(static) deleteOfferFromCartSDKCall(input)

This function is used to make SDK call for deleteOfferFromCart
Parameters:
Name Type Description
input object Current Input Object.

(static) disconnectedCallback()

disconnectedCallback () is invoked when vlocity-dc-shopping-cart is removed from the document’s DOM.

(async, static) getItemsInCart()

Fetching shopping cart items using getItemsInCart()

(static) getItemsInCartGetInput()

This function is used to get getItemsInCart input object

(static) getItemsInCartHandleFailure(error)

This function is used to handle getItemsInCart failure
Parameters:
Name Type Description
error object Error Object from SDK call.

(static) getItemsInCartPostHook(response)

A custom function to be used by customers for customisation, any custom action after getItemsInCart call is successfull can be written here
Parameters:
Name Type Description
response object SDK Response object.

(static) getItemsInCartPreHook(input)

A custom function to be used by customers for customisation, any custom action prior to getItemsInCart call can be written here
Parameters:
Name Type Description
input object Current Input Object.

(static) getItemsInCartPreSDKCalls()

This function is used to execute any action before getItemsInCart SDK call is made.

(static) getItemsInCartProcessResponse(response)

This function is used to process getItemsInCart response
Parameters:
Name Type Description
response object Response Object from SDK call.

(static) getItemsInCartSDKCall(input)

This function is used to make SDK call for getItemsInCart
Parameters:
Name Type Description
input object Current Input Object.

(static) initLogin()

Method to initiate login/signup SDK call.

(async, static) loginSuccess()

Method to create the order.

(async, static) updateOfferInCart(offer)

callback function for event vlocity-dc-update-cart-offer.
Updating offer to bundle with basketAction = "updateBasket"
Parameters:
Name Type Description
offer Object offer that need to be updated.

(static) updateOfferInCartGetInput(offer)

This function is used to get updateOfferInCart input object
Parameters:
Name Type Description
offer Object An object denoting current offer to be updated.

(static) updateOfferInCartHandleFailure(error)

This function is used to handle deleteOfferFromCart failure
Parameters:
Name Type Description
error object Error Object from SDK call.

(static) updateOfferInCartPostHook(response)

A custom function to be used by customers for customisation, any custom action after getItemsInCart call is successfull can be written here
Parameters:
Name Type Description
response object SDK Response object.

(static) updateOfferInCartPreHook(input)

A custom function to be used by customers for customisation, any custom action prior to updateOfferInCart call can be written here
Parameters:
Name Type Description
input object Current Input Object.

(static) updateOfferInCartPreSDKCalls()

This function is used to execute any action before updateOfferInCart SDK call is made.

(static) updateOfferInCartProcessResponse(response)

This function is used to process updateOfferInCart response
Parameters:
Name Type Description
response object Response Object from SDK call.

(static) updateOfferInCartSDKCall(input)

This function is used to make SDK call for updateOfferInCart
Parameters:
Name Type Description
input object Current Input Object.