Issue with display off variable products created programattically
-
I’ll try keep as brief as I can – developing my own plugin which creates variable products on the fly.
When created and then viewed on frontend I get the “This product is currently out of stock and unavailable.” message. Everything else is all good and product appears fine in admin etc, I’m running
WC_Product_Variable::sync( $new_parent_product_id );
and it’s doing all that I’d expect. If I update the product in admin without altering anything then it displays fine on the frontend.Working back through the product templates to variable.php I see that $available_variations in there is empty. Digging into class-wc-product-variable.php noticed when I log $this->children in there the get_children function a product that’s not displaying returns:
$this->children in get_children : Array ( [all] => Array ( ) [visible] => Array ( [0] => 550 [1] => 551 ) )
Once I save/update in the admin and it displays right I get:
$this->children in get_children : Array ( [visible] => Array ( [0] => 550 [1] => 551 ) [all] => Array ( [0] => 550 [1] => 551 ) )
At this point I’m stumped and get a bit lost in the code! I just can’t see what’s causing the [all] array to be empty (or why array keys are reversed)??
Massively appreciate any further pointers, have been stumped for hours & hours on this!
Cheers,
Steve
- The topic ‘Issue with display off variable products created programattically’ is closed to new replies.