This topic has 4 replies, 3 voices, and was last updated 1 months ago ago by Andrew Mitchell
I hope this message finds you well. I am currently trying to add a custom label for products tagged with “Produits occasion” in my WooCommerce shop using the XStore theme. Despite following various tutorials and implementing code snippets in my child theme’s functions.php file, I have not been able to achieve the desired result.
Here’s what I have tried so far:
I added a function to check for the “Produits occasion” tag and display a custom ribbon using the following code: // Add a custom ribbon for products with the tag “Produits occasion”
function add_custom_ribbon_to_product_image() {
global $product;
// Check if the product has the tag “Produits occasion”
if ( has_term( ‘produits-occasion’, ‘product_tag’, $product->get_id() ) ) {
echo ‘
‘;
}
}
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘add_custom_ribbon_to_product_image’, 10 );
I also added custom CSS to style the ribbon and ensure it appears over the product images:
.custom-product-ribbon {
position: absolute;
top: 10px;
left: 10px;
background-color: #FF5733;
color: #fff;
padding: 5px;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
z-index: 10;
}
Could you please assist me with the following:
Confirm whether there is a specific hook I should be using with the XStore theme for this functionality.
Provide any guidance on CSS styles that may be conflicting or overriding my custom styles.
Any additional troubleshooting steps I might not have considered.
Thank you for your support. I look forward to your response!
Dear @Alpha111,
I hope this message finds you well.
We kindly request that you try using the action ‘after_etheme_product_grid_list_product_element_title’ instead of the current one, ‘woocommerce_before_shop_loop_item_title’. The current code is not functioning as expected because your website utilizes the Archive Builder with own Elementor widgets, which does not support all the default hooks of the WooCommerce plugin.
If you require further assistance, please provide us with the correct FTP access so we can review the code and assist you in resolving the issue. Additionally, we checked your child theme’s functions.php file and did not find the snippet you mentioned.
Thank you for your attention to this matter. We look forward to assisting you further.
Best regards,
Jack Richardson
8Theme Team
thanks i found a way arround it to do it
Dear Alpha111,
As we continue our mission to exceed expectations, your insights become increasingly valuable. Could we, with all due respect, request your thoughtful feedback by giving our theme a deserved 5-star rating on ThemeForest?
Click here to share your valuable perspective: https://themeforest.net/downloads
Your time and trust are highly appreciated!
Best Regards,
The 8Theme Team
The issue related to '‘Assistance Needed for Adding Custom Product Labels in XStore Theme’' has been successfully resolved, and the topic is now closed for further responses