Nerloggz Posted August 21, 2014 Share Posted August 21, 2014 Hi ! So what I want to do seems quite simple : allowing the customers to choose a precise hour of delivery for their order (to be displayed in the back-office). I did some research and this is what I did so far : - Added "myVariable" to ps_cart table. - Added public $myVariable in Cart.php - Added 'myVariable' => array('type' => self::TYPE_DATE) in $definition in Cart.php - Created a module : <?php if (!defined('_PS_VERSION_')) exit; class heureLivraison extends Module { public function __construct() { $this->name = 'heurelivraison'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'COLIN Théotime'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6'); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Heure livraison'); $this->description = $this->l('Permet aux clients de choisir une heure de livraison précise.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('HEURELIVRAISON_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (!parent::install()) return false; return true; } public function uninstall() { if (!parent::uninstall()) return false; return true; } public function hookActionCarrierProcess($params) { $cart = $params['cart']; $cart->myVariable = Tools::getValue('myVariable'); } } - Installed it and hooked it to ActionCarrierProcess. - Added an input on the check out page. Though, the variable isn't added to the table. I think my module isn't working as even with a fixed date, nothing is added. Thanks for help ! May give away a little reward (Amazon gift card or anything else) if anyone can help me figure this out. Link to comment Share on other sites More sharing options...
PascalVG Posted August 22, 2014 Share Posted August 22, 2014 I expect the cart isn't saved during the checkout process anymore. Maybe add the variable/field to the Order class/table, instead of the cart. Then when the order is saved (when confirming the order), it should be saved automatically. My 2 cents, pascal Link to comment Share on other sites More sharing options...
Nerloggz Posted August 22, 2014 Author Share Posted August 22, 2014 Hmmm, so basically in which file do I need to get the value and add it to $order ? (using Tools::getValue('myVariable'); I guess ?) I'm sorry, I'm really new to this but I'm slowly beginning to understand ! Thanks a lot for the answer. Link to comment Share on other sites More sharing options...
Nerloggz Posted August 24, 2014 Author Share Posted August 24, 2014 Anyone ? Link to comment Share on other sites More sharing options...
Nerloggz Posted August 28, 2014 Author Share Posted August 28, 2014 I really need help :/ Link to comment Share on other sites More sharing options...
frugalis Posted August 28, 2014 Share Posted August 28, 2014 Hi Nerloggz, You should at first have a look at the Prestashop developer documentation : Your module should consist of some of these : 1- a form : /themes/Mytheme/appli.tpl 2- optional Css or Js files : /themes/Mytheme/css or /themes/Mytheme/js or /themes/Mytheme/modules/XXX/css or /themes/Mytheme/modules/XXX/js 3- controller or override files : - front : /controllers/front/AppliController.php - admin : /controllers/admin/AdminAppliController.php (for the backoffice management) 4- classes : /classes/Db.php contains some variables and the definition (fields) of the database table. 5- Database : using sql command or phpmyadmin, you have to prealably update your database, insert all new fields Hope this help. Link to comment Share on other sites More sharing options...
Nerloggz Posted September 2, 2014 Author Share Posted September 2, 2014 Thanks for the info ! But the only thing I want to know is in which precise file are all the input content sent to the database during the order ? 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