Get Credit memo details by order increment id Magento 2.

You can fetch the Credit memo collection details by Order Increment Id using Magento 2.

When you check the sales_creditmemo table, order_id available in sales_creditmemo table so you first fetch the order entity id from the order increment id.

To get credit memo records, you first fetch the order id by order increment id and pass order id as SearchCriteriaBuilder addFilter() method.

Pass search criteria object to getList() method of CreditmemoRepositoryInterface to fetch credit memo details by order increment id.

Using the above way you got the output as credit memo records as an array.

Iterate over a loop to credit memo array to fetch no. of different credit memo record for an order.

You got the credit memo object for the output of the above code.

Get Credit memo details by order id programmatically Magento 2.

You can get the Credit memo collection details for the specific order by an order id using Magento 2.

Using Magento\Sales\Api\CreditmemoRepositoryInterface interface, you need to use getList() function to fetch no. of credit memo by sales order id.

Using SearchCriteriaBuilder Class, You need to filter by order id and pass search criteria object to getList() method of CreditmemoRepositoryInterface.

Database Table used the store the credit memo data:
sales_creditmemo

Call from a template or other class by,

Output:

The array of Credit memo collection for a Specific Order.

Get Credit memo details by creditmemo id Magento 2.

Magento 2 contains Out of the Box Native feature of Credit memo generation from admin panel for an order after invoice generated.

What is a Credit Memo?

After a customer places and pays for an order for an online payment method and an invoice has been issued for the specific order, Merchant can create a credit memo to refund all or part of the amount paid for any returned or undelivered items.

The memo restores funds to the customer account or refunds to the customer bank account used for an order so that the customer can make future purchases.

Database Table used the store the data:
sales_creditmemo

You can get full details of Creditmemo related data using credit memo id in Magento 2.

Using Magento\Sales\Api\CreditmemoRepositoryInterface class you can get details of credit memo related data in Magento 2.

Pass Creditmemo id to fetch creditmemo records from database table.

echo “<pre>”;print_r($creditMemo->debug());exit;