Jump to content

update the price in cart


Recommended Posts

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 by bilal2005 (see edit history)
Link to comment
Share on other sites

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

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

×
×
  • Create New...