Why am I getting a discount script error in Ruby?

Why am I getting a discount script error in Ruby?

MB_AUS
Visitor
2 0 0

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
Replies 0 (0)