Tuesday, April 27, 2021

Wishlist in Sitecore Commerce

In e-commerce, wishlist or saved products for later purchase is one of the important functionality. I have created simple plugin in sitecore commerce which will save wishlist information of products such as product id, product title, product price in commerce on customer as component.

Wishlist Plugin is built on Sitecore Commerce 9.3 and is shared on github - https://github.com/savalagiakash/Sitecore-Commerce-Wishlist

This wishlist plugin has implementation of 3 apis

  1. Add Wishlist: To add wishlist to Wishlist Component
  2. Get Wishlist: Gets wishlist from Wishlist Component
  3. Remove Wishlist: Remove wishlist from Wishlist Component
Note: This plugin is not extension of OOTB sxa wishlist.
 
Below is the sample code of sitecore commerce proxy request to add, get and remove wishlist.

       
 var addWish = Proxy.DoCommand(ShopsContainer.AddWishlist(new SCPlugin.Commerce.Wishlist.Models.WishlistModel()
      {
        CustomerId = customerId,
        ProductId = productId,
        ProductPrice = productPrice,
        ProductTitle = productTitle
      }
      ));
 
 var getWished = Proxy.GetValue(ShopsContainer.GetWishlist(customerId, 10, 0));
 
 var removeWishList = Proxy.DoCommand(ShopsContainer.RemoveWishlist(customerId, productId));
       
 

No comments:

Post a Comment

Wishlist in Sitecore Commerce

In e-commerce, wishlist or saved products for later purchase is one of the important functionality. I have created simple plugin in sitecore...