Forums › Forums › OroCommerce › Order – Payment Status
This topic contains 4 replies, has 2 voices, and was last updated by Tyler 6 years, 11 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- May 17, 2017 at 5:29 am #31783
Hi !
How to get the payment status of an order ?Thanks.
- CreatorTopic
- AuthorReplies
- May 23, 2017 at 6:09 am #31784
Hello Tyler.
If you want to see payment status of an order via web interface – then you can see it in product`s view page (e.g. /admin/order/view/1, or Admin -> sales -> orders -> view order -> ‘Payment status’ in ‘general’ section)
Or, if you want to get it in code, then you should use
\Oro\Bundle\PaymentBundle\Provider\PaymentStatusProvider::getPaymentStatus($order)
methodMay 23, 2017 at 7:21 am #31785Hi Dmitriy,
Yes I know this method ?
But with this method I have to loop on each orders to know the payment status.
Or there is another way to search my orders by payment status into the code ?I want to explose as API my all order by payment status like a search.
I want to request my order like orderByPaymentStatus($status), then the code return the orders with the status given.
Is it possible ?
I saw the table payement_status doesnt have relation with others tables, but the entity_class is referer.
Have I to make a custom request between both tables ?
LikeMySQL1Select oro_order.*, oro_payment_status.payment_status from oro_order, oro_payment_status where oro_payment_status.entity_identifier = oro_order.id AND oro_payment_status.payment_status :operator :status and oro_payment_status.entity_class = 'Oro\\Bundle\\OrderBundle\\Entity\\Order';May 23, 2017 at 8:47 am #31786Yes, you have to make custom query. But it would be better to do DQL query instead of SQL (to get array of ‘Order’ entities instead of array of … arrays :))
Something like this:PHP12345$orders = $em->createQuery("SELECT o FROM Oro\Bundle\OrderBundle\Entity\Order oJOIN Oro\Bundle\PaymentBundle\Entity\PaymentStatus ps WITH ps.entityIdentifier = o.id AND ps.entityClass = 'Oro\Bundle\OrderBundle\Entity\Order'WHERE ps.paymentStatus = :paymentStatus")->execute(['paymentStatus' => \Oro\Bundle\PaymentBundle\Provider\PaymentStatusProvider::FULL]);May 24, 2017 at 12:38 am #31787Haha, of course.
I made a Subquery and It works.Sorry, I was sure we could not use the joins without a foreign key…
I will try your solution know :)Thx.
- AuthorReplies
The forum ‘OroCommerce’ is closed to new topics and replies.