Skip to content

Commit

Permalink
Allow template property for optionChange
Browse files Browse the repository at this point in the history
  • Loading branch information
bookernath committed Feb 21, 2018
1 parent 643a8e4 commit 25396da
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/api/product-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ export default class extends Base
* @param {Object} params
* @param callback
*/
optionChange(productId, params, callback) {
optionChange(productId, params, template = null, callback) {
let templateArg = template;
let callbackArg = callback;

if (typeof templateArg === 'function') {
callbackArg = templateArg;
templateArg = null;
}

const normalizedQs = normalizeQueryStringParams(params);
this.remoteRequest(this.endpoint + productId, 'POST', { params: normalizedQs }, (err, response) => {
this.remoteRequest(this.endpoint + productId, 'POST', { params: normalizedQs, templateArg }, (err, response) => {
const emitData = {
err,
response,
};

Hooks.emit('product-options-change-remote', emitData);
callback(err, response);
callbackArg(err, response);
});
}

Expand Down

0 comments on commit 25396da

Please sign in to comment.