Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Crating a online order form


blr044

Recommended Posts

Not sure where to post this, so am lookig for a solution or tip in helping me calculating shipping on my order form. If can not find an answer here, I will understand.

 

I have been searching the net for over three months on tips or sample order forms. I am not a programmer. I have put several hints together to create my own orderform.html. When I use whole dollars for different values, it works fine. It's when I change one method to something like 14% in the code, it stops working. Below is the original code:

//-- Updates the totals in the lower part of order details.
function updateTotals() {
var subtotal = 0;
for (var i=1;i<=NumRows;i++) {
subtotal=subtotal+ordData[i].extprice;
}
document.orderform.subtotal.value = currency(subtotal,10);

var shipcost = 0
if (subtotal <= 1.00) {
shipcost = 0.00;
}
else
if (subtotal <= 25.00) {
shipcost = 5.95;
}
else
{
if ((subtotal >25.00) && (subtotal <=50.00)) {
shipcost = 6.95;
}
else
{
if ((subtotal >50.00) && (subtotal <=75.00)) {
shipcost = 7.95;
}
else
{
if ((subtotal >75.00) && (subtotal <=150.00)) {
shipcost = 8.95;
}
else
{
if ((subtotal >150.00) && (subtotal <=300.00)) {
shipcost = 9.95;
}
else
{
  if ((subtotal >300.00) && (subtotal <=500.00)) {
 shipcost = 10.95;
}  
 }}}}}

document.orderform.shipcost.value = currency(shipcost,10);

if (document.orderform.notUS.checked == false){
 document.orderform.international.value = 0;
 international = 00;
 document.orderform.totalship.value = currency (international-shipcost, 10);
 }

 if (document.orderform.expuspspriority.checked == false){
 document.orderform.expediteduspspriority.value = 0;
 overnight = 0;
 document.orderform.totalship.value = currency (international-shipcost, 10);
 }

 if (document.orderform.expexpress.checked == false){
 document.orderform.expediteduspspriority.value = 0;
 overnight = 0;
 document.orderform.totalship.value = currency (international-shipcost, 10);
 } 

if (document.orderform.notUS.checked) {
international = 4.50;
}
document.orderform.international.value = currency(international,10);
document.orderform.totalship.value = currency (international+shipcost, 10);

{//overnight shipping calculation
if (document.orderform.expuspspriority.checked) {
overnight = 4.95;
document.orderform.expediteduspspriority.value = currency(overnight,10);
}
if (document.orderform.expexpress.checked) {
overnight = 17.50;
document.orderform.expediteduspspriority.value = currency(overnight,10);
}
}//end of overnight shipping calculation

 

This what I want:

//-- Updates the totals in the lower part of order details.
function updateTotals() {
var subtotal = 0;
for (var i=1;i<=NumRows;i++) {
subtotal=subtotal+ordData[i].extprice;
}
document.orderform.subtotal.value = currency(subtotal,10);

var shipcost = 0
if (subtotal <= 1.00) {
shipcost = 0.00;
}
else
if (subtotal <= 98.00) {
shipcost = 8.95;
}
else
{
if ((subtotal >98.00) && (subtotal <=1000.00)) {
shipcost = 14%;
}
 }

document.orderform.shipcost.value = currency(shipcost,10);

if (document.orderform.notUS.checked == false){
 document.orderform.international.value = 0;
 international = 00;
 document.orderform.totalship.value = currency (international-shipcost, 10);
 }

 if (document.orderform.expuspspriority.checked == false){
 document.orderform.expediteduspspriority.value = 0;
 overnight = 0;
 document.orderform.totalship.value = currency (international-shipcost, 10);
 }

 if (document.orderform.expexpress.checked == false){
 document.orderform.expediteduspspriority.value = 0;
 overnight = 0;
 document.orderform.totalship.value = currency (international-shipcost, 10);
 } 

if (document.orderform.notUS.checked) {
international = 4.50;
}
document.orderform.international.value = currency(international,10);
document.orderform.totalship.value = currency (international+shipcost, 10);

{//overnight shipping calculation
if (document.orderform.expuspspriority.checked) {
overnight = 4.95;
document.orderform.expediteduspspriority.value = currency(overnight,10);
}
if (document.orderform.expexpress.checked) {
overnight = 17.50;
document.orderform.expediteduspspriority.value = currency(overnight,10);
}
}//end of overnight shipping calculation

So you see I want to charge 14% anything over $98.00

 

I've changed this:

else

{

if ((subtotal >50.00) && (subtotal <=75.00)) {

shipcost = 7.95;

}

to this:

else

if ((subtotal >98.00) && (subtotal <=1000.00)) {

shipcost = 6.5%;

}

 

I hope I did explain this ok.

 

Thanks.

 

Bennett

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...