O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modeling the shopping cart

The ShoppingCartItem struct, defined in the shared/models/shoppingcart.go source file, represents an item in the shopping cart:

type ShoppingCartItem struct {  ProductSKU string `json:"productSKU"`  Quantity int `json:"quantity"`}

The ProductSKU field holds the SKU code of the product (the unique code used to distinguish a product) and the Quantity field holds the quantity of that particular product the user wishes to purchase. Each time the user hits the Add To Cart button on the products listing or product detail page, the quantity value for that particular product will be incremented in the shopping cart.

The ShoppingCart struct, also defined in the shoppingcart.go source file, represents the shopping cart:

type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required