Bigcommerce的当前用户方法

时间:2016-05-03 20:03:41

标签: javascript authentication e-commerce bigcommerce

我想为我的Bigcommerce网站/商店创建一个当前的用户方法。这可能吗?

例如:

if (current_user === XYZ_user) {
  do this
}  else {
  do this other thing
}

感谢您的时间!

1 个答案:

答案 0 :(得分:1)

我将回答最直接的问题,并且我假设您没有使用新的Stencil平台。

使用您在此处看到的%% GLOBAL_CurrentCustomerFirstName %%和%% GLOBAL_CurrentCustomerLastName %%变量:

https://developer.bigcommerce.com/themes/store_wide_variables

窃取你的伪代码:

var XYZ_user = 'BobJohnson'
var current_user = '%%GLOBAL_CurrentCustomerFirstName%%%%GLOBAL_CurrentCustomerLastName%%'
if (current_user === XYZ_user) {
  do this
}  else {
  do this other thing
}

这些变量在每个页面都可用,而某些其他变量(如电子邮件地址)的可用性不完整。

但是,将这些客户放入一个组并使用%% GLOBAL_CustomerGroupId %%变量可能更好。您可以通过API获取客户组ID,也可以在编辑该组时查看控制面板中的URL。

例如:

if (%%GLOBAL_CustomerGroupId%% === 4) {
  do this
}  else {
  do this other thing
}