Page 1 of 1

Gift Voucher Email Sent Prior to Payment

Posted: Sat Sep 29, 2018 6:54 pm
by arslankhaan
Hi,
I trust everybody is doing fine. I am satisfied whenever I contacted, someone must replied me generously. I am yet testing my site and I am having a problem with opencart version 3.0.2.0. Gift Voucher code is being sent through email prior to payment. Whenever I purchse a gift voucher through an account and send it to second account, an email is sent to second account with gift voucher code with second code being able to apply the voucher code, although payment has not been made by purchasing account. It should not happen. Gift Voucher Code should only be sent through email when purchasing account has made the payment. I have searched all through but to no result. Perhaps my searchmay be poor. Please any idea? I would be greatly thankful for any help. :)

Regards
arslan

Re: Gift Voucher Email Sent Prior to Payment

Posted: Sun Oct 07, 2018 2:17 am
by straightlight
Currently, only orders are being focused when creating a voucher during checkout or when using the API. To enforce customer accounts,

in catalog/model/extension/total/voucher.php file,

find:

Code: Select all

$order_query = $this->db->query("SELECT order_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$voucher_query->row['order_id'] . "' AND order_status_id IN(" . implode(",", $implode) . ")");
replace with:

Code: Select all

$order_query = $this->db->query("SELECT order_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$voucher_query->row['order_id'] . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND order_status_id IN(" . implode(",", $implode) . ")");