在Shopify中自动标记客户

时间:2012-09-13 16:45:37

标签: shopify

我似乎无法找到任何关于是否可以使用Liquid或Shopify API为登录客户分配标签的文档。

我知道我可以手动为现有客户添加标签,但我真的希望有一种更有效的方式来实现它 - 例如创建一个按钮/链接,为登录的客户分配特定的客户标签客户个人资料点击它们时 - 让他们自己标记,可以这么说。

我知道Liquid中有{% assign %}函数,但是这个函数似乎不能影响{{ customer.tags }}之类的变量。

1 个答案:

答案 0 :(得分:0)

似乎很容易。如果客户选择标记自己,请将标记发送到您的应用程序,您可以使用API​​更新客户标记。您可以使用Ajax。检查控制台...我快速在客户上设置了一些标签,假设呼叫到达了标签,这一切都有效。

c = Customer.first
=> #<ShopifyAPI::Customer:0x000001012dafa8 @attributes={"accepts_marketing"=>true, "created_at"=>"2012-06-08T22:15:47-04:00", "email"=>"ding@dong.com", "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"=>"ding@dong.com", "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"

所以看起来你可以很快设置一些东西让客户自己标记。