ng-easycommerce 0.0.449 → 0.0.450

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ # version 0.0.450
2
+ - Se arregla el metodo de decidir para que use las url segun el entorno enviado en el campo public_enviroment
3
+ - Se agrega un metodo en el channel-config.service.ts para poder cambiar de canal via hostname.
1
4
  # version 0.0.449
2
5
  - Se quitan los decimales para la moneda de Suecia (SEK)
3
6
 
@@ -15,6 +15,7 @@
15
15
 
16
16
  let modoHead = dataDecidirHead?.config?.public_environment || null
17
17
  modoHead && (modoHead == 'prod' && (modoHead = false) || modoHead == 'test' && (modoHead = true))
18
+ //console.log('modo head',modoHead, dataDecidirHead)
18
19
  !modoHead && (modoHead = window.location.host.includes('easycommerce'))
19
20
  let my_awesome_script = document.createElement('script');
20
21
  my_awesome_script.setAttribute('defer', 'defer')
@@ -88,7 +89,7 @@
88
89
  my_copy_script.setAttribute('type', 'text/javascript');
89
90
 
90
91
  let infoDecidir = JSON.parse(localStorage.getItem('dataDecidir')) || undefined
91
- console.log(infoDecidir)
92
+ //console.log(infoDecidir)
92
93
  let urlBase = 'https://h.online-metrix.net/fp/tags.js';
93
94
  let ord_id = infoDecidir?.config?.public_environment == 'test' ? '1snn5n9w' : 'k8vif92e'
94
95
  let merchand_id = infoDecidir?.config?.public_merchand_id || 'decidir_agregador'
@@ -288,10 +289,9 @@
288
289
  let cybersource = dataDecidir?.config?.public_cybersource && dataDecidir?.config?.public_cybersource == 'deshabilitado'
289
290
  let modo = dataDecidir?.config?.public_environment || null
290
291
 
291
- modo && (modo == 'prod' && (modo = false) || modo == 'test' && (modo = true))
292
- !modo && (modo = window.location.host.includes('easycommerce'))
292
+ modo ? (modo == 'prod' ? modo = false : modo = true): (modo = window.location.host.includes('easycommerce'))
293
293
 
294
- const decidir = new Decidir(modo && urlSandbox || urlProduccion, cybersource);
294
+ const decidir = new Decidir(modo && modo ? urlSandbox : urlProduccion, cybersource);
295
295
  decidir.setPublishableKey(publicApiKey);
296
296
  decidir.setTimeout(5000);
297
297
 
@@ -3480,6 +3480,30 @@
3480
3480
  _this.consts.setCurrency(channelObj.baseCurrency);
3481
3481
  _this.injector.get(AddressingService).setTypeSelectAddress(channelObj.headquarterSelectionOnly || 'LOAD_ADDRESS_AND_SELECTION');
3482
3482
  };
3483
+ /**
3484
+ * @description cambian de canal segun el hostname que recibe por parametro.
3485
+ * @warning esta funcion es util para el caso en que se necesite manejar url distintas,
3486
+ * cada una con su configuración de canal, pero utilizando el mismo frontend.
3487
+ * En cualquier otro caso, utilizar las demas herramientas.
3488
+ * @param {string} hostname hostname del canal que se requiere utilizar.
3489
+ */
3490
+ this.changeChannelByHostname = function (hostname) {
3491
+ //console.log(this.channelsSubject.getValue())
3492
+ _this.connection.get(_this.channelsApi()).toPromise().then(function (res) {
3493
+ var channel = res.filter(function (elem) { return elem.hostname == hostname; });
3494
+ if (channel) {
3495
+ if (channel[0].code != _this.consts.getChannel()) {
3496
+ console.log(channel[0]);
3497
+ _this.changeChannel(channel[0]);
3498
+ window.location.href = window.location.href;
3499
+ }
3500
+ }
3501
+ else {
3502
+ console.log("El hostname no coincide con ninguno que venga en los canales");
3503
+ }
3504
+ });
3505
+ //return channel
3506
+ };
3483
3507
  this.getChannelConfig();
3484
3508
  this.getChannels();
3485
3509
  this.getLocales();