• Resolved gergeda008

    (@gergeda008)


    Hello everybody,

    I have problems with variable product ( for simple products everything works fine ).

    When the last piece of variation is sold, stock changes to zero but the stock status doesn’t change to out of stock, it changes to backorder…
    If stock is zero and save the product in backend (without changes) the product status changes correctly to ‘sold out’.

    Can anyone help me to fix this?

    Regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    When the last piece of variation is sold, stock changes to zero but the stock status doesn’t change to out of stock, it changes to backorder…

    Could you check if Manage stock is checked and backorders are disabled in your attribute setting? – https://snipboard.io/RlkHUy.jpg

    If this is set correctly and the store is still allowing backorders, the issue may be caused by a conflict with your theme or with another plugin. To determine what’s causing the issue, please temporarily switch your theme to Storefront and disable all plugins except for WooCommerce. If that resolves the issue, then re-enable plugins one-by-one until you find the one that’s causing the conflict.

    Thread Starter gergeda008

    (@gergeda008)

    Hallo @maykato,

    Thanks for responding.

    sorry for my english, i use google translator for this.

    I found a plugin that causing the issue, but i can’t just delete it, that plugin is very important for my site…

    I added a code that does not give
    for the client to choose a backorder variation

    add_filter( 'woocommerce_variation_is_active', 'my_jazzy_function', 10, 2 );
    
    function my_jazzy_function( $active, $variation ) {
    
        $var_stock_count = $variation->get_stock_quantity();
    
        
        if( $var_stock_count <= 0 ) {
           return false;
        }
        else {
           return true;
        }
    }

    maybe there is a way to hide backorder items from the catalog? i think it would solve my problem.

    Thanks for any help.

    • This reply was modified 3 years, 10 months ago by gergeda008.
    Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    I’m not aware of any off-the-shelf extensions that would allow for that although if the plugin you’re using is causing the issue, have you considered reaching out to its developer(s) to troubleshooting that in more detail?

    Thread Starter gergeda008

    (@gergeda008)

    hallo @riaanknoetze

    that plugin is no longer supported…

    I found a code that hides out of stock items from the catalog ( without this option enabled in the woocommerce settings ).

    add_action( 'pre_get_posts', 'njengah_hide_out_of_stock_products' );
     
    function njengah_hide_out_of_stock_products( $query ) {
     
      if ( ! $query->is_main_query() || is_admin() ) {
        return;
      }
     
         if ( $outofstock_term = get_term_by( 'name', 'outofstock', 'product_visibility' ) ) {
     
         $tax_query = (array) $query->get('tax_query');
     
          $tax_query[] = array(
          'taxonomy' => 'product_visibility',
          'field' => 'term_taxonomy_id',
          'terms' => array( $outofstock_term->term_taxonomy_id ),
          'operator' => 'NOT IN'
       );
     
      $query->set( 'tax_query', $tax_query );
     
    }
     
      remove_action( 'pre_get_posts', 'njengah_hide_out_of_stock_products' );
     
    }

    this code works fine for out of stock items,
    can you help remake it for backorder?

    Regards

    • This reply was modified 3 years, 10 months ago by gergeda008.
    Thread Starter gergeda008

    (@gergeda008)

    you could just answer “no, we cannot help you with this” so that I do not wait in vain for an answer, it is very offensive when someone ignores you….

    hope your support is more respectful for other customers.

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack.

    Thread Starter gergeda008

    (@gergeda008)

    hallo @maykato ,Thanks for your attention.

    I do not think that anyone here will help me with this question, i will try to find the answer in other forums.

    Regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Stock status doesn’t change to out of stock if stock is zero’ is closed to new replies.