Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hello

    Step 1 :
    Disable mail auto

    add_action( 'woocommerce_email', array(get_class(),'disable_auto_email_customer_completed_order') );

        public static function disable_auto_email_customer_completed_order( $email_class ) {
    
          remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); // cancels automatic email of order complete status update.
        }


    Step 2 :
    Send manually with switch lang and trad strings

         add_action( 'woocommerce_order_actions', array(get_class(),'add_order_action') );
           add_action( 'woocommerce_order_action_send_wc_email_customer_completed_order', array(get_class(),'send_wc_email_customer_completed_order') );
    
        public static function add_order_action( $actions ) {
          $actions['send_wc_email_customer_completed_order'] = 'Envoyer l\'email de commande terminée';
          return $actions;
        }
    
        public static function send_wc_email_customer_completed_order( $order ) {
          global $sitepress;
    
          $order_id = $order->get_id();
          $lang = get_post_meta( $order_id, 'wpml_language');
          if (!empty($lang)) {
            $sitepress->switch_lang( $lang[0], true );
          }
    
          $allmails = WC()->mailer()->emails;
          $email = $allmails['WC_Email_Customer_Completed_Order'];
          $email->settings['subject'] = __('Votre commande est dans les starting-blocks','admin_texts_woocommerce_customer_completed_order_settings');
          $email->settings['heading'] = __('Et une commande prête à partir, une !','admin_texts_woocommerce_customer_completed_order_settings');
          $email->settings['additional_content'] = __('Encore merci de votre confiance.
    
    Team hellowall','admin_texts_woocommerce_customer_completed_order_settings');
    
          $email->trigger( $order_id );
          $order->add_order_note( 'Email "Commande terminée" envoyé' );
        }
        public static function add_order_action( $actions ) {
          $actions['send_wc_email_customer_completed_order'] = 'Envoyer l\'email de commande terminée';
          return $actions;
        }
    
        public static function send_wc_email_customer_completed_order( $order ) {
          global $sitepress;
    
          $order_id = $order->get_id();
          $lang = get_post_meta( $order_id, 'wpml_language');
          if (!empty($lang)) {
            $sitepress->switch_lang( $lang[0], true );
          }
    
          $allmails = WC()->mailer()->emails;
          $email = $allmails['WC_Email_Customer_Completed_Order'];
          $email->settings['subject'] = __('Votre commande est dans les starting-blocks','admin_texts_woocommerce_customer_completed_order_settings');
          $email->settings['heading'] = __('Et une commande prête à partir, une !','admin_texts_woocommerce_customer_completed_order_settings');
          $email->settings['additional_content'] = __('Encore merci de votre confiance.
    
    Team hellowall','admin_texts_woocommerce_customer_completed_order_settings');
    
          $email->trigger( $order_id );
          $order->add_order_note( 'Email "Commande terminée" envoyé' );
        }
Viewing 1 replies (of 1 total)