mechworm Posted October 29, 2017 Share Posted October 29, 2017 I want to create a module that shows the product price in the product page tab. With my limited coding and prestashop structure knowledge, I created the module below. Currently, this module works fine and the simple txt html code in "mymodule.tpl" appears in my product page tabs. The next two steps are 1-Calling product price from database in mymodule.php 2-Printing this variable through the mymodule.tpl. ( Call productprice variable from mymodule.php and print it). The problem is that I don't know how to do both. I tried hard but couldn't find a solution. Can someone please help me? Thanks in advance! ---------------------------------------------------------------------------------------------------- <?php if (!defined('_PS_VERSION_')) { exit; } class MyModule extends Module { public function __construct() { $this->name = 'mymodule'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Firstname Lastname'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('My Module'); $this->description = $this->l('Description of my module.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); return parent::install() && $this->registerHook('displayAdminProductsExtra')&& $this->registerHook('displayProductExtraContent')&& $this->registerHook('ActionProductUpdate') && Configuration::updateValue('MYMODULE_NAME', 'my friend'); } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('MYMODULE_NAME') ) return false; return true; } public function hookDisplayProductExtraContent($params) { $content = $this->display(__FILE__, 'mymodule.tpl'); $array[] = (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent()) ->setTitle('My New Tab Title') ->setContent($content); return $array; } } -------------------------------------------------------------------------------------------------------------------------------- Link to comment 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