function wpshop_ajax_admin_variation_parameters() { check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; $output = ''; /* Display variation options */ $options_tpl_component = array(); $head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true); $options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_SINGLE'] = empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && $head_wpshop_variation_definition['options']['priority'][0] == 'single' ? ' checked="checked"' : ''; $options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRIORITY_COMBINED'] = empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['priority'][0]) || !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['priority'][0]) && $head_wpshop_variation_definition['options']['priority'][0] == 'combined' ? ' checked="checked"' : ''; $options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_ADDITION'] = empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && $head_wpshop_variation_definition['options']['price_behaviour'][0] == 'addition' ? ' checked="checked"' : ''; $options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_BEHAVIOUR_REPLACEMENT'] = empty($head_wpshop_variation_definition['options']) || empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) || !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_behaviour'][0]) && $head_wpshop_variation_definition['options']['price_behaviour'][0] == 'replacement' ? ' checked="checked"' : ''; $options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_TEXT_FROM'] = empty($head_wpshop_variation_definition['options']) || !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['text_from']) && $head_wpshop_variation_definition['options']['price_display']['text_from'] == 'on' ? ' checked="checked"' : ''; $options_tpl_component['ADMIN_VARIATION_OPTIONS_SELECTED_PRICE_DISPLAY_LOWER_PRICE'] = empty($head_wpshop_variation_definition['options']) || !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['price_display']['lower_price']) && $head_wpshop_variation_definition['options']['price_display']['lower_price'] == 'on' ? ' checked="checked"' : ''; $options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_PRODUCT_ID'] = $current_post_id; $options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_NOUNCE'] = wp_create_nonce("wpshop_variation_parameters"); $options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] = ''; $attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute($current_post_id); $default_value_for_attributes = $required_attributes = ''; $attribute_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => get_post_type($current_post_id))); if (!empty($attribute_user_defined)) { foreach ($attribute_user_defined as $attribute_def) { $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_def->code; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_def->code; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_def->frontend_label, 'wpshop'); $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ''; $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && in_array($attribute_def->code, $head_wpshop_variation_definition['options']['required_attributes']) ? ' checked="checked"' : ''; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_def->code; $required_attributes .= str_replace('wpshop_attribute_to_use_for_variation', 'wps_pdt_variations[options][required_attributes]', str_replace('variation_attribute_usable', 'variation_attribute_required', wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item', $tpl_component, array(), 'admin'))); } } if (!empty($attribute_list_for_variations['available'])) { $head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true); foreach ($attribute_list_for_variations['available'] as $attribute_code => $attribute_definition) { /** Default value for attribute */ $tpl_component = array(); $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ' variation_attribute_container_default_value_' . $attribute_code; $attribute_for_default_value = wpshop_attributes::get_attribute_field_definition($attribute_definition['attribute_complete_def'], is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : 'none', array('from' => 'frontend', 'field_custom_name_prefix' => 'empty')); switch ($attribute_for_default_value['type']) { case 'select': case 'multiple-select': case 'radio': case 'checkbox': $attribute_for_default_value['type'] = 'select'; break; default: $attribute_for_default_value['type'] = 'text'; break; } if (!empty($attribute_for_default_value['possible_value'])) { $attribute_for_default_value['possible_value']['none'] = __('No default value', 'wpshop'); foreach ($attribute_for_default_value['possible_value'] as $value_id => $value) { if (!empty($value_id) && $value_id != 'none' && !in_array($value_id, $attribute_definition['values'])) { unset($attribute_for_default_value['possible_value'][$value_id]); } } ksort($attribute_for_default_value['possible_value']); $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = $attribute_for_default_value['id']; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf(__('Default value for %s', 'wpshop'), $attribute_for_default_value['label']); $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_INPUT'] = wpshop_form::check_input_type($attribute_for_default_value, 'wps_pdt_variations[options][attributes_default_value]'); $default_value_for_attributes .= wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item_for_default', $tpl_component, array(), 'admin'); } /** Required attribute for variations */ $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_code; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_definition['label'], 'wpshop'); $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ''; $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && in_array($attribute_code, $head_wpshop_variation_definition['options']['required_attributes']) ? ' checked="checked"' : ''; $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_code; $required_attributes .= str_replace('wpshop_attribute_to_use_for_variation', 'wps_pdt_variations[options][required_attributes]', str_replace('variation_attribute_usable', 'variation_attribute_required', wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item', $tpl_component, array(), 'admin'))); } $options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] .= !empty($required_attributes) ? wpshop_display::display_template_element('wpshop_admin_variation_options_required_attribute_container', array('ADMIN_VARIATION_OPTIONS_REQUIRED_ATTRIBUTE' => $required_attributes), array(), 'admin') : ''; $options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] .= !empty($default_value_for_attributes) ? wpshop_display::display_template_element('wpshop_admin_variation_options_default_value_container', array('ADMIN_VARIATION_OPTIONS_ATTRIBUTE_DEFAULT_VALUE' => $default_value_for_attributes), array(), 'admin') : ''; } $output .= wpshop_display::display_template_element('wpshop_admin_variation_options_container', $options_tpl_component, array(), 'admin'); unset($options_tpl_component); echo $output; die; }
/** * Retrieve and display the variation for a given product * @param integer $product_id The product identifier to get variation for */ public static function wpshop_variation($post_id = '', $from_admin = false, $order_id = '', $qty = 1) { global $wp_query; $output = ''; $product_id = empty($post_id) ? $wp_query->post->ID : $post_id; $wpshop_product_attributes_frontend_display = get_post_meta($product_id, '_wpshop_product_attributes_frontend_display', true); $head_wpshop_variation_definition = get_post_meta($product_id, '_wpshop_variation_defining', true); /** Get attribute order for current product */ $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); $output_order = array(); if (count($product_attribute_order_detail) > 0) { if (!empty($product_attribute_order_detail)) { foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { if (!empty($attribute_def->code)) { $output_order[$attribute_def->code] = $position; } } } } } $variations_params = array(); $variation_attribute = array(); $variation_attribute_ordered = array(); $possible_values = array(); $possible_values_for_selection_calculation = array(); /* Vérification de l'existence de déclinaison pour le produit */ $wpshop_variation_list = self::get_variation($product_id); if (!empty($wpshop_variation_list)) { foreach ($wpshop_variation_list as $variation) { if (!empty($variation['variation_def'])) { $display_option = get_post_meta($post_id, '_wpshop_product_attributes_frontend_display', true); foreach ($variation['variation_def'] as $attribute_code => $attribute_value) { if (empty($display_option) || !empty($display_option['attribute']) && !empty($display_option['attribute'][$attribute_code]) && !empty($display_option['attribute'][$attribute_code]['complete_sheet'])) { $tpl_component = array(); $attribute_db_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); $default_value_is_serial = false; $attribute_list_first_element = $attribute_db_definition->default_value; if (!empty($attribute_db_definition->default_value) && ($attribute_db_definition->default_value == serialize(false) || @unserialize($attribute_db_definition->default_value) !== false)) { $default_value_is_serial = true; $tmp_default_value = unserialize($attribute_db_definition->default_value); $attribute_list_first_element = !empty($tmp_default_value['field_options']['label_for_first_item']) ? $tmp_default_value['field_options']['label_for_first_item'] : null; } if ($default_value_is_serial && !empty($attribute_list_first_element) && $attribute_list_first_element != 'none') { $possible_values[$attribute_code][0][0] = $default_value_is_serial && !empty($attribute_list_first_element) && $attribute_list_first_element != 'none' ? stripslashes(sprintf($attribute_list_first_element, strtolower($attribute_db_definition->frontend_label))) : __('Choose a value', 'wpshop'); } if (!empty($attribute_value) && $attribute_db_definition->data_type_to_use == 'custom') { $tpl_component['VARIATION_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', 'custom')); $position = wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'position', 'custom'); } else { if (!empty($attribute_value) && $attribute_db_definition->data_type_to_use == 'internal') { $post_def = get_post($attribute_value); $tpl_component['VARIATION_VALUE'] = stripslashes($post_def->post_title); $position = $post_def->menu_order; } } if (!empty($variation['variation_dif'])) { foreach ($variation['variation_dif'] as $attribute_dif_code => $attribute_dif_value) { $wpshop_prices_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES); $the_value = $attribute_dif_value; if (in_array($attribute_dif_code, $wpshop_prices_attributes)) { $the_value = wpshop_display::format_field_output('wpshop_product_price', $attribute_dif_value); } $tpl_component['VARIATION_DIF_' . strtoupper($attribute_dif_code)] = stripslashes($the_value); } } if (!empty($attribute_value)) { $possible_values[$attribute_code][$position][$attribute_value] = wpshop_display::display_template_element('product_variation_item_possible_values', $tpl_component, array('type' => 'attribute_for_variation', 'id' => $attribute_code)); $possible_values_for_selection_calculation[$attribute_code][$attribute_value] = $tpl_component['VARIATION_VALUE']; } unset($tpl_component); } } } } $variation_tpl = array(); if (!empty($head_wpshop_variation_definition['attributes'])) { foreach ($head_wpshop_variation_definition['attributes'] as $attribute_code) { $attribute_db_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); if (!empty($attribute_db_definition)) { $attribute_display_state = wpshop_attributes::check_attribute_display($attribute_db_definition->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_code, 'complete_sheet'); $is_required = !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && in_array($attribute_code, $head_wpshop_variation_definition['options']['required_attributes']) ? true : false; if (!$is_required && $attribute_db_definition->is_required == 'yes') { $is_required = true; } $input_def = array(); $input_def['type'] = $attribute_db_definition->frontend_input; $value = isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : (!empty($attribute_db_definition->default_value) ? $attribute_db_definition->default_value : null); if (in_array($attribute_db_definition->frontend_input, array('radio', 'checkbox'))) { unset($possible_values[$attribute_code][0]); $value = array($value); } $input_def['id'] = 'wpshop_variation_attr_' . $attribute_code; $input_def['name'] = $attribute_code; $real_possible_values = array(); if (!empty($possible_values[$attribute_code])) { ksort($possible_values[$attribute_code]); foreach ($possible_values[$attribute_code] as $position => $def) { foreach ($def as $attribute_value => $attribute_value_output) { $real_possible_values[$attribute_value] = $attribute_value_output; } } } $input_def['possible_value'] = $real_possible_values; $input_def['valueToPut'] = 'index'; $input_def['value'] = $value; $input_def['options']['more_input'] = ''; if (!empty($possible_values_for_selection_calculation[$attribute_code])) { foreach ($possible_values_for_selection_calculation[$attribute_code] as $value_id => $value) { $input_def['options']['more_input'] .= '<input type="hidden" disabled="disabled" value="' . str_replace("\\", "", $value) . '" name="' . $input_def['id'] . '_current_value" id="' . $input_def['id'] . '_current_value_' . $value_id . '" />'; } } $input_def['options_label']['original'] = true; $input_def['option'] = ' class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_code . ' ' : '') . ($attribute_db_definition->_display_informations_about_value == 'yes' ? ' wpshop_display_information_about_value' : '') . ' ' . (is_admin() ? $attribute_db_definition->backend_css_class : $attribute_db_definition->frontend_css_class) . '" '; if (!empty($real_possible_values)) { $tpl_component = array(); $attribute_output_def['value'] = isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : $input_def['value']; $tpl_component['VARIATION_INPUT'] = wpshop_form::check_input_type($input_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) . $input_def['options']['more_input']; $tpl_component['VARIATION_LABEL'] = $is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_code . '" >' . stripslashes($attribute_db_definition->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_db_definition->frontend_label); $tpl_component['VARIATION_CODE'] = $attribute_code; $tpl_component['VARIATION_LABEL_HELPER'] = !empty($attribute_db_definition->frontend_help_message) ? ' title="' . $attribute_db_definition->frontend_help_message . '" ' : ''; $tpl_component['VARIATION_LABEL_CLASS'] = !empty($attribute_db_definition->frontend_help_message) ? ' wpshop_att_variation_helper' : ''; $tpl_component['VARIATION_IDENTIFIER'] = $input_def['id']; $tpl_component['VARIATION_PARENT_ID'] = $product_id; $tpl_component['VARIATION_PARENT_TYPE'] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT; $tpl_component['VARIATION_CONTAINER_CLASS'] = ($is_required ? ' attribute_is_required_container attribute_is_required_container_' . $attribute_code : '') . ' wpshop_variation_' . $attribute_code . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product_id; $tpl_component['VARIATION_REQUIRED_INDICATION'] = $is_required ? __('Required variation', 'wpshop') : ''; $variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_code)] = wpshop_display::display_template_element('product_variation_item', $tpl_component); $variation_attribute_ordered[$output_order[$attribute_code]] = $variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_code)]; } $variation_attribute[] = $attribute_code; } } } } $variation_tpl['VARIATION_FORM_ELEMENT_ID'] = $product_id; wp_reset_query(); $attribute_defined_to_be_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode)); if (!empty($attribute_defined_to_be_user_defined)) { foreach ($attribute_defined_to_be_user_defined as $attribute_not_in_variation_but_user_defined) { $is_required = !empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && in_array($attribute_not_in_variation_but_user_defined->code, $head_wpshop_variation_definition['options']['required_attributes']) || $attribute_not_in_variation_but_user_defined->is_required == 'yes' ? true : false; $attribute_display_state = wpshop_attributes::check_attribute_display($attribute_not_in_variation_but_user_defined->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_not_in_variation_but_user_defined->code, 'complete_sheet'); if ($attribute_display_state && array_key_exists($attribute_not_in_variation_but_user_defined->code, $output_order) && !in_array($attribute_not_in_variation_but_user_defined->code, $variation_attribute) && $attribute_not_in_variation_but_user_defined->is_used_for_variation == 'no') { $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_not_in_variation_but_user_defined, is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code] : null); $tpl_component = array(); $attribute_output_def['option'] = ' class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_not_in_variation_but_user_defined->code : '') . ' ' . str_replace('"', '', str_replace('class="', '', $attribute_output_def['option'])) . ' ' . (is_admin() ? $attribute_not_in_variation_but_user_defined->backend_css_class : $attribute_not_in_variation_but_user_defined->frontend_css_class) . '" '; $tpl_component['VARIATION_INPUT'] = wpshop_form::check_input_type($attribute_output_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '[free]') . $attribute_output_def['options']; $tpl_component['VARIATION_LABEL'] = $is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_not_in_variation_but_user_defined->code . '" >' . stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_not_in_variation_but_user_defined->frontend_label); $tpl_component['VARIATION_CODE'] = $attribute_not_in_variation_but_user_defined->code; $tpl_component['VARIATION_LABEL_HELPER'] = !empty($attribute_not_in_variation_but_user_defined->frontend_help_message) ? ' title="' . $attribute_not_in_variation_but_user_defined->frontend_help_message . '" ' : ''; $tpl_component['VARIATION_LABEL_CLASS'] = !empty($attribute_not_in_variation_but_user_defined->frontend_help_message) ? ' wpshop_att_variation_helper' : ''; $tpl_component['VARIATION_REQUIRED_INDICATION'] = $is_required ? __('Required variation', 'wpshop') : ''; $tpl_component['VARIATION_IDENTIFIER'] = $attribute_output_def['id']; $tpl_component['VARIATION_PARENT_ID'] = $product_id; $tpl_component['VARIATION_PARENT_TYPE'] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT; $tpl_component['VARIATION_CONTAINER_CLASS'] = ($is_required ? ' attribute_is_required_container attribute_is_required_container_' . $attribute_not_in_variation_but_user_defined->code : '') . ' wpshop_variation_' . $attribute_not_in_variation_but_user_defined->code . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product_id; $variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_not_in_variation_but_user_defined->code)] = $attribute_output_def['type'] != 'hidden' ? wpshop_display::display_template_element('product_variation_item', $tpl_component) : wpshop_form::check_input_type($attribute_output_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '[free]') . $attribute_output_def['options']; $variation_attribute_ordered[$output_order[$attribute_not_in_variation_but_user_defined->code]] = $variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_not_in_variation_but_user_defined->code)]; } } } $variation_tpl['VARIATION_FORM_VARIATION_LIST'] = ''; if (!empty($variation_attribute_ordered) && is_array($variation_attribute_ordered)) { ksort($variation_attribute_ordered); foreach ($variation_attribute_ordered as $attribute_variation_to_output) { $variation_tpl['VARIATION_FORM_VARIATION_LIST'] .= $attribute_variation_to_output; } } $variation_tpl['FROM_ADMIN_INDICATOR'] = $variation_tpl['ORDER_ID_INDICATOR'] = ''; $variation_tpl['PRODUCT_ADDED_TO_CART_QTY'] = !empty($qty) ? $qty : 1; if ($from_admin && !empty($order_id)) { $variation_tpl['FROM_ADMIN_INDICATOR'] = '<input type="hidden" name="wps_orders_from_admin" value="1" />'; $variation_tpl['ORDER_ID_INDICATOR'] = '<input type="hidden" name="wps_orders_order_id" value="' . $order_id . '" />'; } $output = !empty($variation_tpl['VARIATION_FORM_VARIATION_LIST']) ? wpshop_display::display_template_element('product_variation_form', $variation_tpl) : ''; return $output; }