Skip to content

Commit

Permalink
Merge pull request #5 from FastWhiteCat/data_provider_fix
Browse files Browse the repository at this point in the history
Fixed adding products from wish list
  • Loading branch information
fwc-mb authored Feb 12, 2020
2 parents b300632 + ab58a96 commit 7237ab7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
30 changes: 24 additions & 6 deletions view/frontend/web/js/data-provider.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/web-push/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 7237ab7

Please sign in to comment.