Add additional information when ordering (Tracking_url)

LiteCart Fan
Nuo Bulgaria
Narys nuo bal. 2022

Hello.
I am updating a shipping module, and in the module I have also added a tracking URL, default for the specific Module.
My question is:
How to automatically add a tracking URL to the database after a user makes an order.

Now the addition is done only from the Admin panel, I want to make it take information from the Delivery Module, and automatically add it to the database, depending on which module the customer has chosen.

I will explain it clearly with pictures

In the module I have added to enter URL and output via:

$options[] = [
          'id' => 'zone_'.$i,
          ...............
         [b] 'tracking_url' => $this->settings['tracking_url'],[/b]
          'tax_class_id' => $this->settings['tax_class_id'],
          ....................
        ];
[b][i][u]Picture 1[/u][/i][/b]

When a customer places an order and completes it from [b][i][u]Picture 2[/u][/i][/b], should the tracking URL information be sent and saved to the database?
[b][i][u]Picture 3[/u][/i][/b]

tim
Founder
Nuo Sweden
Narys nuo geg. 2013
tim

As of LiteCart 2.5.2 shipping modules have after_process():


  $order->data['shipping_tracking_url'] = ...;
  $order->save();
}```
LiteCart Fan
Nuo Bulgaria
Narys nuo bal. 2022

Thank you! I do it!

Moderator
Nuo United States
Narys nuo spal. 2019

@tim Are you saying that this:


  database::query(
  'UPDATE '.DB_TABLE_ORDERS."
    SET `shipping_account_num` = '". database::input($this->userdata['shipping_account_num']) ."',
        `shipping_method_ux` = '". database::input($this->userdata['shipping_method_ux']) ."'
    WHERE `id` = '". (int)$order->data['id'] ."'
    LIMIT 1;"
  );
}```

can now be replaced with this?

```function after_process($order) {
  $order->data['shipping_account_num'] = database::input($this->userdata['shipping_account_num']);
  $order->data['shipping_method_ux'] = database::input($this->userdata['shipping_method_ux']);
  $order->save();
}```
tim
Founder
Nuo Sweden
Narys nuo geg. 2013
tim

Correct :)

tim
Founder
Nuo Sweden
Narys nuo geg. 2013
tim

I forgot to mention you will have to modify ent_order.inc.php to handle these custom fields. But once you do, that approach should work.

Moderator
Nuo United States
Narys nuo spal. 2019

That adds an extra level of complexity in my situation.  I think I'll stick with going directly to the db, since I hate having code spread across multiple files, if there's a way to avoid it. 

Too bad there's not a way to have the shipping module automatically input custom fields for you.  Hint, hint.  : )

tim
Founder
Nuo Sweden
Narys nuo geg. 2013
tim

[quote]if there's a way to avoid it.[/quote]
That would be a vmod patch.

[quote]Too bad there's not a way to have the shipping module automatically input custom fields for you.  Hint, hint.  : )[/quote]
If you have a concept that solves this, I'm all ears.

This thread has been closed due to long inactivity. Posting to it is not possible.
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.