why is it that WooCommerce REST API returns total orders 0 for a customer but has 1 order for that customer in order table? - woocommerce-rest-api

I am working on WooCommerce REST API. I am fetching customers and orders. I want to know how WooCommerce calcluates total number of orders as for some customers it is returning less results than the record found in orders table. Is there any issue with API?
here is the customer table result: Customer Table
here is the order table
Orders Table. Sorry stack overflow only allows me to add links of the images.
BTW you can clearly see that customer has one order but in customer table, it shows 0 orders, this data is returned by woocommerce rest api, so there is no chance of error from me. I can't add full image of DB due to some privacy issue and company rules.

Related

How to Find Magento Missing Order and what is the cause of it

Customer Place order payments received with no corresponding orders. From the customer's perspective, they had submitted an order and paid us but nothing was appearing in our order history on the admin side in the sales order grid, just a skipped increment_id.
I have checked the quote table there is order_reserved_id which is the same as order increment_id but I query the same increment_id in the sales_order table query return null.
Q1: how to find all missing orders.
Q2: How to debug this issue.
Q3: what are the possible causes of this issue?
I Have tried different queries (match the reserved_order_id of quote table with increment_id of sales_order table) to find out the missing entries in the sales_order table. I don't know if this is the right way to find the missing order. we are using the Meetanshi_Paya module as a payment method with Magento 2.4.3.

Magento 2 rest order API show duplicate sku in order item if product is configurable

I am getting Magento 2 order details by rest order API but the result is showing the same SKU in configured product order item that is creating an issue in SAP integration.
Anyone let me know how can we overwrite Magento 2 rest API code?
You should not need to “overwrite magento 2 rest API code” because what you described is perfectly normal and expected.
In Magento orders, each configurable product creates two sales order line items due to the way that configurable product data is structured in the catalog. One line corresponds to the “parent” catalog product, and one corresponds to the specific variant “child” (simple) product. Both records contain the same SKU value but their product IDs are different.
In order to get all information about the ordered item both of those records could be important, however if you can get by with just the data from the simple product then you could filter your REST request like below:
GET <host>/rest/V1/orders/items?
searchCriteria[filter_groups][0][filters][0][field]=order_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][1][filters][0][field]=product_type&
searchCriteria[filter_groups][1][filters][0][value]=simple

Postgres SELECT id LAG(id) OVER (ORDER BY id) FROM invoice WHERE id = 2

I've looked all over the internet and I fail to get this query running as expected.
I've got a table of invoices and some invoices are related to one another because they belong to the same project.
My ticket says I've got to get the PREVIOUS invoice based on a provided invoice.
Say Project A has 10 invoices, and I'm looking at invoice #4, I've got to write a query which will return the ID of the previous Invoice. Bear in mind, the invoice table is home to all sorts of projects, and each project could have many invoices on their own, so I want to avoid getting many IDs back and then iterating over them.
To illustrate the issue, I've written this fiddle.
It works somewhat acceptably when I don't filter for steps.id, but that means returning hundreds of IDs to sift through.
I've tried and tried but I can't seem to get the column previousStep to be kind of bound to the ID column.
Simply find the invoice with the next largest id for the same project:
SELECT inv2.id
FROM invoice AS inv1
JOIN invoice AS inv2
ON inv1.project = inv2.project AND inv1.id > inv2.id
WHERE inv1.id = 1057638
ORDER BY inv2.id DESC
LIMIT 1;

Magento 2 REST Search Orders Starting at Order_ID

I'm writing a Magento2 integration and I'm trying to only get a list of orders by order_id since the last order_id that i have sync'd.
So, my orders search call would only get order_id's greater than the last order id that I've synced (i'll keep this in my app).
In this example, I only want order ID's greater than order_id = 20 and sorting by order_id ASC:
/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=order_id&searchCriteria[filter_groups][0][filters][0][value]=20&searchCriteria[filter_groups][0][filters][0][condition_type]=from[sortOrders][0][field]=order_id&searchCriteria[sortOrders][0][direction]=asc
But i'm getting a 500 error thrown from the REST API when I run this.
Any ideas what is wrong with my call?
I am afraid there is no order_id field in Magento 2 sales_order table. Instead of that you can use entity_id ( the primary key).
So your query url will be below and this will pull the orders greater than supplied order id.
https://yourhost.com/rest/V1/orders?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][value]=179&searchCriteria[filterGroups][0][filters][0][conditionType]=gt
Also post your Magento related queries in here for better visibility

Getting multiple invoices from intuit anywhere api at once

When I update an invoice in QB (after its been changed in my system), I want to avoid updating anything that the user has modified in QB. My plan was to use the filter API method and filter by Ids to get the list of invoices from QB that my app created. However, it doesn't look like InvoiceFilter accepts ListIdSet. It does have a TransactionIdSet, but I can't find a way to get ahold of that number (i.e., the TransactionId) via Data Services. It's certainly not in the response when invoices are read. So, how do I query for a specific set of invoices via the API?
The transaction id refers to the id of the invoice here.
For eg, the following invoice query will retrieve the invoice with Id 4 -
<InvoiceQuery xmlns="http://www.intuit.com/sb/cdm/v2">
<TransactionIdSet>
<Id idDomain="QB">4</Id>
</TransactionIdSet>
</InvoiceQuery>