Page 1 of 1

Is it possible to override a checkout segment?

Posted: Sun Apr 04, 2021 7:51 pm
by Piernas
What said, Is it possible to override a checkout segment and how?

Re: Is it possible to override a checkout segment?

Posted: Sun Apr 04, 2021 8:02 pm
by ecartz
Which one?

If you look at how it's loaded, it might be easier to tell. For example, several are loaded by database hooks. Just change the hook.

Re: Is it possible to override a checkout segment?

Posted: Sun Apr 04, 2021 9:19 pm
by Piernas
It was the insert_order one, yes it's a database one thank you.

I wanted to make this for manipulating the attributes (saving product options/attributes ids to the orders_products table) and avoiding to add more queries to the checkout (saving these at the same time as the rest of the attributes) . Do you think there is a less invasive method to do this?

Re: Is it possible to override a checkout segment?

Posted: Sun Apr 04, 2021 9:40 pm
by ecartz
Well, you could just use the hook that's there for manipulating the tables and columns: https://github.com/CE-PhoenixCart/Phoen ... r.php#L139

Re: Is it possible to override a checkout segment?

Posted: Sun Apr 04, 2021 10:12 pm
by Piernas
Thanks, I saw it but it has the con of adding more queries to the already heavy and slow checkout process. While it works great for inserting simpler things i.e. language id to the order, I fear it will add more queries and workload for attributes, so I was thinking in simply overriding the whole segment and just replace the already present queries for faster execution. The bad thing is one app can virtually conflict with another if both tries to replace the whole segment.
I'll test both methods and see if there's any significant difference.

Re: Is it possible to override a checkout segment?

Posted: Sun Apr 04, 2021 10:22 pm
by ecartz
How would adding columns to the existing data structure add more queries? You'd be inserting with the same query as it is already using.

Code: Select all

$parameters['sql_data']['orders_products_attributes'][$i][$j]['column_name'] = $value;
The $i is the line number of the product, starting with zero. The $j would be the same thing for the product attribute.

That's why it has that weird structure where it puts everything into an array before it does any inserts. So you can make data changes with the hook without having to do separate queries.

Re: Is it possible to override a checkout segment?

Posted: Mon Apr 05, 2021 3:18 am
by Piernas
I meant the $attributes_sql and the nested loops to assign them again that has to be repeated again to include the new data. Anyway it's probably not very important.

Re: Is it possible to override a checkout segment?

Posted: Mon Apr 05, 2021 4:08 am
by Piernas
Forget what I said - options_id and options_values_id are already there and there's no need to make any extra queries, just the products loops.