如何添加"显示详细信息" Woocommerce中的购物车按钮附近的按钮

时间:2018-06-05 11:06:24

标签: wordpress button woocommerce add woocommerce-theming

我想在woocommerce单品中添加额外的按钮。我需要在哪个文件中进行更改?

屏幕上的示例: enter image description here

2 个答案:

答案 0 :(得分:0)

试试这段代码,

function wc_shop_demo_button() {
    echo '<a class="button demo_button" style="padding-right: 0.75em;padding-left: 0.75em;margin-left: 8px; background-color: #0ebc30;" href="'.get_field( "url_demo" ).'" target="_blank">Show Details</a>';
}
add_action( 'woocommerce_after_shop_loop_item', 'wc_shop_demo_button', 20 );
add_action( 'woocommerce_after_add_to_cart_button', 'wc_shop_demo_button', 20 );

希望这会对你有所帮助。有关详细信息,请访问

how to add button after woocommerce shop loop item

答案 1 :(得分:0)

首先,使用Woocommerce产品页面的“高级自定义字段”插件创建自定义字段。

有关使用ACF插件创建自定义字段的信息,请参阅以下文章。

https://wpmayor.com/woocommerce-custom-fields-how-to-create-and-display-them/

要在网站的前端显示“自定义按钮”,请在functions.php文件中添加以下代码。

function rf_custom_product_button() {
    echo '<a class="button custom_button" href="'.get_field( "custom_button" ).'" target="_blank">Click Here</a>';
}
add_action( 'woocommerce_after_add_to_cart_button', 'rf_custom_product_button', 20 );
add_action( 'woocommerce_after_shop_loop_item', 'rf_custom_product_button', 20 );

在上面的代码中,将“ custom_button”更改为使用ACF创建的字段的名称。

相关问题