Commit 205a3bbe authored by Varun Sridharan's avatar Varun Sridharan

New order Email & Donation Issue

Fixed issue when donation alredy exit in cart & redirect to checkout
custom donation processing template (new donation)
parent 3cbe7c0c
...@@ -12,6 +12,17 @@ $fields['settings_general']['general'][] = array( ...@@ -12,6 +12,17 @@ $fields['settings_general']['general'][] = array(
'attr' => array('class' => 'wc-enhanced-select','style' => 'width:auto;max-width:35%;') 'attr' => array('class' => 'wc-enhanced-select','style' => 'width:auto;max-width:35%;')
); );
/** General Settings **/
$fields['settings_general']['general'][] = array(
'id' => WC_QD_DB.'already_exist_redirect_user',
'type' => 'select',
'label' => __( 'Donation Exist Redirect', WC_QD_TXT),
'desc' => __( 'Redirect User When Donation Already Exist In Cart',WC_QD_TXT),
'size ' => 'small',
'options' => array('' => 'None', 'cart' => 'Cart Page' , 'checkout' => 'Checkout Page'),
'attr' => array('class' => 'wc-enhanced-select','style' => 'width:auto;max-width:35%;')
);
$fields['settings_general']['general'][] = array( $fields['settings_general']['general'][] = array(
'label' => __( 'Donation Payment Gateway', WC_QD_TXT), 'label' => __( 'Donation Payment Gateway', WC_QD_TXT),
'desc' => __( 'Select Payment gateway for users to pay for donation',WC_QD_TXT), 'desc' => __( 'Select Payment gateway for users to pay for donation',WC_QD_TXT),
...@@ -22,7 +33,6 @@ $fields['settings_general']['general'][] = array( ...@@ -22,7 +33,6 @@ $fields['settings_general']['general'][] = array(
'options' => WC_QD()->f()->get_admin_pay_gate() 'options' => WC_QD()->f()->get_admin_pay_gate()
); );
/** Message Settings **/ /** Message Settings **/
...@@ -37,6 +47,14 @@ $fields['settings_message']['message'][] = array( ...@@ -37,6 +47,14 @@ $fields['settings_message']['message'][] = array(
); );
$fields['settings_message']['message'][] = array(
'label' => __( 'Donation Conflict', WC_QD_TXT),
'desc' => __( 'Custom Message To Show When User Trying To Add Donation With Other Products',WC_QD_TXT),
'id' => WC_QD_DB.'donation_with_other_products',
'attr' => array('style' => 'min-width:35%; width:auto;max-width:75%;'),
'type' => 'textarea'
);
$fields['settings_message']['message'][] = array( $fields['settings_message']['message'][] = array(
'label' => __( 'Empty Donation Amount', WC_QD_TXT), 'label' => __( 'Empty Donation Amount', WC_QD_TXT),
'desc' => __( 'Custom Message To Show When Empty Donation Entered',WC_QD_TXT), 'desc' => __( 'Custom Message To Show When Empty Donation Entered',WC_QD_TXT),
...@@ -45,7 +63,6 @@ $fields['settings_message']['message'][] = array( ...@@ -45,7 +63,6 @@ $fields['settings_message']['message'][] = array(
'type' => 'textarea' 'type' => 'textarea'
); );
$fields['settings_message']['message'][] = array( $fields['settings_message']['message'][] = array(
'label' => __( 'Donation Already Exist', WC_QD_TXT), 'label' => __( 'Donation Already Exist', WC_QD_TXT),
'desc' => __( 'Custom Message To Show When User Trying To Add Another Donation To Cart',WC_QD_TXT), 'desc' => __( 'Custom Message To Show When User Trying To Add Another Donation To Cart',WC_QD_TXT),
......
...@@ -30,10 +30,7 @@ class WC_QD_INSTALL{ ...@@ -30,10 +30,7 @@ class WC_QD_INSTALL{
*/ */
public static function check_donation_exists(){ public static function check_donation_exists(){
$exist = get_option(WC_QD_DB.'product_id'); $exist = get_option(WC_QD_DB.'product_id');
if($exist && get_post_status ($exist)){ return true; }
if($exist && get_post_status ($exist)){
return true;
}
return false; return false;
} }
......
<?php
/**
* functionality of the plugin.
* @author Varun Sridharan <varunsridharan23@gmail.com>
*/
if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Emails_Functions {
public $remove_emails;
private $remove_status;
function __construct(){
add_action('woocommerce_order_status_on-hold',array($this,'check_order'),1);
add_action( 'woocommerce_email',array($this,'remove_email_actions'),1);
}
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',
array($e->emails[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_pending_to_completed_notification',
array($e->emails[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_pending_to_on-hold_notification',
array($e->emails[WC_QD_DB.'new_donation_email'],'trigger'));
}
}
public function wca_onhold(){
var_dump(4333);
}
public function check_order($order_id){
if(!WC_QD()->db()->_is_donation($order_id)){return;}
$this->remove_emails = true;
$this->remove_status = 'onhold';
//exit;
}
private function remove_default_processing_email($e){
remove_action('woocommerce_order_status_pending_to_processing_notification',
array($e->emails['WC_Email_Customer_Processing_Order'],'trigger'));
remove_action('woocommerce_order_status_pending_to_on-hold_notification',
array($e->emails['WC_Email_Customer_Processing_Order'],'trigger'));
}
private function remove_default_new_email($e){
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',
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'));
}
}
...@@ -13,9 +13,10 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -13,9 +13,10 @@ class WooCommerce_Quick_Donation_Functions {
'field-radio.php' => 'fields/field-radio.php', 'field-radio.php' => 'fields/field-radio.php',
'field-select.php' => 'fields/field-select.php', 'field-select.php' => 'fields/field-select.php',
'field-text.php' => 'fields/field-text.php', 'field-text.php' => 'fields/field-text.php',
'emails/donation-customer-invoice.php' => 'emails/donation-customer-invoice.php',
'emails/plaint/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php',
'myaccount/my-donations.php' => 'myaccount/my-donations.php', 'myaccount/my-donations.php' => 'myaccount/my-donations.php',
'emails/donation-customer-invoice.php' => 'emails/donation-customer-invoice.php',
'emails/plain/donation-customer-invoice.php' => 'emails/plain/donation-customer-invoice.php',
), ),
'is_donation' => array( 'is_donation' => array(
...@@ -43,6 +44,16 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -43,6 +44,16 @@ class WooCommerce_Quick_Donation_Functions {
'order/order-details-item.php' => 'order/order-details-item.php', 'order/order-details-item.php' => 'order/order-details-item.php',
'order/order-details-customer.php' => 'order/order-details-customer.php', 'order/order-details-customer.php' => 'order/order-details-customer.php',
'emails/email-addresses.php' => 'emails/donation-email-addresses.php',
'emails/email-footer.php' => 'emails/donation-email-footer.php',
'emails/email-header.php' => 'emails/donation-email-header.php',
'emails/email-order-items.php' => 'emails/donation-email-order-items.php',
'emails/email-styles.php' => 'emails/donation-email-styles.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',
) )
...@@ -56,6 +67,7 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -56,6 +67,7 @@ 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 wc_page_endpoint_title($title, $id){ public function wc_page_endpoint_title($title, $id){
if(is_page($id)){ if(is_page($id)){
global $wp_query; global $wp_query;
...@@ -207,6 +219,7 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -207,6 +219,7 @@ class WooCommerce_Quick_Donation_Functions {
} }
public function wc_locate_template($template_full_path,$template_name,$template_dir){ public function wc_locate_template($template_full_path,$template_name,$template_dir){
if(file_exists($template_full_path)){ return $template_full_path; } if(file_exists($template_full_path)){ return $template_full_path; }
$template_full_path = $template_full_path; $template_full_path = $template_full_path;
...@@ -260,22 +273,26 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -260,22 +273,26 @@ class WooCommerce_Quick_Donation_Functions {
public function get_template($located, $template_name, $args, $template_path, $default_path ){ public function get_template($located, $template_name, $args, $template_path, $default_path ){
$file = $located; $file = $located;
$order_id = 0; $order_id = 0;
if(isset($args['order_id'])){ $order_id = $args['order_id']; } if(isset($args['order_id'])){ $order_id = $args['order_id']; }
if(isset($args['order']->id)){ $order_id = $args['order']->id; } if(isset($args['order']->id)){ $order_id = $args['order']->id; }
if(isset(self::$search_template['general'][$template_name])){ if(isset(self::$search_template['general'][$template_name])){
$file = WC_QD()->f()->locate_template(self::$search_template['general'][$template_name]); $file = WC_QD()->f()->locate_template(self::$search_template['general'][$template_name]);
} else if(WC_QD()->check_donation_exists_cart()){ }
if(WC_QD()->check_donation_exists_cart()){
if(isset(self::$search_template['is_donation'][$template_name])){ if(isset(self::$search_template['is_donation'][$template_name])){
$file = WC_QD()->f()->locate_template(self::$search_template['is_donation'][$template_name]); $file = WC_QD()->f()->locate_template(self::$search_template['is_donation'][$template_name]);
} }
} else { }
if(WC_QD()->db()->_is_donation($order_id)){ if(WC_QD()->db()->_is_donation($order_id)){
if(isset(self::$search_template['after_order'][$template_name])){ if(isset(self::$search_template['after_order'][$template_name])){
$file = WC_QD()->f()->locate_template(self::$search_template['after_order'][$template_name]); $file = WC_QD()->f()->locate_template(self::$search_template['after_order'][$template_name]);
} }
} }
}
return $file; return $file;
} }
......
...@@ -21,7 +21,7 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -21,7 +21,7 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
add_action('woocommerce_add_order_item_meta',array($this,'add_order_meta'),99,3); add_action('woocommerce_add_order_item_meta',array($this,'add_order_meta'),99,3);
add_action( 'woocommerce_checkout_update_order_meta',array($this,'update_order_meta')); add_action( 'woocommerce_checkout_update_order_meta',array($this,'update_order_meta'));
add_action( 'woocommerce_checkout_update_order_meta', array($this,'save_order_id_db')); add_action( 'woocommerce_checkout_update_order_meta', array($this,'save_order_id_db'));
add_action( 'woocommerce_email',array($this,'remove_email_actions')); //add_action( 'woocommerce_email',array($this,'remove_email_actions'));
add_filter( 'wc_quick_donation_cart_project_name', array($this,'change_donation_name')); add_filter( 'wc_quick_donation_cart_project_name', array($this,'change_donation_name'));
} }
$this->process_donation(); $this->process_donation();
...@@ -65,13 +65,6 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -65,13 +65,6 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
array($email->emails['WC_Email_Customer_Completed_Order'],'trigger')); array($email->emails['WC_Email_Customer_Completed_Order'],'trigger'));
// New order emails
add_action('woocommerce_order_status_pending_to_processing_notification',
array($email->emails[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_pending_to_completed_notification',
array($email->emails[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_pending_to_on-hold_notification',
array($email->emails[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_failed_to_processing_notification', add_action('woocommerce_order_status_failed_to_processing_notification',
array($email->emails[WC_QD_DB.'new_donation_email'],'trigger')); array($email->emails[WC_QD_DB.'new_donation_email'],'trigger'));
add_action('woocommerce_order_status_failed_to_completed_notification', add_action('woocommerce_order_status_failed_to_completed_notification',
...@@ -89,7 +82,14 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -89,7 +82,14 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
if($this->check_donation_already_exist()){ if($this->check_donation_already_exist()){
$message = WC_QD()->db()->get_message(WC_QD_DB.'donation_already_exist'); $message = WC_QD()->db()->get_message(WC_QD_DB.'donation_already_exist');
wc_add_notice($message,'error'); wc_add_notice($message,'error');
return ; $this->redirect_cart($key = WC_QD_DB.'already_exist_redirect_user');
return false;
}
if($this->added_with_other_products()){
$message = WC_QD()->db()->get_message(WC_QD_DB.'donation_with_other_products');
wc_add_notice($message,'error');
return false;
} }
global $woocommerce; global $woocommerce;
...@@ -118,7 +118,11 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -118,7 +118,11 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
} }
} }
public function added_with_other_products(){
global $woocommerce;
if(!empty($woocommerce->cart->get_cart())){ return true; }
return false;
}
public function check_donation_already_exist(){ public function check_donation_already_exist(){
global $woocommerce; global $woocommerce;
...@@ -179,9 +183,9 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -179,9 +183,9 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
return true; return true;
} }
public function redirect_cart(){ public function redirect_cart($key = WC_QD_DB.'redirect_user'){
if($this->is_donation_exists){ if($this->is_donation_exists){
$redirect = WC_QD()->settings()->get_option(WC_QD_DB.'redirect_user'); $redirect = WC_QD()->settings()->get_option($key);
$url = ''; $url = '';
if($redirect == 'cart'){ if($redirect == 'cart'){
$url = WC()->cart->get_cart_url(); $url = WC()->cart->get_cart_url();
......
...@@ -35,8 +35,8 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -35,8 +35,8 @@ class WC_QD_Donation_New_Email extends WC_Email {
$this->template_html = 'emails/donation-customer-invoice.php'; $this->template_html = 'emails/donation-customer-invoice.php';
$this->template_plain = 'emails/plain/donation-customer-invoice.php'; $this->template_plain = 'emails/plain/donation-customer-invoice.php';
$this->subject = __( 'Invoice for order {order_number} from {order_date}', 'woocommerce'); $this->subject = __( 'Reg : Your Recent Donation @ {site_title}', WC_QD_TXT);
$this->heading = __( 'Invoice for order {order_number}', 'woocommerce'); $this->heading = __( 'Thank you. Your Donation has been received for {project_name}', 'woocommerce');
$this->subject_paid = __( 'Your {site_title} order from {order_date}', 'woocommerce'); $this->subject_paid = __( 'Your {site_title} order from {order_date}', 'woocommerce');
$this->heading_paid = __( 'Order {order_number} details', 'woocommerce'); $this->heading_paid = __( 'Order {order_number} details', 'woocommerce');
...@@ -71,9 +71,16 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -71,9 +71,16 @@ class WC_QD_Donation_New_Email extends WC_Email {
$this->find['order-date'] = '{order_date}'; $this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}'; $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-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
$this->replace['order-number'] = $this->object->get_order_number(); $this->replace['order-number'] = $this->object->get_order_number();
$this->replace['donation-project-name'] = $project_name;
} }
if ( ! $this->get_recipient() ) { if ( ! $this->get_recipient() ) {
...@@ -91,9 +98,9 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -91,9 +98,9 @@ class WC_QD_Donation_New_Email extends WC_Email {
*/ */
function get_subject() { function get_subject() {
if ( $this->object->has_status( array( 'processing', 'completed' ) ) ) { if ( $this->object->has_status( array( 'processing', 'completed' ) ) ) {
return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $this->subject_paid ), $this->object ); return $this->format_string( $this->subject_paid );
} else { } else {
return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $this->subject ), $this->object ); return $this->format_string( $this->subject );
} }
} }
...@@ -105,9 +112,9 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -105,9 +112,9 @@ class WC_QD_Donation_New_Email extends WC_Email {
*/ */
function get_heading() { function get_heading() {
if ( $this->object->has_status( array( 'completed', 'processing' ) ) ) { if ( $this->object->has_status( array( 'completed', 'processing' ) ) ) {
return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $this->heading_paid ), $this->object ); return $this->format_string( $this->heading_paid );
} else { } else {
return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $this->heading ), $this->object ); return $this->format_string( $this->heading );
} }
} }
...@@ -125,6 +132,7 @@ class WC_QD_Donation_New_Email extends WC_Email { ...@@ -125,6 +132,7 @@ class WC_QD_Donation_New_Email extends WC_Email {
'sent_to_admin' => false, 'sent_to_admin' => false,
'plain_text' => false 'plain_text' => false
) ); ) );
return ob_get_clean(); return ob_get_clean();
} }
......
...@@ -23,13 +23,12 @@ if ( ! defined( 'ABSPATH' ) ) { ...@@ -23,13 +23,12 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text ); ?> <?php do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text ); ?>
<h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2> <h2><?php printf( __( 'Donation ID #%s', 'woocommerce' ), $order->get_order_number() ); ?> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1"> <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
<thead> <thead>
<tr> <tr>
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Donation Project', 'woocommerce' ); ?></th> <th class="td" scope="col" style="text-align:left;"><?php _e( 'Project', WC_QD_TXT ); ?></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> <th class="td" scope="col" style="text-align:left;"><?php _e( 'Price', 'woocommerce' ); ?></th>
</tr> </tr>
</thead> </thead>
...@@ -37,25 +36,29 @@ if ( ! defined( 'ABSPATH' ) ) { ...@@ -37,25 +36,29 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php <?php
switch ( $order->get_status() ) { switch ( $order->get_status() ) {
case "completed" : case "completed" :
echo $order->email_order_items_table( $order->is_download_permitted(), false, true ); echo $order->email_order_items_table( false, false, true );
break; break;
case "processing" : case "processing" :
echo $order->email_order_items_table( $order->is_download_permitted(), true, true ); echo $order->email_order_items_table( false, true, true );
break; break;
default : default :
echo $order->email_order_items_table( $order->is_download_permitted(), true, false ); echo $order->email_order_items_table( false, true, false );
break; break;
} }
?> ?>
</tbody> </tbody>
<tfoot> <tfoot>
<?php <?php
if ( $totals = $order->get_order_item_totals() ) { if ( $totals = $order->get_order_item_totals() ) {
$i = 0; $i = 0;
foreach ( $totals as $total ) {
foreach ( $totals as $subKey => $total ) {
$i++; $i++;
if($subKey == 'cart_subtotal' || $subKey == 'order_total'){continue;}
?><tr> ?><tr>
<td class="td" colspan="2" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['label']; ?></td> <td class="td" colspan="1" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['label']; ?></td>
<td class="td" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['value']; ?></td> <td class="td" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php </tr><?php
} }
......
<?php
/**
* Email Addresses
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">
<tr>
<td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
<h3><?php _e( 'Billing address', 'woocommerce' ); ?></h3>
<p class="text"><?php echo $order->get_formatted_billing_address(); ?></p>
</td>
<?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
<td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
<h3><?php _e( 'Shipping address', 'woocommerce' ); ?></h3>
<p class="text"><?php echo $shipping; ?></p>
</td>
<?php endif; ?>
</tr>
</table>
<?php
/**
* Email Footer
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
</div>
</td>
</tr>
</table>
<!-- End Content -->
</td>
</tr>
</table>
<!-- End Body -->
</td>
</tr>
<tr>
<td align="center" valign="top">
<!-- Footer -->
<table border="0" cellpadding="10" cellspacing="0" width="600" id="template_footer">
<tr>
<td valign="top">
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr>
<td colspan="2" valign="middle" id="credit">
<?php echo wpautop( wp_kses_post( wptexturize( apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ) ) ) ); ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- End Footer -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
<?php
/**
* Email Header
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<!DOCTYPE html>
<html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo get_bloginfo( 'name', 'display' ); ?></title>
</head>
<body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
<div id="wrapper" dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tr>
<td align="center" valign="top">
<div id="template_header_image">
<?php
if ( $img = get_option( 'woocommerce_email_header_image' ) ) {
echo '<p style="margin-top:0;"><img src="' . esc_url( $img ) . '" alt="' . get_bloginfo( 'name', 'display' ) . '" /></p>';
}
?>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_container">
<tr>
<td align="center" valign="top">
<!-- Header -->
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_header">
<tr>
<td id="header_wrapper">
<h1><?php echo $email_heading; ?></h1>
</td>
</tr>
</table>
<!-- End Header -->
</td>
</tr>
<tr>
<td align="center" valign="top">
<!-- Body -->
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_body">
<tr>
<td valign="top" id="body_content">
<!-- Content -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr>
<td valign="top">
<div id="body_content_inner">
<?php
/**
* Email Order Items
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.1.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$order_id = $order->id;
$project_id = WC_QD()->db()->get_project_id($order_id);
$project_name = get_the_title($project_id);
foreach ( $items as $item_id => $item ) :
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
$item_meta = new WC_Order_Item_Meta( $item, $_product );
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;"><?php
// Show title/image etc
if ( $show_image ) {
echo apply_filters( 'woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ( $_product->get_image_id() ? current( wp_get_attachment_image_src( $_product->get_image_id(), 'thumbnail') ) : wc_placeholder_img_src() ) .'" alt="' . esc_attr__( 'Product Image', 'woocommerce' ) . '" height="' . esc_attr( $image_size[1] ) . '" width="' . esc_attr( $image_size[0] ) . '" style="vertical-align:middle; margin-right: 10px;" /></div>', $item );
}
// Product name
echo __( 'Donation For : ', WC_QD_TXT ).' '.$project_name;
?></td>
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
</tr>
<?php
}
if ( $show_purchase_note && is_object( $_product ) && ( $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) ) : ?>
<tr>
<td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php
/**
* Email Styles
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.3.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Load colours
$bg = get_option( 'woocommerce_email_background_color' );
$body = get_option( 'woocommerce_email_body_background_color' );
$base = get_option( 'woocommerce_email_base_color' );
$base_text = wc_light_or_dark( $base, '#202020', '#ffffff' );
$text = get_option( 'woocommerce_email_text_color' );
$bg_darker_10 = wc_hex_darker( $bg, 10 );
$body_darker_10 = wc_hex_darker( $body, 10 );
$base_lighter_20 = wc_hex_lighter( $base, 20 );
$base_lighter_40 = wc_hex_lighter( $base, 40 );
$text_lighter_20 = wc_hex_lighter( $text, 20 );
// !important; is a gmail hack to prevent styles being stripped if it doesn't like something.
?>
#wrapper {
background-color: <?php echo esc_attr( $bg ); ?>;
margin: 0;
padding: 70px 0 70px 0;
-webkit-text-size-adjust: none !important;
width: 100%;
}
#template_container {
box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
background-color: <?php echo esc_attr( $body ); ?>;
border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>;
border-radius: 3px !important;
}
#template_header {
background-color: <?php echo esc_attr( $base ); ?>;
border-radius: 3px 3px 0 0 !important;
color: <?php echo esc_attr( $base_text ); ?>;
border-bottom: 0;
font-weight: bold;
line-height: 100%;
vertical-align: middle;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
}
#template_header h1 {
color: <?php echo esc_attr( $base_text ); ?>;
}
#template_footer td {
padding: 0;
-webkit-border-radius: 6px;
}
#template_footer #credit {
border:0;
color: <?php echo esc_attr( $base_lighter_40 ); ?>;
font-family: Arial;
font-size:12px;
line-height:125%;
text-align:center;
padding: 0 48px 48px 48px;
}
#body_content {
background-color: <?php echo esc_attr( $body ); ?>;
}
#body_content table td {
padding: 48px;
}
#body_content table td td {
padding: 12px;
}
#body_content table td th {
padding: 12px;
}
#body_content p {
margin: 0 0 16px;
}
#body_content_inner {
color: <?php echo esc_attr( $text_lighter_20 ); ?>;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
}
.td {
color: <?php echo esc_attr( $text_lighter_20 ); ?>;
border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
}
.text {
color: <?php echo esc_attr( $text ); ?>;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
}
.link {
color: <?php echo esc_attr( $base ); ?>;
}
#header_wrapper {
padding: 36px 48px;
display: block;
}
h1 {
color: <?php echo esc_attr( $base ); ?>;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
font-size: 30px;
font-weight: 300;
line-height: 150%;
margin: 0;
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>;
-webkit-font-smoothing: antialiased;
}
h2 {
color: <?php echo esc_attr( $base ); ?>;
display: block;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
font-size: 18px;
font-weight: bold;
line-height: 130%;
margin: 16px 0 8px;
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
}
h3 {
color: <?php echo esc_attr( $base ); ?>;
display: block;
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
font-size: 16px;
font-weight: bold;
line-height: 130%;
margin: 16px 0 8px;
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
}
a {
color: <?php echo esc_attr( $base ); ?>;
font-weight: normal;
text-decoration: underline;
}
img {
border: none;
display: inline;
font-size: 14px;
font-weight: bold;
height: auto;
line-height: 100%;
outline: none;
text-decoration: none;
text-transform: capitalize;
}
<?php
<?php
/**
* Email Addresses (plain)
*
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
echo "\n" . strtoupper( __( 'Billing address', 'woocommerce' ) ) . "\n\n";
echo preg_replace( '#<br\s*/?>#i', "\n", $order->get_formatted_billing_address() ) . "\n";
if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) {
echo "\n" . strtoupper( __( 'Shipping address', 'woocommerce' ) ) . "\n\n";
echo preg_replace( '#<br\s*/?>#i', "\n\t", $shipping ) . "\n";
}
<?php
/**
* Email Order Items (plain)
*
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.1.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
foreach ( $items as $item_id => $item ) :
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
$item_meta = new WC_Order_Item_Meta( $item, $_product );
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
// Title
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false );
// SKU
if ( $show_sku && $_product->get_sku() ) {
echo ' (#' . $_product->get_sku() . ')';
}
// allow other plugins to add additional product information here
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
// Variation
echo ( $item_meta_content = $item_meta->display( true, true ) ) ? "\n" . $item_meta_content : '';
// Quantity
echo "\n" . sprintf( __( 'Quantity: %s', 'woocommerce' ), apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item ) );
// Cost
echo "\n" . sprintf( __( 'Cost: %s', 'woocommerce' ), $order->get_formatted_line_subtotal( $item ) );
// Download URLs
if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {
$download_files = $order->get_item_downloads( $item );
$i = 0;
foreach ( $download_files as $download_id => $file ) {
$i++;
if ( count( $download_files ) > 1 ) {
$prefix = sprintf( __( 'Download %d', 'woocommerce' ), $i );
} elseif ( $i == 1 ) {
$prefix = __( 'Download', 'woocommerce' );
}
echo "\n" . $prefix . '(' . esc_html( $file['name'] ) . '): ' . esc_url( $file['download_url'] );
}
}
// allow other plugins to add additional product information here
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order );
}
// Note
if ( $show_purchase_note && ( $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) ) {
echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) );
}
echo "\n\n";
endforeach;
...@@ -32,6 +32,7 @@ class WooCommerce_Quick_Donation { ...@@ -32,6 +32,7 @@ class WooCommerce_Quick_Donation {
public static $donation_id = null; public static $donation_id = null;
public static $settings = null; public static $settings = null;
public static $settings_values = null; public static $settings_values = null;
public static $email = null;
private static $db = null; private static $db = null;
/** /**
* Creates or returns an instance of this class. * Creates or returns an instance of this class.
...@@ -103,6 +104,7 @@ class WooCommerce_Quick_Donation { ...@@ -103,6 +104,7 @@ class WooCommerce_Quick_Donation {
$this->load_files(WC_QD_INC.'class-quick-donation-db.php'); $this->load_files(WC_QD_INC.'class-quick-donation-db.php');
$this->load_files(WC_QD_INC.'class-install.php'); $this->load_files(WC_QD_INC.'class-install.php');
$this->load_files(WC_QD_INC.'class-quick-donation-functions.php'); $this->load_files(WC_QD_INC.'class-quick-donation-functions.php');
$this->load_files(WC_QD_INC.'class-quick-donation-email-functions.php');
if($this->is_request('frontend')){ if($this->is_request('frontend')){
$this->load_files(WC_QD_INC.'class-quick-donation-process.php'); $this->load_files(WC_QD_INC.'class-quick-donation-process.php');
...@@ -120,7 +122,7 @@ class WooCommerce_Quick_Donation { ...@@ -120,7 +122,7 @@ class WooCommerce_Quick_Donation {
* Inits loaded Class * Inits loaded Class
*/ */
private function init_class(){ private function init_class(){
self::$email = new WooCommerce_Quick_Donation_Emails_Functions;
self::$f = new WooCommerce_Quick_Donation_Functions; self::$f = new WooCommerce_Quick_Donation_Functions;
self::$settings = new WooCommerce_Quick_Donation_Settings; self::$settings = new WooCommerce_Quick_Donation_Settings;
self::$db = new WooCommerce_Quick_Donation_DB; self::$db = new WooCommerce_Quick_Donation_DB;
......
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