hhcj Posted June 2, 2014 Posted June 2, 2014 (edited) Hello, In my page I have some products that can only be sent through a carrier. Add this code to the product controller to display the carrier product page $this->context->smarty->assign(array( 'carriers' => $this->product->getCarriers(), But I also show the carrier in the product list, but there is override for the product-list or do not know how. Can you help me? thanks Edited June 2, 2014 by hhcj (see edit history) 1 Share this post Link to post Share on other sites More sharing options...
powerlight Posted August 20, 2021 Posted August 20, 2021 Hi : Did you managed to solve this ? I'm trying to show FREE SHIPPING on the product-list.tpl depending on the product carrier_id , i'm trying to find some help online with no luck . Share this post Link to post Share on other sites More sharing options...
ndiaga Posted August 25, 2021 Posted August 25, 2021 (edited) On 8/20/2021 at 12:09 PM, powerlight said: I'm trying to show FREE SHIPPING on the product-list.tpl depending on the product carrier_id , i'm trying to find some help online with no luck . Hi, Did you try the module product carriers? Edited August 25, 2021 by ndiaga (see edit history) Share this post Link to post Share on other sites More sharing options...
powerlight Posted August 26, 2021 Posted August 26, 2021 Hi , well , that module shows all the carriers for on product , not a free shipping label if the shipping cost are free Share this post Link to post Share on other sites More sharing options...
presta.group Posted August 29, 2021 Posted August 29, 2021 (edited) You can't do it without a module. You need to write a module and use the displayProductListReviews hook, or create your own hook and build it into ./themes/classic/templates/catalog/_partials/miniatures/product.tpl And in order not to show it in the product detail, you will need to treat the pages as an index and category in the hook. This is written either to the TPL template or to the module. E.g. custom hook and Home and Category pages. This is just a sample, it is not functional code !!! TPL file product.tpl: {if $page.name == 'index' || $page.name == 'category'} {block name='product_carrier'} {hook h='displayProductListCarrier' id_product=$product.id_product} {/block} {/if} PHP module: public function install() { $this->installConfiguration(); if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install()) { return false; } $hook = new Hook(); $hook->name = 'displayProductListCarrier'; $hook->title = $this->l('Hook show carriers'); $hook->description = $this->l('This is a hook shoe carriers!'); $hook->position = 1; $hook->add(); $this->registerHook('displayProductListCarrier'); return true; } public function hookDisplayProductListCarrier($params) { $template = ''; $getProductCarriers = Db::getInstance()->executeS(' SELECT c.* FROM `' . _DB_PREFIX_ . 'product_carrier` pc INNER JOIN `' . _DB_PREFIX_ . 'carrier` c ON (c.`id_reference` = pc.`id_carrier_reference` AND c.`deleted` = 0) WHERE pc.`id_product` = ' . (int) $params['id_product'] . ' AND pc.`id_shop` = ' . (int) $this->Context::getContext()->shop->id); if ($getProductCarriers){ $template .= '<div style="display:block">'; foreach ($getProductCarriers as $carrier){ $template .= '<span>'.$carrier['name'].'</span><br>'; } $template .= '</div>'; return $template; } else { return; } } Edited August 29, 2021 by presta.group (see edit history) 1 Share this post Link to post Share on other sites More sharing options...
4you.software Posted August 30, 2021 Posted August 30, 2021 Good instructions. I will just specify that this code does not end there. Some carriers depend on the payment selected and the country or state. So an unregistered customer can see all carriers. Share this post Link to post Share on other sites More sharing options...
powerlight Posted September 2, 2021 Posted September 2, 2021 Thanks , but that solution will only work in product.tpl , not in product-list.tpl , right ? Share this post Link to post Share on other sites More sharing options...
powerlight Posted October 4, 2021 Posted October 4, 2021 On 8/29/2021 at 7:22 PM, presta.group said: You can't do it without a module. You need to write a module and use the displayProductListReviews hook, or create your own hook and build it into ./themes/classic/templates/catalog/_partials/miniatures/product.tpl And in order not to show it in the product detail, you will need to treat the pages as an index and category in the hook. This is written either to the TPL template or to the module. E.g. custom hook and Home and Category pages. This is just a sample, it is not functional code !!! TPL file product.tpl: {if $page.name == 'index' || $page.name == 'category'} {block name='product_carrier'} {hook h='displayProductListCarrier' id_product=$product.id_product} {/block} {/if} PHP module: public function install() { $this->installConfiguration(); if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install()) { return false; } $hook = new Hook(); $hook->name = 'displayProductListCarrier'; $hook->title = $this->l('Hook show carriers'); $hook->description = $this->l('This is a hook shoe carriers!'); $hook->position = 1; $hook->add(); $this->registerHook('displayProductListCarrier'); return true; } public function hookDisplayProductListCarrier($params) { $template = ''; $getProductCarriers = Db::getInstance()->executeS(' SELECT c.* FROM `' . _DB_PREFIX_ . 'product_carrier` pc INNER JOIN `' . _DB_PREFIX_ . 'carrier` c ON (c.`id_reference` = pc.`id_carrier_reference` AND c.`deleted` = 0) WHERE pc.`id_product` = ' . (int) $params['id_product'] . ' AND pc.`id_shop` = ' . (int) $this->Context::getContext()->shop->id); if ($getProductCarriers){ $template .= '<div style="display:block">'; foreach ($getProductCarriers as $carrier){ $template .= '<span>'.$carrier['name'].'</span><br>'; } $template .= '</div>'; return $template; } else { return; } } This solution is valid for product.tpl , but not for product-list.tpl. Am i wrong ? Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now