Skip to content

Hello. I have the improvement for you. #1

Description

@dnkhack
  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 :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions