Post by nbrofree » Sun Jun 13, 2021 4:34 am

I want an extra field in the order_product table on OC 2.3.0.2 so:
in the file "catalog/model/checkout/order.php"
I changed the insert query of "function addOrder($data)" to (added , test_column='foo'):

Code: Select all

INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "', test_column='foo'
However the "test_column" in any new order is still empty in the table.

Of course I triple checked for the same name and variables, created the "test_column" as text type (just for now), cleared cache and I can see that in the "vqcache" folder the file "vq2-system_storage_modification_catalog_model_checkout_order.php" has taken the above change. Also tried both with a vqmod and simply editing the core file with no result.

What am I missing?
Last edited by nbrofree on Sun Jun 13, 2021 5:51 pm, edited 1 time in total.

Newbie

Posts

Joined
Thu Mar 04, 2021 12:23 am

Post by straightlight » Sun Jun 13, 2021 7:08 am

nbrofree wrote:
Sun Jun 13, 2021 4:34 am
I want an extra field in the order_product table so:
in the file "catalog/model/checkout/order.php"
I changed the insert query of "function addOrder($data)" to (added , test_column='foo'):

Code: Select all

INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "', test_column='foo'
However the "test_column" in any new order is still empty in the table.

Of course I triple checked for the same name and variables, created the "test_column" as text type (just for now), cleared cache and I can see that in the "vqcache" folder the file "vq2-system_storage_modification_catalog_model_checkout_order.php" has taken the above change. Also tried both with a vqmod and simply editing the core file with no result.

What am I missing?
OC version.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by cmsroom » Sun Jun 13, 2021 11:48 am

Please share your opencart version.

You may like these extension : - https://www.opencart.com/index.php?rout ... r=cmsrooms


New member

Posts

Joined
Fri Sep 28, 2018 1:37 am

Post by straightlight » Sun Jun 13, 2021 5:39 pm

Redundancy.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by nbrofree » Sun Jun 13, 2021 5:52 pm

Ah. You are right. Opencart version 2.3.0.2.

Newbie

Posts

Joined
Thu Mar 04, 2021 12:23 am

Post by straightlight » Sun Jun 13, 2021 5:55 pm

nbrofree wrote:
Sun Jun 13, 2021 5:52 pm
Ah. You are right. Opencart version 2.3.0.2.
By creating an Event, this can be accomplished already. See documentation: https://github.com/opencart/opencart/wiki/Events-System

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by nbrofree » Sun Jun 13, 2021 11:26 pm

straightlight wrote:
Sun Jun 13, 2021 5:55 pm
By creating an Event, this can be accomplished already. See documentation: https://github.com/opencart/opencart/wiki/Events-System
An event action will trigger before or after the function addOrder(). I want it during/in the function. Should I be doing it with the event for any reason?
Moreover this is somewhat illogical in my head that it is not working with a simple column set in the sql.

Newbie

Posts

Joined
Thu Mar 04, 2021 12:23 am

Post by straightlight » Mon Jun 14, 2021 12:52 am

nbrofree wrote:
Sun Jun 13, 2021 11:26 pm
straightlight wrote:
Sun Jun 13, 2021 5:55 pm
By creating an Event, this can be accomplished already. See documentation: https://github.com/opencart/opencart/wiki/Events-System
An event action will trigger before or after the function addOrder(). I want it during/in the function. Should I be doing it with the event for any reason?
Moreover this is somewhat illogical in my head that it is not working with a simple column set in the sql.
The created order ID can be captured with the $args[0] or $output by using an /after event which means the test field can still be updated right afterwards and before the original model method can exit its statement.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon Jun 14, 2021 5:38 pm

straightlight wrote:
Sun Jun 13, 2021 7:08 am
OC version.
Not a question.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by paulfeakins » Mon Jun 14, 2021 5:39 pm

nbrofree wrote:
Sun Jun 13, 2021 11:26 pm
An event action will trigger before or after the function addOrder(). I want it during/in the function. Should I be doing it with the event for any reason?
Moreover this is somewhat illogical in my head that it is not working with a simple column set in the sql.
You shouldn't be modifying core files directly.

So I would suggest you use an OCMOD or vQmod instead once you've got your change working.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by nbrofree » Mon Jun 14, 2021 9:36 pm

paulfeakins wrote:
Mon Jun 14, 2021 5:39 pm
You shouldn't be modifying core files directly.

So I would suggest you use an OCMOD or vQmod instead once you've got your change working.
I know and I did make a vQmod but it did not work, so I made a backup and modified the core file directly for sanity's shake. In both cases I saw the vQcache file change but not working.
I am currently working with an event (learning mostly).

Newbie

Posts

Joined
Thu Mar 04, 2021 12:23 am

Post by straightlight » Mon Jun 14, 2021 9:49 pm

nbrofree wrote:
Mon Jun 14, 2021 9:36 pm
paulfeakins wrote:
Mon Jun 14, 2021 5:39 pm
You shouldn't be modifying core files directly.

So I would suggest you use an OCMOD or vQmod instead once you've got your change working.
I know and I did make a vQmod but it did not work, so I made a backup and modified the core file directly for sanity's shake. In both cases I saw the vQcache file change but not working.
I am currently working with an event (learning mostly).
Events are the right direction.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 30 guests