Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello. I have the improvement for you. #1

Open
dnkhack opened this issue Nov 6, 2021 · 0 comments
Open

Hello. I have the improvement for you. #1

dnkhack opened this issue Nov 6, 2021 · 0 comments

Comments

@dnkhack
Copy link

dnkhack commented Nov 6, 2021

  1. Custom order can be implemented without Overrides.
    Overrides is bad practice, it is a last point if developers have not other way.
  2. 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant