We provide you with our WooCommerce extension (WordPress) available on our GitLab. Indeed, the extension will allow you to decouple the functionality from your theme. For this, you will be able to change your design if you wish without having to redo the same maneuvers. Download and install on your website. It is however important to note that it is functional with the following conditions:
- First, the extension only works on WordPress sites with WooCommerce installed.
- Then you need to follow the steps below to finalize the setup
As good practice, we will recommend that you do some tests before putting it online. You can, for example, install on a local server or a test website.
How to replace the button using an extension
- First, install and activate the "YITH WooCommerce Request a Quote" extension from your WordPress dashboard.
- Go to "WooCommerce" > "Request a Quote" > "General Options" to configure the extension settings as needed.
- In the "Product settings" tab, you can choose how the quote request form should appear on the product pages. For example, you can choose to display the form on all product pages or only on certain product categories.
- In the "Messages" tab, you can customize the messages that will display when a customer submits a quote request form.
- To replace the add to cart button with a link to the quote request form, go to "WooCommerce" > "Request a Quote" > "Button Replacement Options".
- Enable the "Replace Add to Cart Button" option and select the type of link you want to display. You can choose to display a text link, a button or an icon.
- Customize the link or button text if needed.
- Click "Save Changes" to save your settings.
Now the add to cart button on your WooCommerce product pages will be replaced with a link to the quote request form. Customers will be able to use this form to submit a quote request for the product rather than adding it directly to the cart.
To do it yourself, here are the steps
In this code, the replace_add_to_cart_button_with_form
function retrieves the product ID and creates a link to the custom order form by adding an ID to the product URL. Next, she replaces the "Add to Cart" button with a link to the custom form. You will then need to create the custom form and place it at the location of the ID you added to the URL. For example, if the identifier is #custom-order-form
, you can place the form where you want it to appear on the page by using that identifier in your HTML code.
Leave a comments: