Skip to content

Instantly share code, notes, and snippets.

View lucased's full-sized avatar

Lucas Dobbins lucased

View GitHub Profile
@lucased
lucased / shopify-add-to-cart
Created October 30, 2014 11:03
Shopify - Add product to cart automatically
if (typeof Shopify === 'undefined') var Shopify = {};
Shopify.cart = {{ cart | json }};
Shopify.toAdd = 378589397;
var surchargeInCart = false;
var total = 2507; // total in cents.
for (var i=0; i<Shopify.cart.items.length; i++) {
if (Shopify.cart.items[i].id === Shopify.toAdd) {
surchargeInCart = true;
total -= Shopify.cart.items[i].line_price;