/** * Generate an array with all fields for the address form construction. Classified by address type. * @param $typeof * @return array */ function get_addresss_form_fields_by_type($typeof, $id = '') { $current_item_edited = isset($id) ? (int) wpshop_tools::varSanitizer($id) : null; $address = array(); $all_addresses = ''; /* Get the attribute set details in order to build the product interface */ $atribute_set_details = wpshop_attributes_set::getAttributeSetDetails($typeof, "'valid'"); if (!empty($atribute_set_details)) { foreach ($atribute_set_details as $productAttributeSetDetail) { $address = array(); $group_name = $productAttributeSetDetail['name']; if (count($productAttributeSetDetail['attribut']) >= 1) { foreach ($productAttributeSetDetail['attribut'] as $attribute) { if (!empty($attribute->id)) { if (!empty($_POST['submitbillingAndShippingInfo'])) { $value = $_POST['attribute'][$typeof][$attribute->data_type][$attribute->code]; } else { $value = wpshop_attributes::getAttributeValueForEntityInSet($attribute->data_type, $attribute->id, wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS), $current_item_edited, array('intrinsic' => $attribute->is_intrinsic, 'backend_input' => $attribute->backend_input)); } $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute, $value, array()); $attribute_output_def['id'] = 'address_' . $typeof . '_' . $attribute_output_def['id']; $address[str_replace('-', '_', sanitize_title($group_name)) . '_' . $attribute->code] = $attribute_output_def; } } } $all_addresses[$productAttributeSetDetail['attribute_set_id']][$productAttributeSetDetail['id']]['name'] = $group_name; $all_addresses[$productAttributeSetDetail['attribute_set_id']][$productAttributeSetDetail['id']]['content'] = $address; $all_addresses[$productAttributeSetDetail['attribute_set_id']][$productAttributeSetDetail['id']]['id'] = str_replace('-', '_', sanitize_title($group_name)); $all_addresses[$productAttributeSetDetail['attribute_set_id']][$productAttributeSetDetail['id']]['attribute_set_id'] = $productAttributeSetDetail['attribute_set_id']; } } return $all_addresses; }
/** * * @param unknown_type $attributeSetId * @param unknown_type $currentPageCode * @param unknown_type $itemToEdit * @param unknown_type $outputType * @return Ambigous <multitype:, string> */ public static function entities_attribute_box($attributeSetId, $currentPageCode, $itemToEdit, $outputType = 'box') { $box = $box['box'] = $box['boxContent'] = $box['generalTabContent'] = array(); /* Get the attribute set details in order to build the product interface */ $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid'"); $attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_'); if (count($productAttributeSetDetails) > 0) { /* Read the attribute list in order to output */ $shortcodes_attr = ''; $shortcodes_to_display = false; $attribute_set_id_is_present = false; foreach ($productAttributeSetDetails as $productAttributeSetDetail) { $shortcodes = $currentTabContent = ''; $output_nb = 0; if (count($productAttributeSetDetail['attribut']) >= 1) { foreach ($productAttributeSetDetail['attribut'] as $attribute) { if (!empty($attribute->id)) { if ($attribute->code == 'product_attribute_set_id') { $attribute_set_id_is_present = true; } /** Generic part for attribute field output */ $value = wpshop_attributes::getAttributeValueForEntityInSet($attribute->data_type, $attribute->id, wpshop_entities::get_entity_identifier_from_code($currentPageCode), $itemToEdit, array('intrinsic' => $attribute->is_intrinsic, 'backend_input' => $attribute->backend_input)); $product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true); /** Check if value is empty and get value in meta if not empty */ $value = empty($value) && !empty($product_meta[$attribute->code]) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null); /* Manage specific field as the attribute_set_id in product form */ if ($attribute->code == 'product_attribute_set_id') { $value = empty($value) ? $attributeSetId : $value; } $attribute_specification['current_value'] = $value; $attribute_output_def = wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification); if ($attribute_output_def['field_definition']['type'] != 'hidden' && $attribute->code != 'product_attribute_set_id') { $currentTabContent .= $attribute_output_def['field']; $shortcode_code_def = array(); $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; ob_start(); wps_shortcodes_ctr::output_shortcode('attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])) . ' wpshop_cls'); $shortcodes .= '<li class="wpshop_cls" >' . sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>' . __($attribute_output_def['field_definition']['label'], 'wpshop') . '</span>') . ob_get_contents() . '</li>'; ob_end_clean(); } else { if ($attribute->code == 'product_attribute_set_id') { $attribute_output_def['field_definition']['type'] = 'hidden'; } $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); } $output_nb++; } } $shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group'; $shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit; $shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id']; ob_start(); wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_' . str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])) . ' cls'); $attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>' . $productAttributeSetDetail['name'] . '</span>') . ob_get_contents() . '<ul class="" >' . $shortcodes . '</ul>'; ob_end_clean(); if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box') { $currentTabContent .= '<div class="wpshop_cls" ><strong>' . __('Shortcodes', 'wpshop') . '</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; } else { $shortcodes_attr .= $attribute_group_display; } if ($output_nb <= 0) { $currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop'); } } if ($output_nb > 0) { $shortcodes_to_display = true; if ($outputType == 'box') { $box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name']; $box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; $box['boxContent'][$productAttributeSetDetail['code']] = ' <div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . ' </div><div class="wpshop_cls" ></div>'; } else { if ($outputType == 'column') { $currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent); $currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent); $box['columnTitle'][$productAttributeSetDetail['code']] = __($productAttributeSetDetail['name'], 'wpshop'); $box['columnContent'][$productAttributeSetDetail['code']] = $currentTabContent; } } } } if (!$attribute_set_id_is_present) { /* Get attribute definition */ $attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code'); /* Get attribute input definition */ $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin'))); $input['type'] = 'hidden'; $box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']); } /* Ajout de la boite permettant d'ajouter des valeurs aux attributs de type liste deroulante a la volee */ $dialog_title = __('New value for attribute', 'wpshop'); $dialog_identifier = 'wpshop_new_attribute_option_value_add'; $dialog_input_identifier = 'wpshop_new_attribute_option_value'; ob_start(); include WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'; $box['boxMore'] .= ob_get_contents(); ob_end_clean(); $box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; if ($shortcodes_to_display) { switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) { case 'fixed-tab': case 'movable-tab': if ($outputType == 'box') { $box['box']['shortcode'] = __('Product Shortcodes', 'wpshop'); $box['boxContent']['shortcode'] = $shortcodes_attr; $box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE; } else { $box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop'); $box['columnContent']['shortcode'] = $shortcodes_attr; } break; } } } return $box; }
<div id="wps_mass_update_product_file_list_<?php echo $product['post_datas']->ID; ?>"><?php echo $this->wps_product_attached_files( $product['post_datas']->ID ); ?></div> <center><a class="wps-bton-first-mini-rounded wps_add_files_to_product_in_mass_interface" id="wps_add_files_to_product_in_mass_interface_<?php echo $product['post_datas']->ID; ?>"><?php _e( 'Add files', 'wpshop'); ?></a></center> </td>*/ ?> <?php if (!empty($quick_add_form_attributes)) { $i = 0; ?> <?php foreach ($quick_add_form_attributes as $attribute_id => $att_def) { $att = null; $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_set_id = %d AND attribute_id = %d AND status = %s', $default, $attribute_id, 'valid'); $checking_display_att = $wpdb->get_results($query); if (!empty($checking_display_att)) { $current_value = wpshop_attributes::getAttributeValueForEntityInSet($att_def['data_type'], $attribute_id, $product_entity_id, $product['post_datas']->ID); $output_specs = array('page_code' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'element_identifier' => $product['post_datas']->ID, 'field_id' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product['post_datas']->ID . '_', 'current_value' => !empty($current_value->value) ? $current_value->value : ''); $att = wpshop_attributes::display_attribute($att_def['code'], 'admin', $output_specs); } ?> <td class="wps_mass_interface_line"> <div class="wps-form-group"> <?php /*<label><?php _e( $att['field_definition']['label'], 'wpshop' ); ?></label>*/ ?> <div class="wps-form"><?php echo str_replace('name="wpshop_product_attribute', 'name="wpshop_product_attribute[' . $product['post_datas']->ID . ']', $att['field_definition']['output']); ?> </div> </div> </td>