Soldato
Hi,
Bit of background:
You run the bookmarklet on the View Cart/Basket page.
My query is, why does the ajax call change the behaviour of the "Update Basket" button from doing what it's supposed to, to being a link to the last item?
Here's the code:
Thanks.
Bit of background:
I’ve recently had an order in ‘limbo’ due to stock shortages. Then I got to thinking that OcUK doesn’t show you any sort of stock levels when viewing your basket (so you’d know if they had enough of the items in stock to cover your order).
So I wrote a bookmarklet to get around this.
So I wrote a bookmarklet to get around this.
You run the bookmarklet on the View Cart/Basket page.
My query is, why does the ajax call change the behaviour of the "Update Basket" button from doing what it's supposed to, to being a link to the last item?
Here's the code:
Code:
javascript:(function(){
$('#shoppingBkt th:contains("Qty")').html('Qty / Stock');
$('#shoppingBkt a').each(
function(idx, item) {
var url = $(item).attr('href');
if (url != null) {
$.ajax({
url: url,
async: true,
}).done(function(data) {
var dataRetrieved = $('span.stock',$(data)).last().text();
if (dataRetrieved == 'Pre-order' || dataRetrieved == 'Out of Stock') {
dataRetrieved = '0';
};
$('#shoppingBkt tr').eq(idx+1).children('td').eq(2).html($('#shoppingBkt tr').eq(idx+1).children('td').eq(2).html() + ' / ' + dataRetrieved);
});
}
}
);
})();
Thanks.