/**
  * Get posted data from the checkout form.
  *
  * @since  2.7.0
  * @return array of data and errors.
  */
 protected function get_posted_data()
 {
     $data = array('terms' => (int) isset($_POST['terms']), 'createaccount' => (int) (!empty($_POST['createaccount'])), 'payment_method' => isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : '', 'shipping_method' => isset($_POST['shipping_method']) ? wc_clean($_POST['shipping_method']) : '', 'ship_to_different_address' => !empty($_POST['ship_to_different_address']) && !wc_ship_to_billing_address_only(), 'woocommerce_checkout_update_totals' => isset($_POST['woocommerce_checkout_update_totals']));
     foreach ($this->get_checkout_fields() as $fieldset_key => $fieldset) {
         if ($this->maybe_skip_fieldset($fieldset_key, $data)) {
             continue;
         }
         foreach ($fieldset as $key => $field) {
             $type = sanitize_title(isset($field['type']) ? $field['type'] : 'text');
             switch ($type) {
                 case 'checkbox':
                     $value = (int) isset($_POST[$key]);
                     break;
                 case 'multiselect':
                     $value = isset($_POST[$key]) ? implode(', ', wc_clean($_POST[$key])) : '';
                     break;
                 case 'textarea':
                     $value = isset($_POST[$key]) ? wc_sanitize_textarea($_POST[$key]) : '';
                     break;
                 default:
                     $value = isset($_POST[$key]) ? wc_clean($_POST[$key]) : '';
                     break;
             }
             $data[$key] = apply_filters('woocommerce_process_checkout_' . $type . '_field', apply_filters('woocommerce_process_checkout_field_' . $key, $value));
         }
     }
     return $data;
 }
 /**
  * Save meta box data.
  *
  * @param int $post_id
  * @param WP_Post $post
  */
 public static function save_variations($post_id, $post)
 {
     if (isset($_POST['variable_post_id'])) {
         $parent = wc_get_product($post_id);
         $max_loop = max(array_keys($_POST['variable_post_id']));
         $data_store = $parent->get_data_store();
         $data_store->sort_all_product_variations($parent->get_id());
         for ($i = 0; $i <= $max_loop; $i++) {
             if (!isset($_POST['variable_post_id'][$i])) {
                 continue;
             }
             $variation_id = absint($_POST['variable_post_id'][$i]);
             $variation = new WC_Product_Variation($variation_id);
             $errors = $variation->set_props(array('status' => isset($_POST['variable_enabled'][$i]) ? 'publish' : 'private', 'menu_order' => wc_clean($_POST['variation_menu_order'][$i]), 'regular_price' => wc_clean($_POST['variable_regular_price'][$i]), 'sale_price' => wc_clean($_POST['variable_sale_price'][$i]), 'virtual' => isset($_POST['variable_is_virtual'][$i]), 'downloadable' => isset($_POST['variable_is_downloadable'][$i]), 'date_on_sale_from' => wc_clean($_POST['variable_sale_price_dates_from'][$i]), 'date_on_sale_to' => wc_clean($_POST['variable_sale_price_dates_to'][$i]), 'description' => wp_kses_post(wc_sanitize_textarea($_POST['variable_description'][$i])), 'download_limit' => wc_clean($_POST['variable_download_limit'][$i]), 'download_expiry' => wc_clean($_POST['variable_download_expiry'][$i]), 'downloads' => self::prepare_downloads(isset($_POST['_wc_variation_file_names'][$variation_id]) ? $_POST['_wc_variation_file_names'][$variation_id] : array(), isset($_POST['_wc_variation_file_urls'][$variation_id]) ? $_POST['_wc_variation_file_urls'][$variation_id] : array(), isset($_POST['_wc_variation_file_hashes'][$variation_id]) ? $_POST['_wc_variation_file_hashes'][$variation_id] : array()), 'manage_stock' => isset($_POST['variable_manage_stock'][$i]), 'stock_quantity' => wc_clean($_POST['variable_stock'][$i]), 'backorders' => wc_clean($_POST['variable_backorders'][$i]), 'stock_status' => wc_clean($_POST['variable_stock_status'][$i]), 'image_id' => wc_clean($_POST['upload_image_id'][$i]), 'attributes' => self::prepare_set_attributes($parent->get_attributes(), 'attribute_', $i), 'sku' => isset($_POST['variable_sku'][$i]) ? wc_clean($_POST['variable_sku'][$i]) : '', 'weight' => isset($_POST['variable_weight'][$i]) ? wc_clean($_POST['variable_weight'][$i]) : '', 'length' => isset($_POST['variable_length'][$i]) ? wc_clean($_POST['variable_length'][$i]) : '', 'width' => isset($_POST['variable_width'][$i]) ? wc_clean($_POST['variable_width'][$i]) : '', 'height' => isset($_POST['variable_height'][$i]) ? wc_clean($_POST['variable_height'][$i]) : '', 'shipping_class_id' => wc_clean($_POST['variable_shipping_class'][$i]), 'tax_class' => wc_clean($_POST['variable_tax_class'][$i])));
             if (is_wp_error($errors)) {
                 WC_Admin_Meta_Boxes::add_error($errors->get_error_message());
             }
             $variation->save();
             do_action('woocommerce_save_product_variation', $variation_id, $i);
         }
     }
 }