GBO
-
Posts
3 -
Joined
-
Last visited
Posts posted by GBO
-
-
Brilliant. You are so skilful.
It all works.
Thank you very much.
Gary
-
Hello
I hope you can help.
I have a WordPress Woocommerce website where I've added a short code snippet to change the standard "No products Found" message. At the bottom of the message, I would like to add a short code form which has been produced through the WPForms plugin.
The PHP code as below:
<?php
add_action( 'woocommerce_no_products_found', function(){
remove_action( 'woocommerce_no_products_found', 'wc_no_products_found', 10 );
// HERE change your message below
$message = __( 'Adding parts to the site is an ongoing effort. The part you’re searching for may be within our range but not yet uploaded. If you are unable to find what you are looking for, please fill in our contact form below. Alternatively, email us at sales@crushersparesltd.co.uk , call us on 0044 1443 228329 or via contact us via WhatsApp on 0044 732473727.', 'woocommerce' );
echo '
' . $message .'';
}, 9 );The WPForms shortcode: [wpforms id="1385"].
You can view the message through this link https://www.offershubdirect.com/product-category/model/lt106/.
I have attached an image of what I'm looking for.
Gary
Adding a short code form in WooCommerce Category pages only
in Applications
Posted
Hello
This forum has been a great help in the past.
I have another query.
I'm looking to add a contact form to appear under the contents of the WooCommerce Category pages only - not to appear in the product pages. I'm using the following code to display the form:
add_action( 'woocommerce_after_main_content', function(){
// Title
$header = "<br><b>Contact Us</b><br>";
// Message
$text = "<p>Please do not hesitate to contact us with queries you may have</p><br>";
// WPForms shortcode
$wpforms_shortcode = do_shortcode('[wpforms id="1385"]');
// Output combined message and form
echo '
' . $header .'
' . $text .'
' . $wpforms_shortcode .'
';
}, 9 );
The result can be viewed here:
https://www.offershubdirect.com/product-category/parts-services/
However, using the above code also makes the form appear at the bottom of the product pages (https://www.offershubdirect.com/product/2370-9085-terex-pegson-1412-blow-bar-hammers-chrome/) - no surprise here. How do I prevent the form from appearing on the product pages?
Any help or guidance is appreciated.
Gary