Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
apokaliptis authored Mar 31, 2021
1 parent 51a9a38 commit a3452b3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions simpleCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,16 @@
items[item.id()] = simpleCart.extend(item.fields(), item.options());
});

localStorage.setItem(namespace + "_items", JSON.stringify(items));
// try statement to catch storing errors and avoid
// QUOTA_EXCEEDED_ERR issues in safari
if (!!window.localStorage) {
try {
localStorage.setItem(namespace + "_items", JSON.stringify(items));
}
catch (e){
simpleCart.error( "Error storing data: " + e );
}
}

simpleCart.trigger('afterSave');
},
Expand Down Expand Up @@ -1032,7 +1041,7 @@
data['item_name_' + counter] = item.get('name');
data['item_quantity_' + counter] = item.quantity();
data['item_price_' + counter] = item.price();
data['item_currency_ ' + counter] = simpleCart.currency().code;
data['item_currency_' + counter] = simpleCart.currency().code;
data['item_tax_rate' + counter] = item.get('taxRate') || simpleCart.taxRate();

// create array of extra options
Expand Down Expand Up @@ -1094,7 +1103,7 @@
data['item_title_' + counter] = item.get('name');
data['item_quantity_' + counter] = item.quantity();
data['item_price_' + counter] = item.price();
data['item_sku_ ' + counter] = item.get('sku') || item.id();
data['item_sku_' + counter] = item.get('sku') || item.id();
data['item_merchant_id_' + counter] = opts.merchant_id;
if (item.get('weight')) {
data['item_weight_' + counter] = item.get('weight');
Expand Down Expand Up @@ -1790,9 +1799,11 @@
attr = klass.split("_")[1];
val = "";
switch($item.tag().toLowerCase()) {
case "input":
case "textarea":
case "select":
val = $item.val();
break
case "input":
type = $item.attr("type");
if (!type || ((type.toLowerCase() === "checkbox" || type.toLowerCase() === "radio") && $item.attr("checked")) || type.toLowerCase() === "text" || type.toLowerCase() === "number") {
val = $item.val();
Expand Down

0 comments on commit a3452b3

Please sign in to comment.