Add-to-Cart Button

Add-to-Cart Button

You can easily place a button on a page that will add an item to the cart, and/or direct the user to the cart.

The code for doing so is as follows:

<script src="https://{your back-end domain}/lz_client/base.min.js"></script>
<script type="text/javascript">
   const CaptinaCTA_config = {
      "items":       [
         {
            "cat_id":   1,
            "target":   "foo_1",
            "price_ea": 99.95
         },
         {
            "cat_id": 1151,
            "target": "foo_2"
         }
      ],
      "store_page":  "order",
      "qty_chooser": true,
      "add_to_cart": {
         "string":  "add to cart",
         "success": "go to store"
      }
   };
</script>
<script src="https://{your back-end domain}/lz_client/call_to_action_widget.js"></script>

You may include as many buttons as you like on a page, each of which must be represented by an object in the CaptinaCTA_config.items array. Each object must include the cat_id for the item as well as the id of the html target into which to place the button.

Specify the name of your webstore "slug" in CaptinaCTA_config.store_page. If you want the user to be able to set the quantity, set the qty_chooser to true.

Finally, specify the nature of the button by creating either an add_to_cart or an open_in_store element in CaptinaCTA_config. In either case, the button created will use the string element's content.

If you choose open_in_store then the user will be taken to the store and the item will be displayed.

Choosing add_to_cart will add the item to the shopping cart; if you also specify a success element, which will replace the string once an item has been added. Clicking the button a second time will then take the user to the web store.