Personalized checkout and custom promotions with Shopify Scripts
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi Community
Having errors on the below script on the RATE line. New to Ruby so wanting to check prior to having a go at modifying it.
# Customer Tag Discounts CONSULTANT = 'consultant' TEAM_LEAD = 'team_lead' STAFF = 'staff' $customer_tag = '' if !Input.cart.customer.nil? if Input.cart.customer.tags.include?(CONSULTANT) $customer_tag = CONSULTANT elsif Input.cart.customer.tags.include?(TEAM_LEAD) $customer_tag = TEAM_LEAD elsif Input.cart.customer.tags.include?(STAFF) $customer_tag = STAFF end if $customer_tag != '' Input.cart.line_items.each do |line_item| line_item.variant.product.tags.each do |tag| if tag.include?($customer_tag) RATE = (tag[(tag.index(':') + 1)..-1].to_f) / 100 line_item.change_line_price(line_item.line_price - (line_item.line_price * RATE), message: $customer_tag) end end end end end