From e8c65a5c0d36307ebdbc99fc42affb4313e9e4e9 Mon Sep 17 00:00:00 2001 From: mtytula Date: Wed, 12 Feb 2020 07:35:01 +0100 Subject: [PATCH 1/2] Fixed adding products from wish list --- view/frontend/web/js/data-provider.js | 30 +++++++++++++++++++++------ view/frontend/web/js/web-push/http.js | 2 +- 2 files changed, 25 insertions(+), 7 deletions(-) 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]; From ab58a963760a0e0a3daf8398d6bc03e290f19c9c Mon Sep 17 00:00:00 2001 From: mtytula Date: Wed, 12 Feb 2020 07:41:13 +0100 Subject: [PATCH 2/2] Updated composer and readme --- README.md | 2 ++ composer.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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" ],