[英]Woocommerce Product details page remove add to cart and put Email Button
In my woocommerce website for simple products, I need to remove Add to Cart, quantity box and put a Email Button with mail to link.在我的简单产品的 woocommerce 网站中,我需要删除添加到购物车、数量框并放置一个带有邮件链接的电子邮件按钮。 Can anyone please help me how can i do it.
任何人都可以请帮助我我该怎么做。
Add This code snippet in active theme function.php file在活动主题 function.php 文件中添加此代码片段
// For remove Add to cart button
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
// add inquiry button into every product
add_action( 'woocommerce_after_shop_loop_item', 'prfx_add_inquiry_button', 10); // catalog page
add_action( 'woocommerce_single_product_summary', 'prfx_add_inquiry_button', 30); // single product page
function prfx_add_inquiry_button() {
$current_product_id = get_the_ID(); // get ID of the current post
$current_product_title = get_the_title(); // get the title of the current post
$product = wc_get_product( $current_product_id ); // get the product object
echo $current_product_title;
echo '<a href="mailto:test@example.com?subject=Inquiry for product id:$current_product_id" class="button">Inquiry</a>';
echo '</a>';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.