Fórum Pegar valor de select e enviar em uma variavel no mesmo arquivo. #618814
12/10/2022
0
Olá, alguem pode me ajudar com isto:
Quero pegar o valor do select e enviar na variavel $item->quantity do mercado pago no mesmo arquivo php.
No momento está assim:
Porem ao tentrar abrir no site aparece o seguinte erro:
Notice: Undefined index: client in C:\xampp\htdocs\teste\loja\produtos\item.php on line 144
Fatal error: Uncaught Exception: Wrong type NULL. It should be int for property quantity in ....
Alguem sabe como resolver?
Quero pegar o valor do select e enviar na variavel $item->quantity do mercado pago no mesmo arquivo php.
No momento está assim:
<form action="#">
<div class="form-group">
<label for="produtos-quantidade-itens">Quantidade</label>
<select class="form-control" id="produtos-quantidade-itens" name="client">
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
<?php
# Crear un boton de pago a partir de una preferencia con atributos requeridos minimos
$preference = new MercadoPago\Preference();
# Building an item
$item = new MercadoPago\Item();
$item->id = "00001";
$item->title = 'Item Teste ';
$item->description = 'Skin';
$item->quantity = $_POST['client'];
$item->unit_price = 15;
$preference->items = array($item);
$preference->auto_return = "approved";
$preference->binary_mode = true;
$preference->save(); # Save the preference and send the HTTP Request to create
# Return the HTML code for button
echo "<a class='btn btn-success col-md-12' href='$preference->init_point' type='submit'> Comprar </a>";
?>
</form>
Porem ao tentrar abrir no site aparece o seguinte erro:
Notice: Undefined index: client in C:\xampp\htdocs\teste\loja\produtos\item.php on line 144
Fatal error: Uncaught Exception: Wrong type NULL. It should be int for property quantity in ....
Alguem sabe como resolver?
Victor
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)