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>

Here's the link to view online: http://poloniafoods.weebly.com/store/p10/kozackie

Select any city, click "add to cart" then click "checkout" to see the popup window.

If a button isn't possible maybe I can use a checkbox?

justinpees
  • 420
  • 5
  • 20

2 Answers2

0

Confirm returns true or false. So instead of alert do

Var Result =  Confirm("your string here");
If (result === true) {
  // user wants to proceed write code to handle 
} else {
 // user clicked cancel handle that 
}
Kilmazing
  • 526
  • 7
  • 14
  • Can you incorporate it into the existing code that I provided? As I said I'm extremely new to jquery and don't know how to do it. – justinpees Aug 22 '16 at 03:03
0

I have altered the text in the confirm popup, sightly, but this is what you are looking for:

<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>

Basically if PickupOnly is NOT true, they will stay on the page. If PickupOnly is true, then it will let them proceed to the checkout.

Jeffrey Kastner
  • 651
  • 6
  • 15
  • Thank you so much again Jeffrey, I'll comment here with the link to my next question if I get stuck again. What you did is exactly what I wanted. Is there any way of changing the title of the popup window? – justinpees Aug 24 '16 at 00:17
  • Or is there any way to change the "OK" text to something different? – justinpees Aug 24 '16 at 02:21
  • There is no way to change the button text, or the title in the Confirm popup. You would need to create your own popup. You could use this: http://jsfiddle.net/Xtreu/ as an example, and something to work off of. – Jeffrey Kastner Aug 24 '16 at 13:46
  • Thanks for confirming that for me Jeffrey. Here is my next question in regards to that same site: http://stackoverflow.com/questions/39134814/how-to-disable-lightbox-for-my-gallery-and-open-each-thumbnail-photo-in-the-main – justinpees Aug 25 '16 at 00:11