|
#1
|
|||
|
|||
|
How can I get my website to add this? I find this very effective in getting me to bump up my purchases at other sites and would like this for mine.
|
|
#2
|
|||
|
|||
|
You can do the following:
After the div containing the shopping cart summary (id = display_cart_summary) place the following code: Code:
if (document.getElementById("display_cart_summary").firstChild != null)
{
var myDiv = document.getElementById("display_cart_summary").firstChild;
if (myDiv.className == "cartsummary_full")
{
var myText = myDiv.innerHTML;
var dollars = myText.substring(myText.indexOf("$"),myText.indexOf(")"))
var cents = parseInt(dollars.substring(1) * 100);
var toFreeAmount = (5000- cents); // assume free shipping for $50.00 purchases
amount = toFreeAmount.toString();
var amount1 = amount.substring(0, amount.length-2);
var amount2 = amount.substr(-2)
var value = amount1 + "." + amount2;
alert(value); // replace this with code to display on the page
// if toFreeAmount < 0 then qualified for free shipping.
}
}
|
|
#3
|
|||
|
|||
|
Bookman,
Where exactly does this code go? I'd like to try it but when I put it in the shopping cart.asp it messed things up. Thanks, |
|
#4
|
|||
|
|||
|
Does not seem to work in v5
![]() |
|
#5
|
|||
|
|||
|
It goes in the main template - version 5. Note that this is js code so needs to be wrapped in script tags.
I rewrote the code to clean up a couple of things. You can see it at http://www.waldorfbookshop.com Log in as volusion@waldorfbookshop.com password is volusion. you can find the code inline on the home page though is should be placed in and external file and called when the page is completely loaded. Please don't mess around with the shopping cart too much. thx. bob |
|
#6
|
|||
|
|||
|
Bookman, I cant see this on your site. Please help.
|
|
#7
|
|||
|
|||
|
i changed it a bit to work with my site... how can you make it display just the 2 digits after the period? ($xx.xx instead of $xx.xxxx)
Code:
<script language="javascript">
if (document.getElementById("display_cart_summary").firstChild != null)
{
var myDiv = document.getElementById("display_cart_summary").firstChild;
if (myDiv.className == "cartsummary_full")
{
var myText = myDiv.innerHTML;
var dollars = myText.substring(myText.indexOf("$"),myText.indexOf(")"))
var cents = parseInt(dollars.substring(1) * 100);
var toFreeAmount = (10000- cents); // assume free shipping for $100.00 purchases
amount = toFreeAmount.toString();
var amount1 = amount.substring(0, amount.length-2);
var amount2 = amount.substr(-2)
var value = amount1 + "." + amount2;
document.writeln('<b>$',value,' needed for you to recieve FREE shipping!</b>'); // replace this with code to display on the page
// if toFreeAmount < 0 then qualified for free shipping.
}
}
</script>
|
|
#8
|
|||
|
|||
|
Thanks for this great script. I tried it and I noticed that when you surpass the "free shipping" amount, the count starts showing in Negative amount.
Is there a way to prevent displaying when the amount has been surpassed? Many thanks for your contribution :-)
__________________
website |
|
#9
|
|||
|
|||
|
did anyone figure out how to only display the 2 places for the cents instead of 4? and also being able to change it to say "This order ships free" instead of a negative number would be cool
|
|
#10
|
||||
|
||||
|
Quote:
function formatCurrency(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if(s.indexOf('.') < 0) { s += '.00'; } if(s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; return s; } Just add this code and add the following: formatCurrency(value); AFTER var value = amount1 + "." + amount2; |
![]() |
| Thread Tools | |
| Display Modes | |
|
|