EcommerceService is used to get all the data related to the e-commerce operations such as get cart details, search products, add products to the wishlist. You can import the EcommerceService from the experro-storefront package.
EcommerceService provides.
getCartcreateCartupdateCustomerIdaddToCartupdateCartdeleteItemInCartsearchfacetedSearchgetFacetByCategoryNamegetProductReviewsByProductIdaddProductReviewaddCouponCoderemoveCouponCodeByIdcreateWishlistupdateWishlistdeleteWishlistgetAllWishlistsgetWishlistByIdaddItemToWishlistdeleteItemFromWishlistById
getCart
The function returns cart details.createCart
The function is used to create a cart. It accepts an object withcustomerId and line_items as properties.
userId as a customerId and line_items is an array of the products object that need to be added in cart.
updateCustomerId
The function updates the customer id for the existing cart. It accepts object withcustomerId and cartId the properties.
userId as a customerId.
addToCart
The function adds a product to the cart. It accepts an object withline_items as the property.
line_items is an array of the product object.
updateCart
The function updates the item in the cart. It accepts an object withitemId and line_item as the properties.
itemId is the id of the product item or line_item you want to update in the cart.
deleteItemInCart
The function delete the items from the cart. It accepts an object withitemId as the property.
search
The function provide a ways to search the items or products available for the purchase.It accepts object withsearchObj as property.
searchObj can have the following properties.
| Property | Description | Type |
|---|---|---|
search_term | Search text | String |
skip | Skip the result (for pagination) | Number |
limit | Limit the result (items per page) | Number |
sortBy | Sort the result by | String |
facets | Filters applied to the search | Array |
facetedSearch
This function returns facets based on search criteria. It accepts an object withsearchObj property.
getFacetByCategoryName
The function returns facets based on searched category. It accepts string. The value of the string can either be the name of a category to search orAll for a random search.
getProductReviewsByProductId
The function returns reviews for the given product. It accepts an object withproductId as the property.
addProductReview
The function add a review for the given product. It accepts an object withproductId and body as the properties.
productId is the provider_id_esi of the particular product. body is an object with following properties.
| Property | Description | Type |
|---|---|---|
title | Title of the review | String |
date_reviewed | Date of the submitting the review | Date |
text | Review comment | String |
rating | Rating between 1 to 5 | Number |
name | Name of the user | String |
email | Email of the user | String |
addCouponCode
This function apply the coupon code for the products in the cart. It accepts an object withbody as the property.
body is an object with following property
| Property | Description | Type |
|---|---|---|
coupon_code | Coupon code | String |
removeCouponCodeById
The function removes the coupon code. It accepts an object withcouponId as property.
couponId is an id of the particular coupon that should be removed.
createWishlist
This function create a new wishlist. It accepts an object withbody property.
body is an object with following property.
| Property | Description | Type |
|---|---|---|
customer_id | Logged in customer id | Number |
is_public | Make this wishlist public or not | Boolean |
name | Name of the wishlist | String |
items | Product items to add in wishlist. | Object |
updateWishlist
This function update existing wishlist’s items, name, and visibility. It accepts an object withwishlistId and body as the properties.
wishlistId is an id of an existing wishlist. body is an object.
deleteWishlist
This function deletes the wishlist. It accepts an object withwishlistId property.
getAllWishlists
This function returns all the wishlist.getWishlistById
This function returnswishlist by given id. It accepts an object with wishlistId as property.
addItemToWishlist
This function adds product item into an existing wishlist. The function accepts an object withwishlistId and body as properties.
wishlistId is an id of the existing wishlist in which item needs to be added.
The items is an array of the object with product_id and variant_id properties.
deleteItemFromWishlistById
This function deletes a particular item from the wishlist by item id. The function acceptswishlistId and itemId as properties.
wishlistId is an id of the existing wishlist and itemId is the product item id which is going to be deleted from wishlist.
subscribeToNewsLetter
This method is designed to handle newsletter subscriptions within the context of a BigCommerce store, for now.This function serves as a valuable tool for incorporating newsletter subscription functionality into a BigCommerce store. You only need to provide an
email-id as an input parameter to enable the integration.