Jump to content

[SOLVED] update product price change value


Recommended Posts

Hi, i need to change the price of a product at runtime according to a complex calculation..now i update it successfully in the Ps_product table. but after the addition to cart it still shows 0(old price). Any idea why? is there another place i need to update this??

PS : ive checked in the db the changes are occuring

Link to comment
Share on other sites

basically i change the product price as per the other items in the cart.. so ive added a hook at displayshopping cart and get the products list from there, calculate the price as per that then update the price of my product via sql query. finally i add this product to cart using updateqty.. below is the code..

 $cookie = $this->context->cookie;
        $products = $params['cart']->getProducts(true);
 //       print_r($products);
    //    print_r($cookie);
		foreach ($products as $product) {
		   $result = Db::getInstance()->getRow('SELECT textarea FROM `'._DB_PREFIX_.'belvg_samplemodule` sample WHERE sample.`id_product` = '.$product['id_product']);
//		   print_r($product['id_product']);
$sub_total = $sub_total + $result['textarea'];
$result =DB::getInstance()->Execute('UPDATE `'. _DB_PREFIX_ .'product` SET `price` = ' .$sub_total. ' WHERE `id_product` = 9');
          $params['cart']->updateQty(1, 9);

9 is the product id of my product..

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...