Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: shopping cart window

shopping cart window

lf
Excursionist
57 0 9

Immagine 2024-08-22 190903.pnghow can i put this code in the shopping cart window after clicking the atc button? i need the right code, after that i change the color and the text, please see the photo

Reply 1 (1)

dbuggger
Tourist
3 0 1

Here's a short and simple explanation with concise code:

Steps:

    • Insert a div where you want the message to appear in your cart template:

      Add a Placeholder in the Cart Window:

      html
    <div class="cart-message"></div>
  1. JavaScript to Show the Message After ATC:

    • Add this script to your theme's JavaScript file or directly in theme.liquid:
    javascript
    document.querySelectorAll('.add-to-cart-button').forEach(button => { button.addEventListener('click', () => { setTimeout(() => { document.querySelector('.cart-message').innerHTML = '<div style="padding:10px;background:#f0f0f0;color:#333;border-radius:5px;">Your custom message here!</div>'; }, 500); }); });
  2. Customize:

    • Change "Your custom message here!" and adjust styles as needed.

Explanation:

  • Placeholder: Where the message will go.
  • Script: Adds the message after the "Add to Cart" button is clicked.

That's it! Simple and easy to implement.