したがって、次のように使用できます。
add_filter( 'woocommerce_short_description', 'single_product_short_description', 10, 1 );
function single_product_short_description( $post_excerpt ){
global $product;
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
if ( is_single( $product_id ) )
$post_excerpt = '<p class="some-class">' . __( "article only available in the store.", "woocommerce" ) . '</p>';
return $post_excerpt;
}
通常、この短い説明が存在する場合、このコードは単一の製品ページの既存の短い説明テキストを上書きします…</p>
(更新) - あなたのコメントに関連
抜粋 (短い説明) を上書きせずにこれを表示したい場合は、次の方法で前に追加できます。
add_filter( 'woocommerce_short_description', 'single_product_short_description', 10, 1 );
function single_product_short_description( $post_excerpt ){
global $product;
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
if ( is_single( $product_id ) )
$post_excerpt = '<div class="product-message"><p>' . __( "Article only available in the store.", "woocommerce" ) . '</p></div>' . $post_excerpt;
return $post_excerpt;
}
したがって、メッセージは短い説明の前後 (短い説明が存在する場合) に表示されます…</p>
たとえば、次のように、アクティブなテーマstyle.css
ファイルのクラス セレクターをターゲットにしてスタイルを設定できます。.product-message
.product-message {
background-color:#eee;
border: solid 1px #666;
padding: 10px;
}
必要に応じて独自のスタイル ルールを作成する必要があります。