0
<script>
jQuery(function() {
var $ = jQuery;
$(document).on('touchstart mouseover', 'a#wsite-com-minicart-checkout-button', function(e) {
  var totalCount = $( "span#wsite-nav-cart-num" ).text();
  var totalNeeded = 12;
  if (totalCount < totalNeeded) {
     var totalItems = totalNeeded - totalCount;
     $("a#wsite-com-minicart-checkout-button").click(function(event){
        event.stopImmediatePropagation();
        alert('Orders under ' + totalNeeded + ' packages are only available for pickup. Click "Order for Pickup" to proceed to checkout. If not, click "OK" and add ' + totalItems + ' more packages for us to ship your order.');
       return false;
     });
  }
});
});
</script>

这是在线查看的链接:http: //poloniafoods.weebly.com/store/p10/kozackie

选择任何城市,点击“添加到购物车”,然后点击“结帐”即可看到弹出窗口。

如果一个按钮是不可能的,也许我可以使用一个复选框?

4

2 回答 2

0

确认返回真或假。所以不是 alert 而是

Var Result =  Confirm("your string here");
If (result === true) {
  // user wants to proceed write code to handle 
} else {
 // user clicked cancel handle that 
}
于 2016-08-22T02:25:31.797 回答
0

我已经更改了确认弹出窗口中的文本,但这是您要查找的内容:

<script>
jQuery(function() {
var $ = jQuery;
  $(document).on('touchstart mouseover', 'a#wsite-com-minicart-checkout-button', function(e) {
      var totalCount = $( "span#wsite-nav-cart-num" ).text();
      var totalNeeded = 12;
      if (totalCount < totalNeeded) {
         var totalItems = totalNeeded - totalCount;
         $("a#wsite-com-minicart-checkout-button").click(function(event){
            event.stopImmediatePropagation();
            var PickupOnly = confirm('Orders under ' + totalNeeded + ' packages are only available for local pickup. If this order is for local pickup only, click "Ok" to proceed to checkout. If not, click "Cancel" and add ' + totalItems + ' more packages for us to ship your order.');
            if (PickupOnly !== true) {
               return false;
            }
         });
      }
  });
});
</script>

基本上,如果 PickupOnly 不正确,它们将留在页面上。如果 PickupOnly 为真,那么它将让他们继续结帐。

于 2016-08-23T12:24:45.867 回答