usar window.site
This commit is contained in:
parent
8cee02a713
commit
ff1bc21610
9 changed files with 10 additions and 24 deletions
|
@ -84,20 +84,6 @@ export class CartBaseController extends Controller {
|
|||
return window.liquid
|
||||
}
|
||||
|
||||
/*
|
||||
* Site config (actually just translation strings)
|
||||
*
|
||||
* @return [Object]
|
||||
*/
|
||||
async site () {
|
||||
if (!window.site) {
|
||||
const data = await fetch('assets/data/site.json')
|
||||
window.site = await data.json()
|
||||
}
|
||||
|
||||
return window.site
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates the item counter
|
||||
*/
|
||||
|
@ -125,7 +111,7 @@ export class CartBaseController extends Controller {
|
|||
|
||||
console.error(response.fail())
|
||||
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
|
||||
switch (response.fail().name) {
|
||||
case 'MisconfigurationError':
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class extends CartBaseController {
|
|||
if (this.storage.cart) {
|
||||
const order = this.cart.data.attributes
|
||||
const products = this.products
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
const shipping_address = JSON.parse(this.storage.getItem('shipping_address'))
|
||||
|
||||
const data = { order, products, site, shipping_address }
|
||||
|
|
|
@ -181,7 +181,7 @@ export default class extends CartBaseController {
|
|||
this.fireCajon()
|
||||
|
||||
if (floating_alert) {
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
const content = site.cart.added
|
||||
window.dispatchEvent(new CustomEvent('floating:alert', { detail: { content }}))
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class extends CartBaseController {
|
|||
}
|
||||
|
||||
const payment_methods = response.success().data
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
const cart = this.cart
|
||||
const next = { url: this.data.get('nextUrl') }
|
||||
const back = { url: this.data.get('backUrl') }
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class extends CartBaseController {
|
|||
async connect () {
|
||||
if (this.params.PayerID === undefined) return
|
||||
|
||||
this.site = await this.site()
|
||||
this.site = window.site
|
||||
this.element.innerHTML = this.site.i18n.cart.layouts.paypal.confirming
|
||||
|
||||
fetch(this.executeURL)
|
||||
|
|
|
@ -68,7 +68,7 @@ export default class extends CartBaseController {
|
|||
const shipping_rates = shippingMethods.included.filter(x => x.type == 'shipping_rate')
|
||||
// XXX: No hay varios paquetes
|
||||
const shipping_method = shippingMethods.data[0]
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
|
||||
await this.render({ shipping_method, shipping_rates, site })
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ export default class extends CartBaseController {
|
|||
this.listTarget.appendChild(option)
|
||||
})
|
||||
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
|
||||
// Only allow names on this list
|
||||
this.nameTarget.pattern = countries.map(x => x.attributes.name).join('|')
|
||||
|
|
|
@ -10,7 +10,7 @@ export default class extends CartBaseController {
|
|||
|
||||
async connect () {
|
||||
const products = this.products
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
|
||||
this.render({ products, site })
|
||||
this.subtotalUpdate()
|
||||
|
@ -26,7 +26,7 @@ export default class extends CartBaseController {
|
|||
if (!event.key?.startsWith('cart:item:')) return
|
||||
|
||||
const products = this.products
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
|
||||
this.render({ products, site })
|
||||
this.subtotalUpdate()
|
||||
|
|
|
@ -25,7 +25,7 @@ export default class extends CartBaseController {
|
|||
if (!statesRequired) return
|
||||
|
||||
const states = await this.states(event.detail.iso)
|
||||
const site = await this.site()
|
||||
const site = window.site
|
||||
|
||||
states.forEach(state => {
|
||||
let option = document.createElement('option')
|
||||
|
|
Loading…
Reference in a new issue