forked from M3-Academy/m3-academy-template-checkout
Adiciona função de reset do meu carrinho
This commit is contained in:
parent
d540343819
commit
242abf2373
@ -32,13 +32,12 @@ export default class CheckoutUI {
|
|||||||
toggleFooterDropdown(event) {
|
toggleFooterDropdown(event) {
|
||||||
event.target.classList.toggle("closed");
|
event.target.classList.toggle("closed");
|
||||||
|
|
||||||
event.target.nextElementSibling.classList.toggle(
|
event.target.nextElementSibling.classList.toggle("dropdown__content--closed");
|
||||||
"dropdown__content--closed"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.configThumb();
|
this.configThumb();
|
||||||
|
this.resetTitle();
|
||||||
waitForEl(".product-image img", this.resizeImages.bind(this));
|
waitForEl(".product-image img", this.resizeImages.bind(this));
|
||||||
$(window).on("orderFormUpdated.vtex", this.resizeImages.bind(this));
|
$(window).on("orderFormUpdated.vtex", this.resizeImages.bind(this));
|
||||||
}
|
}
|
||||||
@ -56,14 +55,27 @@ export default class CheckoutUI {
|
|||||||
resizeImages() {
|
resizeImages() {
|
||||||
$(".product-image img").each((i, el) => {
|
$(".product-image img").each((i, el) => {
|
||||||
const $el = $(el);
|
const $el = $(el);
|
||||||
$el.attr(
|
$el.attr("src", alterarTamanhoImagemSrcVtex($el.attr("src"), this.width, this.height));
|
||||||
"src",
|
|
||||||
alterarTamanhoImagemSrcVtex(
|
|
||||||
$el.attr("src"),
|
|
||||||
this.width,
|
|
||||||
this.height
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetTitle() {
|
||||||
|
const orderForm = await window.vtexjs.checkout.getOrderForm();
|
||||||
|
const itemsForm = orderForm.items.length;
|
||||||
|
const cartId = document.querySelector("#cart-title");
|
||||||
|
|
||||||
|
$(window).on("orderFormUpdated.vtex", (evt, oF) => {
|
||||||
|
if (oF.items.length <= 0) {
|
||||||
|
cartId.style.display = "none";
|
||||||
|
} else {
|
||||||
|
cartId.style.display = "block";
|
||||||
|
}
|
||||||
|
if (window.location.hash === "#/shipping" || window.location.hash === "#/payment") {
|
||||||
|
cartId.style.display = "none";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (itemsForm === 0) {
|
||||||
|
cartId.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user