You are XXX.00 $ from free shipping

Get help with nopcart formatting or style related issues.

Moderators: Koibito, Stefko, Randy

You are XXX.00 $ from free shipping

Postby shavit » Fri Nov 09, 2007 10:24 pm

Hi,

I'm using the code below to display on the products pages the total number and price of items. works great.
Code: Select all
<script language="javascript">
   if ( Cart_is_empty()) {
      document.write('Your cart is empty.');
   } else {
      document.write('In your cart:<p>');
      Print_total_products(true);
      document.write(', ');
      Print_total(true);
      document.write('<p>Applicable shipping and taxes extra.<p>');
      document.write('<a href="managecart.html">View Cart</a>');
   }
</script>


Also I use in the nopcart.js file the fixed shipping calculation:
Code: Select all
//***** Begin fixed shipping calculation
if (fTotal >= 300)    // If the total is 300 or more - shipping if FREE
fShipping = 0;
else
fShipping = 35;      // If the total is less than 300 - shipping is 35.00
//***** End fixed shipping calculation


I would like to add on the products pages a line like that:
"You are XXX.00 $ from free shipping"
where it will evaluate (fTotal (in my case 300) - total price of items)
and if the total price of items is >= 300 the line should write "Your order is free of shipping charges"

Can anyone write this code please :?:

Tnx
Danny
shavit
WebMaster
 
Posts: 6
Joined: Mon Nov 05, 2007 3:19 pm

Re: You are XXX.00 $ from free shipping

Postby shavit » Tue Nov 13, 2007 12:27 pm

O.K. It's working.

Took me a lot of time as I'm a complete newbe to JS scripting.

What I did is to duplicate the Print_total Mod, then rename the function name to Print_mtfs (money to free shipping)
then replaced the original Print_total Mod lines:
Code: Select all
fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
}
strTotal = moneyFormat(fTotal);
strOutput+=strTotal;
if ( bSymbol )
   strOutput = strOutput   
document.write(strOutput);
}

with this lines:
Code: Select all
fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
}
strTotal = moneyFormat(300-fTotal);
if (fTotal >= 300) {
strOutput+=('Free Shipping');
document.write(strOutput);
}
else {
strOutput+=strTotal;
if ( bSymbol )
   strOutput = strOutput   
document.write('You are' + strSpace + MonetarySymbol + strOutput + strSpace + 'from free shipping');
}
}


and added this lines to the proucts pages:
Code: Select all
<script language=JavaScript>
<!--      
Print_mtfs(true);
// -->
</script>


Well it works.
shavit
WebMaster
 
Posts: 6
Joined: Mon Nov 05, 2007 3:19 pm

Re: You are XXX.00 $ from free shipping

Postby Stefko » Sat Nov 17, 2007 6:58 am

Excellent, see its not so hard, just requires a little brain strain.

Also, thanks for posting how you resolved this.
KFL Technologies
Web-Enabled Solutions
e-Commerence Solutions
Stefko
Contributor / Guru
 
Posts: 833
Joined: Wed Sep 18, 2002 1:11 am
Location: Wichita, KS


Return to Help: Formatting and Style

Who is online

Users browsing this forum: No registered users and 0 guests

cron