How To
Customer Groups
7 min
to accommodate variable pricing and/or visibility for specific customer group , we will introduce two additional parameters to every api request pricefieldsuffix visibilitygroupid see modify request docid ndrepmgauhyltilxkg o for details on preparing for klevu js overriding see klevu api documentation for https //docs klevu com/apis/smart search examples#gi08z indexing the additional currency pricing data must be supplied at the product level during catalog indexing xml feed example below is a https //github com/klevu/feed/blob/8030b070f2b7d707791e65a2b22b2223d2c421cd/sample xml#l518 example for specific group visibility \<item> \<price>123 45 gbp\</price> \<sale price>100 gbp\</sale price> \<groups> \<group> \<id>vip customer group\</id> \</group> \</groups> below is a https //github com/klevu/feed/blob/8030b070f2b7d707791e65a2b22b2223d2c421cd/sample xml#l546 example for specific group visibility and/or variable pricing \<item> \<price>123 45 gbp\</price> \<sale price>100 gbp\</sale price> \<groups> \<group> \<id>vip customer group\</id> \<price>49 99 gbp\</price> \<sale price>49 99 gbp\</sale price> \</group> \</groups> if you intend to use multiple currencies in addition to group variable pricing and/or visibility, please review the template js docid\ oliq0hmh1p a9kpkszsqv guide for more details template js override the desired group visibility and/or prices are applied to all queries via overrides using the "all" scope value see modify request docid ndrepmgauhyltilxkg o for details on preparing for klevu js overriding example 1 exclude all records which do not belong to the group javascript \<script type="text/javascript"> // the selected customer group \<id> var klevu logincustomergroup = 'vip customer group'; klevu modifyrequest("all", function(data, scope){ klevu each(data request current recordqueries, function(key, query){ klevu setobjectpath(query, "settings visibilitygroupid", klevu logincustomergroup); }); }); \</script> bigcommerce api parameter description format visibilitygroupid exclude all records which do not belong to the group { groupid } see klevu api documentation for https //docs klevu com/apis/smart search examples#gi08z example 2 apply the specific customer group pricing for the appropriate currency javascript \<script type="text/javascript"> / important for bigcommerce app users, indexing through klevu plugin only, refer to bigcommerce tab / // the currency and group of the currently logged in customer var klevu currency = 'gbp'; var klevu logincustomergroup = 'vip customer group'; klevu modifyrequest("all", function(data, scope){ klevu each(data request current recordqueries, function(key, query){ klevu setobjectpath(query, "settings pricefieldsuffix", klevu currency + ' ' + klevu logincustomergroup); }); }); \</script> bigcommerce \<script type="text/javascript"> // the currency and group of the currently logged in customer var klevu currency = '{{currency selector active currency code}}'; var klevu logincustomergroupid = '{{customer customer group id}}' ? '{{customer customer group id}}' ''; // only modify the requests when there is a valid customer group id if (klevu logincustomergroupid) { klevu modifyrequest('all', function(data, scope){ klevu each(data request current recordqueries, function(key, query){ klevu setobjectpath(query, 'settings pricefieldsuffix', klevu currency + ' groupid ' + klevu logincustomergroupid); }); }); } \</script> api parameter description format pricefieldsuffix fetch prices/currency specific to a customer group {currency} {groupid} see klevu api documentation for https //docs klevu com/apis/smart search examples#gi08z

