Any help is greatly appreciated.
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
Code: Select all
<?php if ($stock <= 0) {
echo (<b>Out Of Stock</b>)
} else {
<a class="button" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" ><span><?php echo $button_add_to_cart; ?></span></a>
} ?>
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
edit: catalog/model/catalog/product.php
before the closing php tag add
Code: Select all
public function getProductHasStock($product_id) {
$query = $this->db->query("SELECT quantity FROMM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
if($query->row['total']>0){
return true;
}else{
return false;
}
}
find
Code: Select all
$this->data['products'][] = array(
Code: Select all
'stock' => ($this->model_catalog_product->getProductHasStock($result['product_id'])?1:0),
Your template code should work with this too.
I haven't checked this, so it could be an epic fail.
However, if I read your code correctly, the items will only be returned if they are in stock...What I need is for the item to be returned either way, but if the available quantity is zero, it needs to say "Out of Stock" and if it is available, the add to cart button should be visible.
When the items will be in season, it will be changed to "Pre-Order" and so the custom should be able to see all of the items whether they are available for immediate purchase or not.
Let me know if you can help me get this. Thanks!
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
It will return $product['stock'] as either 1 or 0 (or at least it should)
Then your code you put in the template will do what you expect if you change $stock to $product['stock']
Try it and see

On the template's category.tlp file I now have...
Code: Select all
<?php if ($product['stock'] = 0) {
echo '<b>Out Of Stock</b>';
} else { } ?>
<a class="button" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" ><span><?php echo $button_add_to_cart; ?></span></a>
Code: Select all
public function getProductHasStock($product_id) {
$query = $this->db->query("SELECT quantity FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
if($query->row['quantity']>0){
return true;
}else{
return false;
}
}
Code: Select all
'stock' => ($this->model_catalog_product->getProductHasStock($result['product_id'])?1:0),
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
change
if ($product['stock'] = 0
to
if ($product['stock'] == 0
and change
} else { }
to
} else {
and pop a <?php } ?> after your button html
Code: Select all
<?php if ($product['stock'] == 0) {
echo '<b>Out Of Stock</b>';
} else { ?>
<a class="button" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" ><span><?php echo $button_add_to_cart; ?></span></a><?php } ?>
Now I get
Notice: Undefined variable: product in /catalog/view/theme/dillard/template/product/category.tpl on line 63
Out Of Stock
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
Code: Select all
<?php if ($products[$j]['stock'] == 0) {
echo '<b>Out Of Stock</b>';
} else { ?>
<a class="button" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" ><span><?php echo $button_add_to_cart; ?></span></a><?php } ?>
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
One moment and I will recheck my code and yours and come back with a solution.
Haha @ 14 kids. What do you think I am, a robot? lol
I myself have only 6, but with 6 kids, I could only make a small donation to say thank you for your help!
Custom Website Design from BCO ~ Building Companies Online
If we were of assistance to you, please help my family in return with a small donation.
I'm trying to implement this code but after everything is done what I get is:
Code: Select all
Notice: Undefined index: total in /home/simon/www/simon.wine-express.pl/htdocs/catalog/model/catalog/product.php on line 516Notice: Undefined index: total in /home/simon/www/simon.wine-express.pl/htdocs/catalog/model/catalog/product.php on line 516N
What should I change?
Users browsing this forum: No registered users and 6 guests