Woocommerce产品详细信息页面删除添加到购物车并放入电子邮件按钮

时间:2020-01-23 12:04:17

标签: wordpress woocommerce

在我的woocommerce网站上(用于简单产品),我需要删除“添加到购物车”,“数量”框,然后放置一个带有邮件的“电子邮件”按钮以进行链接。谁能帮我怎么做。

1 个答案:

答案 0 :(得分:0)

在活动主题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>';
    }