Is it possible to override a checkout segment?

Open to all! Ask other shopowners for help.
Post Reply
Piernas
Member
Posts: 98
Joined: Thu Mar 11, 2021 2:16 am
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Is it possible to override a checkout segment?

Post by Piernas »

What said, Is it possible to override a checkout segment and how?


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Is it possible to override a checkout segment?

Post 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.
Piernas
Member
Posts: 98
Joined: Thu Mar 11, 2021 2:16 am
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: Is it possible to override a checkout segment?

Post 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?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Is it possible to override a checkout segment?

Post 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
Piernas
Member
Posts: 98
Joined: Thu Mar 11, 2021 2:16 am
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: Is it possible to override a checkout segment?

Post 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.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Is it possible to override a checkout segment?

Post 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.
Piernas
Member
Posts: 98
Joined: Thu Mar 11, 2021 2:16 am
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: Is it possible to override a checkout segment?

Post 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.
Piernas
Member
Posts: 98
Joined: Thu Mar 11, 2021 2:16 am
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: Is it possible to override a checkout segment?

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply