Edit stylesheet.css
Open \opencart\catalog\view\theme\default\stylesheet\stylesheet.css
add following code in last line
.stock_label
{
width: auto; height:auto; display:inline-block;
padding:2px 5px 2px 5px;
background:#000;
font-size:12px; color:#FFF; font-weight:600;
}
{
width: auto; height:auto; display:inline-block;
padding:2px 5px 2px 5px;
background:#000;
font-size:12px; color:#FFF; font-weight:600;
}
Edit Category.php controller file
Open \opencart\catalog\controller\product\category.php
Find following code
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
Replace this code with following
////// Stock Status ////////
if ($result['quantity'] <= 0) {
$stock_status = $result['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$stock_status = $result['quantity'];
} else {
$stock_status = 'In Stock';
}
////// End Stock Status ////////
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'stock_status'=> $stock_status, // Stock Status
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
Edit category.twig file
Open \opencart\catalog\view\theme\default\template\product\category.twig
Find following line
<h4><a href="{{ product.href }}">{{ product.name }}</a></h4>
after above line add following line
<div class="stock_label">{{ product.stock_status }}</div>
Now your scripts are ready to show stock status but you should refresh in admin panel
How to do it?
- Go to admin panel dashboard
- You can see "Setting icon" under Logut button (I checked with desktop version)
- CLick it
- Now popup will open
- In the popup you can see action field with refresh icon
- Click it in both rows
No comments:
Post a Comment