p.s. I have also noticed, after coupon been used, the "Coupon History" menu, is still blank.
Works correctly when using Cash on Delivery as the payment method, but has exactly the same problem when using Paypal.
During the past few weeks, there has been several coupons used. If you went to each order individually you can see the coupon used, however, the coupon_history table only has 1 item.
In your catalog/model/checkout/coupon.php file,
find:
Code: Select all
public function redeem($coupon_id, $order_id, $customer_id, $amount) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "coupon_history` SET coupon_id = '" . (int)$coupon_id . "', order_id = '" . (int)$order_id . "', customer_id = '" . (int)$customer_id . "', amount = '" . (float)$amount . "', date_added = NOW()");
}
Code: Select all
public function redeem($coupon_id, $order_id, $customer_id, $amount) {
$sql = "INSERT INTO " . DB_PREFIX . "coupon_history
(coupon_id, order_id, customer_id, amount, date_added)
VALUES(" . (int)$coupon_id . ", " . (int)$order_id . ", " . (int)$customer_id . ", " . (float)$amount . ", NOW())
";
$this->db->query($sql);
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I tested your code above and it works when using free checkout(store credit) but not with a real payment using PayPal.
Thanks for your help!
While using Paypal for instance, what is your payment status right now ?ddowdall wrote:Hi, Do you see any reason why this would not work when the person makes the payment with paypal standard?
I tested your code above and it works when using free checkout(store credit) but not with a real payment using PayPal.
Thanks for your help!
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Let me create a new configuration key for you and once published it would be great to tell me if it does update accordingly on the next testing order from Paypal Standard.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
find:
Code: Select all
if (isset($this->request->post['pp_standard_voided_status_id'])) {
$this->data['pp_standard_voided_status_id'] = $this->request->post['pp_standard_voided_status_id'];
} else {
$this->data['pp_standard_voided_status_id'] = $this->config->get('pp_standard_voided_status_id');
}
Code: Select all
if (isset($this->request->post['pp_standard_shipped_status_id'])) {
$this->data['pp_standard_shipped_status_id'] = $this->request->post['pp_standard_shipped_status_id'];
} else {
$this->data['pp_standard_shipped_status_id'] = $this->config->get('pp_standard_shipped_status_id');
}
Code: Select all
$this->data['entry_voided_status'] = $this->language->get('entry_voided_status');
Code: Select all
$this->data['entry_shipped_status'] = $this->language->get('entry_shipped_status');
find:
Code: Select all
$_['entry_voided_status'] = 'Voided Status:';
Code: Select all
$_['entry_shipped_status'] = 'Shipped Status:';
find:
Code: Select all
case 'Voided':
$order_status_id = $this->config->get('pp_standard_voided_status_id');
break;
Code: Select all
case 'Shipped':
$order_status_id = $this->config->get('pp_standard_shipped_status_id');
break;
find:
Code: Select all
<tr>
<td><?php echo $entry_voided_status; ?></td>
<td><select name="pp_standard_voided_status_id">
<?php foreach ($order_statuses as $order_status) { ?>
<?php if ($order_status['order_status_id'] == $pp_standard_voided_status_id) { ?>
<option value="<?php echo $order_status['order_status_id']; ?>" selected="selected"><?php echo $order_status['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $order_status['order_status_id']; ?>"><?php echo $order_status['name']; ?></option>
<?php } ?>
<?php } ?>
</select></td>
</tr>
Code: Select all
<tr>
<td><?php echo $entry_shipped_status; ?></td>
<td><select name="pp_standard_shipped_status_id">
<?php foreach ($order_statuses as $order_status) { ?>
<?php if ($order_status['order_status_id'] == $pp_standard_shipped_status_id) { ?>
<option value="<?php echo $order_status['order_status_id']; ?>" selected="selected"><?php echo $order_status['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $order_status['order_status_id']; ?>"><?php echo $order_status['name']; ?></option>
<?php } ?>
<?php } ?>
</select></td>
</tr>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I tried to add "Payment Received" to the catalog/controller/payment/pp_standard switch case using the same code as the "Complete" case
I even tried to put the redeem function back to the original code.
Then, go to catalog/model/checkout/order.php file,
find twice:
Code: Select all
// Send out any gift voucher mails
if ($this->config->get('config_complete_status_id') == $order_status_id) {
$this->load->model('checkout/voucher');
$this->model_checkout_voucher->confirm($order_id);
}
Code: Select all
// Send out any gift voucher mails
if ($this->config->get('config_complete_status_id') == $order_status_id) {
$this->load->model('checkout/voucher');
$this->model_checkout_voucher->confirm($order_id);
$this->load->model('checkout/coupon');
$this->model_checkout_coupon->confirm($order_id);
}
Find:
Code: Select all
public function redeem($voucher_id, $order_id, $amount) {
Code: Select all
public function confirm($order_id) {
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$this->load->model('localisation/language');
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/coupon');
$coupon_query = $this->db->query("SELECT *, cp.product_id AS coupon_product_id FROM `" . DB_PREFIX . "coupon` c INNER JOIN " . DB_PREFIX . "coupon_history ch ON (ch.coupon_id = c.coupon_id) LEFT JOIN " . DB_PREFIX . "coupon_product cp ON (cp.coupon_id = ch.coupon_id) WHERE ch.order_id = '" . (int)$order_id . "'");
$this->load->model('catalog/product');
foreach ($coupon_query->rows as $coupon) {
$product_info = $this->model_catalog_product->getProduct($coupon['coupon_product_id']);
// HTML Mail
$template = new Template();
$template->data['title'] = sprintf($language->get('text_subject'), $coupon['name']);
$template->data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($coupon['total'], $order_info['currency_code'], $order_info['currency_value']));
$template->data['text_from'] = sprintf($language->get('text_from'), $order_info['store_name']);
$template->data['text_message'] = $language->get('text_message');
$template->data['text_redeem'] = sprintf($language->get('text_redeem'), $coupon['code']);
$template->data['text_footer'] = $language->get('text_footer');
$template->data['store_name'] = $order_info['store_name'];
$template->data['store_url'] = $order_info['store_url'];
$template->data['message'] = (isset($product_info) && !empty($product_info)) ? $product_info['name'] : '';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/coupon.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/coupon.tpl');
} else {
$html = $template->fetch('default/template/mail/coupon.tpl');
}
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($coupon['to_email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject(sprintf($language->get('text_subject'), $order_info['store_name']));
$mail->setHtml($html);
$mail->send();
}
}
}
Then, in your catalog/language/english/mail folder, create a new file named: coupon.php .
Then, add the following:
Code: Select all
<?php
// Text
$_['text_subject'] = 'You have received a %s coupon';
$_['text_greeting'] = 'Congratulations, You have received a discount worth %s';
$_['text_from'] = 'This coupon has been sent to you by %s';
$_['text_message'] = 'With a message saying';
$_['text_redeem'] = 'To redeem this coupon, write down the redemption code which is <b>%s</b> then click on the the link below and purchase the product you wish to use this coupon on. You can enter the coupon code on the shopping cart page before you click checkout.';
$_['text_footer'] = 'Please reply to this email if you have any questions.';
?>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
coupon history doesn't show either, as well as coupon limitation..! pls help thanks!angelaho wrote:how about for open cart 1.53?
coupon limitation doesn't work, and when i've used ur script, the whole site went down and error displayed.. pls help! thanks!
Users browsing this forum: Amazon [Bot] and 35 guests