Code Monkey home page Code Monkey logo

shopify-add-to-cart's Introduction

shopify-add-to-cart

Automatically add a product to every Shopify cart before your customers check out. Great for gifts, packaging materials, or any other line items you need on every order.

Installation

Add the following to your Shopify theme:

<script src='https://ca-la.github.io/shopify-add-to-cart/add.js'></script>
<script>window.ShopifyAddToCart.autoAdd('MY_VARIANT_ID');</script>

โ€” Replace MY_VARIANT_ID with the ID of the variant for the item you'd like to add to each cart.

Hiding items from the cart (beta)

<script>window.ShopifyAddToCart.hideCartItems('MY_VARIANT_ID');</script>

Finding your Variant ID

  1. Create a Shopify product to represent the item you'd like to add to every cart (e.g. "your free gift").
  2. Take the URL of this product in your shopify admin dashboard, and add /variants.json?fields=id on the end.
    • e.g. My product URL is https://mystore.myshopify.com/admin/products/1434053640247, so I want to go to https://mystore.myshopify.com/admin/products/1434053640247/variants.json?fields=id
  3. Grab the ID number that appears on the screen (e.g. 12867262677047). That's your "variant ID" for this gift item.

Editing your Shopify theme

  1. In the sidebar of your admin dashboard, click "Sales Channels" -> "Online Store" -> "Themes". From the "Actions" dropdown, select "Edit Code".
  2. Find the theme.liquid file, scroll to the bottom, and paste the code from before, right before the closing </body> tag.
  3. Hit Save, and enjoy!

Contributing to this project

Edit add.ts. Uses Prettier. Run npm run format before commiting.

shopify-add-to-cart's People

Contributors

alevkon avatar dylanpyle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

webhjorth

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.