django-oscar / django-oscar-api

RESTful JSON API for django-oscar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Voucher discount is applied to every single product in the basket

kevinrenskers opened this issue · comments

I'm running into a weird situation:

  1. I've made a new Offer, set the type to Voucher Offer, which applies to all products. It gives a $25 discount and I set "Max Affected Items" to 1.
  2. I created a new Voucher Set, and made it generate a bunch of voucher codes.

Now, when I add multiple items to my basket, that $25 discount is applied to every single item. This is the basket object I get back from BasketList:

[
  {
    "id": 18702320,
    "owner": "http://localhost:8000/api/users/252094/",
    "status": "Open",
    "lines_url": "http://localhost:8000/api/baskets/18702320/lines/",
    "lines": [
      {
        "url": "http://localhost:8000/api/baskets/18702320/lines/3818082/",
        "product_id": 48,
        "product": "http://localhost:8000/api/products/48/",
        "quantity": 1,
        "attributes": [],
        "price_currency": "USD",
        "price_excl_tax": "374.00",
        "price_incl_tax": "374.00",
        "price_incl_tax_excl_discounts": "399.00",
        "price_excl_tax_excl_discounts": "399.00",
        "is_tax_known": true,
        "warning": null,
        "basket": "http://localhost:8000/api/baskets/18702320/",
        "stockrecord": "http://localhost:8000/api/products/48/stockrecords/46/",
        "date_created": "2023-08-07T14:44:35.202632Z",
        "date_updated": "2023-08-07T14:48:31.285793Z"
      },
      {
        "url": "http://localhost:8000/api/baskets/18702320/lines/3818131/",
        "product_id": 6,
        "product": "http://localhost:8000/api/products/6/",
        "quantity": 1,
        "attributes": [],
        "price_currency": "USD",
        "price_excl_tax": "124.00",
        "price_incl_tax": "124.00",
        "price_incl_tax_excl_discounts": "149.00",
        "price_excl_tax_excl_discounts": "149.00",
        "is_tax_known": true,
        "warning": null,
        "basket": "http://localhost:8000/api/baskets/18702320/",
        "stockrecord": "http://localhost:8000/api/products/6/stockrecords/2/",
        "date_created": "2023-08-07T14:48:33.957707Z",
        "date_updated": "2023-08-07T14:48:33.957713Z"
      }
    ],
    "url": "http://localhost:8000/api/baskets/18702320/",
    "total_excl_tax": "498.00",
    "total_excl_tax_excl_discounts": "548.00",
    "total_incl_tax": "498.00",
    "total_incl_tax_excl_discounts": "548.00",
    "total_tax": "0.00",
    "currency": "USD",
    "voucher_discounts": [
      {
        "description": null,
        "name": "$25 coupon",
        "amount": "50.00",
        "voucher": {
          "name": "Voucher Set - 300",
          "code": "2D8N-KFP3-ZXU5",
          "start_datetime": "2023-08-01T12:15:00Z",
          "end_datetime": "2023-12-31T14:15:00Z"
        }
      }
    ],
    "offer_discounts": [],
    "is_tax_known": true
  }
]

So you can see that a discount of $50 is applied to the basket, even though it shouldn't:

Screenshot 2023-08-07 at 17 12 52