# Envío = Cantidad Peso Simplecart

Hello my name is Mirella and I'm Italian. Excuse me as I write because I use the Google translator. Use Simplecart but I have problems with shipping costs. My client has different shipping costs. The site will sell bottles of wine of different weights. This is the function that I created using your help but I do perform multiplication between weight and quantity. It does not work Ok. Sorry but it is the first time I write on this site and do not know good English.

``````me.shipping = function()
{
var q = 0;
q += item.weight*item.quantity;

if(q <= 3000){
return 19.00;
}
if((q >= 10000)) {
return 23.00;
}
if((q <= 20000)){
return 24.00;
}
if((q <= 30000)){
return 26.00;
}
if((q <= 50000)){
return 32.00;
}
if((q <= 75000)){
return 35.00;
}
if((q <= 100000)){
return 39.00;
}
}
``````

preguntado el 01 de febrero de 12 a las 13:02

Can you markup the code in this? It's very hard to read the way you've formatted it so far -

Another thing: how can I put the total weight of the bottles in the basket? Which class should I use? -

## 3 Respuestas

``````if((q >= 10000)) {
return 23.00;
}
``````

This line means that all the lines below it will never run

All of your weight checks should use <= not >=

p.ej.

``````if (q <= 100)
// less than 100

if (q <= 200)
// 101 to 200

if (q <= 300)
// 201 to 300
``````

etc.

you can finish with

``````else
// more than 300
``````

Respondido 01 Feb 12, 18:02

For insert the function in my cart, using class SHIPPINGCOST? Is possible insert total weight? Is possible? - Lilli73

Yes, if you remove `var q=0;` and put it outside the function. Remember to reset it between transactions. - NibblyPig

First off, it would be nice if you formatted your question - especially the code. Makes it more readable.

You could almost halve your code by doing this;

``````if(q <= 3000){
return 19.00;
}
if(q <= 10000){
return 23.00;
}
if(q <= 20000){
return 24.00;
}
// ... and so on
``````

Perhaps the real problem will become a bit clearer then :-)

Respondido 01 Feb 12, 18:02

Ok. Sorry but it is the first time I write on this site and do not know good English. - Lilli73

No problem! Welcome to the site and don't worry about the English - it's fine - paul

dear, tanks! Insert the function in my cart user class SHIPPINGCOAST? No watch SHIPPING!!! Is possible insert total weight in my cart? - Lilli73

Function for different shipping. Problem var Q for weight. Weight X Quantity = Total Weight. Is correcty script?

``````me.shipping = function()
{
var q = 0;
q += item.weight*item.quantity;

if(q <= 3000){
return 19.00;
}
if((q >= 10000)) {
return 23.00;
}
if((q <= 20000)){
return 24.00;
}
if((q <= 30000)){
return 26.00;
}
if((q <= 50000)){
return 32.00;
}
if((q <= 75000)){
return 35.00;
}
if((q <= 100000)){
return 39.00;
}
}
``````

Respondido 02 Feb 12, 13:02

Creo que el `if((q >= 10000))` debe usar `<=` too. But it should be an edit to the question, not an answer. - Daniel Fischer

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.