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.
During payment procession I want to change transaction statuses several times. But I can load ttransaction only by its ID not by order ID.
But during payment period I can mostly operate with order_id.
There should be function which loads transaction by order_id.
Thanks.
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedI don't think we'll be making this change, as it's possible for there to be multiple payment transactions per order ID. There's already a core Drupal API feature called the EntityFieldQuery that would do the exact same thing, load an entity based on some property (i.e. load payment transactions based on their order ID property). I recommend you research that and use that to load your payment transactions.
Comment #2
a.ross CreditAttribution: a.ross commentedHere's an example of how to do that:
Docs for EFQ are here: http://api.drupal.org/api/drupal/includes!entity.inc/class/EntityFieldQu...
Comment #3
cafuego CreditAttribution: cafuego commentedFor the record, you can use the commerce API to load the entire payment object (or objects in case of multiple transactions) pretty easily:
Comment #4
Samba B CreditAttribution: Samba B commented@cafuego Thanks! This saved my day! :)
Comment #5
tostinni CreditAttribution: tostinni at Agence Propal commentedI found this answer too but it's important to notice that
commerce_payment_transaction_load_multiple()
can also load unsuccessful attempt of the same transaction.So in order to retrieve only the correct object you have to make :