Shopping cart

Fake cart powered by localStorage. Practice scraping cart lines, quantities, line totals, and subtotal — then continue to checkout.

Medium Ecommerce JavaScript

Challenge

After adding items from search/PDP, scrape each cart line: SKU, title, unit price, qty, line total, color/style. Also scrape subtotal, item count, and checkout URL.

← Continue shopping

Stable selectors

  • Cart root: #sc-active-cart · lines: .sc-list-item[data-sku]
  • Qty: select[name="quantity"] · unit price: [data-unit-price]
  • Line total: [data-line-total] · subtotal: #sc-subtotal-amount
  • Item count: #nav-cart-count or #sc-subtotal-count
  • Checkout: #sc-buy-box-ptc-button

Shopping Cart

Loading cart…