abdess Posted March 12, 2017 Share Posted March 12, 2017 (edited) Salut a tous, je developpe un module pour un site e-commerce qui utilise prestashop j'ai cree ma classe class kalkulationmod extends Module et j'ai mis les fonctions de base: install ,uninstall plus les HOOks dans mon hookdisplayProductButtons j'ai le code suivant qui calcule le prix final et j'affect ce prix a une variable qui s'appel $MyCustom_price 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'); } Mtn je veux quand le client click sur button"Ajouter au panier " il ajoute le produit avec le prix final qui est stocke ds la variable $MyCustom_price et non pas le prix standard du produit. j'espère que vous allez m'aider à trouver une solution merci davance Edited March 15, 2017 by abdess (see edit history) Link to comment Share on other sites More sharing options...
abdess Posted March 15, 2017 Author Share Posted March 15, 2017 up Link to comment Share on other sites More sharing options...
dams92 Posted March 15, 2017 Share Posted March 15, 2017 up ! Link to comment Share on other sites More sharing options...
BeComWeb Posted March 16, 2017 Share Posted March 16, 2017 J'ai rien compris Tu veux qu'avec un simple module le CMS, tous ses controleurs, templates et autres décident d'utiliser un autre prix que celui qui est défini pour le produit ??? 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