Change the button link of the add to cart button - Broadcast Theme

New Member
2 0 0

Hello,

Currently we have a popup show up when someone adds a product to the cart, but we want the link to go directly to the cart page. Our theme is broadcast, I saw another thread explaining it for the theme.js, but since ours is a bit different, maybe someone can point out how to program it. I attached the code of the cart section in the theme.js:

 

theme.Cart = (function() {
function Cart(container) {
this.init();
$('[data-cart-additional]').appendTo('[data-additional-insert]').slideDown('slow');

}
Cart.prototype = $.extend({}, Cart.prototype, {
init: function(){
this.initQuantity();

$('.show-calculator').off().on('click', function() {
$('#ShippingCalculator').slideToggle();
$(this).toggleClass('open');
});
$('.show-note').off().on('click', function() {
$('#NoteForSeller').slideToggle();
$(this).toggleClass('open');
});

Shopify.Cart.ShippingCalculator.show( {
submitButton: theme.strings.shippingCalcSubmitButton,
submitButtonDisabled: theme.strings.shippingCalcSubmitButtonDisabled,
customerIsLoggedIn: theme.strings.shippingCalcCustomerIsLoggedIn,
moneyFormat: theme.strings.shippingCalcMoneyFormat
});
},
updateHeader: function() {
try{
window.fetch('/cart.js')
.then(function(response) {
return response.json();
})
.then(function(response) {
var count = response.item_count;
$('#CartButton .cart-count-js').text( count ).show().addClass('pulse-cart-icon');
setTimeout(function(){
$('#CartButton .cart-count-js').removeClass('pulse-cart-icon')
}, 800);
});
} catch(e){
console.warn(e);
}
},
initQuantity: function() {
var instance = this;
$('.js-qty__adjust').off().on('click', function() {
var $element = $(this);

$element.prop('disabled', true)
.parents('.js-qty').addClass('qty--disabled')
.end()
.siblings().prop('disabled', true);

if ($element.hasClass('js-qty__adjust--plus')){
var addVariant = $element.data('variant');
// we use the add endpoint because it returns stockout errors
instance.changeQuantity('/cart/add.js', 1, addVariant);
} else {
var newQuantity = parseInt($element.data('new-quantity'));
var itemKey = $element.data('line-key');
// stockout is not an issue for decrease so we use change with the item key
instance.changeQuantity('/cart/change.js', newQuantity, itemKey);
}
});
},
changeQuantity: function(endpoint, quantity, id) {
var instance = this;
var data = {
quantity: quantity,
id: id
}
var params = {
type: 'POST',
url: endpoint,
data: data,
dataType: 'json',
error: function(XMLHttpRequest, textStatus) {
var $errors = $('[data-form-errors]');
$errors.slideUp('fast');
$errors.empty().html(XMLHttpRequest.responseJSON.description).slideDown('fast');
},
complete: function(jqxhr, text) {
$.get('/cart?view=ajax')
.done(function(data) {
// data-cart-additional -- we move the section-settings generated
// markup around because it cannot be included in our ajax request
$('[data-cart-additional]').slideUp().appendTo('[data-cart-holder]');
$('#dynamic-checkout-cart').empty();
$('[data-cart-form-wrapper]').empty().html(data);
$('[data-cart-additional]').appendTo('[data-additional-insert]').slideDown('slow');
instance.init();
instance.updateHeader();
});
}
}
jQuery.ajax(params);
}
});
return Cart;
})();

0 Likes