Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save schappim/01a12d29e1f9e7bd527e4b84ecbda373 to your computer and use it in GitHub Desktop.
Save schappim/01a12d29e1f9e7bd527e4b84ecbda373 to your computer and use it in GitHub Desktop.
sku_tag_mapping = {
'HLO-TCCC-ST':'Twin',
'HLO-QCCC-ST':'Full/Queen',
'HLO-KCCC-ST':'King',
'HLO-TCPC-ST':'Twin',
'HLO-QCPC-ST':'Full/Queen' #etc etc...
}
order = ShopifyAPI::Order.last
puts "\nProcessing Order:"
url_to_order = "https://resthouse.myshopify.com/admin/orders/#{order.id}"
url_to_customer = "https://resthouse.myshopify.com/admin/customers/#{order.customer.id}"
puts "<a href=\"#{url_to_order}\" target=\"_blank\">#{url_to_order}</a><br>"
customer = ShopifyAPI::Customer.find order.customer.id
order.line_items.each do |line|
puts line.title
if sku_tag_mapping.key?(line.sku)
customer.tags = "#{customer.tags}, #{sku_tag_mapping[line.sku]}"
end
end
puts "\nSaved Tags to:"
puts "<a href=\"#{url_to_customer}\" target=\"_blank\">#{url_to_customer}</a><br>"
customer.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment