-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodaal-JS
58 lines (50 loc) · 1.59 KB
/
modaal-JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
after window.customElements.define('media-gallery', MediaGallery); add
$(document).on('click','button.modaal-close.modaal-toggle, .modaal-overlay.modaal-toggle', function(){
$('.modaal.is-visible').removeClass('is-visible')
})
after:
// Re-enable 'Add to Cart' button. // Re-enable 'Add to Cart' button.
this.submitBtn.classList.remove('is-loading'); this.submitBtn.classList.remove('is-loading');
this.submitBtn.classList.remove('is-success'); this.submitBtn.classList.remove('is-success');
this.submitBtn.removeAttribute('aria-disabled');
add
}
}else{
// if size option is not selected opening a popup
$('.modaal').addClass('is-visible');
leave last two }
}
as-is
add to end:
// Add item from popup and showing in mini cart
function addItem(v_id, but){
but.innerHTML = '✓ Added';
but.disabled = true;
let formData = {
'items': [{
'id': v_id,
'quantity': 1
}]
};
fetch(window.Shopify.routes.root + 'cart/add.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
})
.then(response => {
return response.json();
}).then(data =>{
console.log(data);
but.innerHTML = 'Add To Cart';
but.disabled = false;
let cart_form = document.querySelector('cart-form')
cart_form.refresh()
$('a.cart-link[href="/cart"]')[0].click()
$('.modaal-close')[0].click()
})
.catch((error) => {
console.error('Error:', error);
});
}