Signup

Wholesale - All in one by DigitalCoo

Within your themes storepickup-addons.liquid file add the following code:

<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
  window.customCheckoutValidation = function() {
    document.getElementById("checkoutBtn").innerHTML = "Loading ...";
   
    _coup('a', function(){
      var discount = (window.win_coupanCode === 'undefined') ? ' ' : window.win_coupanCode;
      var checkout_params = Zapiet.Widget.getCheckoutParams();
      checkout_params.discount = discount;
     
      window.location = '/checkout?' + new URLSearchParams(checkout_params);  
    });
  };
});
</script>

That's it. Now both apps should play well together. 


Instructions for new Wholesale version

Step #1: You need to add this code in storepickup-addons.liquid file

<script type="text/javascript"> 
document.addEventListener("DOMContentLoaded", function(event) {
window.customCheckoutValidation = function() {
if(typeof WSAIO != "undefined"){
WSAIO.getDiscountCode(function(b, c) {
var discountt = c.checkout_url.split("discount=")[1];
var discount = (discountt === undefined) ? ' ' : discountt;
var checkout_params = Zapiet.Widget.getCheckoutParams();
checkout_params.discount = discount;
window.location = '/checkout?' + new URLSearchParams(checkout_params);
});
}else{
var checkout_params = Zapiet.Widget.getCheckoutParams();
checkout_params.discount = ' '
window.location = '/checkout?' + new URLSearchParams(checkout_params);
}
};
});
</script>

 

Step #2: Add this function in wholesale-all-in-one.min.js file under WSAIO.checkout function

WSAIO.getDiscountCode = function(callback) {
if (WSAIO["debugger"]) {
debugger;
}
a.fetchCart(function(b, c) {
if (b) {
return h(b);
}

 var note_attr = [];
Object.keys(c.attributes).forEach(function(key, i){
var item = c.attributes[key];
note_attr.push({
"name": key,
"value": item
});
});

}
console.log("note_attr",c.attribute);

a.checkoutRequest({
note_attributes:note_attr,
cart:c,
tags:"wsaio-app",
note:g("[name=note]").val(),
shopInfo:a.shopInfo,
customer:a.customer,
user_mode:a.user_mode,
currency:a.shopInfo.currency,
custom_line_items:[],
shopifyCurrencies:a.getCurrencies(),
discount_code_application:WSAIO.DiscountCode.application,
products_with_collections:a.products_with_collections},
callback);
});
};

 

Step #3: Find this g(document).on("click", a.checkout_selector, function(b) { in wholesale-all-in-one.min.js file and comment inner code

WSAIO.checkoutEventListner = function(b) {
g(a.checkout_selector).removeAttr("disabled");
g(document).on("click", a.checkout_selector, function(b) {
// b.preventDefault();
// b.stopImmediatePropagation();
// b.stopPropagation();
// g(this).attr("disabled");
// g(this).find('[name="discount"], [name="clear_discount"]').remove();
// g(this).parents("form").find('[name="discount"], [name="clear_discount"]').remove();
// k("Wholesale All In One checkout is working.");
// a.checkout();
});
};

 
Step #4: Change checkout discount method to 'Coupon Code' from the application settings. 

 

Validation for NET Terms feature

Check that the window.ZapietCheckoutEnabled is `true`? When that parameter is true it means that "Store Pickup + Delivery" validation has been ran and the customer is allowed to proceed to the checkout. If the value is false then they should not be directed to the checkout.

That's it. Now both apps should play well together.

I
Ismail is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.