• Resolved audiomag

    (@audiomag)


    Hello. Thank you for this plugin. Actually I have a problem with stock display in search results.

    The products “in-backorder” are displayed as if they were actually in stock.

    But on my website, I have three levels of stock display.

    1/ In stock.
    2/ On command. (backorder)
    3/ Out of stock.

    Is it possible to take advantage of its three different degrees in the same way in search results?

    Thank you.

    • This topic was modified 5 years, 2 months ago by audiomag.
    • This topic was modified 5 years, 2 months ago by audiomag.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Please go to plugin settings page and set ‘Show out-of-stock’ option to ‘Hide’.
    This must help you.

    Regards

    Thread Starter audiomag

    (@audiomag)

    Hello, thanks for your reply.

    Unfortunately this currently does not really solve the problem in my case. Products whose orders are authorized while they are being restocked. Always displays the status in stock in green color while the message of the product sheet is: low stock in orange color with the message contact us.

    I miss this degree “backorder” between the “in stock” and the product “out of stock”.

    As this option is proposed by woocommerce I use it but without being able to match it to the way the plugin manages the display of stock.

    I hope there may be another solution!

    • This reply was modified 5 years, 2 months ago by audiomag.
    Plugin Author ILLID

    (@mihail-barinov)

    In this case please use following code snippet

    add_filter( 'aws_search_pre_filter_products', 'my_aws_search_pre_filter_products' );
    function my_aws_search_pre_filter_products( $products_array ) {
        if ( $products_array && ! empty( $products_array ) ) {
            foreach ( $products_array as $key => $product ) {
                if ( $product['stock_status'] && isset( $product['stock_status']['status'] ) && $product['stock_status']['status']) {
    
                    $product_obj = wc_get_product( $product['id'] );
    
                    if ( $product_obj->is_on_backorder() ) {
                        $products_array[$key]['stock_status']['text'] = esc_html__( 'On backorder', 'advanced-woo-search' );
                    }
    
                }
            }
        }
        return $products_array;
    }
    Thread Starter audiomag

    (@audiomag)

    A big thank you indeed there it works very well it is perfect.

    I have now 2 problematic little details.

    How to translate “backorder” into French?

    I did not find the term “backorder” in locotraslate.

    How to change your font color. I see that the css is the same as for in stock suddenly it changes me the color of “In stock” and “Backorder” simultaneously.

    If you could help me on these last two points I would be the happiest of men!

    Thread Starter audiomag

    (@audiomag)

    I found the first one by editing the code.
    I now just block on the css color.
    For that I cannot find alone.

    Plugin Author ILLID

    (@mihail-barinov)

    For color change please replace code line

    $products_array[$key]['stock_status']['text'] = esc_html__( 'On backorder', 'advanced-woo-search' );

    with

    $products_array[$key]['stock_status']['text'] = '<span style="color:#eaa600;">' . esc_html__( 'On backorder', 'advanced-woo-search' ) . '</span>';

    Thread Starter audiomag

    (@audiomag)

    That’s it, everything is perfect. It’s really great. Thank you so much for this precious help.

    Thread Starter audiomag

    (@audiomag)

    Close. thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to display backorder products correctly ?’ is closed to new replies.