例えば、Woocommerceマイページの注文ページに特定のメッセージを表示させたい場合は「コードスニペット」で簡単に挿入できます。
以下の見本コードをWordPressのfunctions.php内に設置すると、Woocommerceマイページの注文に「ご購入ありがとうございます。何かお困りなことがあればお問合せください。」と表示されます。
add_action('woocommerce_order_details_after_order_table', 'action_order_details_after_order_table', 10, 4 );
function action_order_details_after_order_table( $order, $sent_to_admin = '', $plain_text = '', $email = '' ) {
// 「マイアカウント」 > 「注文表」 に表示
if ( is_wc_endpoint_url( 'view-order' ) ) {
printf( '<p class="custom-text">' .
__("ご購入ありがとうございます。何かお困りなことがあればお問合せください。" ,"woocommerce"),
'<strong>"' .__("ご購入ありがとうございます", "woocommerce") . '"</strong>.</p>' );
}
}
最終更新日: 2025-12-05