Calculate Gross Sales using Shopify API - shopify

I want to calculate Gross Sales using Shopify API. I have already readed the shopify API documentation and tried the formula they used to calculate gross sales and failed to get the same result they have at the shopify reports website.
I used this shopify endpoint to retrieve all orders
/admin/api/2020-07/orders.json?status=any&created_at_min=2020-07-03T00:00:00-04:00&created_at_max=2020-07-04T00:00:00-04:00&limit=250
PS: The number of orders from shopify API and shopify Dashboard is equal. ( I am getting all the orders correctly)
I tried to use the sum of total_line_items_price, but I got a different result from Shopify Reports.
Shopify API results after summing the total_line_items_price: X
Also, I tried to use the formula they provided at Shopify API documentation where they mentioned that Gross Sales = product selling price x ordered quantity and I got the same result as sum of the total_line_items_price: X
Shopify Gross Sales at the financial report dashboard: Y
Shopify API sum of total_tax: Z Which is equal to the financial report taxes.
Please I need your help to calculate Gross Sales Correctly
Thank you

You want to go through Transactions. Transactions include refunds and cancellations, whereas using totals from orders is not dynamic.
Shopify reports are and have always been a bit of a mess. Even today in 2020, a lot of merchants complain to me that the numbers do not add up, as there are numerous places for the uninformed to make mistakes. Takes for example editing orders. A lot of merchants use that. When line items are changes, draft orders are created and attached to orders, as a sequence. So if you are failing to follow those breadcrumbs, you may be double billing some items, or otherwise messing with totals.
So my advice to you is to use the numbers in the transactions, and see what that does for your reporting.

Related

How to get returns/refund value from shopify api

I am trying to calculate the total sales of orders overtime similar to shopify reports dashboard. I tried using the transactions api and calculated the total sales by subtracting the refund value from sale value but the value I calculated and the one in shopify reports dashboard seems different but when I tried subtracting the returns value in the shopify dashboard and sale value from the transactions api I got the same value as in shopify dashboard.
So where can I find the returns data in shopify api ? or How can I calculate the returns value through shopify api?
For refund amount check Order API and Order object
You will find there field refunds that will contain transactions and refund_line_items.
I hope that will contain all information that will be required.

Shopify API get Total Returns/Refunds

I am trying to get the Net Sales of orders of our Shopify store on daily basis. I can do it with the Orders API, but there seems to be a mismatch for the refunds returned by the API and the refunds/returns that show up in the dashboard.
In fact, the API doesnt show any refunds for the orders at all but there does seem to be some amount deducted from the Total Sales of Orders which make the actual Net Sales for that particular day.
I can retrieve the orders for one day by this example URL. I iterate through all the orders and add up each Order's amount which gives an exact number of Total Sales which match up to the number in the dashboard. But this Total Sales value doesnt take into account the refunds/returns.
/admin/api/2021-07/orders.json?status=any&created_at_min=2021-08-17T00:00:00-04:00&created_at_max=2021-08-18T00:00:00-04:00&limit=250
There is a refunds in the returned json for each order as well in the above call but that is empty for all the objects.
I have explicitly tried to retrieve the refunds as well by following API call but it also returns empty for all the orders.
/admin/api/2021-07/orders/{order_id}/refunds.json
You may have a look at the Dashboard Sales image for one day. Please note in this image, I can get the exact value for Total Orders from the API but can not retrieve a single refund/return for any of the order.
Would you be having an idea what are these Refunds/Returns shown in the Dashboard? If so, is there a way how can I accurately calculate the Refunds/Returns by the API as well, so I can accurately calculate the Total Sales for one day?
You should be working with Transactions. Specifically, the refund transactions. An Order has many transactions. So given some order, you can get at the interesting transactions, and calculate your important values, like Net. I have aced this for many clients, as Shopify does not report this type of value very well. So I generate reports with Net, refunds, taxes, etc, providing much clearer guidance than the standard Shopify reports.

I would like to run a query to produce a price list for each customer and product taking into consideration promotional prices and discount prices?

We have a number of different promotions (fixed prices and discount %) for each customer. I want to be able to produce an extract so that we can work out what the price the customer would pay if they were entering a Sales Order direct within Epicor. I then want to use this as part on an internal portal so I will store these prices in a seperate table.
I can extract each item individually i.e. customers & products. but I can't seem to get the logic correct for working out the correct sales price.
This is for Epicor 9.05
Thanks
It sounds like you want to use customer price lists to track pricing for your customers. This will allow you to set discounts or custom prices for some or all of your parts.
While the material is proprietary to Epicor, you can take a look at the "Customers and Accounts Receivable" chapter of the EpicorAppplication_UserGuide for your version as found on your EpicWeb customer portal for more information on using these.

How to set custom price for products on the basis of quantity in shopify?

Greetings.
I am working on a eCommerce website based on shopify. And for product I want to set a custom price. For example, The standard price of product is $500 but price will vary if user increased the quantity i.e. On 5 - 10 it will cost $450, On 11 - 15 it will cost $400 and on 20+ quantity it will cost $300.
I have searched module for this and also found a module i.e. https://apps.shopify.com/quantity-breaks. But its working on the basis of "Percent" that I don't need. Because I want to place price manually on the basis of quantity.
So please help me out from this and provide your valuable thoughts on the same.
Thanks in advance.
The way this is generally done in Shopify is to create variants where the option values are the price breaks. You have to modify your theme so that when a Qty > price break is entered the product page selects the variant that corresponds to that price level.
Other than the coding portion of this the main issue becomes inventory management since Shopify treats each variant as a separate inventory item but if you use variants to manage price breaks they are not actually separate items.
I think the easiest way to do this would be with a Shopify App. There are many that have price breaks etc. and they are usually easier to set up than using variants as the price break amounts.

shopify api: calculate total shipping price

There is a nice helper - shipping_price - available in liquid templates (for order). Returns total order shipping price (hopefully). How do I get the same via API?
Should I go through order order.shipping_lines and sum their price? Is that the right way to do it?
EDIT
Or, perhaps, order.subtotal_price + order.total_tax?
If you just want the shipping price then summing the shipping line prices is the correct approach.
At this time, there's only ever one shipping line per order but it's built as an array to accomodate potential changes to this situation.