Browse - Add to Basket

First step towards making an honest buck is getting customers to add items to the basket. Discover the server-side APIs to get it done and sneak a peek at the client-side APIs available in the Razor Store.

 


Relevant APIs

UCommerce.Api
     TransactionLibrary.AddToBasket(
          quantity, 
          sku,
          variantSku = null,
          addToExistingLine = true,
          executeBasketPipeline = true,
          catalogId = null)

Hands-on

The SKU and VariantSku from the page are posted back the POST method in your product controller. Use the API above to add the product to the basket.


Bonus

Add another field to class “AddToBasketViewModel” that takes a quantity. Modify the form to allow the user to enter a quantity by modifying the Product.cshtml under the views folder.

{{lineitem.ProductName}}

{{lineitem.VariantName}} - {{lineitem.Quantity}} x {{lineitem.FormattedPrice}} {{lineitem.FormattedPrice}}

Your cart is empty ;(
Total {{basket.FormattedProductsTotal}}
Checkout