[英]WooCommerce | Add custom text at the end of the short description
How can I put the following code at the end of my short product description?如何将以下代码放在我的简短产品描述的末尾? (WooCommerce)
(WooCommerce)
<tbody class="table-hover">
<?php if ( get_field( 'platform' ) ): ?>
<tr>
<td class="text-left prd-platform ">Platform:</td>
<td class="text-left trd-platform">
<?php $terms = get_field('platform');
if( $terms ): ?>
<?php foreach( $terms as $term ): ?>
<a class="acflinkcls" href="<?php echo esc_url( get_term_link( $term ) ); ?>"><?php echo esc_html( $term->name ); ?></a>
<?php endforeach; ?>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
I want this code to be part of my short product description我希望此代码成为我的简短产品描述的一部分
Thanks for guiding me谢谢你指导我
It seems to me, you have two alternatives:在我看来,你有两种选择:
1: edit your theme_name/woocommerce
or use child_theme
. 1:编辑您的
theme_name/woocommerce
或使用child_theme
。 (Personally I prefer to use a child theme as a solution.) (我个人更喜欢使用子主题作为解决方案。)
2: you may use woocommerce_short_description
to add your code. 2:您可以使用
woocommerce_short_description
添加您的代码。
3: add the following code in functions.php
of your theme. 3:在你的主题的
functions.php
中添加如下代码。 you will see functions.php
in the following path: wp-content/teme_name/functions.php
您将在以下路径中看到
functions.php
: wp-content/teme_name/functions.php
add_action( 'woocommerce_single_product_summary', 'sally_below_single_product_summary', 20 );
function sally_below_single_product_summary() {
?>
<tbody class="table-hover">
<?php if ( get_field( 'platform' ) ): ?>
<tr>
<td class="text-left prd-platform ">Platform:</td>
<td class="text-left trd-platform">
<?php $terms = get_field('platform');
if( $terms ): ?>
<?php foreach( $terms as $term ): ?>
<a class="acflinkcls" href="<?php echo esc_url( get_term_link( $term ) ); ?>"><?php echo esc_html( $term->name ); ?></a>
<?php endforeach; ?>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php }
Adding your custom text at the end of the short description content, ( not for variable products ):在简短描述内容的末尾添加您的自定义文本(不适用于可变产品):
add_filter( 'woocommerce_short_description', 'add_text_after_excerpt_single_product', 20, 1 );
function add_text_after_excerpt_single_product( $post_excerpt ){
if ( ! $short_description )
return;
// Your custom text
$post_excerpt .= '<ul class="fancy-bullet-points red">
<li>Current Delivery Times: Pink Equine - 4 - 6 Weeks, all other products 4 Weeks</li>
</ul>';
return $post_excerpt;
}
Follow the URL below to resolve your issue:按照下面的 URL 解决您的问题:
Add Text under Single Product Short Description in Woocommerce 在 Woocommerce 中的单个产品简短描述下添加文本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.