Home Forums WoodMart support forum STOCK STATUS FOR PRODUCTS IN DIFFERENT CATEGORIES

STOCK STATUS FOR PRODUCTS IN DIFFERENT CATEGORIES

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #474896

    techpixelshop
    Participant

    Hello 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! 🙂

    #475067

    Luke Nielsen
    Keymaster

    Hello,

    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

    #475821

    techpixelshop
    Participant

    Hello 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.
    #476029

    Luke Nielsen
    Keymaster

    Hello,

    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

Viewing 4 posts - 1 through 4 (of 4 total)