KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: impiastro on September 14, 2010, 09:39:21 am

Title: coupon "times used" not updated
Post by: impiastro on September 14, 2010, 09:39:21 am
Hi everyone, have you ever experienced this issue?

I'm collecting the coupon code during the checkout process.
I set the collected coupon code using the order.setCouponCode() before saving the order (using the method saveOrder()) and I can see the order discount is applied correctly and the order is saved in the orders table with the correct coupon_ids but the value of times_used is not decremented.
It says always 0 times used (both from konakartadmin app and from coupon table).

Should I decrement the coupon "times used" field manually?

I'm using KK version 4.1.0.0.

Thanks for your precious time,

ROb
Title: Re: coupon "times used" not updated
Post by: trevor on September 14, 2010, 01:41:08 pm
The times_used field gets decremented once the order has been paid for and not when it is saved.

The API call which triggers it is updateInventory().
Title: Re: coupon "times used" not updated
Post by: impiastro on September 14, 2010, 01:53:07 pm
Thank you Trevor, but what about a order of final price 0 when the coupon is applied?

For example: final order total 100, coupon value 100, final price 0.

The order will not be paid by customer because its price is 0.

Another question, when updateInventory() API is called? During the order change status to payed?

ROb
Title: Re: coupon "times used" not updated
Post by: trevor on September 14, 2010, 02:19:06 pm
If you look at the action classes like AuthorizeNet.java you'll see that it gets called when the payment is approved. However you can call it from anywhere to suit your business needs.
Title: Re: coupon "times used" not updated
Post by: impiastro on September 14, 2010, 02:34:17 pm
OK, perfect.

But in this way it's possible to generate 4 orders with the same coupon id (even if it can used only once), receiving also the coupon discount, and pay all of them later.

In this scenario will the updateInventory function give an error during coupon times used decrement or not?

Don't you think it could be more safe to decrement the times used field after order creation?

ROb
Title: Re: coupon "times used" not updated
Post by: trevor on September 14, 2010, 02:39:47 pm
Once the coupon has been used once and the times_used attribute is incremented by calling updateInventory(), then it will no longer activate the promotion in other orders.
Title: Re: coupon "times used" not updated
Post by: impiastro on September 14, 2010, 02:47:41 pm
OK, Trevor.

Thank you for your attention!

ROb

Title: Re: coupon "times used" not updated
Post by: impiastro on September 16, 2010, 09:00:49 am
Just an update.

The function updateInventory() after order creation works as expected.
The coupon "times used" was correctly decremented.

We have choosen to update coupon usage number just after order confirmation and not after order payment.

Thanks to Trevor and all KK Community.