Hi guys,
My Javascript is none-existent can you help with this please?
I believe the code below is the TC javascript, I just want to adapt it so it goes to another page or displays some text when the user clicks to view the cart when it is empty, it currently displays an empty page.
You can see what i mean at
http://121photo.co.uk/index.php?id=54
function emptyCart() {
$.post(cart_doc, {
action: 'count'
},
function(a) {
cart_count = eval("(" + a + ")");
if (!cart_count.length) {
tb_remove();
$(cart_el).animate({
opacity: '1.0'
},
'slow',
function() {
$(cart_el).html('')
});
return false
} else {
if (confirm(cart_warn)) {
$.post(cart_doc, {
action: 'empty'
});
$(cart_el).animate({
opacity: '1.0'
},
'slow',
function() {
$(cart_el).html('')
})
}
}
});
return false
}
function checkout(a) {
TB_remove();
jQuery('#treasureChestCheckout').remove();
jQuery('<div id="treasureChestCheckout">' + a + '</div>').appendTo('body').hide();
document.paypal.submit()
}
function cartCount() {
$.post(cart_doc, {
action: 'count'
},
function(a) {
cart_count = eval("(" + a + ")");
if (cart_count.length) {
cart_string = '<a class="thickbox tc_view" title="' + cart_view + '" href="#" onclick="return false;">' + '<span class="tc_cart_view_text">' + cart_view + '</span><span class="tc_cart_count" class="tc_count">' + cart_count.length + '</span></a>' + '<a class="tc_cart_empty ' + class_empty + '" href="#" title="' + cart_empty + '">' + cart_empty + '</a>';
$(cart_el).show().html(cart_string);
$('.tc_view').click(function() {
if (!cart_count.length) {
emptyCart()
}
TB_show(cart_name, cart_doc + '&TB_iframe=true&height=350&width=500&action=view', false);
return false
})
} else {
$(cart_el).hide();
return false
}
$('a.' + class_empty).click(emptyCart);
return true
})
}
function addToCart(a, b, c) {
$.post(cart_doc, {
action: 'add',
selector: b,
item: c
},
cartCount);
$(cart_el).animate({
opacity: '0.9'
},
'fast').animate({
opacity: '1.0'
},
'normal');
$(a).animate({
opacity: '1.0'
},
'fast').animate({
opacity: '1.0'
},
'normal');
return false
}
function tcConfig(a) {
config = eval("(" + a + ")");
cart_name = config['business_name'];
cart_view = config['cart_view'];
cart_empty = config['cart_empty'];
cart_warn = config['cart_warn'];
cart_el = config['cart_el'];
class_add = config['class_add'];
class_empty = config['class_empty'];
$('.' + class_add).click(function() {
addToCart(this, this.rel, this.name);
return false
});
cartCount()
}
function paypalForm(a) {
$.post(cart_doc, {
action: 'item_opts',
name: a.name,
value: a.value
});
op_field = a.name;
$%2