Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Ubercart allows interaction with orders using hook_order, in a nodeapi way.
Unfortunately there's no presave stage of this hook, so there's no direct way to modify an order before it's saved to database.
This simple patch adds a new op value for hook_order, 'presave', that's called just before order is saved to database.
Code added:
uc_order_module_invoke('presave', $order, NULL);
Comment | File | Size | Author |
---|---|---|---|
ubcercart_order_presave.patch | 842 bytes | tunic | |
Comments
Comment #1
tunicChanging status to 'needs review' because there's a patch attachted.
Comment #2
longwaveTrivial patch, and a useful feature.
Comment #3
Island Usurper CreditAttribution: Island Usurper commentedThanks. Committed trivial patch. This $op should be documented in hooks.php, too.
Comment #4
longwaveAlso needs porting to 7.x.
Comment #5
longwavePorted to 7.x and documented in both branches.
Comment #7
dgtlmoon CreditAttribution: dgtlmoon commentedI see this is not documented in http://www.ubercart.org/docs/api/hook_order
how can I change the documentation?
Comment #8
dgtlmoon CreditAttribution: dgtlmoon commentedI found this hook because the 'save' $op did not appear to do what the documentation says it does..
save When an order object is being saved, the hook gets invoked with this op to let other modules do any necessary saving. $arg1 is a reference to the order object.
So what is the difference with presave? or does save happen after it has been written to the database?
Comment #9
tunicIt is documented in docs/hooks.php as said above:
Ubercart.org doc is a little bit outdatted, I think.
Comment #10
dgtlmoon CreditAttribution: dgtlmoon commentedThanks.
Yeah kind of annoying.