【问题标题】:Add custom text below Add To Cart button in WooCommerce single product pages在 WooCommerce 单个产品页面中的“添加到购物车”按钮下方添加自定义文本
【发布时间】:2018-03-22 13:52:57
【问题描述】:
【问题讨论】:
标签:
php
css
wordpress
woocommerce
product
【解决方案1】:
你可以试试这个(你会看到这是 margin-top 的 CSS 样式问题):
add_action( 'woocommerce_after_add_to_cart_button', 'custom_content_after_addtocart_button', 100 );
function custom_content_after_addtocart_button() {
// custom content.
echo '<br/><div><p style="font-size:10px; font-style=italic; margin-top:20px;">(*Contact us for bulk purchase enquiry)</p></div>';
}
代码进入您的活动子主题(活动主题或任何插件文件)的 function.php 文件中。
经过测试并且有效。你会得到:
【解决方案2】:
此代码将其放置在“添加到购物车”按钮下方:
add_action( 'woocommerce_after_add_to_cart_form','content_after_addtocart', 100 );
function content_after_addtocart() {
// place your content below.
echo 'Hello There !!';
}