JavaScript to open Cart Tray?

New Member
2 0 0



I have a Wordpress Website with Shopify Buy Buttons. I would like to know the JavaScript trigger to open the cart tray on the right hand side, so that I can have a button in my navigation to do this. It would be helpful if the trigger / code could include the function of enforcing the cart on a page without a buy now button.


I believe the code below, is now out of date so I am looking for the up to date trigger.


Thank you!


A previous forum post made reference to this code:



For safety you'd at least want to make sure that the Shopfy embed code is even on the page to start with. A verbose safety check could look like so:

if(typeof ShopifyEmbed === 'object'){
  if(typeof ShopifyEmbed.root === 'object'){
    if(typeof ShopifyEmbed.root.showCartContent === 'function'){