How to override order/history.phtml template in Magento 2?

You can override history.phtml file using layout XML by creating a module or directly add template file to the theme level under Magento_Sales module under the theme.

History.phtml file initiated by History.php Block class. Continue reading “How to override order/history.phtml template in Magento 2?”

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. Continue reading “Get Credit memo details by order increment id Magento 2.”

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. Continue reading “Get Credit memo details by order id programmatically Magento 2.”