• hello i have this code:

    $product = new WC_Product($product_id);
    					
    					if( !$product->has_child()){
    						
    						
    						
    						
    					} else if( $product->has_child() ){
    							
    								foreach($prod->products->product AS $varition ){
    									
    									$varition_id  = wc_get_product_id_by_sku($varition->sku);
    									if($varition_id != 0){
    											$varition_for_up = new WC_Product_Variable( $varition_id );
    									
    											if($varition->available != $varition_for_up->get_stock_quantity()){
    												$varition_for_up->set_stock($varition->available );
    											}
    									}
    									
    								
    										
    								
    								}
    					 
    					 
    					}

    for some reason set_stock function is not working…
    any idea?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘add stock from plugin’ is closed to new replies.