/** * Save attributes via ajax. */ public static function save_attributes() { check_ajax_referer('save-attributes', 'security'); if (!current_user_can('edit_products')) { die(-1); } parse_str($_POST['data'], $data); $post_id = absint($_POST['post_id']); $product = wc_get_product($post_id); $attributes = WC_Meta_Box_Product_Data::prepare_attributes($data); $product->set_attributes($attributes); $product->save(); die; }