Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kmishal's full-sized avatar
🎯
Focusing

Kaustubh Mishal kmishal

🎯
Focusing
View GitHub Profile
@kmishal
kmishal / shopify-money.js
Created March 9, 2023 11:28 — forked from stewartknapman/shopify-money.js
The Shopify.formatMoney method extracted from option_selection.js for stand-alone purposes.
var Shopify = Shopify || {};
// ---------------------------------------------------------------------------
// Money format handler
// ---------------------------------------------------------------------------
Shopify.money_format = "${{amount}}";
Shopify.formatMoney = function(cents, format) {
if (typeof cents == 'string') { cents = cents.replace('.',''); }
var value = '';
var placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
var formatString = (format || this.money_format);
discounted_product = 12275195905
products_needed = [592406273]
products_seen = []
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
products_seen << product.id if products_needed.include?(product.id)
end
Input.cart.line_items.each do |line_item|