Adding Min Order QTY to tpl_pi_qty_input.php
Posted: Sat Sep 21, 2024 5:29 am
Hi
I have added a minimum order qty field to my products database products_min_order_qty
I am trying to modify tpl_pi_qty_input.php to force the user to purchase no less than this number....
this is what I have done;
the bit that I added at the top does not read the value of products_min_order_qty... what have I done wrong here? do I have to define the variables in the main file rather than the tempalte file?(the if statement is a bit wierd I know but thats only because I set the default value to 0)
ALSO
in the input field, how do I change around the 'min="1"' bit so that it reflects $min_qty ? I've tried multiple things but cant get it to work
I have added a minimum order qty field to my products database products_min_order_qty
I am trying to modify tpl_pi_qty_input.php to force the user to purchase no less than this number....
this is what I have done;
Code: Select all
<?php
$products_id = Text::input($_GET['pID'] ?? '');
$grab_val = $GLOBALS['db']->query("SELECT products_min_order_qty FROM products WHERE products_id = " . (int)$products_id)->fetch_assoc();
$product_min_order_qty = $grab_val['products_min_order_qty'];
if ($product_min_order_qty == 0) {
$min_qty = 1;
} else {
$min_qty = $product_min_order_qty;
}
?>
<div class="col-sm-<?= $content_width; ?> text-right mt-2 pi-qty-input">
<div class="input-group mb-2">
<div class="input-group-prepend">
<?php
if (PI_QTY_INPUT_BUTTONS == 'True') {
?>
<button class="btn btn-info spinner" type="button" data-spin="minus">
<i class="fa fa-minus"></i>
</button>
<?php
}
else {
?>
<div class="input-group-text"><?= PI_QTY_INPUT_BUTTON_TEXT; ?></div>
<?php
}
?>
</div>
<?php
echo tep_draw_input_field('qty', $min_qty, 'min="1"', 'number', true, 'class="form-control form-control-lg" id="pi-qty-input"');
if (PI_QTY_INPUT_BUTTONS == 'True') {
?>
<div class="input-group-append">
<button class="btn btn-info spinner" type="button" data-spin="plus">
<i class="fa fa-plus"></i>
</button>
</div>
<?php
}
?>
</div>
</div>ALSO
in the input field, how do I change around the 'min="1"' bit so that it reflects $min_qty ? I've tried multiple things but cant get it to work