You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom order can be implemented without Overrides.
Overrides is bad practice, it is a last point if developers have not other way.
And you can easily change all old orders to new syntax.
1). use hook
` public function hookActionValidateOrder($params)
{
if (!$this->active)
return false;
$new_ref = $this->generateReference($params['order']); // your generator function
$order_payment = new OrderPayment();
$transaction_id = $order_payment->getByOrderReference($params['order']->reference);
if(count($transaction_id)){
foreach($transaction_id as $transaction){
$transaction->order_reference = $new_ref;
$transaction->update();
}
}
$params['order']->reference = $new_ref;
$params['order']->update();
}
`
2). update in database public function updateAllOrders_to_my_synax () { $sql = "SELECT id_order FROM "._DB_PREFIX_."orders ORDER BY id_order ASC"; foreach (Db::getInstance()->executeS($sql) as $row) { $order = new Order((int) $row['id_order']); $ref = (string) $this->generateReference($order); Db::getInstance()->execute("UPDATE "._DB_PREFIX_."orders SET reference = '".pSQL($ref)."' WHERE id_order = ".$order->id); } }
Have Good day and experience :)
The text was updated successfully, but these errors were encountered:
Overrides is bad practice, it is a last point if developers have not other way.
1). use hook
` public function hookActionValidateOrder($params)
{
if (!$this->active)
return false;
`
2). update in database
public function updateAllOrders_to_my_synax () { $sql = "SELECT id_order FROM "._DB_PREFIX_."orders ORDER BY id_order ASC"; foreach (Db::getInstance()->executeS($sql) as $row) { $order = new Order((int) $row['id_order']); $ref = (string) $this->generateReference($order); Db::getInstance()->execute("UPDATE "._DB_PREFIX_."orders SET reference = '".pSQL($ref)."' WHERE id_order = ".$order->id); } }
Have Good day and experience :)
The text was updated successfully, but these errors were encountered: