Gugis Posted August 23, 2014 Share Posted August 23, 2014 (edited) Is it possible to override productPrice variable? I've tried to do it by overriding ProductController <?php class ProductController extends ProductControllerCore{ public function initContent() { self::$smarty->assign('productPrice', 10 . 'extra text'); parent::initContent(); } } I had more success by overriding Product class, but "extra text" string vas removed: <?php class Product extends ProductCore { public static function priceCalculation(){ return 10 . 'extra text'; } } Edited August 23, 2014 by Gugis (see edit history) Link to comment Share on other sites More sharing options...
Paul C Posted August 23, 2014 Share Posted August 23, 2014 (edited) The key to these is WHEN you override. I used the following in override/classes/Product.php to add an RRP (set in each product as a group price) to products: public static function getTaxesInformations($row, Context $context = null) { $row = parent::getTaxesInformations($row, $context); $module = Module::getInstanceByName('yourmodulethatcontainsthefunction'); $row['rrp_price'] = $module->getGroupPriceStatic($row['id_product'], (int)MembershipCard::getRRPGroup(), true, 6, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : null)); return $row; } $row is an array that contains the source data that's passed to the theme.....It's not really clear though what you're trying to achieve - is it to change the actual price charged (which the above won't achieve) or to modify how the price is displayed (which the above type of solution COULD achieve)? Edited August 23, 2014 by Paul C (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted August 24, 2014 Share Posted August 24, 2014 tip: in first example, you should first call parent the set the new value. now you set value and if also set in parent, it's gone. 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