mr.v Posted November 11, 2008 Share Posted November 11, 2008 i want to change default order status for 'cash on delivery' module to my custom order status.how to? please help. :sick: Link to comment Share on other sites More sharing options...
mr.v Posted November 18, 2008 Author Share Posted November 18, 2008 can anyone help me please? Link to comment Share on other sites More sharing options...
presta1 Posted April 23, 2009 Share Posted April 23, 2009 if still interested, (and for others with same problem). here is my take on this:1) in config/config.inc.php find /* Order states */ (line N°100 i think)2) copy the name of your desired order status. (ex: _PS_OS_PAYMENT_)3) in /modules/cacheondelivery/validation.php find the validateOrderCOD function ex: $cashOnDelivery->validateOrderCOD(intval($cart->id), _PS_OS_PREPARATION_, $total, $cashOnDelivery->displayName); 4) replace the _PS_OS_PREPARATION_ with the one you picked from config.inc.phphere are Order status default titles (titles are editable in BO Orders > Order status)1 _PS_OS_CHEQUE_ : wailting for cheque payment2_PS_OS_PAYMENT_ : payement successful3_PS_OS_PREPARATION_ : preparing order4_PS_OS_SHIPPING_ : order shipped5_PS_OS_DELIVERED_ : order delivered6_PS_OS_CANCELED_ : order canceled7_PS_OS_REFUND_ : order refunded8_PS_OS_ERROR_ : payement error9_PS_OS_OUTOFSTOCK_ : product out of stock10_PS_OS_BANKWIRE_ : wailting for bank wire 3 Link to comment Share on other sites More sharing options...
blueraccoon Posted April 23, 2013 Share Posted April 23, 2013 Hi, I am trying to find the same solution using a new order status that I have added myself. How do I assign the new order status in validation.php? I am running 1.5.3.1. Thanks for your help Link to comment Share on other sites More sharing options...
rahumateo Posted July 11, 2013 Share Posted July 11, 2013 Hi, how do you create a new order status in your payment module? Link to comment Share on other sites More sharing options...
blueraccoon Posted July 11, 2013 Share Posted July 11, 2013 In backend navigate to following: Orders > Statuses > Add New (Button in top right of screen) Link to comment Share on other sites More sharing options...
scorpionsworld Posted July 16, 2013 Share Posted July 16, 2013 (edited) In backend navigate to following: Orders > Statuses > Add New (Button in top right of screen) Thats adding a status by hand, not by module To create an order status by module in Prestashop v1.5.x add the following to your module's install function: change code in red to your needs // create new order status STATUSNAME $values_to_insert = array( 'invoice' => 1, 'send_email' => 1, 'module_name' => $this->name, 'color' => 'RoyalBlue', 'unremovable' => 0, 'hidden' => 0, 'logable' => 1, 'delivery' => 0, 'shipped' => 0, 'paid' => 1, 'deleted' => 0); if(!Db::getInstance()->autoExecute(_DB_PREFIX_.'order_state', $values_to_insert, 'INSERT')) return false; $id_order_state = (int)Db::getInstance()->Insert_ID(); $languages = Language::getLanguages(false); foreach ($languages as $language) Db::getInstance()->autoExecute(_DB_PREFIX_.'order_state_lang', array('id_order_state'=>$id_order_state, 'id_lang'=>$language['id_lang'], 'name'=>'Status name', 'template'=>''), 'INSERT'); if (!@copy(dirname(__FILE__).DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'logo.gif', _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'os'.DIRECTORY_SEPARATOR.$id_order_state.'.gif')) return false; Configuration::updateValue('PS_OS_STATUSNAME', $id_order_state); unset($id_order_state); To set the order status in a module's function (for ex. validation) call: change code in red to your needs $this->module->validateOrder($this->context->cart->id, Configuration::get('PS_OS_STATUSNAME'), $this->context->cart->getOrderTotal(true, 3), 'payment method name', 'Optional transaction message', array(), false, false, $this->context->cart->secure_key); Edited July 16, 2013 by scorpionsworld (see edit history) 4 Link to comment Share on other sites More sharing options...
rahumateo Posted July 17, 2013 Share Posted July 17, 2013 (edited) To create an order status by module in Prestashop v1.5.x add the following to your module's install function: change code in red to your needs // create new order status STATUSNAME $values_to_insert = array( 'invoice' => 1, 'send_email' => 1, 'module_name' => $this->name, 'color' => 'RoyalBlue', 'unremovable' => 0, 'hidden' => 0, 'logable' => 1, 'delivery' => 0, 'shipped' => 0, 'paid' => 1, 'deleted' => 0); if(!Db::getInstance()->autoExecute(_DB_PREFIX_.'order_state', $values_to_insert, 'INSERT')) return false; $id_order_state = (int)Db::getInstance()->Insert_ID(); $languages = Language::getLanguages(false); foreach ($languages as $language) Db::getInstance()->autoExecute(_DB_PREFIX_.'order_state_lang', array('id_order_state'=>$id_order_state, 'id_lang'=>$language['id_lang'], 'name'=>'Status name', 'template'=>''), 'INSERT'); if (!@copy(dirname(__FILE__).DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'logo.gif', _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'os'.DIRECTORY_SEPARATOR.$id_order_state.'.gif')) return false; Configuration::updateValue('PS_OS_STATUSNAME', $id_order_state); unset($id_order_state); This sure answer it. Thanks Edited July 17, 2013 by rahumateo (see edit history) Link to comment Share on other sites More sharing options...
patrmich Posted January 29, 2014 Share Posted January 29, 2014 (edited) Hi,I am using Prestahsop 1.4.7.0, with the Cash on delivery module v0.4.In that module, is the /module/cashondelivery/validation.php file, where one can find the here below line :$cashOnDelivery->validateOrder((int)$cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $cashOnDelivery->displayName, NULL, array(), NULL, false, $customer->secure_key);So, by default the orders made with this way of payment get the "In preparation" status.I would like to do the following :a-create a new status called "Cash on delivery payment" - that's easy to do here : "Control panel > Orders > Status"b-assign this status by default to any order made with this way of payment.The status list is located in /config.inc.phpAs an example one status is defined as : - define('_PS_OS_CHEQUE_', Configuration::get('PS_OS_CHEQUE'));So to add the new status in /config.inc.php, does I need only to add the here below line ? - define('_PS_OS_xxxxxx_', Configuration::get('PS_OS_xxxxxx'));And if I does only need to do that, what I have to put in place of xxxxxx ?Thank you very much in advance for any reply.Patrick Edited January 29, 2014 by patrmich (see edit history) Link to comment Share on other sites More sharing options...
elvispl Posted March 14, 2014 Share Posted March 14, 2014 Its simple way. edit: /modules/cashondelivery/controllers/front/validation.php change line: $this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); repleace with: $this->module->validateOrder((int)$this->context->cart->id, 22, $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); ex. 22 - its status ID in your BO 1 Link to comment Share on other sites More sharing options...
patrmich Posted March 14, 2014 Share Posted March 14, 2014 Hi elvispl, Thank you, It works ! Patrick 1 Link to comment Share on other sites More sharing options...
Janekx Posted June 25, 2014 Share Posted June 25, 2014 I did try with bankwire validation add Configuration::get('PS_OS_PREPARATION') and if I used got the error that somethin goes wrong, and not got final screen with bank acounts price to pay. Can be possible that bankwire module work diferent then others because of final screen ? Thanks Jan Link to comment Share on other sites More sharing options...
Rain_xx Posted September 8, 2014 Share Posted September 8, 2014 (edited) Thats adding a status by hand, not by module To create an order status by module in Prestashop v1.5.x add the following to your module's install function: change code in red to your needs To set the order status in a module's function (for ex. validation) call: change code in red to your needs Sorry but there's something wrong during the database creation of a new status. I mean in "ps_configuration" table. The id value is "null", it doesn't generate a valid id (es. 14), so the module can't work properly. Thanks. Edit: Solved. Just cancel the line "unset($id_order_state);" , it's contradictory. Edited September 8, 2014 by Rain_xx (see edit history) Link to comment Share on other sites More sharing options...
usmdev Posted November 10, 2015 Share Posted November 10, 2015 Hi to all ,can i transfer all order information to my couriers company after customer select cash on delivery on checkout ,i am new on prestashop can any body help me. Link to comment Share on other sites More sharing options...
Ysiak Posted October 25, 2018 Share Posted October 25, 2018 3) in /modules/cacheondelivery/validation.php find the validateOrderCOD function ex: $cashOnDelivery->validateOrderCOD(intval($cart->id), _PS_OS_PREPARATION_, $total, $cashOnDelivery->displayName); Where can I find it in prestashop 1.7.4.3 ? Link to comment Share on other sites More sharing options...
Ysiak Posted November 14, 2018 Share Posted November 14, 2018 Some one know how i can do it in 1.7.4.3 ? Link to comment Share on other sites More sharing options...
Shopcreator Posted December 19, 2018 Share Posted December 19, 2018 In 1.7 you will need to go to: modules / ps_cashondelivery / controllers / front / validation.php Find $this->module->validateOrder (around line 57) and swap out Configuration::get('PS_OS_PREPARATION') with the id you want. i.e. $this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); becomes $this->module->validateOrder((int)$this->context->cart->id, X, $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); where X is the id of the order status that you want it to use. Link to comment Share on other sites More sharing options...
nbowlinger Posted March 6, 2019 Share Posted March 6, 2019 (edited) An alternative is to make a similar implementation as Cash on delivery where AdminOrdersControllerCore is setting $defaults_order_state according to PS_OS_COD_VALIDATION set in ps_configuration table: $defaults_order_state = array( 'cheque' => (int)Configuration::get('PS_OS_CHEQUE'), 'bankwire' => (int)Configuration::get('PS_OS_BANKWIRE'), 'cashondelivery' => Configuration::get('PS_OS_COD_VALIDATION') ? (int)Configuration::get('PS_OS_COD_VALIDATION') : (int)Configuration::get('PS_OS_PREPARATION'), 'other' => (int)Configuration::get('PS_OS_PAYMENT') ); This is the way it is implemented in PS1.6.1.17. In my case i updated PS_OS_COD_VALIDATION from 14 (pending payment at delivery) to 3 (preparing order) directly in the database. Edited March 6, 2019 by nbowlinger (see edit history) 1 Link to comment Share on other sites More sharing options...
prakhar-ap Posted September 16, 2020 Share Posted September 16, 2020 On 9/8/2014 at 5:22 PM, Rain_xx said: Sorry but there's something wrong during the database creation of a new status. I mean in "ps_configuration" table. The id value is "null", it doesn't generate a valid id (es. 14), so the module can't work properly. Thanks. Edit: Solved. Just cancel the line "unset($id_order_state);" , it's contradictory. Hi, I am new to Prestashop. I tried the steps to add CustomOrderStatus within the module. But, while installing module, it gives out an error. I tried to install the function in the install() as suggested as well. public function install() { if (!parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn') || !$this->registerHook('backOfficeHeader') || $this->addCustomOrderStatus() ) { return false; } return true; } Tried to log the error and surrounded the DB step into a try catch but no luck there as well using PrestashopLogger::addLog(). Can you suggest what am i missing as well as how to log the errors? 1 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