Add additional information when ordering (Tracking_url)

LiteCart Fan
Depuis Bulgaria
Membre depuis avr. 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
Depuis Sweden
Membre depuis mai 2013
tim

As of LiteCart 2.5.2 shipping modules have after_process():


  $order->data['shipping_tracking_url'] = ...;
  $order->save();
}```
LiteCart Fan
Depuis Bulgaria
Membre depuis avr. 2022

Thank you! I do it!

Moderator
Depuis United States
Membre depuis oct. 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
Depuis Sweden
Membre depuis mai 2013
tim

Correct :)

tim
Founder
Depuis Sweden
Membre depuis mai 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
Depuis United States
Membre depuis oct. 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
Depuis Sweden
Membre depuis mai 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.

Ce fil de discussion a été fermé en raison d'une longue inactivité. Il n'est pas possible de publier dessus.
Ce site n'utilise aucun cookie ni aucune technologie de suivi tierce. Nous pensons pouvoir faire mieux que les autres et nous nous soucions vraiment de votre vie privée.