Search
 
SCRIPT & CODE EXAMPLE
 

PHP

email to customer to cancel woocommerce order

add_action('woocommerce_order_status_changed', 'custom_send_email_notifications', 10, 4 );
function custom_send_email_notifications( $order_id, $old_status, $new_status, $order ){
    if ( $new_status == 'cancelled' || $new_status == 'failed' ){
        $wc_emails = WC()->mailer()->get_emails(); // Get all WC_emails objects instances
        $customer_email = $order->get_billing_email(); // The customer email
    }

    if ( $new_status == 'cancelled' ) {
        // change the recipient of this instance
        $wc_emails['WC_Email_Cancelled_Order']->recipient = $customer_email;
        // Sending the email from this instance
        $wc_emails['WC_Email_Cancelled_Order']->trigger( $order_id );
    } 
    elseif ( $new_status == 'failed' ) {
        // change the recipient of this instance
        $wc_emails['WC_Email_failed_Order']->recipient = $customer_email;
        // Sending the email from this instance
        $wc_emails['WC_Email_failed_Order']->trigger( $order_id );
    } 
}
Comment

new order email filter woocommerce

add_action( 'woocommerce_email_order_details', function( $order, $sent_to_admin )
{
    if ( $sent_to_admin && ! defined('TST_ADMIN_EMAIL') ) {
        define( 'TST_ADMIN_EMAIL', true );
    }
}, 9, 2 );

add_filter( 'woocommerce_email_order_item_quantity', 'tst_filter_woocommerce_email_order_item_quantity', 10, 2 );
function tst_filter_woocommerce_email_order_item_quantity( $qty_display, $item )
{
    if (
        defined('TST_ADMIN_EMAIL')
        && true === TST_ADMIN_EMAIL
        && 'line_item' === $item->get_type()
    ) {
        $product = $item->get_product();
        $product_id = $product->get_id();

        if ( $product_id == 6960 ) {
            $qty_display = $qty_display * 2;
        }
    }

    return $qty_display; 
}; 
Comment

PREVIOUS NEXT
Code Example
Php :: how do i use $variables as values in php 7 mysqli insert 
Php :: if statement php 
Php :: laravel eloquent relationship 
Php :: command to create middleware in laravel 
Php :: get page templete 
Php :: how to get value in to radio button php 
Php :: oops concepts in php 
Php :: download file using jquery php 
Php :: wp_schedule_event 
Php :: laravel nginx 
Php :: Add Text After or Before on the Shop Page/Archive Page 
Php :: how to rename a table element in laravel 
Php :: wp php blog info image 
Php :: php public folder 
Php :: Laravel SPA cors 
Php :: laravel cookie (flash meesage for time) 
Php :: download pdf file from database in php 
Php :: Detect the page realod in php 
Php :: audio validation in jquery validation 
Php :: php file iterator 
Php :: You are *required* to use the date.timezone setting or t 
Php :: cara install php7.3 di ubuntu 20.04 
Php :: composer require rtconner/laravel-tagging 
Php :: php get woocommerce attribute from database 
Php :: php array_diff 
Php :: Laravel htaccess for aws ec2 
Php :: READIMAGE FUNCTION PHP 
Php :: readable date in php 
Php :: php function to get the last value of array 
Php :: php get the two number of time second 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =