2013-08-06 10:41:20 +00:00
< ? php
/**
2015-11-03 13:53:50 +00:00
* Product Data
2013-08-06 10:41:20 +00:00
*
* Displays the product data box , tabbed , with several panels covering price , stock etc .
*
2015-07-02 20:42:22 +00:00
* @ author WooThemes
* @ category Admin
* @ package WooCommerce / Admin / Meta Boxes
2017-03-15 16:36:53 +00:00
* @ version 3.0 . 0
2013-08-06 10:41:20 +00:00
*/
2014-06-27 13:08:39 +00:00
if ( ! defined ( 'ABSPATH' ) ) {
2016-10-26 17:02:50 +00:00
exit ;
2014-06-27 13:08:39 +00:00
}
2013-08-06 10:41:20 +00:00
/**
2015-11-03 12:28:01 +00:00
* WC_Meta_Box_Product_Data Class .
2013-08-06 10:41:20 +00:00
*/
class WC_Meta_Box_Product_Data {
/**
2015-11-03 12:28:01 +00:00
* Output the metabox .
2016-01-04 21:31:36 +00:00
*
* @ param WP_Post $post
2013-08-06 10:41:20 +00:00
*/
public static function output ( $post ) {
2016-10-27 13:08:16 +00:00
global $post , $thepostid , $product_object ;
2013-08-06 10:41:20 +00:00
2016-10-26 17:02:50 +00:00
$thepostid = $post -> ID ;
2016-10-27 13:08:16 +00:00
$product_object = $thepostid ? wc_get_product ( $thepostid ) : new WC_Product ;
2013-08-06 10:41:20 +00:00
2016-10-27 13:08:16 +00:00
include ( 'views/html-product-data-panel.php' );
}
2014-08-31 07:18:21 +00:00
2016-10-27 13:08:16 +00:00
/**
* Show tab content / settings .
*/
private static function output_tabs () {
global $post , $thepostid , $product_object ;
include ( 'views/html-product-data-general.php' );
include ( 'views/html-product-data-inventory.php' );
include ( 'views/html-product-data-shipping.php' );
include ( 'views/html-product-data-linked-products.php' );
include ( 'views/html-product-data-attributes.php' );
include ( 'views/html-product-data-advanced.php' );
}
2013-08-06 10:41:20 +00:00
2016-10-27 13:08:16 +00:00
/**
* Return array of product type options .
* @ return array
*/
private static function get_product_type_options () {
return apply_filters ( 'product_type_options' , array (
2013-08-06 10:41:20 +00:00
'virtual' => array (
2013-08-17 00:55:05 +00:00
'id' => '_virtual' ,
2013-08-06 10:41:20 +00:00
'wrapper_class' => 'show_if_simple' ,
2013-08-17 00:55:05 +00:00
'label' => __ ( 'Virtual' , 'woocommerce' ),
'description' => __ ( 'Virtual products are intangible and aren\'t shipped.' , 'woocommerce' ),
2016-08-27 01:46:45 +00:00
'default' => 'no' ,
2013-08-06 10:41:20 +00:00
),
'downloadable' => array (
2013-08-17 00:55:05 +00:00
'id' => '_downloadable' ,
2013-08-06 10:41:20 +00:00
'wrapper_class' => 'show_if_simple' ,
2013-08-17 00:55:05 +00:00
'label' => __ ( 'Downloadable' , 'woocommerce' ),
'description' => __ ( 'Downloadable products give access to a file upon purchase.' , 'woocommerce' ),
2016-08-27 01:46:45 +00:00
'default' => 'no' ,
),
2013-08-06 10:41:20 +00:00
) );
2016-10-27 13:08:16 +00:00
}
2013-08-06 10:41:20 +00:00
2016-10-27 13:08:16 +00:00
/**
* Return array of tabs to show .
* @ return array
*/
private static function get_product_data_tabs () {
2017-02-21 07:34:43 +00:00
$tabs = apply_filters ( 'woocommerce_product_data_tabs' , array (
2016-10-27 13:08:16 +00:00
'general' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'General' , 'woocommerce' ),
'target' => 'general_product_data' ,
'class' => array ( 'hide_if_grouped' ),
'priority' => 10 ,
2016-10-27 13:08:16 +00:00
),
'inventory' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'Inventory' , 'woocommerce' ),
'target' => 'inventory_product_data' ,
'class' => array ( 'show_if_simple' , 'show_if_variable' , 'show_if_grouped' , 'show_if_external' ),
'priority' => 20 ,
2016-10-27 13:08:16 +00:00
),
'shipping' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'Shipping' , 'woocommerce' ),
'target' => 'shipping_product_data' ,
'class' => array ( 'hide_if_virtual' , 'hide_if_grouped' , 'hide_if_external' ),
'priority' => 30 ,
2016-10-27 13:08:16 +00:00
),
'linked_product' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'Linked Products' , 'woocommerce' ),
'target' => 'linked_product_data' ,
'class' => array (),
'priority' => 40 ,
2016-10-27 13:08:16 +00:00
),
'attribute' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'Attributes' , 'woocommerce' ),
'target' => 'product_attributes' ,
'class' => array (),
'priority' => 50 ,
2016-10-27 13:08:16 +00:00
),
'variations' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'Variations' , 'woocommerce' ),
'target' => 'variable_product_options' ,
'class' => array ( 'variations_tab' , 'show_if_variable' ),
'priority' => 60 ,
2016-10-27 13:08:16 +00:00
),
'advanced' => array (
2017-02-21 07:34:43 +00:00
'label' => __ ( 'Advanced' , 'woocommerce' ),
'target' => 'advanced_product_data' ,
'class' => array (),
'priority' => 70 ,
2016-10-27 13:08:16 +00:00
),
) );
2017-02-21 07:34:43 +00:00
2017-04-04 14:40:02 +00:00
// Sort tabs based on priority.
2017-02-21 07:34:43 +00:00
uasort ( $tabs , array ( __CLASS__ , 'product_data_tabs_sort' ) );
return $tabs ;
}
/**
* Callback to sort product data tabs on priority .
2017-04-04 14:40:02 +00:00
*
* @ since 3.1 . 0
* @ param int $a First item .
* @ param int $b Second item .
*
* @ return bool
2017-02-21 07:34:43 +00:00
*/
private static function product_data_tabs_sort ( $a , $b ) {
2017-04-04 14:40:02 +00:00
if ( ! isset ( $a [ 'priority' ], $b [ 'priority' ] ) ) {
return - 1 ;
}
if ( $a [ 'priority' ] == $b [ 'priority' ] ) {
return 0 ;
}
2017-02-21 07:34:43 +00:00
return $a [ 'priority' ] < $b [ 'priority' ] ? - 1 : 1 ;
2016-10-27 13:08:16 +00:00
}
2013-08-06 10:41:20 +00:00
2016-10-27 13:08:16 +00:00
/**
* Filter callback for finding variation attributes .
* @ param WC_Product_Attribute $attribute
* @ return bool
*/
private static function filter_variation_attributes ( $attribute ) {
return true === $attribute -> get_variation ();
2013-08-06 10:41:20 +00:00
}
/**
2015-11-03 12:28:01 +00:00
* Show options for the variable product type .
2013-08-06 10:41:20 +00:00
*/
2013-09-24 15:21:12 +00:00
public static function output_variations () {
2016-10-27 13:08:16 +00:00
global $post , $wpdb , $product_object ;
2013-08-06 10:41:20 +00:00
2016-10-27 13:08:16 +00:00
$variation_attributes = array_filter ( $product_object -> get_attributes (), array ( __CLASS__ , 'filter_variation_attributes' ) );
$default_attributes = $product_object -> get_default_attributes ();
2015-09-02 21:11:28 +00:00
$variations_count = absint ( $wpdb -> get_var ( $wpdb -> prepare ( " SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private') " , $post -> ID ) ) );
2015-09-14 15:54:58 +00:00
$variations_per_page = absint ( apply_filters ( 'woocommerce_admin_meta_boxes_variations_per_page' , 15 ) );
2015-07-06 01:00:38 +00:00
$variations_total_pages = ceil ( $variations_count / $variations_per_page );
2016-10-27 13:08:16 +00:00
include ( 'views/html-product-data-variations.php' );
2013-08-06 10:41:20 +00:00
}
/**
2016-10-26 17:02:50 +00:00
* Prepare downloads for save .
* @ return array
2013-08-06 10:41:20 +00:00
*/
2016-11-18 19:29:37 +00:00
private static function prepare_downloads ( $file_names , $file_urls , $file_hashes ) {
2016-10-26 17:02:50 +00:00
$downloads = array ();
2016-11-02 18:50:42 +00:00
if ( ! empty ( $file_urls ) ) {
2016-10-26 17:02:50 +00:00
$file_url_size = sizeof ( $file_urls );
for ( $i = 0 ; $i < $file_url_size ; $i ++ ) {
if ( ! empty ( $file_urls [ $i ] ) ) {
$downloads [] = array (
2016-11-18 19:29:37 +00:00
'name' => wc_clean ( $file_names [ $i ] ),
'file' => wp_unslash ( trim ( $file_urls [ $i ] ) ),
'previous_hash' => wc_clean ( $file_hashes [ $i ] ),
2016-10-26 17:02:50 +00:00
);
2013-08-06 10:41:20 +00:00
}
}
}
2016-10-26 17:02:50 +00:00
return $downloads ;
}
2014-08-31 07:18:21 +00:00
2016-10-26 17:02:50 +00:00
/**
* Prepare children for save .
* @ return array
*/
private static function prepare_children () {
2016-12-21 13:23:26 +00:00
return isset ( $_POST [ 'grouped_products' ] ) ? array_filter ( array_map ( 'intval' , ( array ) $_POST [ 'grouped_products' ] ) ) : array ();
2016-10-26 17:02:50 +00:00
}
2013-08-06 10:41:20 +00:00
2016-10-26 17:02:50 +00:00
/**
* Prepare attributes for save .
* @ return array
*/
public static function prepare_attributes ( $data = false ) {
$attributes = array ();
2013-08-06 10:41:20 +00:00
2016-10-26 17:02:50 +00:00
if ( ! $data ) {
$data = $_POST ;
}
2013-08-06 10:41:20 +00:00
2016-10-26 17:02:50 +00:00
if ( isset ( $data [ 'attribute_names' ], $data [ 'attribute_values' ] ) ) {
$attribute_names = $data [ 'attribute_names' ];
$attribute_values = $data [ 'attribute_values' ];
$attribute_visibility = isset ( $data [ 'attribute_visibility' ] ) ? $data [ 'attribute_visibility' ] : array ();
$attribute_variation = isset ( $data [ 'attribute_variation' ] ) ? $data [ 'attribute_variation' ] : array ();
$attribute_position = $data [ 'attribute_position' ];
2015-06-05 12:37:45 +00:00
$attribute_names_max_key = max ( array_keys ( $attribute_names ) );
2013-08-06 10:41:20 +00:00
2015-05-19 16:53:00 +00:00
for ( $i = 0 ; $i <= $attribute_names_max_key ; $i ++ ) {
2017-03-02 16:21:20 +00:00
if ( empty ( $attribute_names [ $i ] ) || ! isset ( $attribute_values [ $i ] ) ) {
2013-08-06 10:41:20 +00:00
continue ;
2014-06-27 13:08:39 +00:00
}
2016-10-26 17:02:50 +00:00
$attribute_name = wc_clean ( $attribute_names [ $i ] );
$attribute_id = wc_attribute_taxonomy_id_by_name ( $attribute_name );
$options = isset ( $attribute_values [ $i ] ) ? $attribute_values [ $i ] : '' ;
2013-08-06 10:41:20 +00:00
2016-10-26 17:02:50 +00:00
if ( is_array ( $options ) ) {
// Term ids sent as array.
$options = wp_parse_id_list ( $options );
} else {
// Terms or text sent in textarea.
$options = 0 < $attribute_id ? wc_sanitize_textarea ( wc_sanitize_term_text_based ( $options ) ) : wc_sanitize_textarea ( $options );
$options = wc_get_text_attributes ( $options );
2016-03-09 20:12:19 +00:00
}
2013-08-06 10:41:20 +00:00
2017-03-02 16:21:20 +00:00
if ( empty ( $options ) ) {
continue ;
}
2016-10-26 17:02:50 +00:00
$attribute = new WC_Product_Attribute ();
$attribute -> set_id ( $attribute_id );
$attribute -> set_name ( $attribute_name );
$attribute -> set_options ( $options );
$attribute -> set_position ( $attribute_position [ $i ] );
$attribute -> set_visible ( isset ( $attribute_visibility [ $i ] ) );
$attribute -> set_variation ( isset ( $attribute_variation [ $i ] ) );
$attributes [] = $attribute ;
2014-06-27 13:08:39 +00:00
}
2013-08-06 10:41:20 +00:00
}
2016-10-26 17:02:50 +00:00
return $attributes ;
}
2013-08-06 10:41:20 +00:00
2016-11-02 18:50:42 +00:00
/**
* Prepare attributes for a specific variation or defaults .
* @ param array $all_attributes
* @ param string $key_prefix
* @ param int $index
* @ return array
*/
private static function prepare_set_attributes ( $all_attributes , $key_prefix = 'attribute_' , $index = null ) {
$attributes = array ();
if ( $all_attributes ) {
foreach ( $all_attributes as $attribute ) {
if ( $attribute -> get_variation () ) {
$attribute_key = sanitize_title ( $attribute -> get_name () );
if ( ! is_null ( $index ) ) {
$value = isset ( $_POST [ $key_prefix . $attribute_key ][ $index ] ) ? stripslashes ( $_POST [ $key_prefix . $attribute_key ][ $index ] ) : '' ;
} else {
$value = isset ( $_POST [ $key_prefix . $attribute_key ] ) ? stripslashes ( $_POST [ $key_prefix . $attribute_key ] ) : '' ;
}
$value = $attribute -> is_taxonomy () ? sanitize_title ( $value ) : wc_clean ( $value ); // Don't use wc_clean as it destroys sanitized characters in terms.
$attributes [ $attribute_key ] = $value ;
}
}
}
return $attributes ;
}
2016-10-26 17:02:50 +00:00
/**
* Save meta box data .
*/
public static function save ( $post_id , $post ) {
// Process product type first so we have the correct class to run setters.
2017-04-06 14:56:55 +00:00
$product_type = empty ( $_POST [ 'product-type' ] ) ? WC_Product_Factory :: get_product_type ( $post_id ) : sanitize_title ( stripslashes ( $_POST [ 'product-type' ] ) );
$classname = WC_Product_Factory :: get_product_classname ( $post_id , $product_type ? $product_type : 'simple' );
2017-01-05 16:54:47 +00:00
$product = new $classname ( $post_id );
$attributes = self :: prepare_attributes ();
$errors = $product -> set_props ( array (
2016-11-02 18:50:42 +00:00
'sku' => isset ( $_POST [ '_sku' ] ) ? wc_clean ( $_POST [ '_sku' ] ) : null ,
'purchase_note' => wp_kses_post ( stripslashes ( $_POST [ '_purchase_note' ] ) ),
'downloadable' => isset ( $_POST [ '_downloadable' ] ),
'virtual' => isset ( $_POST [ '_virtual' ] ),
2016-11-30 18:20:18 +00:00
'featured' => isset ( $_POST [ '_featured' ] ),
'catalog_visibility' => wc_clean ( $_POST [ '_visibility' ] ),
2016-12-22 14:41:35 +00:00
'tax_status' => isset ( $_POST [ '_tax_status' ] ) ? wc_clean ( $_POST [ '_tax_status' ] ) : null ,
'tax_class' => isset ( $_POST [ '_tax_class' ] ) ? wc_clean ( $_POST [ '_tax_class' ] ) : null ,
2016-11-02 18:50:42 +00:00
'weight' => wc_clean ( $_POST [ '_weight' ] ),
'length' => wc_clean ( $_POST [ '_length' ] ),
'width' => wc_clean ( $_POST [ '_width' ] ),
'height' => wc_clean ( $_POST [ '_height' ] ),
'shipping_class_id' => absint ( $_POST [ 'product_shipping_class' ] ),
'sold_individually' => ! empty ( $_POST [ '_sold_individually' ] ),
2017-01-03 14:16:58 +00:00
'upsell_ids' => isset ( $_POST [ 'upsell_ids' ] ) ? array_map ( 'intval' , ( array ) $_POST [ 'upsell_ids' ] ) : array (),
'cross_sell_ids' => isset ( $_POST [ 'crosssell_ids' ] ) ? array_map ( 'intval' , ( array ) $_POST [ 'crosssell_ids' ] ) : array (),
2016-11-02 18:50:42 +00:00
'regular_price' => wc_clean ( $_POST [ '_regular_price' ] ),
'sale_price' => wc_clean ( $_POST [ '_sale_price' ] ),
'date_on_sale_from' => wc_clean ( $_POST [ '_sale_price_dates_from' ] ),
'date_on_sale_to' => wc_clean ( $_POST [ '_sale_price_dates_to' ] ),
'manage_stock' => ! empty ( $_POST [ '_manage_stock' ] ),
'backorders' => wc_clean ( $_POST [ '_backorders' ] ),
'stock_status' => wc_clean ( $_POST [ '_stock_status' ] ),
'stock_quantity' => wc_stock_amount ( $_POST [ '_stock' ] ),
'download_limit' => '' === $_POST [ '_download_limit' ] ? '' : absint ( $_POST [ '_download_limit' ] ),
'download_expiry' => '' === $_POST [ '_download_expiry' ] ? '' : absint ( $_POST [ '_download_expiry' ] ),
2016-11-18 19:29:37 +00:00
'downloads' => self :: prepare_downloads (
isset ( $_POST [ '_wc_file_names' ] ) ? $_POST [ '_wc_file_names' ] : array (),
isset ( $_POST [ '_wc_file_urls' ] ) ? $_POST [ '_wc_file_urls' ] : array (),
isset ( $_POST [ '_wc_file_hashes' ] ) ? $_POST [ '_wc_file_hashes' ] : array ()
),
2016-11-02 18:50:42 +00:00
'product_url' => esc_url_raw ( $_POST [ '_product_url' ] ),
'button_text' => wc_clean ( $_POST [ '_button_text' ] ),
'children' => 'grouped' === $product_type ? self :: prepare_children () : null ,
'reviews_allowed' => ! empty ( $_POST [ '_reviews_allowed' ] ),
'attributes' => $attributes ,
'default_attributes' => self :: prepare_set_attributes ( $attributes , 'default_attribute_' ),
2016-10-26 17:02:50 +00:00
) );
2013-08-06 10:41:20 +00:00
2016-10-26 17:02:50 +00:00
if ( is_wp_error ( $errors ) ) {
WC_Admin_Meta_Boxes :: add_error ( $errors -> get_error_message () );
2014-06-19 11:25:07 +00:00
}
2013-08-06 10:41:20 +00:00
2017-01-23 10:20:09 +00:00
/**
2017-03-15 16:36:53 +00:00
* @ since 3.0 . 0 to set props before save .
2017-01-23 10:20:09 +00:00
*/
do_action ( 'woocommerce_admin_process_product_object' , $product );
2016-10-26 17:02:50 +00:00
$product -> save ();
2015-06-16 14:10:53 +00:00
2017-01-04 15:18:02 +00:00
if ( $product -> is_type ( 'variable' ) ) {
$product -> get_data_store () -> sync_variation_names ( $product , wc_clean ( $_POST [ 'original_post_title' ] ), wc_clean ( $_POST [ 'post_title' ] ) );
}
2013-08-06 10:41:20 +00:00
do_action ( 'woocommerce_process_product_meta_' . $product_type , $post_id );
}
/**
2015-11-03 12:28:01 +00:00
* Save meta box data .
2015-07-06 04:50:20 +00:00
*
2016-01-04 21:31:36 +00:00
* @ param int $post_id
* @ param WP_Post $post
2013-08-06 10:41:20 +00:00
*/
public static function save_variations ( $post_id , $post ) {
2016-11-02 18:50:42 +00:00
if ( isset ( $_POST [ 'variable_post_id' ] ) ) {
2016-12-08 14:28:51 +00:00
$parent = wc_get_product ( $post_id );
2016-12-13 20:03:00 +00:00
$parent -> set_default_attributes ( self :: prepare_set_attributes ( $parent -> get_attributes (), 'default_attribute_' ) );
$parent -> save ();
2016-12-08 14:28:51 +00:00
$max_loop = max ( array_keys ( $_POST [ 'variable_post_id' ] ) );
$data_store = $parent -> get_data_store ();
$data_store -> sort_all_product_variations ( $parent -> get_id () );
2013-08-06 10:41:20 +00:00
for ( $i = 0 ; $i <= $max_loop ; $i ++ ) {
2016-11-02 18:50:42 +00:00
if ( ! isset ( $_POST [ 'variable_post_id' ][ $i ] ) ) {
2013-08-06 10:41:20 +00:00
continue ;
2014-06-19 15:47:04 +00:00
}
2016-11-02 18:50:42 +00:00
$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 ] ),
2017-04-06 16:21:34 +00:00
'description' => wp_kses_post ( $_POST [ 'variable_description' ][ $i ] ),
2016-11-02 18:50:42 +00:00
'download_limit' => wc_clean ( $_POST [ 'variable_download_limit' ][ $i ] ),
'download_expiry' => wc_clean ( $_POST [ 'variable_download_expiry' ][ $i ] ),
2016-11-18 19:29:37 +00:00
'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 ()
),
2016-11-02 18:50:42 +00:00
'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 ] ),
2016-12-22 14:41:35 +00:00
'tax_class' => isset ( $_POST [ 'variable_tax_class' ][ $i ] ) ? wc_clean ( $_POST [ 'variable_tax_class' ][ $i ] ) : null ,
2016-11-02 18:50:42 +00:00
) );
if ( is_wp_error ( $errors ) ) {
WC_Admin_Meta_Boxes :: add_error ( $errors -> get_error_message () );
2014-06-27 13:08:39 +00:00
}
2013-10-01 16:54:29 +00:00
2016-11-02 18:50:42 +00:00
$variation -> save ();
2013-08-06 10:41:20 +00:00
2013-10-21 11:37:27 +00:00
do_action ( 'woocommerce_save_product_variation' , $variation_id , $i );
2013-09-24 15:21:12 +00:00
}
2013-08-06 10:41:20 +00:00
}
}
2014-03-27 23:37:00 +00:00
}