post_type || ! self::is_enabled() ) { return $payload; } $variations = get_posts( array( 'post_parent' => $post->ID, 'post_type' => 'product_variation', 'post_status' => 'any', 'numberposts' => -1, 'orderby' => 'ID', 'order' => 'ASC', ) ); $variation_data = array(); foreach ( $variations as $variation ) { $meta = get_post_meta( $variation->ID ); if ( is_array( $meta ) ) { unset( $meta['_edit_lock'], $meta['_edit_last'] ); ksort( $meta ); } $variation_data[ $variation->ID ] = array( 'post_name' => $variation->post_name, 'post_title' => $variation->post_title, 'post_status' => $variation->post_status, 'menu_order' => (int) $variation->menu_order, 'meta' => $meta, ); } $payload['wc_variations'] = $variation_data; $product = function_exists( 'wc_get_product' ) ? wc_get_product( $post->ID ) : null; if ( $product ) { $payload['wc_product'] = array( 'type' => $product->get_type(), 'sku' => $product->get_sku( 'edit' ), 'regular_price' => $product->get_regular_price( 'edit' ), 'sale_price' => $product->get_sale_price( 'edit' ), 'stock' => $product->get_stock_quantity( 'edit' ), 'stock_status' => $product->get_stock_status( 'edit' ), 'category_ids' => $product->get_category_ids( 'edit' ), 'children' => $product->get_children( 'edit' ), ); } return $payload; } }