Skip to content

Instantly share code, notes, and snippets.

@couellet
Created November 11, 2015 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save couellet/98dcadb35fa5c9fd91e6 to your computer and use it in GitHub Desktop.
Save couellet/98dcadb35fa5c9fd91e6 to your computer and use it in GitHub Desktop.
var copyAttribute = function (attr, source, target, altAttr) {
if (!!altAttr && !!source.data(altAttr)) {
target.data(attr, source.data(altAttr));
}
else {
target.data(attr, source.data(attr));
}
};
var setSnipAttributes = function (item) {
copyAttribute('item-id', item, opts.target);
copyAttribute('item-name', item, opts.target);
copyAttribute('item-price', item, opts.target, 'data-item-price-rebate');
copyAttribute('item-url', item, opts.target);
copyAttribute('item-max-quantity', item, opts.target);
copyAttribute('item-description', item, opts.target);
copyAttribute('item-taxable', item, opts.target);
copyAttribute('item-taxes', item, opts.target);
copyAttribute('item-shippable', item, opts.target);
copyAttribute('item-image', item, opts.target);
App.mediator.notify('snipcart.refresh');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment