Commit f4b73b3e authored by Varun Sridharan's avatar Varun Sridharan

Version 1.3.6.1

* Fixed donation order delete, restore issue
* Added Processing & Completed Email Templates
* Minor Bug Fix
parent e41eddd2
...@@ -35,6 +35,7 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -35,6 +35,7 @@ class WooCommerce_Quick_Donation_Admin {
public function load_required_files(){ public function load_required_files(){
WC_QD()->load_files(WC_QD_ADMIN.'metabox_framework/meta-box.php'); WC_QD()->load_files(WC_QD_ADMIN.'metabox_framework/meta-box.php');
WC_QD()->load_files(WC_QD_ADMIN.'wp-donation-listing-table.php');
} }
public function init_hooks(){ public function init_hooks(){
...@@ -52,36 +53,42 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -52,36 +53,42 @@ class WooCommerce_Quick_Donation_Admin {
} }
public function admin_screen(){ public function admin_screen(){
if($this->sys_info == $this->current_screen()){ if($this->sys_info == $this->current_screen()){
if(!WC_QD()->is_request('ajax')){ if(!WC_QD()->is_request('ajax')){
$this->add_notice(); $this->add_notice();
} }
} }
if($this->order_menu_slug == $this->current_screen()){
$donor_listing = new WC_Quick_Donation_Listing_Table;
$donor_listing->process_bulk_action();
}
} }
public function sub_donation_order_menu(){ public function sub_donation_order_menu(){
$this->order_menu_slug = add_submenu_page('edit.php?post_type=wcqd_project', $this->order_menu_slug = add_submenu_page('edit.php?post_type='.WC_QD_PT,
__('Donation Orders',WC_QD_TXT), __('Donation Orders',WC_QD_TXT),
__('Donation\'s',WC_QD_TXT), __('Donation\'s',WC_QD_TXT),
'administrator', 'administrator',
'wc_qd_orders', 'wc_qd_orders',
array($this,'donation_orders_page')); array($this,'donation_orders_page'));
$this->donors_list = add_submenu_page('edit.php?post_type=wcqd_project', $this->donors_list = add_submenu_page('edit.php?post_type='.WC_QD_PT,
__('Donors List',WC_QD_TXT), __('Donors List',WC_QD_TXT),
__('Donors List',WC_QD_TXT), __('Donors List',WC_QD_TXT),
'administrator', 'administrator',
'wc_qd_donors', 'wc_qd_donors',
array($this,'donors_listing_page')); array($this,'donors_listing_page'));
$this->sys_info = add_submenu_page('edit.php?post_type=wcqd_project', $this->sys_info = add_submenu_page('edit.php?post_type='.WC_QD_PT,
__('System Tools',WC_QD_TXT), __('System Tools',WC_QD_TXT),
__('System Tools',WC_QD_TXT), __('System Tools',WC_QD_TXT),
'administrator', 'administrator',
'wc_qd_sys_info', 'wc_qd_sys_info',
array($this,'system_tools')); array($this,'system_tools'));
$this->tools = add_submenu_page('edit.php?post_type=wcqd_project', $this->tools = add_submenu_page('edit.php?post_type='.WC_QD_PT,
__('',WC_QD_TXT), __('',WC_QD_TXT),
__('',WC_QD_TXT), __('',WC_QD_TXT),
'administrator', 'administrator',
...@@ -95,6 +102,8 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -95,6 +102,8 @@ class WooCommerce_Quick_Donation_Admin {
$name = 'edit.php?post_type='.WC_QD_PT; $name = 'edit.php?post_type='.WC_QD_PT;
if(empty($submenu)){return $submenu;} if(empty($submenu)){return $submenu;}
$arr = array(); $arr = array();
$submenu[$name][18][2] = $submenu[$name][5][2].'&page='.$submenu[$name][18][2];
$arr[] = $submenu[$name][18]; $arr[] = $submenu[$name][18];
$arr[] = $submenu[$name][19]; $arr[] = $submenu[$name][19];
$arr[] = $submenu[$name][5]; $arr[] = $submenu[$name][5];
...@@ -103,6 +112,7 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -103,6 +112,7 @@ class WooCommerce_Quick_Donation_Admin {
$arr[] = $submenu[$name][16]; $arr[] = $submenu[$name][16];
$arr[] = $submenu[$name][17]; $arr[] = $submenu[$name][17];
$arr[] = $submenu[$name][20]; $arr[] = $submenu[$name][20];
//var_dump($arr); exit;
$submenu[$name] = $arr; $submenu[$name] = $arr;
return $menu_ord; return $menu_ord;
} }
...@@ -183,7 +193,7 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -183,7 +193,7 @@ class WooCommerce_Quick_Donation_Admin {
} }
if(isset($_GET['post_status'])){ $args['post_status'] = $_GET['post_status'];} if(isset($_GET['post_status'])){ $args['post_status'] = $_GET['post_status'];}
$wp_query = new WP_Query($args); $wp_query = new WP_Query($args);
require('wp-donation-listing-table.php');
tt_render_list_page($wp_query); tt_render_list_page($wp_query);
} }
......
...@@ -7,6 +7,13 @@ ...@@ -7,6 +7,13 @@
* @since 3.1.0 * @since 3.1.0
* @access private * @access private
*/ */
/**
* Check that 'class-wp-list-table.php' is available
*/
if(!class_exists('WP_List_Table')) :
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
endif;
class WC_Quick_Donation_Listing_Table extends WP_List_Table { class WC_Quick_Donation_Listing_Table extends WP_List_Table {
/** /**
...@@ -70,17 +77,17 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -70,17 +77,17 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
* *
* @param array $args An associative array of arguments. * @param array $args An associative array of arguments.
*/ */
public function __construct( $query,$args = array() ) { public function __construct( $query = '',$args = array() ) {
if(!empty($query)){
global $post_type_object, $wpdb; global $post_type_object, $wpdb;
$this->querypost = $query; $this->querypost = $query;
set_current_screen( 'shop_order' ); $this->init();
}
parent::__construct( array( }
'plural' => 'Donations',
'screen' => get_current_screen(),
) );
public function init(){
set_current_screen( 'shop_order' );
parent::__construct( array('plural' => 'Donations','screen' => get_current_screen(),));
$this->screen->post_type = 'shop_order'; $this->screen->post_type = 'shop_order';
//$this->screen->id = 'shop_order'; //$this->screen->id = 'shop_order';
$post_type = $this->screen->post_type; $post_type = $this->screen->post_type;
...@@ -112,19 +119,31 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -112,19 +119,31 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
global $pagenow; global $pagenow;
if(!isset($_REQUEST['_wpnonce'])){return;} if(!isset($_REQUEST['_wpnonce'])){return;}
$nonce = esc_attr( $_REQUEST['_wpnonce'] ); $nonce = esc_attr( $_REQUEST['_wpnonce'] );
if ( ! wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ) { if ( ! wp_verify_nonce( $nonce, 'bulk-donations') ) {
die( 'Invalid Nonce' ); wp_die( __('Invalid Nonce for deleting WC Donation Orders', WC_QD_TXT));
} }
//check_admin_referer('bulk-posts');
$pagenum = $this->get_pagenum();
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
if ( ! $sendback )
$sendback = admin_url( $parent_file );
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( strpos($sendback, 'post.php') !== false )
$sendback = admin_url($post_new_file);
$post_ids = array_map('intval', $_REQUEST['post']); $post_ids = array_map('intval', $_REQUEST['post']);
$total_post = count($post_ids);
$ids = implode(', ',$post_ids);
$doaction = $this->current_action(); $doaction = $this->current_action();
$Notice_Txt = '';
switch ( $doaction ) { switch ( $doaction ) {
case 'trash': case 'trash':
$trashed = $locked = 0; $trashed = $locked = 0;
foreach( (array) $post_ids as $post_id ) { foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) ) if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.') ); wp_die( __('You are not allowed to move this item to the Trash.'));
if ( wp_check_post_lock( $post_id ) ) { if ( wp_check_post_lock( $post_id ) ) {
$locked++; $locked++;
...@@ -135,9 +154,19 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -135,9 +154,19 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
wp_die( __('Error in moving to Trash.') ); wp_die( __('Error in moving to Trash.') );
$trashed++; $trashed++;
$Notice_Txt = ' Trashed ';
} }
//$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback ); $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );
wc_qd_notice(
sprintf(
_n( '%s Donation Order Trashed ( %s )',
'%s Donation Orders Trashed ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,$ids
)
);
break; break;
case 'untrash': case 'untrash':
$untrashed = 0; $untrashed = 0;
...@@ -150,7 +179,17 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -150,7 +179,17 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
$untrashed++; $untrashed++;
} }
//$sendback = add_query_arg('untrashed', $untrashed, $sendback); $sendback = add_query_arg('untrashed', $untrashed, $sendback);
wc_qd_notice(
sprintf(
_n( '%s Donation Order restored from trash ( %s )',
'%s Donation Orders restored from trash ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,
$ids
)
);
break; break;
case 'delete': case 'delete':
$deleted = 0; $deleted = 0;
...@@ -170,6 +209,14 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -170,6 +209,14 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
$deleted++; $deleted++;
} }
$sendback = add_query_arg('deleted', $deleted, $sendback); $sendback = add_query_arg('deleted', $deleted, $sendback);
wc_qd_notice(
sprintf(
_n( '%s Donation Order permanently deleted ( %s )',
'%s Donation Orders permanently deleted ( %s )' , $total_post, $ids, WC_QD_TXT ),
$total_post,
$ids
)
);
break; break;
case 'edit': case 'edit':
if ( isset($_REQUEST['bulk_edit']) ) { if ( isset($_REQUEST['bulk_edit']) ) {
...@@ -184,10 +231,10 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -184,10 +231,10 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
} }
break; break;
} }
$redirect_url = menu_page_url('wc_qd_tools',false);
if(isset($_REQUEST['post_status']) && !empty($_REQUEST['post_status'])){$redirect_url .= '&post_status='.$_REQUEST['post_status'];} $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
wp_safe_redirect( admin_url() ); wp_redirect($sendback);
exit; exit();
} }
/** /**
...@@ -202,8 +249,6 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -202,8 +249,6 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
$avail_post_stati = wp_edit_posts_query(); $avail_post_stati = wp_edit_posts_query();
$this->process_bulk_action();
$this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $this->querypost->query['orderby'] ); $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $this->querypost->query['orderby'] );
$total_items = $this->hierarchical_display ? $this->querypost->post_count : $this->querypost->found_posts; $total_items = $this->hierarchical_display ? $this->querypost->post_count : $this->querypost->found_posts;
...@@ -318,6 +363,7 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -318,6 +363,7 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
$class = ' class="current"'; $class = ' class="current"';
$status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>'; $status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
$status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
$allposts = '&all_posts=1'; $allposts = '&all_posts=1';
$class = ''; $class = '';
} }
...@@ -444,7 +490,9 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -444,7 +490,9 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>'; echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
wp_dropdown_categories( $dropdown_options ); wp_dropdown_categories( $dropdown_options );
} }
if(! $this->is_trash){
$this->get_donation_projects(); $this->get_donation_projects();
}
/** /**
* Fires before the Filter button on the Posts and Pages list tables. * Fires before the Filter button on the Posts and Pages list tables.
* *
...@@ -1172,6 +1220,7 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -1172,6 +1220,7 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
} }
$post_type_object = get_post_type_object( $post->post_type ); $post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( 'edit_post', $post->ID ); $can_edit_post = current_user_can( 'edit_post', $post->ID );
$actions = array(); $actions = array();
......
...@@ -11,67 +11,105 @@ class WooCommerce_Quick_Donation_Emails_Functions { ...@@ -11,67 +11,105 @@ class WooCommerce_Quick_Donation_Emails_Functions {
function __construct(){ function __construct(){
add_action('woocommerce_order_status_on-hold',array($this,'check_order'),1); add_action('woocommerce_order_status_on-hold',array($this,'check_order'),1);
add_action('woocommerce_order_status_pending',array($this,'check_order'),1);
add_action('woocommerce_order_status_processing',array($this,'check_order'),1);
add_action('woocommerce_order_status_completed',array($this,'check_order'),1);
add_action('woocommerce_order_status_failed',array($this,'check_order'),1);
add_action( 'woocommerce_email',array($this,'remove_email_actions'),1); add_action( 'woocommerce_email',array($this,'remove_email_actions'),1);
// Triggers for this email
add_action( 'woocommerce_donation_email_header', array( $this, 'email_header' ) );
add_action( 'woocommerce_donation_email_footer', array( $this, 'email_footer' ) );
//add_filter( 'woocommerce_template_directory', array( $this, 'change_dir'),2,2);
} }
public function remove_email_actions($e){
if($this->remove_emails){
$this->remove_default_new_email($e);
$this->remove_default_processing_email($e);
// New order emails /**
add_action('woocommerce_order_status_pending_to_processing_notification', * Get the email header.
array($e->emails[WC_QD_DB.'new_donation_email'],'trigger')); *
add_action('woocommerce_order_status_pending_to_completed_notification', * @param mixed $email_heading heading for the email
array($e->emails[WC_QD_DB.'new_donation_email'],'trigger')); */
add_action('woocommerce_order_status_pending_to_on-hold_notification', public function email_header( $email_heading ) {
array($e->emails[WC_QD_DB.'new_donation_email'],'trigger')); wc_get_template( 'emails/donation-email-header.php', array( 'email_heading' => $email_heading ) );
} }
/**
* Get the email footer.
*/
public function email_footer() {
wc_get_template( 'emails/donation-email-footer.php');
} }
public function wca_onhold(){ public function change_dir($dir,$emailtemplate){
$template = WC_QD()->f()->get_template_list();
foreach($template as $temp){
if(in_array($emailtemplate,$temp)){
$dir = $dir.'/donation';
}
}
return $dir;
}
public function remove_email_actions($e){
if($this->remove_emails){
$this->remove_default_new_email($e->emails);
$this->remove_default_processing_email($e->emails);
$this->add_donation_new_email($e->emails);
$this->add_donation_processing_email($e->emails);
}
} }
public function check_order($order_id){ public function check_order($order_id){
if(!WC_QD()->db()->_is_donation($order_id)){return;} if(!WC_QD()->db()->_is_donation($order_id)){return;}
$this->remove_emails = true; $this->remove_emails = true;
$this->remove_status = 'onhold';
//exit;
} }
private function remove_default_processing_email($e){ private function remove_default_processing_email($email_class){
remove_action('woocommerce_order_status_pending_to_processing_notification', remove_action('woocommerce_order_status_pending_to_processing_notification',
array($e->emails['WC_Email_Customer_Processing_Order'],'trigger')); array( $email_class['WC_Email_Customer_Processing_Order'], 'trigger'));
remove_action('woocommerce_order_status_pending_to_on-hold_notification', remove_action('woocommerce_order_status_pending_to_on-hold_notification',
array($e->emails['WC_Email_Customer_Processing_Order'],'trigger')); array( $email_class['WC_Email_Customer_Processing_Order'], 'trigger'));
} }
private function remove_default_new_email($e){ private function remove_default_new_email($email_class){
remove_action( 'woocommerce_order_status_pending_to_processing_notification',
array($e->emails['WC_Email_New_Order'],'trigger'));
remove_action( 'woocommerce_order_status_pending_to_completed_notification',
array($e->emails['WC_Email_New_Order'],'trigger'));
remove_action( 'woocommerce_order_status_pending_to_on-hold_notification',
array($e->emails['WC_Email_New_Order'],'trigger'));
remove_action( 'woocommerce_order_status_failed_to_processing_notification',
array($e->emails['WC_Email_New_Order'],'trigger'));
remove_action( 'woocommerce_order_status_failed_to_completed_notification',
array($e->emails['WC_Email_New_Order'],'trigger'));
remove_action( 'woocommerce_order_status_failed_to_on-hold_notification',
array($e->emails['WC_Email_New_Order'],'trigger'));
remove_action('woocommerce_order_status_pending_to_processing_notification', remove_action('woocommerce_order_status_pending_to_processing_notification',
array($e->emails['WC_Email_New_Order'],'trigger')); array( $email_class['WC_Email_New_Order'],'trigger'));
remove_action('woocommerce_order_status_pending_to_completed_notification', remove_action('woocommerce_order_status_pending_to_completed_notification',
array($e->emails['WC_Email_New_Order'],'trigger')); array( $email_class['WC_Email_New_Order'],'trigger'));
remove_action('woocommerce_order_status_pending_to_on-hold_notification', remove_action('woocommerce_order_status_pending_to_on-hold_notification',
array($e->emails['WC_Email_New_Order'],'trigger')); array( $email_class['WC_Email_New_Order'],'trigger'));
remove_action('woocommerce_order_status_failed_to_processing_notification', remove_action('woocommerce_order_status_failed_to_processing_notification',
array($e->emails['WC_Email_New_Order'],'trigger')); array( $email_class['WC_Email_New_Order'],'trigger'));
remove_action('woocommerce_order_status_failed_to_completed_notification', remove_action('woocommerce_order_status_failed_to_completed_notification',
array($e->emails['WC_Email_New_Order'],'trigger')); array( $email_class['WC_Email_New_Order'],'trigger'));
remove_action('woocommerce_order_status_failed_to_on-hold_notification', remove_action('woocommerce_order_status_failed_to_on-hold_notification',
array($e->emails['WC_Email_New_Order'],'trigger')); array( $email_class['WC_Email_New_Order'],'trigger'));
}
private function add_donation_new_email($email_class){
add_action('woocommerce_order_status_pending_to_processing_notification',
array($email_class[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_pending_to_completed_notification',
array($email_class[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_pending_to_on-hold_notification',
array($email_class[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_failed_to_processing_notification',
array($email_class[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_failed_to_completed_notification',
array($email_class[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_failed_to_on-hold_notification',
array($email_class[WC_QD_DB.'new_donation_email'],'trigger'));
} }
private function add_donation_processing_email($email_class){
add_action('woocommerce_order_status_pending_to_processing_notification',
array($email_class[WC_QD_DB.'donation_processing_email'], 'trigger'));
add_action('woocommerce_order_status_pending_to_on-hold_notification',
array($email_class[WC_QD_DB.'donation_processing_email'], 'trigger'));
}
} }
...@@ -53,8 +53,10 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -53,8 +53,10 @@ class WooCommerce_Quick_Donation_Functions {
'emails/plain/email-addresses.php' => 'emails/plain/donation-email-addresses.php', 'emails/plain/email-addresses.php' => 'emails/plain/donation-email-addresses.php',
'emails/plain/email-order-items.php' => 'emails/plain/donation-email-order-items.php', 'emails/plain/email-order-items.php' => 'emails/plain/donation-email-order-items.php',
'emails/plain/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php', 'emails/plain/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php',
)
'emails/donation-processing.php' => 'emails/donation-processing.php',
'emails/plain/donation-processing.php' => 'emails/plain/donation-processing.php',
)
); );
...@@ -66,6 +68,10 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -66,6 +68,10 @@ class WooCommerce_Quick_Donation_Functions {
add_filter( 'the_title', array($this,'wc_page_endpoint_title' ),10,2); add_filter( 'the_title', array($this,'wc_page_endpoint_title' ),10,2);
} }
public function get_template_list(){
return self::$search_template;
}
public function wc_page_endpoint_title($title = '', $id = ''){ public function wc_page_endpoint_title($title = '', $id = ''){
if(is_page($id)){ if(is_page($id)){
...@@ -97,8 +103,8 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -97,8 +103,8 @@ class WooCommerce_Quick_Donation_Functions {
public function add_email_classes($email_classes){ public function add_email_classes($email_classes){
$email_classes[WC_QD_DB.'new_donation_email'] = require(WC_QD_INC.'emails/class-new-email.php'); $email_classes[WC_QD_DB.'new_donation_email'] = require(WC_QD_INC.'emails/class-new-email.php');
//$email_classes[WC_QD_DB.'processing_donation_email'] = require(WC_QD_INC.'emails/class-processing-email.php'); $email_classes[WC_QD_DB.'donation_processing_email'] = require(WC_QD_INC.'emails/class-processing-email.php');
//$email_classes[WC_QD_DB.'completed_donation_email'] = require(WC_QD_INC.'emails/class-completed-email.php'); $email_classes[WC_QD_DB.'donation_completed_email'] = require(WC_QD_INC.'emails/class-completed-email.php');
return $email_classes; return $email_classes;
} }
......
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_QD_donation_completed_email' ) ) :
/**
* Customer Completed Order Email
*
* Order complete emails are sent to the customer when the order is marked complete and usual indicates that the order has been shipped.
*
* @class WC_QD_donation_completed_email
* @version 2.0.0
* @package WooCommerce/Classes/Emails
* @author WooThemes
* @extends WC_Email
*/
class WC_QD_donation_completed_email extends WC_Email {
/**
* Constructor
*/
function __construct() {
$this->id = WC_QD_DB.'donation_completed_email';
$this->title = __( 'Completed Donation', WC_QD_TXT);
$this->description = __( 'Order complete emails are sent to customers when their orders are marked completed and usually indicate that their orders have been shipped.', 'woocommerce' );
$this->heading = __( 'Your Donation for {project_name} is complete', WC_QD_TXT);
$this->subject = __( 'Your {site_title} donation from {order_date} is complete', 'woocommerce' );
$this->template_html = 'emails/donation-completed.php';
$this->template_plain = 'emails/plain/donation-completed.php';
$this->template_base = WC_QD_TEMPLATE;
// Call parent constuctor
parent::__construct();
}
/**
* Trigger.
*/
function trigger( $order_id ) {
if ( $order_id ) {
$this->object = wc_get_order( $order_id );
$this->recipient = $this->object->billing_email;
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';
$this->find['donation-project-name'] = '{project_name}';
$order_id = $this->object->get_order_number();
$project_id = WC_QD()->db()->get_project_id($order_id);
$project_name = get_the_title($project_id);
$this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
$this->replace['order-number'] = $this->object->get_order_number();
$this->replace['donation-project-name'] = $project_name;
}
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
return;
}
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
/**
* get_subject function.
*
* @access public
* @return string
*/
function get_subject() {
if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) {
return $this->format_string( $this->subject_downloadable );
} else {
return $this->format_string( $this->subject );
}
}
/**
* get_heading function.
*
* @access public
* @return string
*/
function get_heading() {
if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) {
return $this->format_string( $this->heading_downloadable );
} else {
return $this->format_string( $this->heading );
}
}
/**
* get_content_html function.
*
* @access public
* @return string
*/
function get_content_html() {
ob_start();
wc_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => false
) );
return ob_get_clean();
}
/**
* Get content plain.
*
* @return string
*/
function get_content_plain() {
ob_start();
wc_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => true
) );
return ob_get_clean();
}
/**
* Initialise settings form fields.
*/
function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable this email notification', 'woocommerce' ),
'default' => 'yes'
),
'subject' => array(
'title' => __( 'Subject', 'woocommerce' ),
'type' => 'text',
'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject ),
'placeholder' => '',
'default' => ''
),
'heading' => array(
'title' => __( 'Email Heading', 'woocommerce' ),
'type' => 'text',
'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading ),
'placeholder' => '',
'default' => ''
),
'email_type' => array(
'title' => __( 'Email type', 'woocommerce' ),
'type' => 'select',
'description' => __( 'Choose which format of email to send.', 'woocommerce' ),
'default' => 'html',
'class' => 'email_type wc-enhanced-select',
'options' => $this->get_email_type_options()
)
);
}
}
endif;
return new WC_QD_donation_completed_email();
...@@ -48,8 +48,6 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -48,8 +48,6 @@ class WC_QD_Donation_New_Email extends WC_Email {
$this->subject_paid = $this->get_option( 'subject_paid', $this->subject_paid ); $this->subject_paid = $this->get_option( 'subject_paid', $this->subject_paid );
add_filter('woocommerce_template_directory',array($this,'change_dir'),2,1); add_filter('woocommerce_template_directory',array($this,'change_dir'),2,1);
add_action( 'woocommerce_donation_email_header', array( $this, 'email_header' ) );
add_action( 'woocommerce_donation_email_footer', array( $this, 'email_footer' ) );
} }
public function change_dir($dir){ public function change_dir($dir){
...@@ -59,21 +57,6 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -59,21 +57,6 @@ class WC_QD_Donation_New_Email extends WC_Email {
/**
* Get the email header.
*
* @param mixed $email_heading heading for the email
*/
public function email_header( $email_heading ) {
wc_get_template( 'emails/donation-email-header.php', array( 'order' => $this->object, 'email_heading' => $email_heading ) );
}
/**
* Get the email footer.
*/
public function email_footer() {
wc_get_template( 'emails/donation-email-footer.php',array( 'order' => $this->object) );
}
/** /**
* Trigger. * Trigger.
*/ */
......
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_QD_Processing_donation' ) ) :
/**
* Customer Processing Order Email
*
* An email sent to the customer when a new order is received/paid for.
*
* @class WC_QD_Processing_donation
* @version 2.0.0
* @package WooCommerce/Classes/Emails
* @author WooThemes
* @extends WC_Email
*/
class WC_QD_Processing_donation extends WC_Email {
/**
* Constructor
*/
function __construct() {
$this->id = WC_QD_DB.'donation_processing_email';
$this->title = __( 'Processing Donation',WC_QD_TXT);
$this->description = __( 'This is an order notification sent to customers containing their donation details after payment.', WC_QD_TXT);
$this->heading = __( 'Reg : Your {site_title} donation receipt from {order_date}', WC_QD_TXT);
$this->subject = __( 'Thanks for donation', 'woocommerce' );
$this->template_html = 'emails/donation-processing.php';
$this->template_plain = 'emails/plain/donation-processing.php';
$this->template_base = WC_QD_TEMPLATE;
// Call parent constructor
parent::__construct();
}
/**
* Trigger.
*/
function trigger( $order_id ) {
if ( $order_id ) {
$this->object = wc_get_order( $order_id );
$this->recipient = $this->object->billing_email;
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';
$this->find['donation-project-name'] = '{project_name}';
$order_id = $this->object->get_order_number();
$project_id = WC_QD()->db()->get_project_id($order_id);
$project_name = get_the_title($project_id);
$this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
$this->replace['order-number'] = $this->object->get_order_number();
$this->replace['donation-project-name'] = $project_name;
}
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
return;
}
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
/**
* get_content_html function.
*
* @access public
* @return string
*/
function get_content_html() {
ob_start();
wc_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => false
) );
return ob_get_clean();
}
/**
* get_content_plain function.
*
* @access public
* @return string
*/
function get_content_plain() {
ob_start();
wc_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => true
) );
return ob_get_clean();
}
}
endif;
return new WC_QD_Processing_donation();
<?php
/**
* Customer completed order email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php do_action( 'woocommerce_donation_email_header', $email_heading ); ?>
<p><?php printf( __( "Hi there. Your recent order on %s has been completed. Your order details are shown below for your reference:", 'woocommerce' ), get_option( 'blogname' ) ); ?></p>
<?php do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text ); ?>
<h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
<thead>
<tr>
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Product', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Price', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody>
<?php echo $order->email_order_items_table( true, false, true ); ?>
</tbody>
<tfoot>
<?php
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
?><tr>
<th class="td" scope="row" colspan="2" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>
</tfoot>
</table>
<?php do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>
<?php
/**
* Customer processing order email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php do_action('woocommerce_email_header', $email_heading); ?>
<p><?php _e( "Your donation has been received and is now being processed. Your donation details are shown below for your reference:", WC_QD_TXT ); ?></p>
<?php do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text ); ?>
<h2><?php printf( __( 'Donation #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
<thead>
<tr>
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Project', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Price', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody>
<?php echo $order->email_order_items_table( $order->is_download_permitted(), true, $order->has_status( 'processing' ) ); ?>
</tbody>
<tfoot>
<?php
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $subKey => $total ) {
$i++;
if($subKey == 'cart_subtotal' || $subKey == 'order_total'){continue;}
?><tr>
<th class="td" scope="row" colspan="2" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>
</tfoot>
</table>
<?php do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>
<?php
/**
* Customer completed order email (plain text)
*
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo "= " . $email_heading . " =\n\n";
echo sprintf( __( "Hi there. Your recent order on %s has been completed. Your order details are shown below for your reference:", 'woocommerce' ), get_option( 'blogname' ) ) . "\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( true, false, true, '', '', true );
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
echo $total['label'] . "\t " . $total['value'] . "\n";
}
}
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
<?php
/**
* Customer processing order email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo "= " . $email_heading . " =\n\n";
echo __( "Your order has been received and is now being processed. Your order details are shown below for your reference:", 'woocommerce' ) . "\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( $order->is_download_permitted(), true, $order->has_status( 'processing' ), '', '', true );
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
echo $total['label'] . "\t " . $total['value'] . "\n";
}
}
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment