Home › Forums › WoodMart support forum › STOCK STATUS FOR PRODUCTS IN DIFFERENT CATEGORIES
STOCK STATUS FOR PRODUCTS IN DIFFERENT CATEGORIES
- This topic has 3 replies, 2 voices, and was last updated 1 year, 8 months ago by
Luke Nielsen.
-
AuthorPosts
-
June 14, 2023 at 3:02 pm #474896
techpixelshopParticipantHello and have a nice day!
I’m developing an eshop and want to add a different text in products based on their categories.
I added a code and succeedded to add a text in Greek “Διαθέσιμο σε 7-15 εργάσιμες” in the products of one. But when I used the same code by changing the category slug and text to “Άμεσα Διαθέσιμο” for the products of the other category it didn’t work.
The code I used is this:
// Προσθέστε το λεκτικό “Διαθέσιμο σε 7-15 εργάσιμες” σε μια κατηγορία προϊόντων
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘add_custom_stock_status_to_category’, 10 );function add_custom_stock_status_to_category() {
global $product;$categories = get_the_terms( $product->get_id(), ‘product_cat’ );
if ( $product->is_in_stock() && ! empty( $categories ) ) {
foreach ( $categories as $category ) {
if ( $category->slug === ‘shipping-7-15-business-days’ ) {
echo ‘<span class=”stock-status”>Διαθέσιμο σε 7-15 εργάσιμες</span>’;
break;
}
}
}
}and then changed the slug and text for the other category but didn’t work as in the first one.
Should I change this part maybe add_custom_stock_status_to_category’, 10 ) with 20 at the end?
Thanx in advance for any help! 🙂June 15, 2023 at 9:58 am #475067
Luke NielsenKeymasterHello,
May I request you send some screenshots for a better understanding of where you want to show that text?
Looking forward to hearing back from you!
Kind Regards
June 19, 2023 at 11:27 am #475821
techpixelshopParticipantHello again and thank you very much for your reply!
I need the text to be added above as shown in the screenshots for the other category products I mentioned above.
For the category ‘Quick Shipping’ Ι need to add the text “Άμεσα Διαθέσιμο” in the same position.
Hope I made it more clear for you now, let me know if you need further explanation 🙂Best regards
Attachments:
You must be logged in to view attached files.June 20, 2023 at 11:19 am #476029
Luke NielsenKeymasterHello,
Thank you for the explanation.
Sorry to say but right now there is no option in Theme Settings available for that. It requires Customization and this is beyond our limitations and support policy scope. Hope you can understand our limitations.
I’d be happy to assist if you have any other questions or concerns.
Kind Regards
-
AuthorPosts
Tagged: adding text to product page
- You must be logged in to create new topics. Login / Register