...

View Full Version : combine shipping based on cart quantity and item name



question123
12-08-2010, 09:52 PM
I am trying to combine shipping across different items in a javascript shopping cart. I can comine shipping based on how many items are in the cart, and characteristics of the item being added. But not both. I need the script to combine shipping based on how many items are in the cart, as well as the item name of the item being added to the cart.

I assume I need to check the cart quantity in 1 function, then have it call 1 of 2 other functions based on how many items are in the cart. The 2nd function would charge the shipping based on the item name. I don't know if the code is wrong, and where I should put the 2 additional functions I am adding. It isn't working though.

I am adding 2 ways I have tried below.



me.shipping = function(){

switch(me.quantity){
case '0':
return 0;
break;
case '1':
return oneItemInCart();
break;
default: otherNumber;
return moreThanOneItemInCart();
break;
}

function oneItemInCart();
{
if(item.name)
{
if(item.name.match = "Cricut Cartridge")
return 4.39
else if(item.name.match = "Glitter")
return 5.00
else
return quantity*0.00;
}
}

function moreThanOneItemInCart();
{
if(item.name)
{
if(item.name.match = "Cricut Cartridge")
return item.quantity*3.00-3.00+4.39
if(item.name.match = "Glitter")
return item.quantity*4.00-4.00+5.00
else
return quantity*0.00;
}
}










me.shipping = function(){
if( parseInt(me.quantity,10)===0 )
return 0;
else if( parseInt(me.quantity,10)===1)
return oneItemInCart();
else if( parseInt(me.quantity,10) > 1)
return moreThanOneItemInCart();
else
return quantity*0.00;

function oneItemInCart();
{
if(item.name)
{
if(item.name.match = "Cricut Cartridge")
return 4.39
else if(item.name.match = "Glitter")
return 5.00
else
return quantity*0.00;
}
}

function moreThanOneItemInCart();
{
if(item.name)
{
if(item.name.match = "Cricut Cartridge")
return item.quantity*3.00-3.00+4.39
if(item.name.match = "Glitter")
return item.quantity*4.00-4.00+5.00
else
return quantity*0.00;
}
}




Here is the original document - the part I edited is the me.shipping part
http://simplecartjs.com/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum