Jump to content

POF email to admin with confirmation


peterp
 Share

Recommended Posts

Hi All,

       I have a client that has the admin parameter that determines when the emails of confirmation are sent and it is set to processing this all works as expected , however what they would like to happen for POF sales which sets the status of their orders to pending and are always paid by Bank Transfer the next day, which is ok but admin/accounts doesn't get an email that alerts the staff that there is an order wih a pending status which would hve been paid by Bank Transfer. What they would like to happen is to be notified that there are pending orders that have been created via the POF payment gateway.

Is there a way that I could change the POF payment gateway to produce an email that informs the staff that an order has been placed and has a pending status  and they should be looking for the associated bank transfer in their banking statement. The email could be the same as the email that is sent when the pending orders status is changed to processing. Could I try placing the code for this process just after the email that is sent to the customer thanking them for the order but only for pending status POF orders.

I will greatly appreciate any help with this issue

Thankyou and best Regards,

Peterp

Link to comment
Share on other sites

The POF does not actually set the order to Pending. CubeCart does that itself. The POF makes no attempt to change that.

In admin, Store Settings, Features tab, Misc section, "Order status for admin email notifications" can be set to Pending.

But this is not what you want.

You want specifically to have the POF send an email to the admin.

Try:

Near the end of the POF gateway.class.php file, find:

$GLOBALS['cart']->clear();

On a blank line ABOVE that, add:

$POF_Admin_Mailer = new Mailer();
$POF_Admin_Content = $POF_Admin_Mailer->loadContent('admin.order_received');
$order->assignOrderDetails(null, true);
$POF_Admin_Mailer->sendEmail($GLOBALS['config']->get('config', 'email_address'), $POF_Admin_Content);

I have yet to try this, so please report back.

Link to comment
Share on other sites

Hi Brian,

               Thankyou for this piece of code, I implemented it into the POF payment gateway and also the BANK_Transfer gateway that we created recently and it sent an email stating that and order had been received but unfortunately there was not data inserted into any of the fields. So you could not see the order number or the address or the paid by information. So where do we get this information (see Below)

Zippy Tie Man Order Received

ABN: 16505977418

just placed order number on .

 Paid By:

----------------------------------------------------------------------

Customer Comments:

----------------------------------------------------------------------

This order can be managed online by following the link below.

Billing address:








Email:
Shipping address:




 
Item Quantity Cost
  Shipping:  
  Discount:  
  Subtotal:  
  Order Total:  

Kind regards,

The Zippy Tie Man Staff

I have put the code on the blank line above the  line you suggested please see below I hope I have put it in the correct place

                        $order_summary['link']         = $GLOBALS['storeURL'].'/index.php?_a=vieworder&cart_order_id='.$order_summary['cart_order_id'];
                        $GLOBALS['smarty']->assign('DATA', $order_summary);
                        $GLOBALS['smarty']->assign('BILLING', $billing);
                        $GLOBALS['smarty']->assign('SHIPPING', $shipping);
                        $GLOBALS['smarty']->assign('TAXES', $vars['taxes']);
                        $GLOBALS['smarty']->assign('PRODUCTS', $vars['products']);
                        Mailer::getInstance()->sendEmail($order_summary['email'], $content);
                }
                
            }

$POF_Admin_Mailer = new Mailer();
$POF_Admin_Content = $POF_Admin_Mailer->loadContent('admin.order_received');
$order->assignOrderDetails(null, true);
$POF_Admin_Mailer->sendEmail($GLOBALS['config']->get('config', 'email_address'), $POF_Admin_Content);

            $GLOBALS['cart']->clear();
        }
    }

    public function process() {
        return false;
    }

    ##################################################

    public function form() {
        return false;
    }
}

Thanks again Brian appreciate your help

Best Regards,

Peterp

Link to comment
Share on other sites

In the POF file gateway.class.php:

Find:

public function call() {

Then find the closing brace for that function. It is just above:

public function process() {

You will be replacing the entire function call() with the following:

	public function call() {
		//@todo everything
		$form_file	= dirname(__FILE__).CC_DS.'skin';

		$GLOBALS['gui']->changeTemplateDir(dirname(__FILE__).CC_DS.'skin'.CC_DS);

		$GLOBALS['smarty']->assign('MODULE', $this->_module);

		$order = Order::getInstance();
		$cart_order_id = sanitizeVar($_GET['cart_order_id']);
		$order_summary = $order->getSummary($cart_order_id);

		if ($order_summary) {

			$transData['trans_id'] = null;
			$transData['notes'] = 'Print order form displayed to customer with payment instructions. Do not dispatch until postal payment has been received and cleared.';
			$transData['gateway'] = 'Print Order Form';
			$transData['order_id'] = $order_summary['cart_order_id'];
			$transData['amount'] = $order_summary['total'];
			$transData['status'] = 'Pending';
			$transData['customer_id'] = $order_summary['customer_id'];
			$order->logTransaction($transData);

			// Get the Inventory
			if (($inventory = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $order_summary['cart_order_id']))) !== false) {
				foreach ($inventory as $item) {
					if (!empty($item['product_options'])) {
						if (($list = unserialize($item['product_options'])) !== false) {
							foreach ($list as $value) {
								$item['options'][] = $value;
							}
						} else {
							$options = explode("\n", $item['product_options']);
							foreach ($options as $option) {
								$value	= trim($option);
								if (empty($value)) continue;
								$item['options'][] = $value;
							}
						}
					}
					$item['price_total'] = $GLOBALS['tax']->priceFormat(($item['price'] * $item['quantity']), true);
					$item['price'] = $GLOBALS['tax']->priceFormat($item['price']);
					$smarty_data['items'][] = $item;
				}
			}

			// Get the Taxes
			if(($taxes= $GLOBALS['db']->select('CubeCart_order_tax', false, array('cart_order_id' => $order_summary['cart_order_id']))) !== false) {
				Tax::getInstance()->loadTaxes($order_summary['country']);
				foreach ($taxes as $vat) {
					$detail = Tax::getInstance()->fetchTaxDetails($vat['tax_id']);
					$smarty_data['taxes'][] = array('value' => $GLOBALS['tax']->priceFormat($vat['amount']), 'tax_amount' => $GLOBALS['tax']->priceFormat($vat['amount']), 'name' => $detail['name'], 'tax_name' => $detail['name'], 'tax_percent' => sprintf('%.3F',$detail['tax_percent']));
				}
			}

			$order_summary['percent'] = '';
			if ($order_summary['discount_type'] == 'p') {
				$order_summary['percent'] = number_format(($order_summary['discount']/$order_summary['subtotal'])*100) . '%';
			}

			// Format the Prices
			$format = array('discount','shipping','subtotal','total_tax','total');
			foreach ($format as $field) {
				if (isset($order_summary[$field])) $order_summary[$field] = $GLOBALS['tax']->priceFormat($order_summary[$field]);
			}

			// Format the Invoice Address
			$elements = array('title', 'first_name', 'last_name', 'company_name', 'line1', 'line2', 'town', 'state', 'postcode', 'country', 'phone', 'email');
			foreach ($elements as $key) {
				if (isset($order_summary[$key]) && !empty($order_summary[$key])) {
					if ($key == 'country') $order_summary[$key] = getCountryFormat($order_summary[$key]);
					if ($key == 'state') $order_summary[$key] = getStateFormat($order_summary[$key]);
					$address_i[$key] = strip_tags($order_summary[$key]);
				}
			}

			// Format the Delivery Address
			$elements = array('title_d', 'first_name_d', 'last_name_d', 'company_name_d', 'line1_d', 'line2_d', 'town_d', 'state_d', 'postcode_d', 'country_d');
			foreach ($elements as $key) {
				if (isset($order_summary[$key]) && !empty($order_summary[$key])) {
					if ($key == 'country_d') $order_summary[$key] = getCountryFormat($order_summary[$key]);
					if ($key == 'state_d') $order_summary[$key] = getStateFormat($order_summary[$key]);
					$address_d[str_replace('_d','',$key)] = strip_tags($order_summary[$key]);
				}
			}

			// Format the Store Logo
			if (isset($this->_config['skin_style']) && !empty($this->_config['skin_style'])) {
				$skin_logo = $this->_config['skin_folder'].'-'.$this->_config['skin_style'];
			} else {
				$skin_logo = $this->_config['skin_folder'];
			}
			$store_logo = $GLOBALS['gui']->getLogo(true, 'invoices');

			// Format the Store Address
			$store_address = array(
				'address' => $GLOBALS['config']->get('config', 'store_address'),
				'county' => getStateFormat($this->_config['store_zone']),
				'country' => getCountryFormat($this->_config['store_country']),
				'postcode' => $GLOBALS['config']->get('config', 'store_postcode'),
				'url' => CC_STORE_URL,
				'name' => $GLOBALS['config']->get('config', 'store_name'),
			);

			$order_summary['link'] = $GLOBALS['storeURL'].'/index.php?_a=vieworder&cart_order_id='.$order_summary['cart_order_id'];
			$order_summary['order_date'] = formatTime($order_summary['order_date'],false,true);
			$order_summary['gateway'] = str_replace('_', ' ', $order_summary['gateway']);

			$GLOBALS['smarty']->assign('STORE', $store_address);
			$GLOBALS['smarty']->assign('SUM', $order_summary);
			$order_summary['link'] = $GLOBALS['storeURL'].'/'.$GLOBALS['config']->get('config', 'adminFile').'?_g=orders&action=edit&order_id='.$order_id;
			$GLOBALS['smarty']->assign('DATA', $order_summary);
			$GLOBALS['smarty']->assign('ITEMS', $smarty_data['items']);
			$GLOBALS['smarty']->assign('PRODUCTS', $smarty_data['items']);
			$GLOBALS['smarty']->assign('TAXES', $smarty_data['taxes']);
			$GLOBALS['smarty']->assign('STORE_LOGO', $store_logo);
			$GLOBALS['smarty']->assign('ADDRESS_INVOICE', $address_i);
			$GLOBALS['smarty']->assign('BILLING', $address_i);
			$GLOBALS['smarty']->assign('ADDRESS_DELIVERY', $address_d);
			$GLOBALS['smarty']->assign('SHIPPING', $address_d);
			$GLOBALS['smarty']->assign('ORDER_DATE', formatTime($order_summary['order_date'],false,true));
			$GLOBALS['smarty']->assign('VAL_ORDER_DATE',formatTime($order_summary['order_date']));

			// Payment Methods
			if ($this->_module['cheque']) $GLOBALS['smarty']->assign('CHEQUE', true); // I know, I know us stupid brits spell it the right way?! :)

			if ($this->_module['card']) {
				$cards = explode(',',$this->_module['cards']);
				if (is_array($cards)) {
					$GLOBALS['smarty']->assign('CARDS', $cards);
				}
			}
			if ($this->_module['bank']) {
				$GLOBALS['smarty']->assign('BANK', true);
			}

			$GLOBALS['smarty']->display('print.tpl');

			if ($this->_module['confirmation_email'] && ($content = Mailer::getInstance()->loadContent('cart.order_confirmation', $order_summary['lang']))) {
			// Send the Order Confirmation email to the customer
				Mailer::getInstance()->sendEmail($order_summary['email'], $content);
			}
$POF_Admin_Mailer = new Mailer();
$POF_Admin_Content = $POF_Admin_Mailer->loadContent('admin.order_received');
//$order->getOrderDetails($cart_order_id);
//$order->assignOrderDetails(null, true);
$POF_Admin_Mailer_Send_Result = $POF_Admin_Mailer->sendEmail($GLOBALS['config']->get('config', 'email_address'), $POF_Admin_Content);
			$GLOBALS['cart']->clear();
		}
	}

Recall that the POF does not move the order to Processing. Also recall that if the admin's settings is to receive notices when orders go to Processing, there will be no notice sent to the admin when an order is made using the POF.

The above new version of this function coalesces all the data regarding the order into one step and assigns that data to the respective major Smarty variables used by each of the POF printable template, the courtesy email that the POF sent to the customer, and now the email sent to the admin.

Note: if you do decide to set the admin's settings to receive notices when orders go to Pending, then this hack may cause a duplicate email sent.

Link to comment
Share on other sites

Hi Brian,

           Thanks for this solution, the client is aware that the POF gateway does not set the status to 'Processing' and is aware that with this modification they will simple get an email stating that there has been an POF order placed and they will have to go to admin to change the status to 'Processing' to get the order. Currently the client has the admin settings set to receive notices when orders have a status of 'Processing' this is unlikely to change.

I haven't implemented this code as yet as I'm on the road and it won't be until Friday my time before I will be able to implement it

Thanks again for your help

Best Regards,

Peterp

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...