Skip to content

Commit

Permalink
ADD: Checkes if values exists
Browse files Browse the repository at this point in the history
  • Loading branch information
HHarsevoord committed Nov 27, 2020
1 parent b0c3766 commit 4ef46ef
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions view/frontend/web/js/catalog/add-to-cart-mixin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
define(["jquery", "mage/translate", "jquery/ui"], function ($) {
"use strict";

var config = window["checkout"]["add_to_cart_notification"];
if (typeof window["checkout"] !== 'undefined') {
var config = window["checkout"]["add_to_cart_notification"];
}

var mixin = {
/**
Expand All @@ -20,8 +22,8 @@ define(["jquery", "mage/translate", "jquery/ui"], function ($) {
var product = data[0];
var title = $.mage.__("Added To Bag");
var message = $.mage.__('You added %1 to your <a href="%2">shopping cart</a>.')
.replace("%1", product["name"])
.replace("%2", product["cart_url"]);
.replace("%1", product["name"])
.replace("%2", product["cart_url"]);

var modalCloseBtn =
'<button class="action-close"><span>' + $.mage.__("Close") + "</span></button>";
Expand Down Expand Up @@ -119,8 +121,10 @@ define(["jquery", "mage/translate", "jquery/ui"], function ($) {
};

return function (target) {
if (!config["enabled"]) {
return target;
if (typeof config !== 'undefined') {
if (!config['enabled']) {
return target;
}
}

$.widget("mooore.catalogAddToCart", target, mixin);
Expand Down

0 comments on commit 4ef46ef

Please sign in to comment.