// Create Notification Object
$Notifications = new GlmNotifications( $this->wpdb, $this->config );
- echo '<pre>$type: ' . print_r( $type, true ) . '</pre>';
-
// Trigger sending the email notifications for send by action 'payment received'
switch ( $type ) {
case $this->config['transaction_numb']['Invoice']:
case $this->config['transaction_numb']['Payment']:
+ $data = array(
+ 'type' => $type,
+ 'type_id' => $type_id,
+ 'account' => $account,
+ 'amount' => $current_invoice_total,
+ 'payment' => $current_payment_total,
+ );
$notices = $Notifications->getNotificationsWithSendByAction( $type );
- echo '<pre>$notices: ' . print_r( $notices, true ) . '</pre>';
foreach ( $notices as $notice ) {
- $Notifications->sendEmailNotification( $notice['id'], $account );
+ $Notifications->sendEmailNotification( $notice['id'], $account, $data );
}
break;
default:
* @access public
* @return void
*/
- public function sendEmailNotification( $notification_id, $account_id )
+ public function sendEmailNotification( $notification_id, $account_id, $data = null )
{
// Support Class
$BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
// If there's no account then return false.
return false;
}
- // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
- // exit;
$to_email = $account['email'];
- // echo '<pre>$to_email: ' . print_r( $to_email, true ) . '</pre>';
if ( !$to_email ) {
// If there's no email then return false.
return false;
}
// get the Notification type
- // var_dump( $notification_id );
$notification_type = $this->getNotificationTypeById( $notification_id );
- // echo '<pre>$notification_type: ' . print_r( $notification_type, true ) . '</pre>';
if ( !$notification_type ) {
// If there's no notification type then return false.
return false;
'phone' => $account['billing_phone'],
)
);
- // echo '<pre>$notification_type[message]: ' . print_r( $notification_type['message'], true ) . '</pre>';
+ // Merge any data passed into this method
+ $account_data['data'] = $data;
$notification_message = $this->parseSmartyTemplateString(
$account_data,
wpautop( $notification_type['message'] )
);
- // echo '<pre>$account_data: ' . print_r( $account_data, true ) . '</pre>';
- // echo '<pre>$notification_message: ' . print_r( $notification_message, true ) . '</pre>';
- // exit;
$smarty->templateAssign( 'title', $notification_type['subject'] );
$smarty->templateAssign( 'html_content', $notification_message );
// Add data from model to Smarty template
if ( is_array( $data ) && count( $data ) > 0 ) {
foreach ( $data as $key => $value ) {
- echo '<pre>$key: ' . print_r( $key, true ) . '</pre>';
$smarty->templateAssign( $key, $value );
}
}
*
* Return array of notifications with send_by_action as $type
*
- * @param mixed $type Type of send_by_action ('Create Invoice', 'Payment Received')
+ * @param int $type Type of send_by_action (10 => 'Create Invoice', 20 => 'Payment Received')
*
* @access public
* @return array
$this->wpdb->prepare(
"SELECT id
FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "notification_types
- WHERE send_by_action
+ WHERE send_by_action <> false
AND send_action = %d",
- $this->config['send_action'][$type]
+ $type
),
ARRAY_A
);