bilal2005 Posted April 23, 2015 Share Posted April 23, 2015 I add a new attribute and do specal calcul for price now I need to update the price in panel price and add to cart there is a function in presta do that ?, there is n exemple of that ?? thanks Link to comment Share on other sites More sharing options...
NemoPS Posted April 24, 2015 Share Posted April 24, 2015 How are you managing the special price calculation? Link to comment Share on other sites More sharing options...
bilal2005 Posted April 25, 2015 Author Share Posted April 25, 2015 (edited) I create method for get the price by Id public static function getPriceByIds($id){ $s=' SELECT p.price FROM ps_product p where p.id_product='.(int)$id.' GROUP BY p.id_product'; $rowprice = Db::getInstance()->getValue($s); return $rowprice; } and after that I write ths code for calculte the price and get the price public function hookDisplayFooterProduct($params) { global $smarty; require_once(dirname(__FILE__).'/entity/AttributeInfos.php'); $this->context->controller->addJquery(); $this->context->controller->addJS($this->_path.'js/jquery-1.7.1.min.js'); $id_product = Tools::getValue('id_product'); $sampleObj = Sariri_Sample::loadByIdProduct($id_product); if(!empty($sampleObj) && isset($sampleObj->id)){ $this->context->smarty->assign(array( 'bel_textarea' => $sampleObj->textarea, )); $attributes = Product::getAttributesInformationsByProduct($id_product); $byGroupAttributes = array(); foreach($attributes as &$attribute){ $infos = AttributeInfos::getInformationByIds($id_product, $attribute["id_attribute"]); $attribute["price"] = Tools::displayPrice($infos["price"] * (1+ Tax::getProductTaxRate($id_product)/100)); $byGroupAttributes[$attribute["group"]][] = $attribute; } $this->context->smarty->assign(array( 'GroupAttributes' => $byGroupAttributes, 'pda_combinations_price' => $pda_combinations_price )); $price = AttributeInfos::getPriceByIds($id_product); $y=(Tax::getProductTaxRate($id_product)*$price)/100; $tv=$price +$y; $p=round($tv,2); $t=floatval($p); $this->context->smarty->assign('tv',$t); $this->context->smarty->assign('id_produits',$id_product); } return $this->display(__FILE__, 'views/frontend/sample.tpl'); } so my problem how can I dispmay my price in cart Edited April 25, 2015 by bilal2005 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 25, 2015 Share Posted April 25, 2015 That way, you cannot. The only way I know, and which I always used, was overriding the PriceCalculation method of the Product class. There, return your price given certain condition. Otherwise, you will never be able to use that price throughout the whole store seamlessly Link to comment Share on other sites More sharing options...
kishoreunni Posted April 25, 2015 Share Posted April 25, 2015 I also caught this how to get price in add to cart. How we can override the PriceCalculation method of the product class ? Since it is called under getPriceStatic method. And changing the price in PriceCalculation is enough to display our custom price in the add to cart page ? please help me. Thanks in advance Link to comment Share on other sites More sharing options...
NemoPS Posted April 27, 2015 Share Posted April 27, 2015 Here: http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-OverridingaclassDepending on what you need, you might have to add another parameter to track what kind of product has been added, to getPriceStatic as well, and references to it (which might take a whole lot, to find it wherever it's needed) Link to comment Share on other sites More sharing options...
Recommended Posts