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