Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commercelayer

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commercelayer - npm Package Compare versions

Comparing version 1.7.9 to 1.8.0

2

package.json
{
"name": "commercelayer",
"version": "1.7.9",
"version": "1.8.0",
"description": "The Official Commerce Layer JS library",

@@ -5,0 +5,0 @@ "main": "./src/main.js",

@@ -57,4 +57,2 @@ const config = require('./config')

ui.disableElement(document.querySelector(".clayer-add-to-bag"))
let variants = document.querySelectorAll('.clayer-variant')

@@ -80,15 +78,21 @@

variant = document.querySelector('.clayer-variant[data-sku-code="' + skus[i].code + '"]')
let variant = document.querySelector('.clayer-variant[data-sku-code="' + skus[i].code + '"]')
if (variant) {
variant.value = skus[i].id
ui.enableElement(variant)
if (i == 0) {
module.exports.selectVariant(variant)
// if (i == 0) {
// module.exports.selectVariant(variant)
// }
let addToBag = document.querySelector('.clayer-add-to-bag[data-sku-code="' + skus[i].code + '"]')
if (addToBag) {
addToBag.dataset.skuId = skus[i].id
addToBag.dataset.skuName = variant.dataset.skuName
}
}
}
}
);
}

@@ -95,0 +99,0 @@ },

@@ -26,25 +26,27 @@ const ui = require('./ui')

setAddToShoppingBag: function() {
let addToBag = document.querySelector(".clayer-add-to-bag")
setAddToShoppingBagButtons: function() {
let addToBagButtons = document.querySelectorAll(".clayer-add-to-bag")
if (addToBag) {
addToBag.addEventListener('click', function(event) {
event.preventDefault()
if (addToBagButtons.length > 0) {
addToBagButtons.forEach(function (addToBag) {
addToBag.addEventListener('click', function(event) {
event.preventDefault()
orderPromise = utils.getOrderToken() ? api.getOrder() : api.createOrder()
orderPromise = utils.getOrderToken() ? api.getOrder() : api.createOrder()
orderPromise.then(function(order){
orderPromise.then(function(order){
api.createLineItem(order.get('id')[0], addToBag.dataset.skuId, addToBag.dataset.skuName, addToBag.dataset.skuImageUrl).then(function(lineItem){
api.getOrder()
ui.openShoppingBag()
})
.catch(function(error) {
if (error.response) {
switch(error.response.status) {
case 422:
ui.displayUnavailableMessage()
break
api.createLineItem(order.get('id')[0], addToBag.dataset.skuId, addToBag.dataset.skuName, addToBag.dataset.skuImageUrl).then(function(lineItem){
api.getOrder()
ui.openShoppingBag()
})
.catch(function(error) {
if (error.response) {
switch(error.response.status) {
case 422:
ui.displayUnavailableMessage()
break
}
}
}
})
})

@@ -51,0 +53,0 @@ })

@@ -25,3 +25,3 @@ function initCommercelayer() {

listeners.setVariantSelect()
listeners.setAddToShoppingBag()
listeners.setAddToShoppingBagButtons()
listeners.setShoppingBagToggle()

@@ -28,0 +28,0 @@ api.refreshOrder()

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc