我有一个客户想为不同的客户收取不同的价格。有些产品折扣 43%,有些产品折扣 47%,促销代码仅适用于美元金额折扣或 % 折扣。这是否可以让客户根据他们的登录登录查看特价?
问问题
681 次
1 回答
3
是的,你可以这么做。您需要为每种帐户类型设置不同的安全区域订阅。涉及到一些编码。
例如,您可以设置“零售”和“批发”安全区。{module_subscriptions}
然后,使用一些 javascript/jQuery,您可以通过将标签粘贴在隐藏的 div 中来确定用户的订阅级别。当用户登录时,标签将输出用户订阅的安全区域列表,然后您可以使用它来确定要显示的价格。
HTML:
<!--stick this before the closing body tag in your template-->
<div id="userSecureZones" style="display: none;">
<!--outputs all secure zone subscriptions when logged in -->
{module_subscriptions}
</div>
<!--When the page loads, BC will replace the {module_subscriptions}
with something like this-->
<div id="userSecureZones" style="display: none;">
<li>
<ul>
<!--each one of these represents a zone a user is subscribed to-->
<li class="zoneName">
<a href="/Default.aspx?PageID=14345490">Retail Zone</a>
</li>
<li class="zoneName">
<a href="/Default.aspx?PageID=15904302">Wholesale Zone</a>
</li>
</ul>
</li>
</div>
编码:
function getSecureZone() {
var loggedIn = !!parseInt('{module_isloggedin}');//true or false
if (!loggedIn)//user is not logged in
return false;//
var subscription = "";
var zonesList = new Array();
//grab the zones from our hidden div
var $zones = $('#userSecureZones .zoneName a');
//add each zone a user is subscribed to the zonesList array
$zones.each(function () {
var zoneName = $(this).text().toUpperCase();
//add each one to the array
zonesList.push(zoneName);
});
//set the subscription variable to the zone the user is subscribed to
//if a user can only be subscribed to one zone, then this part is simple
//if a user is subscribed to multiple zones then list the zone
//you want to take precedence last.
if (zonesList.indexOf("RETAIL ZONE")!=-1){
subscription = "RETAIL";
}
if (zonesList.indexOf("WHOLESALE ZONE")!=-1){
subscription = "WHOLESALE";
}
return subscription;//return the zone
}
正在使用:
$(function(){
var plan = getSecureZone();
if(plan=="RETAIL"){
//your code here
}
if(plan=="WHOLESALE"){
//your code here
}
});
于 2013-10-27T23:51:45.493 回答