How can i do it?
but i don't know how to set the limit
maybe this should be the strings to change but how?
$this->data['products'] = array();
$products = explode(',', $this->config->get('featured_product'));
if (empty($setting['limit'])) {
$setting['limit'] = 5;
}
$products = array_slice($products, 0, (int)$setting['limit']);
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id); $product_infos[] = $product_info;
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $product_info['rating'];
} else {
$rating = false;
}
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
}
}
Code: Select all
'name' => $product_info['name'],
Code: Select all
'name' => substr($product_info['name'], 0, 20),
In version 3.0.3.2 => product/category.php doing the below adds ... to the end of every product name even when it wasn't shortened.
Code: Select all
'name' => substr($result['name'], 0, 30) . "...",
MarketInSG wrote: ↑Sat Oct 05, 2013 11:21 amYou want to cut off their name, so you have to find this:
and add a substr functionCode: Select all
'name' => $product_info['name'],
Code: Select all
'name' => substr($product_info['name'], 0, 20),
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
nightwing wrote: ↑Fri Jul 24, 2020 12:58 amHi Marketing SG, great solution, however, how do I add three dots to the end
In product/category.php doing the below adds ... to the end of every product name even when it wasn't shortened.Code: Select all
'name' => substr($result['name'], 0, 30) . "...",
MarketInSG wrote: ↑Sat Oct 05, 2013 11:21 amYou want to cut off their name, so you have to find this:
and add a substr functionCode: Select all
'name' => $product_info['name'],
Code: Select all
'name' => substr($product_info['name'], 0, 20),
Here's the solution for you...
Code: Select all
'name' => strlen($product_info['name']) > 20 ? utf8_substr(html_entity_decode($product_info['name']),0,20)."..." : $product_info['name'],
Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here
kestas wrote: ↑Fri Jul 24, 2020 2:39 amnightwing wrote: ↑Fri Jul 24, 2020 12:58 amHi Marketing SG, great solution, however, how do I add three dots to the end
In product/category.php doing the below adds ... to the end of every product name even when it wasn't shortened.Code: Select all
'name' => substr($result['name'], 0, 30) . "...",
MarketInSG wrote: ↑Sat Oct 05, 2013 11:21 amYou want to cut off their name, so you have to find this:
and add a substr functionCode: Select all
'name' => $product_info['name'],
Code: Select all
'name' => substr($product_info['name'], 0, 20),
Here's the solution for you...Code: Select all
'name' => strlen($product_info['name']) > 20 ? utf8_substr(html_entity_decode($product_info['name']),0,20)."..." : $product_info['name'],
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Code: Select all
<div class="description"><?php echo utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, 50) . '...'; ?></div>
My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Demo: https://www.jwbasics.com
IP_CAM wrote: ↑Fri Jul 24, 2020 3:53 amCould also be added directly into the Theme File in charge: (NON TWIG Solution, tested in OC v.1.5.6.5, item-description)Code: Select all
<div class="description"><?php echo utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, 50) . '...'; ?></div>
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Ernie
My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Users browsing this forum: No registered users and 58 guests