根据提醒消息内容

时间:2016-03-15 14:59:47

标签: javascript jquery ajax business-catalyst

我已经创建了一些自定义购物车警报,但我现在遇到一个问题,一些脚本运行一些ajax响应,应该刷新Business Catalyst中的购物车。

我不确定它是什么,但是给我时间来研究发生的事情我需要根据警告信息做一些事情所以我们说:

已将1个商品添加到购物车中,这将执行一些window.location.reload();

或者如果它只是说:你需要选择一个尺寸DOHINGHING

在他的片刻,我的警报是:

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);
};

请让我知道我现阶段可以做的事。

2 个答案:

答案 0 :(得分:1)

关闭,你需要检查警报并根据它运行代码。

以下是我在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来代替模态代码。

答案 1 :(得分:0)

使用此代码 - Develop =&gt;布局=&gt; OnlineShop =&gt; 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>
相关问题