In /admin/orders.php there is a section of "case" statements in the first several hundred lines. Put the following directly above the "case: deleteconfirm" line: case 'push_gv_credit': if (isset($_POST['push_gv_amount'])) { $oID = zen_db_prepare_input($_POST['oID']); $amount = abs(preg_replace('/[^0-9.]/', '', $_POST['push_gv_amount'])); if ($amount <= 0 || (int)$oID == 0) break; $custinfo = $db->Execute("select customers_id, customers_email_address, customers_name from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'"); if ($custinfo->RecordCount() == 0) break; $customers_id = $custinfo->fields['customers_id']; $result = $db->Execute("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . (int)$customers_id . "'"); if ($result->RecordCount() > 0) { $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = amount + '" . $amount . "' where customer_id = '" . (int)$customers_id . "'"); } else { $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$customers_id . "', '" . $amount . "')"); } $custinfo = $db->Execute("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'"); $subject = 'Credit applied to your account'; $message = ''; $message .= "Please note that a Gift Voucher credit has been applied to your account in the amount of " . $currencies->format($amount) . ".\n\n"; $message .= "You can apply it to any future purchases during checkout.\n\nWe appreciate your business and look forward to serving your needs in the future."; $html_msg['EMAIL_MESSAGE_HTML'] = $message; $html_msg['EMAIL_FIRST_NAME'] = $custinfo->fields['customers_firstname']; $html_msg['EMAIL_LAST_NAME'] = $custinfo->fields['customers_lastname']; $message .= "\n\n\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n"; zen_mail($custinfo->fields['customers_firstname'] . ' ' . $custinfo->fields['customers_lastname'], $custinfo->fields['customers_email_address'], $subject , $message, STORE_NAME, EMAIL_FROM, $html_msg, 'push_gv_credit'); $messageStack->add_session('GV amount of ' . $amount . ' applied to customer account: ' . $custinfo->fields['customers_firstname'] . ' ' . $custinfo->fields['customers_lastname'], 'success'); zen_redirect(zen_href_link(FILENAME_ORDERS, 'oID=' . (int)$oID . '&page=' . $_GET['page'], 'NONSSL')); } break;and then near the bottom of the file is a "default:" statement. Put this bit of code above the line shown:```
[B] $contents[] = array('text' => zen_draw_form('push_gv_credit', FILENAME_ORDERS, 'action=push_gv_credit&page=' . $_GET['page'], 'post', 'enctype="multipart/form-data"'));
$contents[] = array('text' => '<br>Give GV credit: <br>' . zen_draw_input_field('push_gv_amount') . zen_draw_hidden_field('oID', $oInfo->orders_id) . '</form>');
[/B] $contents[] = array('text' => '<br />' . TEXT_DATE_ORDER_CREATED . ' ' . zen_date_short($oInfo->date_purchased));
If you wanted to do it in the /admin/customers.php file instead, it would look like the following. Same placement idea applies. A good spot for this one is above "case: update":```
case 'push_gv_credit':
if (isset($_POST['push_gv_amount']))
{
$amount = abs(preg_replace('/[^0-9.]/', '', $_POST['push_gv_amount']));
if ($amount <= 0) break;
$result = $db->Execute("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . (int)$customers_id . "'");
if ($result->RecordCount() > 0) {
$db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = amount + '" . $amount . "' where customer_id = '" . (int)$customers_id . "'");
} else {
$db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int)$customers_id . "', '" . $amount . "')");
}
$custinfo = $db->Execute("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
$subject = 'Credit applied to your account';
$message = '';
$message .= "Please note that a Gift Voucher credit has been applied to your account in the amount of " . $currencies->format($amount) . ".\n\n";
$message .= "You can apply it to any future purchases during checkout.\n\nWe appreciate your business and look forward to serving your needs in the future.";
$html_msg['EMAIL_MESSAGE_HTML'] = $message;
$html_msg['EMAIL_FIRST_NAME'] = $custinfo->fields['customers_firstname'];
$html_msg['EMAIL_LAST_NAME'] = $custinfo->fields['customers_lastname'];
$message .= "\n\n\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
zen_mail($custinfo->fields['customers_firstname'] . ' ' . $custinfo->fields['customers_lastname'], $custinfo->fields['customers_email_address'], $subject , $message, STORE_NAME, EMAIL_FROM, $html_msg, 'push_gv_credit');
$messageStack->add_session('GV amount of ' . $amount . ' applied to customer account: ' . $custinfo->fields['customers_firstname'] . ' ' . $custinfo->fields['customers_lastname'], 'success');
zen_redirect(zen_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers_id . '&page=' . $_GET['page'], 'NONSSL'));
}
break;
```And at the bottom:```
$contents[] = array('text' => '<br />' . TEXT_INFO_GV_AMOUNT . ' ' . $currencies->format($customer_gv_balance));
$contents[] = array('text' => zen_draw_form('push_gv_credit', FILENAME_CUSTOMERS, 'action=push_gv_credit&page=' . $_GET['page'], 'post', 'enctype="multipart/form-data"'));
$contents[] = array('text' => '<br>Give GV credit: <br>' . zen_draw_input_field('push_gv_amount') . zen_draw_hidden_field('cID', $cInfo->customers_id) . '</form>');
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.