0
votes

I can't seem to find any documentation on whether it's possible to use either Liquid or the Shopify API to assign tags to logged in customers.

I know that I can manually add tags to existing customers, but I'm really hoping there's a more efficient way of going about it - such as creating a button/link that would assign a specific customer tag to a logged in customer's customer profile when they click on it - let them tag themselves, so to speak.

I know there's the {% assign %} function in Liquid, but that one doesn't seem to be capable of affecting variables such as {{ customer.tags }}.

1

1 Answers

0
votes

Seems easy enough. If a customer choose to tag themselves, send the tags to your App, where you can use the API to update the customer tags. You can use Ajax for that. Checking the console out... I quickly set some tags on a customer, assuming call arrived with the tags, it all worked.

c = Customer.first
=> #<ShopifyAPI::Customer:0x000001012dafa8 @attributes={"accepts_marketing"=>true, "created_at"=>"2012-06-08T22:15:47-04:00", "email"=>"[email protected]", "first_name"=>"d", "id"=>92898480, "last_name"=>"dong", "last_order_id"=>nil, "note"=>nil, "orders_count"=>0, "state"=>"disabled", "total_spent"=>"0.00", "updated_at"=>"2012-06-08T22:21:22-04:00", "tags"=>"", "last_order_name"=>nil, "addresses"=>[#<ShopifyAPI::Address:0x000001012d77b8 @attributes={"address1"=>"1330 14th Street", "address2"=>"", "city"=>"Santa Monica", "company"=>"dong incorporated", "country"=>"Canada", "first_name"=>"d", "id"=>128540200, "last_name"=>"dong", "phone"=>"3103950840", "province"=>"", "zip"=>"90404", "name"=>"d dong", "province_code"=>nil, "country_code"=>"CA", "default"=>true}, prefix_options{}, persistedfalse]}, prefix_options{}, persistedtrue

>> c.tags = "Holy Roller, Vagrant Snafu"
=> "Holy Roller, Vagrant Snafu"
>> c.save!
=> true
>> c = Customer.first
=> #<ShopifyAPI::Customer:0x00000101339968 @attributes={"accepts_marketing"=>true, "created_at"=>"2012-06-08T22:15:47-04:00", "email"=>"[email protected]", "first_name"=>"d", "id"=>92898480, "last_name"=>"dong", "last_order_id"=>nil, "note"=>nil, "orders_count"=>0, "state"=>"disabled", "total_spent"=>"0.00", "updated_at"=>"2012-09-13T14:23:39-04:00", "tags"=>"Holy Roller, Vagrant Snafu", "last_order_name"=>nil, "addresses"=>[#<ShopifyAPI::Address:0x000001013372d0 @attributes={"address1"=>"1330 14th Street", "address2"=>"", "city"=>"Santa Monica", "company"=>"dong incorporated", "country"=>"Canada", "first_name"=>"d", "id"=>128540200, "last_name"=>"dong", "phone"=>"3103950840", "province"=>"", "zip"=>"90404", "name"=>"d dong", "province_code"=>nil, "country_code"=>"CA", "default"=>true}, prefix_options{}, persistedfalse]}, prefix_options{}, persistedtrue
>> c.tags
=> "Holy Roller, Vagrant Snafu"

So it seems you could set up something pretty quickly to let customers tag themselves.