Post by ct1000 » Fri Jan 23, 2015 4:46 am

Greetings,

I just downloaded and installed 2.0.1.1. I have been testing the coupon and voucher features and have run into some issues. When using coupons and vouchers to check out, they work fine. However, coupon and voucher history never get recorded upon checkout. I tried invoicing the order and marking it shipped, but this didn't do anything either. I tried COD and bank transfer payment methods.

This means that a customer can keep using the same coupon (even if it is marked 1 use only) and the same voucher over and over again. That will certainly be bad for business. I searched the forums and found several reports of coupon history not working in 1.5.*. No results yet in the 2.0 board.

Any suggestions? Am I missing something? Any help would be greatly appreciated.

Thanks in advance!

Chris

Newbie

Posts

Joined
Fri Jan 23, 2015 4:40 am

Post by tpalella » Sat Jan 24, 2015 2:19 am

Same question here.

i don't actually even see a voucher history link.

is there a way for customer to see the balance? i don't see any extensions yet either.

thank you

Newbie

Posts

Joined
Mon Dec 29, 2014 12:11 pm

Post by etl » Sun Apr 19, 2015 9:36 pm

Hello,

Has anyone had any luck with this problem? I am experiencing the same - on a clean install of 2.0.2.0 coupons can be used multiple times, even when set to 1 use per customer.


eg - Create a single use coupon of type 'fixed amount'
Add a product with value $100, and then apply a coupon with value $100
The coupon is applied at cart, and balance is zero, and order is registered as pending.
The OC admin shows no log of the coupon use, only that the order is pending and the sale total in zero.

I have tested this with guest checkout and registered users - the coupon cab be used multiple times.

Thanks,
Marty

etl
Newbie

Posts

Joined
Sun Apr 19, 2015 9:18 pm

Post by etl » Tue Apr 28, 2015 3:32 pm

It was my mistake - coupons are working as expected in 2.0.1.1

As stated in System > Settings > Store > Options > Checkout : The 'Processing Order Status' defines when the coupon is applied.

I had expected coupons to be applied when the customer enters the coupon data, but by default they are applied when the order status is updated to 'Processing'.

Thanks,
Marty

etl
Newbie

Posts

Joined
Sun Apr 19, 2015 9:18 pm

Post by Qphoria » Tue Oct 27, 2015 3:13 am

I'm still unsure about this working correctly.

It works correctly if your payment order status is set to one of the "Processing" or "Completed" statuses at the time of checkout. So if I have the actual order status of "Processing" checked and then set my payment order status = "Processing" then the coupon is redeemed.

But if I set the payment status = to "Pending" or some other order status not checked in the Processing or Completed areas during checkout, the confirm function does not get called... which is fine. But if I then goto the admin area and change the status to "Processing".. I see nothing in place to call model_coupon_confirm() function or any attempt at inserting into coupon_history table. So the coupon never gets redeemed. This means the customer can reuse the coupon over and over if he was supposed to have a limit.

Test this:
1. Set the Processing and completed statuses to processing and completed respectively.
2. Set Cash on Delivery order status = Pending
3. Set a coupon for single use per customer
4. Checkout with the coupon and use COD to pay
5. Check the coupon history, you'll see it has none.
6. Set the order to "Processing" from the admin and check the coupon history again. It is STILL blank
7. Now try to checkout again with that coupon. It should still work since it didn't find an existing coupon in the history
This time, be sure COD is set to "processing" Now when you checkout, the coupon history should be updated immediately
8. Next time you try to use that coupon, it will disallow it which is correct now that there is a coupon history.

So the issue is that there needs to be a call to the "confirm" function of all order totals when the admin updates the status to one of the config settings for processing or completed.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by alber99 » Sun Nov 22, 2015 12:34 am

same problem here in 2.0.3.1, anyone find a solution?

A related problem, the voucher recipient is supposed to receive an email which is not happening. There is a fix mentioned here at https://github.com/opencart/opencart/issues/3093 but not sure how to find/apply the fix (short of upgrade to 2.1).

Thoughts anyone?

New member

Posts

Joined
Sun Apr 08, 2012 9:14 am

Post by mutluh » Fri Oct 13, 2017 6:22 pm

I think the problem is in /catalog/model/total/coupon.php

Code: Select all

		if ($code) {
			$coupon_info = $this->getCoupon($code);

			if ($coupon_info) {
				$this->db->query("INSERT INTO `" . DB_PREFIX . "coupon_history` SET coupon_id = '" . (int)$coupon_info['coupon_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', customer_id = '" . (int)$order_info['customer_id'] . "', amount = '" . (float)$order_total['value'] . "', date_added = NOW()");
			} else {
				return $this->config->get('config_fraud_status_id');
			}
		}
When $coupon_info calls the function getCoupon it returns nothing, as the function also has other variables from the cart, and the cart is emptied while the system checks for payment confirmation. However, in the confirm function we don't need any of these variables, but coupon_id only. Thus, to correct the problem, i created another function called getCouponInfo to call coupon_id. As i am new to PHP and coding it might not be the best solution but it worked for me. I inserted the code as below.

Code: Select all

	public function getCouponInfo($code) {
		$status = true;

		$coupon_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "coupon` WHERE code = '" . $this->db->escape($code) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND status = '1'");

		if ($status) {
			return array(
				'coupon_id'     => $coupon_query->row['coupon_id'],
			);
		}
	}
	public function confirm($order_info, $order_total) {
		$code = '';

		$start = strpos($order_total['title'], '(') + 1;
		$end = strrpos($order_total['title'], ')');

		if ($start && $end) {
			$code = substr($order_total['title'], $start, $end - $start);
		}

		if ($code) {
			$coupon_info = $this->getCouponInfo($code);

			if ($coupon_info) {
				$this->db->query("INSERT INTO `" . DB_PREFIX . "coupon_history` SET coupon_id = '" . (int)$coupon_info['coupon_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', customer_id = '" . (int)$order_info['customer_id'] . "', amount = '" . (float)$order_total['value'] . "', date_added = NOW()");
			} else {
				return $this->config->get('config_fraud_status_id');
			}
		}
	}

To simplify, i changed getCoupon to getCouponInfo, and added the getCouponInfo function. Hope it will solve some people's problem, as it took me days to find the problem :D

Newbie

Posts

Joined
Fri Oct 13, 2017 6:06 pm
Who is online

Users browsing this forum: No registered users and 9 guests