Skip to content

Commit

Permalink
[Cart.js] Fix fetch url so it's not hard coded (#2357) (#2365)
Browse files Browse the repository at this point in the history
* fix fetch url so it's not hard coded

* change url
  • Loading branch information
ludoboludo authored Mar 6, 2023
1 parent d8a06c5 commit cfefdd7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assets/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CartItems extends HTMLElement {
}

onCartUpdate() {
fetch('/cart?section_id=main-cart-items')
fetch(`${routes.cart_url}?section_id=main-cart-items`)
.then((response) => response.text())
.then((responseText) => {
const html = new DOMParser().parseFromString(responseText, 'text/html');
Expand Down Expand Up @@ -116,9 +116,9 @@ class CartItems extends HTMLElement {
if (cartDrawerWrapper) cartDrawerWrapper.classList.toggle('is-empty', parsedState.item_count === 0);

this.getSectionsToRender().forEach((section => {
const elementToReplace =
const elementToReplace =
document.getElementById(section.id).querySelector(section.selector) || document.getElementById(section.id);
elementToReplace.innerHTML =
elementToReplace.innerHTML =
this.getSectionInnerHTML(parsedState.sections[section.section], section.selector);
}));
const updatedValue = parsedState.items[line - 1] ? parsedState.items[line - 1].quantity : undefined;
Expand Down

0 comments on commit cfefdd7

Please sign in to comment.