Hi @tanishbaansal ,
Thanks for using our plugin!
Our plugin operates using the default WooCommerce hooks.
To display our sticker on the product listing page, it uses the hook: woocommerce_before_shop_loop_item
.
For the product details page, it uses the hook: woocommerce_before_single_product_summary
.
It appears that your theme’s search results page either does not use these hooks or is overriding them.
If you need to modify the theme code to make it compatible, you can try adjusting it as shown in the sample code below in your child theme’s functions.php file and let us know if it works!
function get_product_badge_html() {
// Ensure this path points to the correct plugin file
$plugin_dir = WP_PLUGIN_DIR . '/woo-stickers-by-webline/public/class-woo-stickers-by-webline-public.php';
// Check if the plugin's class file exists before including it
if (file_exists($plugin_dir)) {
// Include the plugin's public class file
require_once $plugin_dir;
// Instantiate the main class and its public class
$woo_stickers = new Woo_Stickers_By_Webline();
$plugin_public = new Woo_Stickers_By_Webline_Public($woo_stickers->get_plugin_name(), $woo_stickers->get_version());
// Get the current product ID
$product_id = get_the_ID();
// Check if the 'show_product_new_badge' method exists in the public class
if (method_exists($plugin_public, 'show_product_new_badge')) {
// Start output buffering
ob_start();
// Call the method to display the product badge
$plugin_public->show_product_new_badge($product_id);
// Get the buffered output and clean the buffer
$output = ob_get_clean();
// Output the badge HTML
echo $output;
} else {
// Output a message if the method does not exist
echo 'Method show_product_new_badge does not exist.';
}
} else {
// Output a message if the plugin file is not found
echo 'Plugin file not found.';
}
}
// Your theme's search result 'YOUR_THEME_SEARCH_LISTING_PRODUCT_HOOK' action
add_action('YOUR_THEME_SEARCH_LISTING_PRODUCT_HOOK', 'get_product_badge_html');