Post by Nawid » Fri Jul 15, 2016 2:13 am

Hi,

I am using OC version 2.1.0.2
All customers can use succesfully a Coupon Code, it works just fine.
But I cannot change order history in admin area for people who used a coupon code.
It doesn't matter what status I give in admin area, it goes automatically to Canceled.

How is this possible? No problems with orders without the use of coupon code.
Last edited by Nawid on Fri Jul 15, 2016 2:22 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Fri Aug 19, 2011 6:47 am

Post by Nawid » Fri Jul 15, 2016 2:21 am

Problem solved, I followed this:
https://github.com/opencart/opencart/is ... -174047947
qphoria wrote:
I think this is a problem actually. Basically if a coupon is used already, it triggers the "fraud order id", even if it is being edited from the admin side. It is a side effect of how the admin order edit uses the api to login and apply the changes as if it is doing it from the front end.

It is caused by this code in catalog/model/total/coupon.php:

Code: Select all

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');
}
Which is because you are trying to catch people hacking coupons. At the very least, this should be ignored when editing the order from the admin, otherwise admins can't change the order history because the coupon is trying to be reconfirmed after it already has been.

Quick fix, Just remove the else portion of that.
A more proper fix would be to add something to the session that shows that the order is being placed from the admin. It looks like there is already a temp_session_xxx variable created when logging in, but since that uses a unique id, you'd have to iterate over the session variable to see if it exists. Perhaps a simple flat variable like $this->session->data['is_admin'] = 1

User avatar
New member

Posts

Joined
Fri Aug 19, 2011 6:47 am
Who is online

Users browsing this forum: No registered users and 39 guests