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.
Related
I found similar question in the forum, and from this answer I come to know about Career service. Which looks promising initially, but after reading the doc from here, I found that there is an issue for my use case.
This is my use case:
There will be multiple items in the cart with different delivery dates set(I store delivery dates in the line_item property)
now when user go to checkout the shipping rate has to be calculated based on the delivery dates(which are stored in the line item property for each line item)
shipping price should be calculated like ...... if there is only one delivery day, we need to offer x price, if there are two different delivery dates we need to offer 2x price and so on....
so the issue is, Carrier Service uses Server side cashing and it will only ask for price if any of these(variant IDs, default shipping box weight and dimensions, variant quantities, carrier service ID, origin address, destination address, item weights and signatures) field change. It doesn't include line item properties(where I have stored delivery dates).
I have also checked the shopify scripts from here, but after some mockups I come to know that we can only provide discount to the existing shipping rates and can not add new shipping method, or increase shipping price for existing shipping method.
Please help me to find a solution for this problem.
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 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.
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.
So, here's the problem:
A product costs $10. You then have the option to customize it (with a photo upload to be printed on it) for an additional one-off price of $5, no matter how many products are ordered (e.g. you can order 1 or 5 or 10000 items and the customization price will always be a flat $5).
Currently, when you buy, for example, twenty items and choose the customization option, OpenCart will calculate it: (Product Price + Option Price)*Quantity = (10+5)*20 = $300 . Instead, what I aim to achieve is something like (Product Price*Quantity) + Option Price = 10*20 + 5 = $205
Ideally, I would like certain options to ignore the quantity (so that it will be an additional $5 no matter how many products are ordered), while other option prices should go up with quantity (so that one product customization costs $5, two product customizations cost $10, etc.).
Surely, OpenCart must offer some way to deliver such a fundamental customer experience?
This isn't a standard feature that you will be able to do out of the box. The way I would solve this would be to create a custom Order Total extension and add $5 to the subtotal/total at checkout if any product has that particular option set. This does require some PHP knowledge to do
Instead of rolling your own, you could probably use the Handling Fee extension. You may need to create a new Tax Class for that. But as Jay said, creating your own would be ideal, and yu could certainly use the Handling Fee as a starting point.
Check this out
ADD ONCE OPTION PRICE REGARDLESS QUANTITY
http://www.opencart.com/index.php?route=extension/extension/info&extension_id=13390
My commercial OpenCart extension Setup Fees for Product Options should do what you need. You can see an example here by selecting the rush production option.