PHP - Problemas al introducir gastos de envío en paypal

 
Vista:
sin imagen de perfil

Problemas al introducir gastos de envío en paypal

Publicado por Jordi (1 intervención) el 13/06/2016 12:53:48
Hola a todos! Tengo un problema que no consigo resolver y agradecería si le podéis echar un vistazo, se trata de cuando envío los datos a paypal, pues los gastos de transporte no se introducen bien, por ejemplo si los gastos de tres productos son 25€ en Paypal me sale como gastos de envío 75€ por cada producto le suma 25€
SI alguien conoce el código y me puede ayudar os lo agradeceré,
Saludos,
Jordi



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
    session_start();
    include './conexion.php';
    if(isset($_SESSION['carrito'])){
        if(isset($_GET['id'])){
                    $arreglo=$_SESSION['carrito'];
                    $encontro=false;
                    $numero=0;
                    for($i=0;$i<count($arreglo);$i++){
                        if($arreglo[$i]['Id']==$_GET['id']){
                            $encontro=true;
                            $numero=$i;
                        }
                    }
                    if($encontro==true){
                        $arreglo[$numero]['Cantidad']=$arreglo[$numero]['Cantidad']+1;
                        $_SESSION['carrito']=$arreglo;
                    }else{
                        $nombre="";
                        $precio=0;
                        $imagen="";
                        $re=mysql_query("select * from productos where id=".$_GET['id']);
                        while ($f=mysql_fetch_array($re)) {
                            $nombre=$f['nombre'];
                            $precio=$f['precio'];
                            $imagen=$f['imagen'];
                        }
                        $datosNuevos=array('Id'=>$_GET['id'],
                                        'Nombre'=>$nombre,
                                        'Precio'=>$precio,
                                        'Imagen'=>$imagen,
                                        'Cantidad'=>1);
 
                        array_push($arreglo, $datosNuevos);
                        $_SESSION['carrito']=$arreglo;
 
                    }
        }
 
 
 
 
    }else{
        if(isset($_GET['id'])){
            $nombre="";
            $precio=0;
            $imagen="";
            $re=mysql_query("select * from productos where id=".$_GET['id']);
            while ($f=mysql_fetch_array($re)) {
                $nombre=$f['nombre'];
                $precio=$f['precio'];
                $imagen=$f['imagen'];
            }
            $arreglo[]=array('Id'=>$_GET['id'],
                            'Nombre'=>$nombre,
                            'Precio'=>$precio,
                            'Imagen'=>$imagen,
                            'Cantidad'=>1);
            $_SESSION['carrito']=$arreglo;
        }
    }
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="utf-8"/>
    <title>Carrito de Compras</title>
    <link rel="icon" type="image/png" href="/images/favicon.png" />
    <link rel="stylesheet" type="text/css" href="./css/estilos2.css">
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript"  src="./js/scripts.js"></script>
    <style type="text/css">
<!--
.Estilo1 {font-family: Arial, Helvetica, sans-serif}
-->
    </style>
</head>
<body>
    <header>
        <img src="./imagenes/LOGO-DEFINITIU.png" id="logo">
        <a href="./carritodecompras.php" title="ver carrito de compras">
            <img src="./imagenes/carrito.png">
        </a>
    </header>
    <section>
    <?php
session_start();
?>
<?php
if (isset($_SESSION['k_username'])) {
    echo '<center><h3>Usuario: '.$_SESSION['k_username']."</h3></center>";
    echo '<p><center><a href="http://www.miweb.com/registro-usuario/logout.php" class="aceptar" style="width:330px"> Cerrar sesión y salir</a></center></p>';
}
?>
        <?php
            $total=0;
            if(isset($_SESSION['carrito'])){
            $datos=$_SESSION['carrito'];
 
            $total=0;
            for($i=0;$i<count($datos);$i++){
 
    ?>
                <div class="producto">
                    <center>
                        <img src="./productos/<?php echo $datos[$i]['Imagen'];?>"><br>
                        <span ><?php echo $datos[$i]['Nombre'];?></span><br>
                        <span>Precio: <?php echo $datos[$i]['Precio'];?></span><br>
                        <span class="subtotal">Subtotal:<?php echo $datos[$i]['Cantidad']*$datos[$i]['Precio'];?></span><br>
                    </center>
                </div>
            <?php
                $total=($datos[$i]['Cantidad']*$datos[$i]['Precio'])+$total;
            }
 
            if($total > 0) {
            $sumar = 9;
            }
            if($total < 100) {
            $sumar = 9;
            }
            if($total > 100) {
            $sumar = 25;
            }
            if($total > 150) {
            $sumar = 25;
            }
            if($total > 600) {
            $sumar = 35;
            }
            if($total > 1000) {
            $sumar = 65;
            }
            if($total > 3000) {
            $sumar = 120;
            }
            if($total > 5000) {
            $sumar = 160;
            }
            if($total > 6000) {
            $sumar = 200;
            }
 
            $total2 = $sumar;
 
            $total3 = $total+$total2;
            echo '<center><h2 id="total">Gastos de transporte: '.$total2.' €</h2></center>';
            echo '<center><h2 id="total">Total: '.$total3.' €</h2></center>';
            if($total!=0){
                }else{
                echo '<center><h2>No has añadido ningun producto</h2></center>';
            }
 
            ?>
                <form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="formulario">
                    <input type="hidden" name="cmd" value="_cart">
                    <input type="hidden" name="upload" value="1">
                    <input type="hidden" name="business" value="xxxxxxxx@gmail.com">
                    <input type="hidden" name="currency_code" value="EUR">
 
                    <?php
                        for($i=0;$i<count($datos);$i++){
                    ?>
                        <input type="hidden" name="item_name_<?php echo $i+1;?>" value="<?php echo $datos[$i]['Nombre'];?>">
                        <input type="hidden" name="amount_<?php echo $i+1;?>" value="<?php echo $datos[$i]['Precio'];?>">
                        <input  type="hidden" name="quantity_<?php echo $i+1;?>" value="<?php echo $datos[$i]['Cantidad'];?>">
                        <input type="hidden" name="shipping_<?php echo $i+1;?>" value="<?php echo $total2;?>">
                        <?php
                        }
                    ?>
 
 
                <center>
                <input type="submit" value="Pago mediante PayPal" class="aceptar" style="width:330px">
                </center>
            </form>
            <?php
            }
 
        ?>
 
        <br>
        <center>
        <form action="https://www.miweb.com/carrito2/pago2.php"><input type="submit" value="Pago mediante transferencia" class="aceptar" style="width:330px">
        </form>
        </center>
    </section>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder