根据警报消息内容做一些事情
Do something based on the alert message content
我已经创建了一些自定义购物车提醒,但我目前遇到一些脚本 运行 一些 ajax 响应的问题,这些响应本应刷新 Business Catalyst 中的购物车。
我不确定它是什么,但给我时间看看发生了什么我需要根据警报消息做一些事情 所以让我们说:
1 件商品已添加到您的购物车,这将起到一些作用 window.location.reload();
或者如果它只是说:您需要选择尺寸 什么都不做
此刻我的警报是:
window.alert = function(message) {
$('.shop-main').addClass('blur');
$('.messageAlert').fadeIn().text(message).prepend('<img src="/images/ui-pieces/shopping-cart.png" width="40" height="40" alt="cart alert"/>');
setTimeout(function() {
$('.messageAlert').fadeOut();
$('.shop-main').removeClass('blur');
// window.location.reload();
}, 4000);
};
请让我知道现阶段我能做些什么。
您的关闭,您需要检查警报和运行代码。
这是我在 BC 所做的事情:
window.alert = function(text) {
if (text.indexOf("Please choose relevant options before") > -1) {
//CODE TO RUN IF ALERT MATCHES THE ABOVE TEXT
$('#choose-option').foundation('reveal', 'open');
} else if (text.indexOf("item(s) added to your cart") > -1) {
//CODE TO RUN IF ALERT MATCHES THE ABOVE TEXT
$('#store-modal').foundation('reveal', 'open');
} else if (text.indexOf("Quantity entered is too large, please enter a smaller quantity.") > -1) {
//CODE TO RUN IF ALERT MATCHES THE ABOVE TEXT
$('#limited-quantity').foundation('reveal', 'open');
}
};
在我的例子中,我打开了页面上的某些模式。您可以插入自己的 JS 来代替模态代码。
使用此代码 - 开发 => 布局 => 在线商店 => small_product.html
(将下面的代码粘贴到页面底部)
<span class="cartalert" style="display:none"></span>
<style>
.cartalert {
position: fixed;
bottom: 10%;
right: 10%;
padding: 15px 20px;
text-align: center;
background: #333;
color: #fff !important;
z-index:999999;
border-radius: 5px;
font-size: 16px;
}
</style>
<script>
$(function() {
window.alert = function(msg) {
msg = msg.replace('ERROR: ','');
$('.cartalert').text(msg).fadeIn().delay(1000).fadeOut()
}
});
</script>
我已经创建了一些自定义购物车提醒,但我目前遇到一些脚本 运行 一些 ajax 响应的问题,这些响应本应刷新 Business Catalyst 中的购物车。
我不确定它是什么,但给我时间看看发生了什么我需要根据警报消息做一些事情 所以让我们说:
1 件商品已添加到您的购物车,这将起到一些作用 window.location.reload();
或者如果它只是说:您需要选择尺寸 什么都不做
此刻我的警报是:
window.alert = function(message) {
$('.shop-main').addClass('blur');
$('.messageAlert').fadeIn().text(message).prepend('<img src="/images/ui-pieces/shopping-cart.png" width="40" height="40" alt="cart alert"/>');
setTimeout(function() {
$('.messageAlert').fadeOut();
$('.shop-main').removeClass('blur');
// window.location.reload();
}, 4000);
};
请让我知道现阶段我能做些什么。
您的关闭,您需要检查警报和运行代码。
这是我在 BC 所做的事情:
window.alert = function(text) {
if (text.indexOf("Please choose relevant options before") > -1) {
//CODE TO RUN IF ALERT MATCHES THE ABOVE TEXT
$('#choose-option').foundation('reveal', 'open');
} else if (text.indexOf("item(s) added to your cart") > -1) {
//CODE TO RUN IF ALERT MATCHES THE ABOVE TEXT
$('#store-modal').foundation('reveal', 'open');
} else if (text.indexOf("Quantity entered is too large, please enter a smaller quantity.") > -1) {
//CODE TO RUN IF ALERT MATCHES THE ABOVE TEXT
$('#limited-quantity').foundation('reveal', 'open');
}
};
在我的例子中,我打开了页面上的某些模式。您可以插入自己的 JS 来代替模态代码。
使用此代码 - 开发 => 布局 => 在线商店 => small_product.html (将下面的代码粘贴到页面底部)
<span class="cartalert" style="display:none"></span>
<style>
.cartalert {
position: fixed;
bottom: 10%;
right: 10%;
padding: 15px 20px;
text-align: center;
background: #333;
color: #fff !important;
z-index:999999;
border-radius: 5px;
font-size: 16px;
}
</style>
<script>
$(function() {
window.alert = function(msg) {
msg = msg.replace('ERROR: ','');
$('.cartalert').text(msg).fadeIn().delay(1000).fadeOut()
}
});
</script>