I am working on a plugin that auto adjusts product prices. All of my products are variable products which has made this tougher than I can solve.
if( $product->is_type( 'variable' ) ){
foreach ( $product->get_available_variations() as $key => $variation ) {
foreach ($variation['attributes'] as $attribute ) {
if ( ! $attribute->get_weight() ) {
I have a check to make sure the product is variable. The only product Attribute is 'Size'. Here I have 4-8 different Size Variations per product. Each of these have a weight value which seemed to be default implemented by Woocommerce. I am unable to get the weight though from each variation. Curious if I am calling get_weight() from the wrong place, or if there is a different method for this. get_weight() of course does not work so I wonder if getting attributes from variations is completely wrong?