mmsh Posted December 23, 2013 Share Posted December 23, 2013 hi, i wrote a php script that gets the product reference, goes to the distributor page, compares the weight and delivery prices and writes the correct values to the database... the script is working really fine... i need it when a user click on a product page with a specific range of references... but if i call this from a smarty template i have to reload the page to view the correct values from the database... so, please let me know how to get the product reference before the template loading and where i can call this script from... thank you very much and happy holidays and happy new year to everyone!!! Link to comment Share on other sites More sharing options...
vekia Posted December 23, 2013 Share Posted December 23, 2013 you can do it in product controller (controllers/ProductController.php) for example inside displayContent function before $this->product = new Product($id_product, true, self::$cookie->id_lang); inside public function preProcess() Link to comment Share on other sites More sharing options...
mmsh Posted December 24, 2013 Author Share Posted December 24, 2013 (edited) you can do it in product controller (controllers/ProductController.php) for example inside displayContent function before $this->product = new Product($id_product, true, self::$cookie->id_lang); inside public function preProcess() that is...something like this? public function preProcess() { if ($id_product = (int)Tools::getValue('id_product')) exec('php /path/to/script.php "'.$id_product.'"'); .... .... i tried and it doesn't work... in script.php i have $id_product = $argv[1]; seems that it doesn't get the variable... so, i need the current id_product OR the reference 1) the user clicks on a product page link 2) correct values are written on database 3) user must see the correct values in realtime how can i do? thanks Edited December 24, 2013 by mmsh (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted December 24, 2013 Share Posted December 24, 2013 i dn't know what you exactly want to achieve. can you describe it a bit more? Link to comment Share on other sites More sharing options...
mmsh Posted December 24, 2013 Author Share Posted December 24, 2013 (edited) OK, revisited the code and it works...it was a syntax error but i have another problem: i thought that the deliverypricebyweight external sql worked but it doesn't work as expected: SELECT d.`price` FROM ps_delivery d LEFT JOIN ps_range_weight w ON ( d.`id_range_weight` = w.`id_range_weight` ) WHERE d.`id_zone` =1 AND '.(float)(15.294).' >= w.`delimiter1` AND '.(float)(15.294).' < w.`delimiter2` AND d.`id_carrier` =11 it should return 19.99 instead it returns the price 5.99 as it was between 0 and 2 KG (the real weight is 15.294 ) what's the problem in your opinion? that's not the correct sql ? edit: checked the tables and seem good id_range_weight is 386 OK id_zone is 1 OK delimiters for id_range_weight 386 are 15.000000 and 25.000000 so for 15.294 KG it should correctly return 19.99 but it doesn't... .. Edited December 24, 2013 by mmsh (see edit history) Link to comment Share on other sites More sharing options...
mmsh Posted December 24, 2013 Author Share Posted December 24, 2013 (edited) if i remove the '.(float)(15.294).' part and just write 15.294 it works...but why? why internally from Prestashop it works and instead called the sql from another script doesn't ? what format is the prestashop $totalweight variable? Edited December 24, 2013 by mmsh (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts