View Issue Details

IDProjectCategoryView StatusLast Update
0006562OXID eShop (all versions)1.02. Price calculations (discounts, coupons, additional costs etc.)public2018-07-13 14:08
Reportermksschroeder 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version4.10.0 / 5.3.0 
Target VersionFixed in Version 
Summary0006562: Wrong Voucher Calculation - session basket mixing
DescriptionThis bug has been already reported, but has been closed as not reproducable(https://bugs.oxid-esales.com/print_bug_page.php?bug_id=6213)

It only appears if the voucher calculation is set on percentual and categories or articles are assigned to it.

I could solve the problem by passing the basket object to the oxvoucher model before calculating the voucherdiscount.

I added a function setRealBasket($oBasket) in oxvoucher to set the basket.

In oxbasket::_calcVoucherDiscount() i set the basket before calling $oVoucher->getDiscountValue($dPrice)

In oxvoucher->_getSessionBasketItems() i use this basket for calculation.
TagsNo tags attached.
ThemeAll
BrowserAll
PHP Version5.6
MySQL VersionNot defined

Relationships

duplicate of 0006854 acknowledgedbenjamin.joerger Wrong voucher calculation - discount sharing between user's baskets 

Activities

mksschroeder

2016-12-08 17:10

reporter   ~0011894

Last edited: 2016-12-08 18:32

View 3 revisions

Update: Problem is not solved by passing the basket object to oxvoucher.
We still have orders with the applied discount of an previous order using the same voucher code.

Another series with percentage and assigned articles seems to be calculated correctly. (This series uses unique voucher codes)

QA

2016-12-09 10:16

administrator   ~0011895

Please provide Steps to Reproduce (hopefully with screenshots) to help us reproduce the issue and thereby analyse it.

mksschroeder

2016-12-09 10:49

reporter  

oxordervoucherexception.jpg (534,397 bytes)

mksschroeder

2016-12-09 10:58

reporter   ~0011896

Last edited: 2016-12-09 11:00

View 2 revisions

I uploaded a screenshots of the orders with the assigned voucher. The voucher was set to 5% for an assigned group of articles only. The voucher code is the same for the voucherseries. (no unique vouchercodes - this is important)

The red highlited parts are orders with the same voucherdiscount amount, but with wrong calculation for the newer one. - so it seems that the amount is taken by the older order/session ??

We stopped this promotion, because it caused too much trouble, so iam nnot able to produce the error in live situtation. we will try to reproduce this bug in dev and give feedback.

mksschroeder

2016-12-09 11:59

reporter  

voucherdebug.jpg (80,456 bytes)
voucherdebug.jpg (80,456 bytes)

mksschroeder

2016-12-09 12:00

reporter   ~0011897

Last edited: 2016-12-09 12:16

View 2 revisions

I´ve been able to reproduce it in stage env.

1. Create voucherseries with percentage discount
(OXALLOWSAMESERIES=0, OXALLOWOTHERSERIES=0, OXMINIMUMVALUE=0, OXCALCULATEONCE=0)
2. assign a bunch of articles to it
3. Create vouchers with a single voucher code (e.g. "08154711")
4. open several sessions signin with mutltiple accounts
5. use voucher code to buy articles (assigned to voucherseries)

in my case i left some session with voucher and didn´t finish those orders

As you can see in provided screenshot (voucherdebug.jpg) it took 5 orders till the calculation was wrong.

QA

2016-12-12 11:04

administrator   ~0011898

The issue is not reproducable from our end. Kindly try to reproduce the issue in our Reference sytem : http://demoshop.oxid-esales.com/professional-edition/

d3

2017-03-01 15:54

reporter   ~0011987

Last edited: 2017-03-01 16:05

View 2 revisions

This part is the same:
1. Create voucherseries with percentage discount
(OXALLOWSAMESERIES=0, OXALLOWOTHERSERIES=0, OXMINIMUMVALUE=0, OXCALCULATEONCE=0)
2. assign a bunch of articles to it
3. Create vouchers with a single voucher code (e.g. "08154711")


The session.gc_maxlifetime should be higher than standard iVoucherTimeout (oxvoucher::_getVoucherTimeout() standard 3*3600 seconds)

2 customers are necessary:
1. customer A assign voucher to basket -> oxreserved will be set on 3*3600 seconds = 3 hours -> Timestamp #1
2. customer A keeps the session alive for 3 or more hours.
3. customer B assigns the same voucher code to the basket 3 hours after {Timestamp #1}.
   As a result the same oxvouchers__oxid will be assigned -> Timestamp #2
4. customer B finishes the order process (oxorderid, oxuserid and oxdiscount will set!)
5. customer A refreshes the basket after {Timestamp #2} (in step 1 ala cart :D ) and get the oxvouchers__oxdiscount from customer B's order.
5. customer A fineshes the order process and saves the discount value from the already used voucher

Hint #1: this is not reproducable in demoshop.oxid-esales.com because of the hourly reset
Hint #2: set the oxreserved field in oxvouchers at the oxvoucher from customer A to a lower value or wait 3 hours ;).

KH


edit:
possible solution in oxvoucher::checkBasketVoucherAvailability():
      if("0000-00-00" != $this->oxvouchers__oxdateused->value || false == empty($this->oxvouchers__oxorderid->oxvalue)) {
            $oEx = oxNew( 'oxVoucherException' );
            $oEx->setMessage('Do not use expired vouchers');
            $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
            throw $oEx;
        }