VM deletes coupons after an order - coupons get lost on cancelled/pending status

Started by lindapowers, November 12, 2013, 12:44:44 PM

Previous topic - Next topic

lindapowers

Hi

VM 2.024a and Joomla 2.5.16

Real example from our live shop=

1 -A customer makes an order applying a gift coupon with a total discount.

2 -The customer chooses to pay via credit card or paypal, the order remains pending or gets cancelled due to incorrect digits entered or any other reason.

3 -VM understands the coupon is used and deleted, so the customer has lost his coupon without making use of it.

4 -You manually as shop admin have to restore the coupon, basicly by creating a new one.

-----------------------------------------

This bug has existed in VM for years, seems no one though about it.

Stan from Rupostel's one page checkout luckily solved this issue from his component adding a feature that makes sure that gift coupons are not deleted until a certain state is reach.

A simple logic that solves the problem:

Do not delete VM coupons until order reaches this status= confirmed, pending, order cancelled etc= a dropdown box where you select the status.

------------------------------------------

Please consider solving this from the core VM as is Virtuemart the one deleting the coupons after the order is done independently of the order status, IMO a big mistake.

Regards

Milbo

It is wrong the other way.

When I go in a shop and use a coupont, the coupon is gone,.. when I do refund, I may get another coupon. From my point of view it is absolutly correct that a coupon is gone in the moment you have it in the cart and press "confirm checkout".

In your case, someone can checkout more than once with ONE coupon.
When you set the first order on confirmed,... the invoice of the others must be blocked and set to cancelled. Stan logic is imho clearly hackable.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

lindapowers

Quote from: Milbo on November 15, 2013, 09:59:48 AM
It is wrong the other way.

When I go in a shop and use a coupont, the coupon is gone,.. when I do refund, I may get another coupon. From my point of view it is absolutly correct that a coupon is gone in the moment you have it in the cart and press "confirm checkout".

In your case, someone can checkout more than once with ONE coupon.
When you set the first order on confirmed,... the invoice of the others must be blocked and set to cancelled. Stan logic is imho clearly hackable.

So from your point of view is normal that a customer that checkouts and makes a failed order (pending or cancelled) looses his coupon?

With Stan's logic the coupon is used (deleted) when an order is confirmed or any other selectable status, why should customers loose coupons on pending or cancelled orders?

How can you hack that if the coupon is deleted after a succesfull checkout?


Yes they can checkout several times with ONE coupon until the order is confirmed and therefore the coupon is really used.

The actual logic of VM makes us admins have to manually re-create coupons when customers fail to checkout succesfully when using a coupon.

A refund again is a manual process where admins will have to set that status to restore the coupon so you are loosing orders there due to customers not being able to use their coupons anymore since VM deletes them always, independently of the order status.

Don't know what is the best solution but I don't think that loosing coupons on pending or cancelled orders makes much sense no?

Regards

stAn99

Hello friends, just to clear this out and share the code for the change needed, let me write here how i overrode the VM behavior on deleting the coupons before checking if the payment went through (got confirmed).

within a system plugin (or you can do this within appropriate vm plugin section) you can do this:

// when this function returns true, the gift coupon will never get deleted:
public function plgVmRemoveCoupon($_code, $_force)
{
   if (empty($_force))
    {
   include(JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'config'.DS.'onepage.cfg.php');
   if (!empty($do_not_allow_gift_deletion)) return true;
}
return null;
}




// if the order status changes into a specific status (confirmed or other perconfiguration), remove the coupon:
public function plgVmOnUpdateOrderPayment(&$data,$old_order_status)
{

  require_once(JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'helpers'.DS.'plugin.php');
  OPCplugin::checkGiftCoupon($data, $old_order_status); 
 
 
}


The code above is just for an illustration of the triggerers.

Best Regards,
Stan
----
RuposTel.com
www.rupostel.com
Your customized checkout solution for Virtuemart

lindapowers

Thanks Stan for the code and the feature in OPC.

Ill cry one last time for this one, I can't believe people are loosing coupons in pending or cancelled orders and no one cried for it before.

Now coupons are deleted on confirmed status (when they are actually used).

This was a real pain of customers calling, telling us to please restore their coupon cause they chose the wrong payment or cause they entered incorrect digits in their credit card or just cause they couldn't complete an order and their coupon was gone already.

-----------------------------
We are happy with OPC handling this feature but please consider it as a VM2 fix for the future cause a coupon can't be lost when is not used, it makes no sense at all and I have not seen any e-commerce solution that deletes coupons for customers ignoring the order status.

We were supposed to tell our customers that they lost the coupon cause they failed to complete an order? can't be that way Max.

Regards