help with shop cart
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: help with shop cart
Follow the variables back.
5. $valuetota is from $valuetotal.
4. $valuetotal is from $value.
3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].
2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).
1. $_POST['code'] gets set if there is a form with a field with name="code".
So check the values of the variables starting with the value of $_POST['code'].
5. $valuetota is from $valuetotal.
4. $valuetotal is from $value.
3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].
2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).
1. $_POST['code'] gets set if there is a form with a field with name="code".
So check the values of the variables starting with the value of $_POST['code'].
(#10850)
Re: help with shop cart
Celauran wrote:$valuetota is just a formatted version of $valuetotal which, in turn, is coming from $value set in your switch statement. So, as I asked earlier, have you confirmed that $value is getting set? Have you confirmed that the queries in your switch statement actually work?
Christopher wrote:Follow the variables back.
5. $valuetota is from $valuetotal.
4. $valuetotal is from $value.
3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].
2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).
1. $_POST['code'] gets set if there is a form with a field with name="code".
So check the values of the variables starting with the value of $_POST['code'].
The variable is correctly returning the values in the table html, my problem would only be time to insert in the database
i have this project in a online server...u can check on line if u want.
if u want follow this:
-go to http://www.meucaixa.tk/
-click on the image
-username:teste
password:teste
-click "VENDER"
-in the search field type "8237-207 Branco"
-click "COMPRAR" in one of the results
now is the shop cart
-in the column "A Vista/Parcelado" select one of the options in the combo box (this combo box is the switch
-in the column "Preço" shows the variable $forma and $value both from switch
-in the column "Total" shows the variable $valuetotal from switch too
when click in the button "finalizar venda" runs the queries...and the query with this variable variable shows zero
as i said, i put this variable on script alert.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: help with shop cart
For each step I listed, did you echo the values of the variables I showed above? Please show us the values in each step.
(#10850)
Re: help with shop cart
Yes...i didChristopher wrote:For each step I listed, did you echo the values of the variables I showed above? Please show us the values in each step.
I will use the example I gave q as a reference to your question
1. $_POST['code'] gets set if there is a form with a field with name="code".
$_POST ['code'] = 1 or 2 or 3
2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).
3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].
$value if $_POST['code'] = 1 $value = 70,00 ->$resu6['precovenda']
$value if $_POST['code'] = 2 $value = 24,00 ->$resu7['precotres']
$value if $_POST['code'] = 3 $value = 13,00 ->$resu8['precoseis']
4. $valuetotal is from $value.
$valuetotal if $_POST['code'] = 1 $value = 70,00 ->$resu6['precovenda'] * 1
$valuetotal if $_POST['code'] = 2 $value = 24,00 ->$resu7['precotres'] * 3
$valuetotal if $_POST['code'] = 3 $value = 13,00 ->$resu8['precoseis'] * 6
5. $valuetota is from $valuetotal.
$valuetota and $valuetotal = $resu6['precovenda'] * 1 = 70,00
$valuetota and $valuetotal = $resu7['precotres'] * 3 = 72,00
$valuetota and $valuetotal = $resu8['precoseis'] * 6 = 78,00
the variables is correctly
just in time to save in db shows the value zero
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: help with shop cart
if you try to manually do the insert with the value '78,00' what value do you get in valorunitario? Do you get an error?
e.g, INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('1','2','3','78,00',NOW())
Is the problem that your database is configured for '.' for the decimal place, and not ',' ?
e.g, INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('1','2','3','78,00',NOW())
Is the problem that your database is configured for '.' for the decimal place, and not ',' ?
(#10850)
Re: help with shop cart
insert manually okChristopher wrote:if you try to manually do the insert with the value '78,00' what value do you get in valorunitario? Do you get an error?
e.g, INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('1','2','3','78,00',NOW())
Is the problem that your database is configured for '.' for the decimal place, and not ',' ?

- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: help with shop cart
I assume you mean there are no errors and the value is not 0. Correct? (you did not show the value, so we don't know).tsalmeida wrote:insert manually ok
If the value is correct, then is the SQL for the INSERT exactly the same if you do:
Code: Select all
echo "INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())<br>";
$sqlinsereitens = mysql_query("INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())")or die(mysql_error());
(#10850)
Re: help with shop cart
Hi Christopher,Christopher wrote:I assume you mean there are no errors and the value is not 0. Correct? (you did not show the value, so we don't know).tsalmeida wrote:insert manually ok
If the value is correct, then is the SQL for the INSERT exactly the same if you do:Code: Select all
echo "INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())<br>"; $sqlinsereitens = mysql_query("INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())")or die(mysql_error());
I did two ways to understand ... before clicking the button "FINALIZAR VENDA" the result of insert was this image

after clicking the "FINALIZAR VENDA", the result is that

Re: help with shop cart
help!!!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: help with shop cart
I am really not clear how to help at this point. You get to your shopping cart and you have a value. Then you submit again from the shopping cart to the shopping cart -- and the value is zero. You need to check step-by-step to see where the value is not being passed or being set to zero.
(#10850)