我想更改评价商品数据标签中的默认文字。
我尝试了以下代码,它适用于描述,但现在只是新的描述而没有显示任何其他内容。 没有评论,星级或选择留下新的评论。
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['reviews']['callback'] = 'woo_custom_description_tab_content'; // Custom reviews callback
return $tabs;
}
function woo_custom_description_tab_content() {
echo '<h2>Custom Description</h2>';
echo '<p>Here\'s a custom description</p>';
}
有人为我解决了吗?
由于
答案 0 :(得分:0)
我为我找到了一个解决方案:
copy /wp-content/plugins/woocommerce/templates/single-product-reviews.php
到你的子主题文件夹并编辑comment_form数组。
我在自定义说明中添加了密钥comment_notes_before:
&#39; comment_notes_before&#39; =&GT; &#39; CUSTOM TEXT到这里&#39;,
$comment_form = array(
'title_reply' => have_comments() ? __( 'Add a review', 'woocommerce' ) : sprintf( __( 'Be the first to review “%s”', 'woocommerce' ), get_the_title() ),
'title_reply_to' => __( 'Leave a Reply to %s', 'woocommerce' ),
'comment_notes_after' => '',
'comment_notes_before' => 'CUSTOM TEXT GOES HERE',
'fields' => array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'woocommerce' ) . ' <span class="required">*</span></label> ' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" required /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'woocommerce' ) . ' <span class="required">*</span></label> ' .
'<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-required="true" required /></p>',
),
'label_submit' => __( 'Submit', 'woocommerce' ),
'logged_in_as' => '',
'comment_field' => ''
);