Sometime i am getting error about missing post data from Ajax, this isn't happen every-time and i cant understand why i am getting error message like this in my controller
PHP Notice: Undefined index: product_id
Template
<ul class="block-price">
<li<?php if (!$stock): ?> style="display:none" <?php endif; ?>>
<i onclick="priceUpdate('plus');" class="fa fa-minus price-minus" aria-hidden></i>
<input type="text" name="quantity" value="<?php echo $minimum; ?>" size="2" id="input-quantity" class="form-control" />
<i onclick="priceUpdate('minus');" class="fa fa-plus price-plus" aria-hidden></i>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
</li>
</ul>
jQuery
function priceUpdate(type) {
var i = parseInt($('#input-quantity').val());
if(type == 'plus'){
f = Number(i + 1).toString();
}else{
f = Number(i - 1).toString();
}
$('input[name="quantity"]').val(''+f+'').trigger('change')
}
$('#product').on('input change', 'input, select', function() {
$.ajax({
url: 'index.php?route=priceUpdate',
type: 'post',
data: $('#product input[type=\'hidden\'], #product input[type=\'checkbox\']:checked, #product select'),
dataType: 'json',
success: function(json) {
}
});
});
Controller
public function priceUpdate(){
$data = [
'cart_id' => false,
'product_id' => $this->request->post['product_id'], (error message is this lane)
'quantity' => $quantity
];
}