Comments (7)
Hi @ckepper. Discounts are calculated by applying offers on the complete basket, not just per line. So this is a bit of an edge-case as we follow the way oscar caclulates the discounts on a basket.
Do you mean btw that price_excl_tax
and price_excl_tax_excl_discounts
are not automatic recalculated on your client when not retrieving the basket again? These fields are only available in the basket right?
from django-oscar-api.
I am aware that this might be an edge case and I know that Oscar calculates discounts on the basket and not on a single line item.
What I found confusing was that I received a response to the PUT
request that included price_excl_tax_excl_discounts
but the value was incorrect. I would have expected that the response shows either the correct value (with discount applied) or no discount field at all. Hope that makes sense.
Here is the output of the PUT
request. As you can see, price_excl_tax == price_incl_tax_excl_discounts
:
{
"url": "https://localhost/shop/api/v1/baskets/37/lines/31/",
"product": "https://localhost/shop/api/v1/products/8/",
"quantity": 100,
"attributes": [],
"price_currency": "USD",
"price_excl_tax": 299,
"price_incl_tax": 299,
"price_incl_tax_excl_discounts": 299,
"price_excl_tax_excl_discounts": 299,
"is_tax_known": false,
"warning": null,
"basket": "https://localhost/shop/api/v1/baskets/37/",
"stockrecord": "https://localhost/shop/api/v1/stockrecords/8/",
"date_created": "2016-11-13T00:17:06.447193Z"
}
The call to the basket lines however reveals that there is a discount on the product (price_excl_tax != price_incl_tax_excl_discounts
):
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"url": "https://localhost/shop/api/v1/baskets/37/lines/31/",
"product": "https://localhost/shop/api/v1/products/8/",
"quantity": 100,
"attributes": [],
"price_currency": "USD",
"price_excl_tax": 269.1,
"price_incl_tax": 269.1,
"price_incl_tax_excl_discounts": 299,
"price_excl_tax_excl_discounts": 299,
"is_tax_known": false,
"warning": null,
"basket": "https://localhost/shop/api/v1/baskets/37/",
"stockrecord": "https://localhost/shop/api/v1/stockrecords/8/",
"date_created": "2016-11-13T00:17:06.447193Z"
}
]
}
from django-oscar-api.
@ckepper Ah ok, I see now that the price_excl_tax_excl_discounts
is also serialized in the line response (which means that we don't apply the offers to the basket before the response). This should be fixed (or we should leave out the price_incl_tax_excl_discounts
and price_excl_tax_excl_discounts
fields). I'll investigate this further and will come up with a proper solution. Thanks for reporting!
from django-oscar-api.
I will try to fix this (when I have more time) in a proper way. In the meanwhile I have this branch which hopefully fixes this : https://github.com/django-oscar/django-oscar-api/tree/fix/update-line-quantity Can I ask you try this (just to see if I'm lucky :) )
from django-oscar-api.
Thank you for supplying this patch so quickly. I tried it out but unfortunately it didn't fix it. I stepped through the code with a debugger and found that the correct value was in the result cache (basket._lines._result_cache[0]
) but this was not used for the output.
from django-oscar-api.
Hi @ckepper, I think I fixed this in https://github.com/django-oscar/django-oscar-api/tree/fix/update-line-quantity now (and I added a test for it). Can you confirm this works for you? Then I'll review it next week and make a new release of oscarapi. Thnx.
from django-oscar-api.
@ckepper, We already made a proper solution for this and merged this to master. Maybe you can check this so we are sure we have the correct solution?
from django-oscar-api.
Related Issues (20)
- Unable to create an account HOT 1
- How to Login with react js HOT 16
- How to Overwrite Oscar API URL ? HOT 1
- getting HOT 2
- Weird results in attributes with patching Childs HOT 3
- AttributeError: 'NoneType' object has no attribute 'strategy' HOT 3
- Is there any good way to make price range filter with oscar api? HOT 1
- Why doesn't ProductList filter out non-public products?
- AdminProductSerializer validation
- `cookies_to_delete` is always an empty list HOT 12
- AdminProductSerializer error when trying to add products HOT 1
- Voucher discount is applied to every single product in the basket
- Add to basket api returns 403 forbidden when user is logged in HOT 5
- ImproperlyConfigured at /api/admin/products/ when a Product has an optiongroup HOT 13
- master ahead of main? HOT 1
- _ in both ApiBasketMiddleWare and translations? HOT 1
- Potential problem with basket for unauthenticated users
- Inconsistency between product class and product category HOT 1
- PUT on productclasses HOT 6
- Empty attribute values cause an exception
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-oscar-api.