Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order creates an outstanding amount when using single use discount #55

Open
danaenz opened this issue Apr 20, 2017 · 11 comments
Open

Order creates an outstanding amount when using single use discount #55

danaenz opened this issue Apr 20, 2017 · 11 comments

Comments

@danaenz
Copy link

danaenz commented Apr 20, 2017

Silvershop Discounts dev-master
SS version 3.3

  1. Create a few single use Coupons, which use a percentage (eg 99%) and apply to the whole order.
  2. Open an incognito window
  3. Make an order and apply a single use discount. This order will go through fine
  4. In the same session, create a new order, using a new single use coupon. The order will appear to not apply the discount and have the full amount as the remaining to pay. The correct discounted amount goes through to the payment gateway (eg DPS) but the order does not get marked as Paid.

I've run into this issue consistently across SilverStripe, SilverShop and Discount versions. It has been notoriously hard to replicate, but the above should work.

screen shot 2017-04-20 at 4 27 30 pm

@danaenz
Copy link
Author

danaenz commented Apr 20, 2017

Interestingly, the Receipt notification does not display this problem.

screen shot 2017-04-20 at 4 29 12 pm

@danaenz
Copy link
Author

danaenz commented Jul 5, 2017

This is still a serious issue and we have been unable to find the cause despite many developer hours.

@wilr
Copy link
Contributor

wilr commented Jul 5, 2017

@danaenz So this is for a single use coupon used twice or 2 different single use coupons? Can you replicate on a clean checkout of the latest releases.

@christopherbolt
Copy link
Contributor

Does this issue occur if you use a different gateway, perhaps just test with the dummy gateway and confirm. If the issue only happens when using DPS as your gateway then it may be caused by the same issue described here (unresolved). Because DPS notifies the site that the payment went through in the background (not part of the user session) any order data in session or requiring session isn't available which affects discounts.
silvershop/silvershop-core#705

@danaenz
Copy link
Author

danaenz commented Jan 31, 2019

@christopherbolt this would definitely explain it! We haven't been able to replicate the issue on local test environments reliably. It would explain a lot, actually. I'll keep looking into it.

@beeonlinenz
Copy link

@danaenz did you ever make any progress with a fix for this?
I have a client with the same issue, i.e. DPS payments are still showing an 'outstanding' amount for discounted orders.

@danaenz
Copy link
Author

danaenz commented Jun 12, 2019

Sorry @beeonlinenz , no progress yet. I'm actually working more with SwipeStripe now so haven't had the chance to try and solve this.

@christopherbolt
Copy link
Contributor

Please see my related bug report where I have posted a solution to this issue: silvershop/silvershop-core#705

@wernerkrauss
Copy link
Contributor

I had this issue on a project with unlimited discounts. The problem is, that the order is calculated somehow, but not saved to DB with multistep checkout.

I changed the setCoupon method to:

    public function setcoupon($data, $form)
    {
        $this->checkoutconfig()->setData($form->getData());

        $order = $this->checkoutconfig()->getOrder();
        $order->calculate();
        if ($order->isChanged()) {
            $order->write();
        }

       return $this->owner->redirect($this->NextStepLink());
    }

This seems to fix the error.

@wilr
Copy link
Contributor

wilr commented Jul 20, 2020

@wernerkrauss Did you want to send this as a PR?

@alex-dna
Copy link

alex-dna commented Nov 25, 2020

I've used the onPayment hook to update the final order:

public function onPayment()
{
        $subtotal = $this->owner->Total();
        $total = $this->owner->calculate();
        $discounted = $total < $subtotal;

        if ($discounted === true) {
            $this->owner->setTotal($total);
            $this->owner->write();
        }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants