Skip to content

Instantly share code, notes, and snippets.

View westondeboer's full-sized avatar

weston deboer westondeboer

View GitHub Profile
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
max_qty_tag = product.tags.find { |tag| tag.start_with?('max_') }
if max_qty_tag
max_qty = max_qty_tag.gsub('max_', '').to_i
reduce_by = line_item.quantity - max_qty
line_item.split(take: reduce_by) if reduce_by > 0
end
end