question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offers are consumed twice on basket lines

See original GitHub issue

I am wondering about how to apply offer for consume offer for django oscar 1.6.4,

I was digging in to the code base, and found out that we call consume 2 times when applying a benefit. For example

  • In apps.basket.abstract_models.py
 def discount(self, discount_value, affected_quantity, incl_tax=True,
                 offer=None):
        """
        Apply a discount to this line
        """
        if incl_tax:
            if self._discount_excl_tax > 0:
                raise RuntimeError(
                    "Attempting to discount the tax-inclusive price of a line "
                    "when tax-exclusive discounts are already applied")
            self._discount_incl_tax += discount_value
        else:
            if self._discount_incl_tax > 0:
                raise RuntimeError(
                    "Attempting to discount the tax-exclusive price of a line "
                    "when tax-inclusive discounts are already applied")
            self._discount_excl_tax += discount_value
        self.consume(affected_quantity, offer=offer)

And then again in apps.offer.conditions.py in each condition, they have def consume_items(self, offer, basket, affected_lines): and call line.consume(quantity_to_consume, offer=offer) method again.

I don’t think it’s supposed to call consume twice like this?

Technical details

  • Oscar version: django oscar 1.6.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pjstevnscommented, Mar 19, 2019

I’ll prepare a fix for this asap.

0reactions
pjstevnscommented, Mar 24, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

macroeconomics asu 3 Flashcards - Quizlet
In year two, the price of the same basket is $8.00. ... Use the orange line (square symbol) to plot the initial money...
Read more >
Utility Maximization - ECON 150: Microeconomics
The law of diminishing marginal utility states that as more of the good is consumed, the additional satisfaction from another bite will eventually...
Read more >
6.2 The Indifference Curve – Principles of Microeconomics
An indifference curve maps the consumption bundles that the consumer views ... Let's assume instead that José likes T-shirts twice as much as...
Read more >
Basketball Violations - Rookie Road
Double Dribble: Dribbling the ball before picking it up and dribbling again. Eight-Second Violation (Backcourt Violation): The offense fails to cross half-court ...
Read more >
Multiple Coupons in a Basket
Products aren't discounted multiple times, and exclusivity rules remain the same. There is one exception: product promotions of type With Amount of Qualifying ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found