is ejunkie considering implementing a mini cart so that my customers can see how many items (and the value of) are in the cart without having to open the cart.
created
Jan '09
last reply
Feb '19
- 31
replies
- 3.6k
views
- 12
users
- 10
links
is ejunkie considering implementing a mini cart so that my customers can see how many items (and the value of) are in the cart without having to open the cart.
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>
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.
For some reason it does not show the 0 on the price. Say the total is 17.90 is show 17.9. Here is the link to my site www.blacklabelprinting.com2
Any help would be greatly appreciated.
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.
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
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.
If you'd like to hire a programmer to help you set that up, we can recommend the competent, E-junkie-experienced developers listed here:
2http://www.e-junkie.com/ej/developer-directory.htm2