🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

How to add an inquiry button below the WooCommerce shopping button?

Many friends building Foreign Trade Independent Websites use the WooCommerce Plugin for their product system. Some B2B websites wish to add a contact button or inquiry button on the product page. Previously, we introducedseveral inquiry button plugins. This article shareshow to use code to add a custom button below the WooCommerce Add to Cart buttonWooCommerce页面新增按钮The effect is as shown above, adding a button with customizable text and link below the Add to Cart button.Usage Method:Copy the code below and paste it into your Theme's functions.php file.
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="naibabutton" href="https://blog.naibabiji.com">Contact us immediately</a>';
}
After saving, you will see a „Contact us immediately“ button on your website„s Frontend, but it won“t have any styling yet. You can customize the style of `.naibabutton` in your Theme„s CSS. If you don“t know how, simply copy and add the following code snippet.
.naibabutton {
    color: #111;
    background-color: rgba(0,0,0,0.1);
    border-style: solid;
    border-width: 1px 1px 1px 1px;
    border-color: #009688;
    padding: 10px;
}
Don't want to figure it out? Pay to have it solved.Contact Me

Add an Amazon Redirect Button

Many foreign trade companies have Amazon stores, so they want to add a button on their independent website's product page that redirects to their Amazon store. There are three methods to achieve this function. 1. Insert a button when filling in the product short description. 2. Add code using a method similar to the inquiry button shared above. 3. Use a Plugin.Code Method:Here, I use a Custom Field to add it. First, add a Custom Field on the WooCommerce product page, for example, `amazon_link`, and then fill in the Amazon URL in the value of `amazon_link`. Next, add the following code to the Theme file, and it can be used directly.Code SnippetsPlugin Method.
add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );

function my_extra_button_on_product_page() {
global $product;
if ( get_post_meta(get_the_ID(), 'amazon_link', true) ){
echo '<a class="amazon-button" href="'.get_post_meta(get_the_ID(), 'amazon_link', true).'" target="_blank">Buy on Amazon</a>';
}

}
add_action( 'wp_head', function () { ?>
<style>
.product-desc li:before {
content: "\f112";
font: normal normal normal 16px/1 LineAwesome;
color: #f0494c;
}
.product-desc li {
list-style: none;
padding-bottom: 7px;
}
.product-desc ul {
padding-left: 0px;
}
</style>
<?php } );
After saving, products that have an Amazon URL filled in will display an Amazon button on the Frontend, while those without will not show it.Plugin Method:[vk-content] Install aQuick Buy Now Button for WooCommercePlugin. Then, when editing a WooCommerce product, a corresponding settings box will appear.Fill in "buy on amazon" yourself, then choose a custom page for the redirect, enter the URL below. After publishing the product, a button redirecting to Amazon will appear. If you don't change the link yourself, it will just add a quick buy button. [/vk-content]

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step.

「Naibabiji WordPress Website Building Coaching Service」—From choosing a domain and buying hosting, to installing a Theme and publishing content, I「ll coach you through every step, helping you avoid detours and reach your goal directly.

👉 Learn about the Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan QR Code to Follow

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: