1 / 32
Jan 2009

NOTE: This method for our classic cart is no longer supported with our new standard cart. Please jump down to this reply in this thread for our new minicart method.

There is an unofficial hack you can use to show cart item quantity and total in your page.

On every page where you want this displayed, add this to your View Cart code, just before the "// -->" line:

function EJEJC_config() {
EJEJC_POSTCALL=true;
}
function EJEJC_shown() {
document.getElementById('itemsInCart').innerHTML=EJEJC_cartsize()+" Items : Total $"+EJEJC_cartamt();
}

If you already have EJEJC_config or EJEJC_shown, just add the extra line shown above before the final "}" -- apparently that line got linewrap-broken here, but it should be one long, unbroken line from "document." to "cartamt();". You can of course customize the part that says " Items : Total $" with whatever text or HTML you wish (but avoid using any "double quote" characters -- you can use 'single quotes' instead).

Then in your page body wherever you want the cart items/total displayed, just insert this:

<div id='itemsInCart'></div>

2 months later

Tyson,

Is it possible to get <div id='itemsInCart'></div> to show without having to click on an e-junkie related button? Right now on my website it only shows cart information on website after I click an e-junkie related button and then close the lightbox.



Thanks,

Josh

I did say it was an unofficial hack. :^)



I don't know of any way to display the itemsInCart div contents automatically before the cart is rendered, but I might guess there could be some way to do that with JavaScript?



I'll assign this to the attention of our Lead Developer, in case he has a solution to offer.

19 days later

Thank you for the Hack, but for some reason it is not displaying the total right. In my shopping cart I have a total of $104.00 and 51 items but in the div it displays the correct amount of items but the total is $0. What are your thoughts on this?



Thanks,

1 month later

I have the same issue. The # of items is fine but no total :frowning:

12 days later
24 days later

We have been unable to reproduce the $0 problem in testing. If someone could provide the URL of a page where the $0 display is happening, we can examine that particular case. Note that the minicart status display can only show a full Item Total before shipping/tax/discounts have been factored in.

Hi Tyson

I'm using a fat.free.cart and it's working fine itself. When adding your hack minicart shows always $0

thank you

nobo

Note this will only work with an E-junkie Cart; I don't think it should work with a FatFreeCart.com cart. Although the two carts appear and behave similarly from a buyer's viewpoint, they are actually completely different and unrelated in how they operate under the skin.

exactly what I was thinking. thanks for clarifying that

6 months later

blacklabel what cart are you using? E-junkie Cart or Fat Free Cart?

10 months later
Hi, all working fine here but we need a html 'onload refresh' type thing for the cart to work pre rendering - did you ask your Lead Devloper?



I am sure there must be a method for doing this.



Cheers



Jez



E-junkieGuruI did say it was an unofficial hack. :^)



I don't know of any way to display the itemsInCart div contents automatically before the cart is rendered, but I might guess there could be some way to do that with JavaScript?



I'll assign this to the attention of our Lead Developer, in case he has a solution to offer.

If you're handy with JavaScript, our Lead Developer says you can use the functions EJEJC_cartsize(); and EJEJC_cartamt(); at will, to get the number of items and the cart total respectively. The amount currently does not reflect discounts but that'll be fixed shortly.

18 days later

Slight update to help formatting :-



function EJEJC_config() { EJEJC_POSTCALL=true; }

function EJEJC_shown() {

items=EJEJC_cartsize();

if (items== null) {items = 0};

document.getElementById('itemsInCart').innerHTML=items+" Items <BR/>£"+EJEJC_cartamt().toFixed(2)+" total";

}



This gets rid of null value and helps currency format, results of an emply cart :-



0 Items

£0.00 total



Still struggling to get html values on initial page load.



Jez

1 month later
E-junkieGuruIf you're handy with JavaScript, our Lead Developer says you can use the functions EJEJC_cartsize(); and EJEJC_cartamt(); at will, to get the number of items and the cart total respectively. The amount currently does not reflect discounts but that'll be fixed shortly.





can you check with you DEV guy as those functions quoted are returning errors and only available after EJEJC_shown has been run - has he got example code?



thanks



Jez

Note those functions would not be used in cart customization code, although they do depend on having our cart's box.js script loaded into your page (via the <script> portion of our View Cart code); you would need to write your own custom javascript to call those functions and output cart items/total onload within your page.

2 months later

yarg. so close... only the last bit is missing!

how to automatically initialize the mini cart on page load...

too bad my javascript knowledge ends exactly there :frowning: