Anton | настройка cart

This commit is contained in:
ab.an.ev@yandex.ru
2026-04-02 12:04:10 +03:00
parent 3be8f9d1c4
commit e5c963ef58
6 changed files with 294 additions and 96 deletions

View File

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