hosting tutorials WeChat Top

👋🏼Welcome to my WP-Host blog where I am excited to share my knowledge and expertise on WordPress hosting and website construction tutorials with you. Let’s connect and learn from each other! You can reach me at info@yrshare.com.

Email Me

(如果你会中文,可以点击微信图标与我联系。)

扫一扫加我

注:因个人英文水平有限,所以暂时只能为懂中文的朋友提供wordpress建站服务

微信:18200592859 或 yrwordpress

Add an inquiry button to the Woocommerce product page

Add an inquiry button to the Woocommerce product page: Many people like to use wordpress+woocommerce to make product display websites. They don’t need the shopping function, they only need the inquiry function, allowing users to inquire through forms or emails. So today’s WordPress tutorial will share with you how to add an inquiry button link to the woocommerce product page.

【WP-Host/悦然wordpress建站】

Keep sharing wordpress tutorials.
The recent wordpress website building project used the woocommerce plug-in, and the woocommerce plug-in itself is a mall, so its product page defaults to the purchase button.
However, some products may not be suitable for direct online sales, or if you want to add an inquiry button under the purchase button, then you can refer to the following method.


add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );

function my_extra_button_on_product_page() {
  global $product;
  echo '<a class="zsxxfx" href="https://www.aaa.com">Inquiry</a>';
}

You just need to replace the URL in the above code with the address you need to point to. For example, you can replace it with the chat link of the customer service tool, or replace it with your QQ account consultation link, or replace it with your third-party website.
Store address, followed by [Inquiry] is the name of the button, you can modify it according to your needs.
The code can be directly added to the functions.php file of the current wordpress website building theme, or use the Code Snippets plugin to add the code to the plugin.

2023032309060498

Although the above method can add an inquiry button link, its original purchase button is still there. If none of your products are going to be sold online, you can also hide the add to shopping cart button, as shown in the picture above. The shopping cart button is hidden when the site is built. The implementation code is as follows:

//Hide buy button
add_action( 'init', 'woocommerce_hide_buy_button' );
function woocommerce_hide_buy_button(){
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}

Similarly, we can add the above code to the functions.php file of the current wordpress website building theme, or use the Code Snippets plugin to add it.

The method introduced today is relatively simple, and the style of the inquiry button is relatively primitive, which can only be used for improvisation. You can use CSS to modify it later.

继续分享wordpress建站教程。最近做的wordpress建站项目用到了woocommerce插件,而woocommerce插件本身是做商城的,所以它的产品页面默认是购买按扭。但是有些产品可能不适合直接在线销售,或者是你想在购买按扭下面多加一下询盘按扭,那么可以参考下面的方法。


add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );

function my_extra_button_on_product_page() {
  global $product;
  echo '<a class="zsxxfx" href="https://www.aaa.com">Inquiry</a>';
}

你只需要把上面代码中的网址换成你需要指向的地址就可以了,比如可以换成客服工具的聊天链接,或者是换成你的QQ号咨询链接,或者是换成你的第三方网店地址,后面的【Inquiry】则是按钮的名字,你可以根据需要进行修改。代码可以直接添加到当前wordpress建站主题的functions.php文件中,或者是使用Code Snippets插件,把代码添加到插件中即可。

2023032309060498

上面这种方法虽然可以添加一个询盘按钮链接,但是它原来的购买按钮还在,如果你的产品全部都不准备在线销售,那么也可以把添加到购物车的按钮隐藏掉,如上图悦然建站就把购物车按钮隐藏了,实现代码如下:

//Hide buy button
add_action( 'init', 'woocommerce_hide_buy_button' );
function woocommerce_hide_buy_button(){
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}

同样我们可以把上面的代码添加到当前wordpress建站主题的functions.php文件中,或者是使用Code Snippets插件添加。

今天介绍的这种方法比较简单,而且询盘按钮的样式也比较原始,只能凑合用,后续你可以使用CSS来修饰。

WordPress Hosting / 悦然wordpress建站

WordPress Hosting / 悦然wordpress建站

【WordPress Hosting / 悦然wordpress建站】I am a WordPress hobby from China, and I like to communicate with friends from all over the world to learn WordPress website building and maintenance related knowledge.