Code Monkey home page Code Monkey logo

headless-shopping-cart's Introduction

Headless Shopping Cart

This was inspired by Snipcart, this is a client side, headless, JavaScript/jQuery shopping cart with CSS styling. If you have access to HTML you can use it.


Headless Shopping Cart Installation

  1. The first step is to include the following two <script> tags and the one <link> tag in your HTML <head>. In order to optimize performance you should implement the minified versions of jQuery and Headless Shopping Cart just like the ones below.
<script src="https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.min.js"></script>
<script id="headlessshoppingcartjs" data-autopop="true" src="https://cdn.jsdelivr.net/gh/Seantheprogrammer93/[email protected]/HeadlessShoppingCart.min.js"></script>
<link rel="stylesheet" crossorigin="anonymous" type="text/css" href="https://cdn.jsdelivr.net/gh/Seantheprogrammer93/[email protected]/HeadlessShoppingCart.min.css">

You may set the data-autopop attribute in the <script> tag to true or false. Setting the data-autopop to true will allow the shopping cart modal to pop up automatically, setting the data-autopop to false will prevent the shopping cart modal from automatically popping up.

  1. The last step is to include the following <div> tag in the <body> of your HTML document.
<div class="headlessshoppingcartjs"></div>

After you complete steps 1 and 2, your HTML document should look like the example code below. Please, feel free to copy the code below if you want a simple starting point for your HTML document.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Headless Shopping Cart Demo</title>
    <script src="https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.min.js"></script>
    <script id="headlessshoppingcartjs" data-autopop="true" src="https://cdn.jsdelivr.net/gh/Seantheprogrammer93/[email protected]/HeadlessShoppingCart.min.js"></script>
    <link rel="stylesheet" crossorigin="anonymous" type="text/css" href="https://cdn.jsdelivr.net/gh/Seantheprogrammer93/[email protected]/HeadlessShoppingCart.min.css">
</head>

<body>
    <div class="headlessshoppingcartjs"></div>

    <button class="button-add" data-title="Shirt" data-description="This is a shirt" data-price="10.75"
        data-url="https://example.com/shirt"
        data-imageSrc="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fdemo.wpstartersites.com%2Fcordero-demo%2Fwp-content%2Fuploads%2Fsites%2F12%2F2020%2F06%2Fmens-tee-blue.jpg&f=1&nofb=1&ipt=3beb7e4030c314bdbafe6cfd288aaadd051db5111832d3023afbf9fcf781c4ed&ipo=images">
        Add Shirt to Cart
    </button>

    <button class="button-add" data-title="Hat" data-description="This is hat" data-price="8.12"
        data-url="https://example.com/hat"
        data-imageSrc="https://cdn.shopify.com/s/files/1/1045/5130/products/DB-GD_2000x2000.jpg?v=1544714533">
        Add Hat to Cart
    </button>
</body>

</html>

๐ŸŽ‰ Congratulations! ๐ŸŽ‰

You have successfully installed Headless Shopping Cart!


How to Use Headless Shopping Cart

After you install Headless Shopping Cart you will be able to implement a <button> in your HTML code to add a product to the cart and checkout. The following <button> tag is an example.

<button class="button-add"
        data-title="Hat"
        data-description="This is hat"
        data-price="8.12"
        data-url="https://example.com/hat"
        data-imageSrc="https://cdn.shopify.com/s/files/1/1045/5130/products/DB-GD_2000x2000.jpg?v=1544714533">
    Add Hat to Cart
</button>

headless-shopping-cart's People

Contributors

seantheprogrammer93 avatar

Stargazers

 avatar

Watchers

 avatar

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.