Пользовательская электронная почта Woocommerce - PullRequest
0 голосов
/ 03 ноября 2018

Мне нужна помощь с настраиваемым адресом электронной почты для woocommerce.

Я пытаюсь отправить другое электронное письмо в зависимости от идентификатора продукта, когда продукт будет завершен.

Мой код, который не работает, выглядит следующим образом:

/**************
DIFFERENT MESSAGES FOR DIFFERENT PRODUCTS
****************/

//hook our function to the new order email
add_action('woocommerce_email_order_details',     'uiwc_email_order_details_products', 1, 4);

function uiwc_email_order_details_products($order, $admin, $plain, $email) {
 $status = $order->get_status();

 // checking if it's the order status we want
  if ( $status == "completed" ) {
   $items = $order->get_items();

    if ( $item['product_id'] == "3181") {
      echo __( '<strong>IMPORTANT - NEXT STEP:</strong><br>To get started, please follow <a href="https:XXXXX">this link</a> to complete the Policies form.<br><br>This is a really important first step, and only takes about 5 minutes.  After completeing the Policies form, you will receive additional instructions on next steps.<br><br>Congratulations! Let your journey begin.<br><br>', 'uiwc' );
  }

   elseif ( $item['product_id'] == "3223") {
      echo __( '<strong>IMPORTANT - NEXT STEP:</strong><br>Differnet product so differenct email....<br><br>', 'uiwc' );
  }
}  
}

Любые предложения приветствуются

1 Ответ

0 голосов
/ 03 ноября 2018

В вашем коде есть некоторые ошибки, вместо этого попробуйте следующее

//hook our function to the new order email
add_action( 'woocommerce_email_order_details', 'custom_email_order_details', 4, 4 );
function custom_email_order_details( $order, $admin, $plain, $email ) {
    $domain = 'woocommerce';

    // checking if it's the order status we want
    if ( $order->has_status('completed') ) {
        foreach( $order->get_items() as $item ){
            if ( $item->get_product_id() == '3181' ) {
                echo __( '<strong>IMPORTANT - NEXT STEP:</strong><br>To get started, please follow <a href="https://xxxxxx">this link</a> to complete the Policies form.<br><br>This is a really important first step, and only takes about 5 minutes. After completeing the Policies form, you will receive additional instructions on next steps.<br><br>Congratulations! Let your journey begin.<br><br>', $domain );
                break;
            }
            elseif ( $item->get_product_id() == '3223' ) {
                echo __( '<strong>IMPORTANT - NEXT STEP:</strong><br>Differnet product so differenct email....<br><br>', $domain );
                break;
            }
        } 
    }  
}

Код помещается в файл function.php вашей активной дочерней темы (или активной темы). Проверено и работает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...