/** * Variation list creation */ function ajax_add_new_variation_list() { check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); global $wpdb; $attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? $_POST['wpshop_attribute_to_use_for_variation'] : null; $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; /** Get the list of values of the attribute to affect to a variation */ $var = array(); foreach ($attributes_for_variation as $attribute_code) { $query = $wpdb->prepare("SELECT data_type_to_use FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code); $var[$attribute_code] = wpshop_attributes::get_affected_value_for_list($attribute_code, $current_post_id, $wpdb->get_var($query)); } $possible_variations = wpshop_tools::search_all_possibilities($var); wpshop_products::creation_variation_callback($possible_variations, $current_post_id); $output = wpshop_products::display_variation_admin($current_post_id); echo $output; die; }