abdess Posted March 10, 2017 Share Posted March 10, 2017 Hello everyone, in prestashop (1.6.1.5) on product detail page I have my custom price for the current product. Now when I click on "add to cart" the standard product is added to the cart with standard price. I will add the product with my custom price to cart . Could anyone give me some needable ideas in the right direction please... Thank you very much Link to comment Share on other sites More sharing options...
phinq1910 Posted March 11, 2017 Share Posted March 11, 2017 You can use override method Link to comment Share on other sites More sharing options...
abdess Posted March 11, 2017 Author Share Posted March 11, 2017 thanks for your reply can you give me an example? Link to comment Share on other sites More sharing options...
El Patron Posted March 12, 2017 Share Posted March 12, 2017 what module are you using if any for custom price? if you have module for this have you contacted the developer? also please post link too product and how to produce as there is not not enough information for community to help. Link to comment Share on other sites More sharing options...
phinq1910 Posted March 13, 2017 Share Posted March 13, 2017 thanks for your reply can you give me an example? Example public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true) { $order_total = parent::getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache); // custom here $order_total += 5; // example return Tools::ps_round((float)$order_total, $compute_precision); } Link to comment Share on other sites More sharing options...
abdess Posted March 13, 2017 Author Share Posted March 13, 2017 thnx for you reply : so i have created an module which calculate an specific price for Product and this price is stored in variable $MyCustom_price and i want add this custom price to CART when customer click on "ADD TO CART" here is my code function hookdisplayProductButtons(){ //generate Fields User $id_product = (int)Tools::getValue('id_product'); $this->fields=$this->getUserFields($id_product); $this->context->smarty->assign("fields",$this->fields); $this->lagermaterial=$this->getLagermaterial(); $this->context->smarty->assign("lagermaterial",$this->lagermaterial); if (Tools::getValue('submitKalkulation')) { $valueFields=Tools::getValue('data'); //print_r($valueFields);die(); $countFields=sizeof($valueFields); // count of posting data $name_field_user=array(); $value_field_user=array(); foreach ($valueFields as $val) { //echo $val; $name_field_user[]=array_search($val, $valueFields); // name field on user page $value_field_user[]=$val; //value field on user page } $this->id_material=Tools::getValue('selectMaterial'); $getPrice=$this->getPriceMaterial($this->id_material)["price"]; // get price from selected lagermaterial by user //start generate formula //get variables or fields admin $this->getVariables=$this->getVariables($id_product); foreach($this->getVariables as $key => $value){ $name_field[] =$value['name_field']; // all field admin by product $value_field[]=$value['value_field']; // all value admin by product } //push array fields and values user page into array fields and values admin $allNames=array_merge($name_field,$name_field_user); $allValues=array_merge($value_field,$value_field_user); $allNames[]="preis"; // add price to array of allNames $allValues[]=$getPrice; // add price Value to array of allValues // get formula product $getFormula=$this->getProductFormula($id_product); $formulaProduct[0]=$getFormula["formula"]; for ($i=0; $i <count($allValues) ; $i++) { $formulaProduct[$i+1]=str_replace($allNames[$i],$allValues[$i],$formulaProduct[$i]); } //print_r($formulaProduct);echo "<br>"; $countValues=count($allValues); eval("\$formulaProduct[$countValues] = $formulaProduct[$countValues];"); $MyCustom_price =$formulaProduct[$countValues]; $this->context->smarty->assign("MyCustom_price ",$MyCustom_price); // MyCustom price = final price //get data in textbox // $this->context->smarty->assign('valueFields',$valueFields); // $this->context->smarty->assign('SelectedMaterial',$this->id_material); return $this->display(__FILE__, 'kalk_client.tpl'); //end generate formula } return $this->display(__FILE__, 'kalk_client.tpl'); } Link to comment Share on other sites More sharing options...
abdess Posted March 15, 2017 Author Share Posted March 15, 2017 any help ? Link to comment Share on other sites More sharing options...
LauraPresta Posted June 14, 2018 Share Posted June 14, 2018 did you finally found an answer ? Link to comment Share on other sites More sharing options...
silviosmith Posted July 20, 2018 Share Posted July 20, 2018 On 13/03/2017 at 4:06 AM, phinq1910 said: Example public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true) { $order_total = parent::getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache); // custom here $order_total += 5; // example return Tools::ps_round((float)$order_total, $compute_precision); } Where i put this code? Link to comment Share on other sites More sharing options...
silviosmith Posted July 20, 2018 Share Posted July 20, 2018 On 13/03/2017 at 4:31 AM, abdess said: thnx for you reply : so i have created an module which calculate an specific price for Product and this price is stored in variable $MyCustom_price and i want add this custom price to CART when customer click on "ADD TO CART" here is my code function hookdisplayProductButtons(){ //generate Fields User $id_product = (int)Tools::getValue('id_product'); $this->fields=$this->getUserFields($id_product); $this->context->smarty->assign("fields",$this->fields); $this->lagermaterial=$this->getLagermaterial(); $this->context->smarty->assign("lagermaterial",$this->lagermaterial); if (Tools::getValue('submitKalkulation')) { $valueFields=Tools::getValue('data'); //print_r($valueFields);die(); $countFields=sizeof($valueFields); // count of posting data $name_field_user=array(); $value_field_user=array(); foreach ($valueFields as $val) { //echo $val; $name_field_user[]=array_search($val, $valueFields); // name field on user page $value_field_user[]=$val; //value field on user page } $this->id_material=Tools::getValue('selectMaterial'); $getPrice=$this->getPriceMaterial($this->id_material)["price"]; // get price from selected lagermaterial by user //start generate formula //get variables or fields admin $this->getVariables=$this->getVariables($id_product); foreach($this->getVariables as $key => $value){ $name_field[] =$value['name_field']; // all field admin by product $value_field[]=$value['value_field']; // all value admin by product } //push array fields and values user page into array fields and values admin $allNames=array_merge($name_field,$name_field_user); $allValues=array_merge($value_field,$value_field_user); $allNames[]="preis"; // add price to array of allNames $allValues[]=$getPrice; // add price Value to array of allValues // get formula product $getFormula=$this->getProductFormula($id_product); $formulaProduct[0]=$getFormula["formula"]; for ($i=0; $i <count($allValues) ; $i++) { $formulaProduct[$i+1]=str_replace($allNames[$i],$allValues[$i],$formulaProduct[$i]); } //print_r($formulaProduct);echo "<br>"; $countValues=count($allValues); eval("\$formulaProduct[$countValues] = $formulaProduct[$countValues];"); $MyCustom_price =$formulaProduct[$countValues]; $this->context->smarty->assign("MyCustom_price ",$MyCustom_price); // MyCustom price = final price //get data in textbox // $this->context->smarty->assign('valueFields',$valueFields); // $this->context->smarty->assign('SelectedMaterial',$this->id_material); return $this->display(__FILE__, 'kalk_client.tpl'); //end generate formula } return $this->display(__FILE__, 'kalk_client.tpl'); } Please, Where i do put this code??? Link to comment Share on other sites More sharing options...
abdess Posted July 20, 2018 Author Share Posted July 20, 2018 silviosmith what do you want to do exactly? 1 Link to comment Share on other sites More sharing options...
silviosmith Posted July 31, 2018 Share Posted July 31, 2018 Hi On 20/07/2018 at 5:39 PM, abdess said: silviosmith what do you want to do exactly? i want to put a custom field in the product to show in add to cart button, and this field have to be sum with others procucts, like a price... like a secund price... 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