help with shop cart

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with shop cart

Post by Christopher »

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'].
(#10850)
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: help with shop cart

Post by tsalmeida »

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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with shop cart

Post by Christopher »

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)
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: help with shop cart

Post by tsalmeida »

Christopher 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.
Yes...i did

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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with shop cart

Post by Christopher »

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 ',' ?
(#10850)
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: help with shop cart

Post by tsalmeida »

Christopher 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 ',' ?
insert manually ok

Image
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with shop cart

Post by Christopher »

tsalmeida wrote:insert manually ok
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).

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)
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: help with shop cart

Post by tsalmeida »

Christopher wrote:
tsalmeida wrote:insert manually ok
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).

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());
Hi Christopher,

I did two ways to understand ... before clicking the button "FINALIZAR VENDA" the result of insert was this image

Image

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

Image
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: help with shop cart

Post by tsalmeida »

help!!!
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: help with shop cart

Post by tsalmeida »

:( :( :( :( :( :( :( :(
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with shop cart

Post by Christopher »

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)
Post Reply