diff --git a/README.md b/README.md index 0d87ca5..eecb08d 100644 --- a/README.md +++ b/README.md @@ -70,3 +70,5 @@ Installing via a composer (NOTE: These steps are only necessary when installing ##### 1.0.1 - Fixed javascript file ##### 1.0.2 - Fixed index controller return data ##### 1.0.3 - Fixed observer +##### 1.0.4 - Fixed PHP version in composer require dependencies +##### 1.0.5 - Fixed adding products from wish list diff --git a/composer.json b/composer.json index 7db3d57..ad71ee0 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "fastwhitecat/sarehub", "description": "SAREhub integration for Magento2", "type": "magento2-module", - "version": "1.0.4", + "version": "1.0.5", "license": [ "OSL-3.0" ], diff --git a/view/frontend/web/js/data-provider.js b/view/frontend/web/js/data-provider.js index 39cccf5..3361394 100644 --- a/view/frontend/web/js/data-provider.js +++ b/view/frontend/web/js/data-provider.js @@ -1,30 +1,48 @@ define([ 'jquery', - 'mage/url' + 'mage/url', + ], function ($, url) { 'use strict'; return { getSareAjaxData: function () { - var jqXHR = $.ajax({ - url: url.build('sarehub/dataprovider/index'), - type: 'POST', - data: {}, + var response = '', + dataProviderUrl = window.location.origin + '/sarehub/dataprovider/index'; + + $.ajax({ + url: dataProviderUrl, + type: 'GET', + dataType: 'json', + success: function(data) { + response = data; + }, + error: function(request, error) { + console.log(error); + }, async: false, //todo::promise or sth }); - return JSON.parse(jqXHR.responseText); + return response; }, isEventAvailable: function (eventId) { let configData = this.getSareAjaxData(); + if (configData === '') { + return false + } + return configData.events[eventId]; }, getData: function (eventId, eventObject) { let configData = this.getSareAjaxData(); + if (configData === '') { + return false + } + var eventParams = { '_userId': configData.additionalData.userId, '_email': configData.additionalData.email, diff --git a/view/frontend/web/js/web-push/http.js b/view/frontend/web/js/web-push/http.js index 9d6a532..0c51fe9 100644 --- a/view/frontend/web/js/web-push/http.js +++ b/view/frontend/web/js/web-push/http.js @@ -3,8 +3,8 @@ require([ 'Fwc_SAREhub/js/data-provider', 'domReady!' ], function ($, dataProvider) { - configData = dataProvider.getSareAjaxData(); if (window['sareX_params']) { + configData = dataProvider.getSareAjaxData(); (function (p) { for (var key in p) { window['sareX_params'][key] = p[key];