WooCommerce 覚書

情報を追記している場合はありますが、古い情報を訂正はしていませんので、公開年月日を参照してください。プラグイン・タグ、いずれもワードプレス・PHPのバージョン等によって動作しない場合もあります。

*お客様宛のメールの宛名をフルネームに
メールテンプレートplugins/woocommerce/templates/emails/以下をthemes/使用テーマ/woocommerce/emails/ にコピーして
$order->get_billing_first_name() を$order->get_formatted_billing_full_name() に

*受注メールの商品名に商品カテゴリー名をつける

function woocommerce_add_term_to_name( $name, $item ){

    $product_id = $item['product_id'];
    $tax = 'product_cat';

    $terms = wp_get_post_terms( $product_id, $tax, array( 'fields' => 'names' ) );

    if( $terms && ! is_wp_error( $terms )) {
        $taxonomy = get_taxonomy($tax);
        $name .= ' <br><label>' . $taxonomy->label . ': </label>' . implode( ', ', $terms );
    }

    return $name;
}
add_filter( 'woocommerce_order_item_name', 'woocommerce_add_term_to_name', 10, 2 );