<!-- Begin Impact Radius Tracking Code -->
<% if @order && @order.completed_at && @order.completed_at > 1.minute.ago && @order.send_to_impact_radius? %>

  <script type='text/javascript' src='<%= ENV['IMPACT_RADIUS_JS_URL'] %>'></script>
  <script type='text/javascript'>
    irEvent.setOrderId('<%= j @order.number %>');
    <% @order.line_items.each do |line_item| %>
    irEvent.addItem('<%= j line_item.variant.product.name %>', '<%= j line_item.variant.sku %>', '<%= line_item.price %>', '<%= line_item.quantity %>');
    <% end %>
    irEvent.setPromoCode("<%= j @order.all_adjustments.promotion.eligible.map{|a| a.source.promotion.code }.join(', ') %>");
    irEvent.setCustomerId("<%= j @order.email.first(50) %>");
    irEvent.setPostcode("<%= j @order.ship_address.zipcode %>");
    irEvent.setSubTotal("<%= @order.item_total %>");
    irEvent.setCurrency("<%= @order.currency || 'USD' %>");
    irEvent.fire();
  </script>

<% end %>
<!-- End Impact Radius Tracking Code -->
<!-- Begin Impact Radius Tracking Code -->
<% if @order && @order.completed_at && @order.completed_at > 1.minute.ago && @order.send_to_impact_radius? %>

  <script type='text/javascript' src='<%= ENV['IMPACT_RADIUS_JS_URL'] %>'></script>
  <script type='text/javascript'>
    irEvent.setOrderId('<%= j @order.number %>');
    <% @order.line_items.each do |line_item| %>
    irEvent.addItem('<%= j line_item.variant.product.name %>', '<%= j line_item.variant.sku %>', '<%= line_item.price %>', '<%= line_item.quantity %>');
    <% end %>
    irEvent.setPromoCode("<%= j @order.all_adjustments.promotion.eligible.map{|a| a.source.promotion.code }.join(', ') %>");
    irEvent.setCustomerId("<%= j @order.email.first(50) %>");
    irEvent.setPostcode("<%= j @order.ship_address.zipcode %>");
    irEvent.setSubTotal("<%= @order.item_total %>");
    irEvent.setCurrency("<%= @order.currency || 'USD' %>");
    <% if Rails.env.production? %>
      irEvent.fire();
    <% else %>
      // did not call irEvent.fire because not in production environment
    <% end %>
  </script>

<% end %>
<!-- End Impact Radius Tracking Code -->
Update to only send to IR in production.
Update to only send to IR in production.
