LogoLogo
HomeTheme DocsSupportTry Primavera
  • Primavera Theme Docs
  • Guides
    • Quick start
    • Accessibility
    • SEO
    • How to set up the same homepage sections as the demo stores
    • How to add a mega menu
    • How to add a sidebar menu promotion
    • How to add product swatches
    • How to add a product subtitle/cutline
    • How to add product badges
    • How to add product recommendations
    • How to add an external video
    • How do I enable right-to-left support
  • Theme settings
    • Spacing
    • Appearance
    • Logo
    • Colors
    • Typography
    • Product card
    • Mini product
    • Collection card
    • Blog post card
    • Search behavaior
    • Social media
    • Currency format
    • Cart
    • Optimizations
    • Custom CSS
  • Sections
    • Announcement bar
    • Back to top
    • Banner grid
    • Before/after image
    • Bottom bar
    • Blog posts
    • Cart drawer
    • Collapsible content
    • Collection list
    • Contact form
    • Countdown timer
    • Custom liquid
    • External video
    • Featured collection
    • Featured post
    • Featured product
    • Footer
    • Header
    • Image banner
    • Image hotspot
    • Image with text
    • Logo list
    • Media grid
    • Multicolumn
    • Newsletter
    • Newsletter popup
    • Rich text
    • Rich text columns
    • Scrolling content
    • Search modal
    • Section header
    • Shoppable banner
    • Sidebar menu
    • Slideshow
    • Split banner
    • Split card
    • Stacked images with text
    • Testimonials
    • Video banner
    • Video with text
  • Blocks
    • Badges
    • Buttons
    • Card
    • Collapsible
    • Heading
    • Image
    • Liquid
    • Mini product
    • Page
    • Product
    • Text
    • Video
  • Templates
    • 404
    • Account
    • Blog
    • Blog post
    • Cart page
    • Collection
    • Collection list
    • Gift card
    • Home page
    • Product
    • Password
    • Search
  • FAQs
    • Why isn't my video autoplaying?
    • How do I edit the default theme content?
    • Where do newsletter signups go?
    • Why are my images cropped?
    • How can I change the meta color?
  • Advanced
    • Customizing code
    • JavaScript events
    • How to refresh the cart using JavaScript
    • Use a custom font
  • Contact support
Powered by GitBook
On this page
  1. Advanced

How to refresh the cart using JavaScript

This is an advanced customization. We recommend enlisting the help of a developer if you need assistance in implementing this functionality.

If your store uses custom apps, there may be occasions where you need to refresh the the cart from custom code or application code. The cart can be refreshed globally by calling the refreshCartmethond on the cart-items web component.

let cartDrawer = document.querySelector('cart-items');
cartDrawer?.refreshCart();

Note, this only refreshes the cart count and the cart drawer. If you wish to open the cart in addition to refreshing the cart, you can do so by firing a custom event.

const event = new CustomEvent('dialog:trigger:cart-drawer');
document.dispatchEvent(event);

PreviousJavaScript eventsNextUse a custom font

Last updated 1 month ago