• Resolved msbbill115

    (@msbbill115)


    Hi!

    Great plugin!!!

    When I create a Variable product with multiple variations having different stock levels at various locations, the Admin Stock column shows Out of stock. The Stock at Locations column gives correct details.

    Do you have a code fix for that?

    Also, if it is a variable product, is there a way to prevent it from displaying the base product inventory, since all purchasable options are connected to product variants? It’s taking up unnecessary space in a tiny column.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @msbbill115

    Can you try this code?

    Also, if it is a variable product, is there a way to prevent it from displaying the base product inventory, since all purchasable options are connected to product variants? It’s taking up unnecessary space in a tiny column.

    Currently I don’t have a solution for that.

    I have 2 fixes to integrate for this and another related issue.
    1. In file src/classes/class-slw-stock-locations-tab.php, at line 305, the system should update the parent stock status after updating the variations, so add the last line after the loop:

    foreach( $product_variations as $variation ) {
    	$variation_id = $variation['variation_id'];
    	$this->update_product_meta($variation_id, $product_stock_location_terms, $terms_total);
    }
    SlwProductHelper::update_wc_stock_status( $post_id );

    2. At line 388, the system updates the stock status only if there are terms, but it should update also if we remove all quantities, so I’ve commented out the “if” statement:

    // Check if stock in terms exist
    //if( ! empty( $product_terms_stock ) ) {
    	// update stock status
    	SlwProductHelper::update_wc_stock_status( $id, array_sum($input_amounts) );
    //}

    A similar thing happens when a customer runs out all variations, and the parent is not updated remaining as available. To fix this, edit the file src/helpers/helper-slw-order-item.php adding the first line of code in the “if” statement already present at line 136:

    // allow other functions to deduct WC stock on the main variation product
    if( $mainProduct->get_type() == 'variation' ) {
    	SlwProductHelper::update_wc_stock_status( $mainProduct->get_parent_id() );
    	do_action( 'slw_allow_variation_product_stock_reduce', $mainProduct->get_parent_id() );
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Admin Out-of-Stock on Variable Products’ is closed to new replies.