Hi there :-)
How can I disable the standard VM order confirmation email from being send? We do not need it anymore because we have a 3'th party system sending out very nice emails for us.
I don't want to hack in the core of VirtueMart as suggested in many threads. I just like to improve the payment method file (we are using QuickPay) so it does not send standard VM order confirmations emails anymore.
Here is the callback-code from QuickPay:
function plgVmOnPaymentNotification() {
if (!class_exists('VirtueMartModelOrders')) {
require (JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php');
}
$callbackDataGet = JRequest::get('get');
$requestBody = file_get_contents("php://input");
$request = json_decode($requestBody);
$operation = end($request->operations);
$order_number=$request->order_id;
$virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
return null; // Another method was selected, do nothing
}
// Remove prefix from ordernumber
$prefix = $method->prefix;
if ($prefix && preg_match('/' . $prefix . '/', $order_number)) {
$order_number = str_replace($prefix, '', $order_number);
}
$order_number = intval($order_number);
$virtuemart_order_id = $order_number;
if (!$virtuemart_order_id) {
return;
}
$vendorId = 0;
$payment = $this->getDataByOrderId($virtuemart_order_id);
$method = $this->getVmPluginMethod($payment->virtuemart_paymentmethod_id);
if (!$this->selectedThisElement($method->payment_element)) {
return false;
}
if (!$payment) {
$this->logInfo('getDataByOrderId payment not found: exit ', 'ERROR');
return null;
}
$this->logInfo('quickpay callback data ' . implode(' ', $request), 'message');
// get all know columns of the table
$db = JFactory::getDBO();
$query = 'SHOW COLUMNS FROM `' . $this->_tablename . '` ';
$db->setQuery($query);
$columns = $db->loadResultArray(0);
$post_msg = '';
$response_fields="";
$response_fields['quickpay_qpstatmsg']=$operation->qp_status_msg;
$response_fields['quickpay_qpstat']=$operation->qp_status_code;
$response_fields['quickpay_time']=$operation->created_at;
$response_fields['quickpay_chstat']=$operation->aq_status_code;
$response_fields['quickpay_chstatmsg']=$operation->aq_status_msg;
$response_fields['quickpay_chstatmsg']=$operation->aq_status_msg;
$response_fields['payment_name'] = $this->renderPluginName($method);
$return_context = $callbackDataGet['sessionid'];
$response_fields['order_number'] = $order_number;
$response_fields['virtuemart_order_id'] = $virtuemart_order_id;
$response_fields['virtuemart_paymentmethod_id'] = $payment->virtuemart_paymentmethod_id;
$this->storePSPluginInternalData($response_fields, 'virtuemart_order_id', true);
if ($request->accepted && $operation->qp_status_code=="20000") {
$new_status = $method->status_success;
$this->logInfo('process OK, status', 'message');
} else {
$this->logInfo('process ERROR', 'ERROR');
$new_status = $method->status_canceled;
}
$this->logInfo('plgVmOnPaymentNotification return new_status:' . $new_status, 'message');
$this->logInfo('plgVmOnPaymentNotification session:', $return_context);
// Update any payment fee
if (isset($operation->fee)) {
$quickPayFee = (float)($operation->fee) / (float)100.0;
$db = JFactory::getDBO();
$query = "update #__virtuemart_orders SET order_payment=" . $quickPayFee . ",order_total = order_total+$quickPayFee WHERE virtuemart_order_id=" . $virtuemart_order_id . " AND order_payment = 0";
$db->setQuery($query);
$db->query();
}
$modelOrder = VmModel::getModel('orders');
$order = array();
$order['order_status'] = $new_status;
$order['customer_notified'] = 1;
$modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order, true);
$this->logInfo('Notification, sentOrderConfirmedEmail ' . $order_number . ' ' . $new_status, 'message'); //// remove vmcart
$this->emptyCart($return_context);
}
What to disable?
You mention no versions -- but in all later VM3 versions there is extensive configuration choices as to when or if emails are sent
VM3
You control which emails to be sent in the configs
Virtuemart - Configuration tab - Configuration - Checkout Tab - "Standard ordrestatus for at sende email til kunde"