Anton | настройка cart
This commit is contained in:
15
index3.js
15
index3.js
@@ -13,6 +13,7 @@ const audienceContent = {
|
||||
const cartCloseButton = document.getElementById('cartCloseButton')
|
||||
const modalBackdrop = document.getElementById('orderModal')
|
||||
const modalCloseButton = document.getElementById('modalCloseButton')
|
||||
const viewCartButton = document.getElementById('viewCartButton')
|
||||
const checkoutButton = document.getElementById('checkoutButton')
|
||||
const orderButtons = document.querySelectorAll('[data-open-order]')
|
||||
const addToCartButtons = document.querySelectorAll('.add-to-cart')
|
||||
@@ -166,7 +167,14 @@ const audienceContent = {
|
||||
return
|
||||
}
|
||||
|
||||
window.location.href = wooCommerceConfig.checkoutUrl
|
||||
cart.push({
|
||||
name: button.dataset.name,
|
||||
volume: button.dataset.volume,
|
||||
price: Number(button.dataset.price)
|
||||
})
|
||||
renderCart()
|
||||
openCart()
|
||||
button.disabled = false
|
||||
})
|
||||
.catch(() => {
|
||||
button.disabled = false
|
||||
@@ -191,6 +199,11 @@ const audienceContent = {
|
||||
openCart()
|
||||
})
|
||||
cartCloseButton.addEventListener('click', closeCart)
|
||||
viewCartButton.addEventListener('click', () => {
|
||||
if (wooCommerceConfig && wooCommerceConfig.cartUrl) {
|
||||
window.location.href = wooCommerceConfig.cartUrl
|
||||
}
|
||||
})
|
||||
checkoutButton.addEventListener('click', () => {
|
||||
if (wooCommerceConfig && wooCommerceConfig.checkoutUrl) {
|
||||
window.location.href = wooCommerceConfig.checkoutUrl
|
||||
|
||||
Reference in New Issue
Block a user