WC_Post_Data::wp_insert_post_data PHP Method

wp_insert_post_data() public static method

Forces certain product data based on the product's type, e.g. grouped products cannot have a parent.
public static wp_insert_post_data ( array $data ) : array
$data array
return array
    public static function wp_insert_post_data($data)
    {
        if ('shop_order' === $data['post_type'] && isset($data['post_date'])) {
            $order_title = 'Order';
            if ($data['post_date']) {
                $order_title .= ' – ' . date_i18n('F j, Y @ h:i A', strtotime($data['post_date']));
            }
            $data['post_title'] = $order_title;
        } elseif ('product' === $data['post_type'] && isset($_POST['product-type'])) {
            $product_type = stripslashes($_POST['product-type']);
            switch ($product_type) {
                case 'grouped':
                case 'variable':
                    $data['post_parent'] = 0;
                    break;
            }
        }
        return $data;
    }