public static function advanced_settings_field($input)
    {
        /*
        WPSHOP_DEBUG_MODE_ALLOWED_IP
        WPSHOP_DEBUG_MODE
        WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION
        WPSHOP_DISPLAY_TOOLS_MENU
        
        WPSHOP_INTERNAL_TYPES_TO_EXCLUDE
        
        WPSHOP_ATTRIBUTE_VALUE_PER_USER
        
        WPSHOP_PAYMENT_METHOD_CIC
        */
        $advanced_settings_output = '
	<!--	DEFINE EXTRA PARAMS WPSHOP_DEBUG_MODE_ALLOWED_IP	WPSHOP_DEBUG_MODE	WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION	WPSHOP_DISPLAY_TOOLS_MENU	WPSHOP_ATTRIBUTE_VALUE_PER_USER	WPSHOP_INTERNAL_TYPES_TO_EXCLUDE	-->
	<ul>';
        $wpshop_advanced_settings = get_option('wpshop_extra_options', array());
        if (!empty($wpshop_advanced_settings)) {
            $i = 0;
            foreach ($wpshop_advanced_settings as $setting_name => $setting_value) {
                $advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>' . __('Extra parameter key', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[existing][' . $i . '][key]', 'wpshop_extra_options_new_key', $setting_name, 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>' . __('Extra parameter value', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[existing][' . $i . '][value]', 'wpshop_extra_options_new_value', $setting_value, 'text') . '</div><div class="wpshop_cls" ></div></li>';
                $i++;
            }
        }
        $advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>' . __('New extra parameter key', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[new][key]', 'wpshop_extra_options_new_key', '', 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>' . __('New extra parameter value', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[new][value]', 'wpshop_extra_options_new_value', '', 'text') . '</div><div class="wpshop_cls" ></div></li>
	</ul>';
        echo $advanced_settings_output;
    }
 /**
  * OPTIONS - Display Free Shipping alert option field
  */
 function wpshop_free_shipping_cost_alert_field()
 {
     $cart_option = get_option('wpshop_cart_option');
     $input_def = array();
     $input_def['name'] = '';
     $input_def['id'] = 'wpshop_cart_option[free_shipping_cost_alert]';
     $input_def['type'] = 'checkbox';
     $input_def['valueToPut'] = 'index';
     $input_def['value'] = !empty($cart_option['free_shipping_cost_alert']) ? $cart_option['free_shipping_cost_alert'][0] : '';
     $input_def['possible_value'] = 'yes';
     $output = wpshop_form::check_input_type($input_def, 'wpshop_cart_option[free_shipping_cost_alert]') . '<a href="#" title="' . __('Check this box if you want to display an free shipping cost in the mini-cart', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
     echo $output;
 }
 function wpshop_entity_filter()
 {
     if (isset($_GET['post_type'])) {
         $post_type = $_GET['post_type'];
         if (post_type_exists($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
             $filter_possibilities = array();
             $filter_possibilities[''] = __('-- Select Filter --', 'wpshop');
             $filter_possibilities['no_picture'] = __('List products without picture', 'wpshop');
             $filter_possibilities['no_price'] = __('List products without price', 'wpshop');
             $filter_possibilities['no_description'] = __('List products without description', 'wpshop');
             $filter_possibilities['no_barcode_products'] = __('List products without barcode / with barcode not well formated', 'wpshop');
             $filter_possibilities['no_barcode_variations'] = __('List products with options without barcode / with barcode not well formated', 'wpshop');
             echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, !empty($_GET['entity_filter']) ? $_GET['entity_filter'] : '', '', 'index');
         }
     }
 }
    public static function wpshop_shipping_address_field()
    {
        global $wpdb;
        $choice = get_option('wpshop_shipping_address_choice', unserialize(WPSHOP_SHOP_CUSTOM_SHIPPING));
        $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
        $entity_id = $wpdb->get_var($query);
        $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
        $content = $wpdb->get_results($query);
        $input_def['name'] = 'wpshop_shipping_address_choice[choice]';
        $input_def['id'] = 'wpshop_shipping_address_choice[choice]';
        $input_def['possible_value'] = $content;
        $input_def['type'] = 'select';
        $input_def['value'] = $choice['choice'];
        $active = !empty($choice['activate']) ? $choice['activate'] : false;
        $display_model = !empty($choice['display_model']) ? addslashes(serialize($choice['display_model'])) : '';
        echo '<input type="checkbox" name="wpshop_shipping_address_choice[activate]" id="wpshop_shipping_address_choice[activate]" ' . ($active ? 'checked="checked"' : null) . '/> <label for="wpshop_shipping_address_choice[activate]">' . __('Activate shipping address', 'wpshop') . '</label><br/>
		<div>' . wpshop_form::check_input_type($input_def) . '</div>';
    }
Exemplo n.º 5
0
 function list_table_filters()
 {
     if (isset($_GET['post_type'])) {
         $post_type = $_GET['post_type'];
         if (post_type_exists($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
             $filter_possibilities = array();
             $filter_possibilities[''] = __('-- Select Filter --', 'wpshop');
             $filter_possibilities['orders'] = __('List customers with orders', 'wpshop');
             $filter_possibilities['no_orders'] = __('List customers without orders', 'wpshop');
             echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, !empty($_GET['entity_filter']) ? $_GET['entity_filter'] : '', '', 'index');
         }
     }
 }
Exemplo n.º 6
0
    /**
     * Add metaboxes to the custom post types defined by entities
     */
    public static function add_meta_boxes_to_custom_types($post)
    {
        global $post, $wpdb;
        /*
         * Add a specific metabox for customer
         */
        if ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
            //add_meta_box($post->post_type . '_customers_purchase', __('Orders', 'wpshop'), array('wpshop_orders', 'display_orders_for_customer'), $post->post_type, 'normal');
            //add_meta_box ($post->post_type.'_customer_note', __('Customers Notes' , 'wpshop'), array('wpshop_customer', 'display_notes_for_customer'), $post->post_type, 'side');
        }
        /*
         * Product are managed from another place
         */
        if ($post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
            /*
             * Get the attribute set list for current entity
             */
            $attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code($post->post_type));
            /*
             * Check if a attribute set is defined for current entity
             */
            $attribute_set_id = get_post_meta($post->ID, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $post->post_type), true);
            if (count($attribute_set_list) == 1 || count($attribute_set_list) > 1 && !empty($attribute_set_id)) {
                if (count($attribute_set_list) == 1 || empty($attribute_set_id)) {
                    $attribute_set_id = $attribute_set_list[0]->id;
                }
                /*
                 * Get attribute list for the current entity
                 */
                $currentTabContent = wpshop_attributes::entities_attribute_box($attribute_set_id, $post->post_type, $post->ID);
                $fixed_box_exist = false;
                /*
                 * Read the different element for building output for current entity
                 */
                if (!empty($currentTabContent['box']) && is_array($currentTabContent['box'])) {
                    foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
                        if (!empty($currentTabContent['box'][$boxIdentifier . '_backend_display_type']) && $currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'movable-tab') {
                            add_meta_box($post->post_type . '_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'default', array('currentTabContent' => $currentTabContent['boxContent'][$boxIdentifier]));
                        } else {
                            $fixed_box_exist = true;
                        }
                    }
                }
                if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) {
                    add_meta_box($post->post_type . '_fixed_tab', __('Informations', 'wpshop'), array('wpshop_entities', 'meta_box_content_datas'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent));
                }
            } elseif (count($attribute_set_list) > 1) {
                $input_def['id'] = $post->post_type . '_attribute_set_id';
                $input_def['name'] = $post->post_type . '_attribute_set_id';
                $input_def['value'] = '';
                $input_def['type'] = 'select';
                $input_def['possible_value'] = $attribute_set_list;
                $input_def['value'] = '';
                foreach ($attribute_set_list as $set) {
                    if ($set->default_set == 'yes') {
                        $input_def['value'] = $set->id;
                    }
                }
                $currentTabContent = '
		<ul class="attribute_set_selector" >
			<li class="attribute_set_selector_title_select" ><label for="title" >' . sprintf(__('Choose a title for the %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label></li>
			<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label>&nbsp;' . wpshop_form::check_input_type($input_def) . '</li>
			<li class="attribute_set_selector_save_instruction" >' . sprintf(__('Save the %s with the "Save draft" button on the right side', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</li>
			<li class="attribute_set_selector_after_save_instruction" >' . __('Once the group chosen, the different attribute will be displayed here', 'wpshop') . '</li>
		</ul>';
                add_meta_box($post->post_type . '_attribute_set_selector', sprintf(__('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent));
            }
        }
    }
    /**
     * Display the differents forms fields
     * @param string $type : Type of address
     * @param string $first : Customer first address ?
     * @param string $referer : Referer website page
     * @param string $admin : Display this form in admin panel
     */
    function display_form_fields($type, $id = '', $first = '', $referer = '', $special_values = array(), $options = array(), $display_for_admin = array(), $other_customer = '')
    {
        global $wpshop, $wpshop_form, $wpdb;
        $choosen_address = get_option('wpshop_billing_address');
        $shipping_address = get_option('wpshop_shipping_address_choice');
        $output_form_fields = $form_model = '';
        $user_id = !empty($other_customer) ? $other_customer : get_current_user_id();
        if (empty($type)) {
            $type = $choosen_address['choice'];
        }
        $result = wps_address::get_addresss_form_fields_by_type($type, $id);
        /** Check if it's shipping or billing **/
        if ($type == $choosen_address['choice']) {
            $form_model = !empty($choosen_address['display_model']) ? $choosen_address['display_model'] : null;
        } elseif ($type == $shipping_address['choice']) {
            $form_model = !empty($shipping_address['display_model']) ? $shipping_address['display_model'] : null;
        }
        $form = $result[$type];
        // Take the post id to make the link with the post meta of  address
        $values = array();
        // take the address informations
        $current_item_edited = !empty($id) ? (int) wpshop_tools::varSanitizer($id) : null;
        foreach ($form as $group_id => $group_fields) {
            if (empty($options) || !empty($options) && $options['title']) {
                $output_form_fields .= '<h2>' . __($group_fields['name'], 'wpshop') . '</h2>';
            }
            $end_line_indicator = 0;
            $fields_limit_per_line = -1;
            foreach ($group_fields['content'] as $key => $field) {
                $attribute_def = wpshop_attributes::getElement($field['name'], $element_status = "'valid'", $field_to_search = 'code');
                /** Grid opening **/
                if (!empty($form_model) && !empty($form_model[$group_id]) && in_array('wps-attribute-end-line-' . $end_line_indicator, $form_model[$group_id]) && $fields_limit_per_line == -1) {
                    $current_key = array_search('wps-attribute-end-line-' . $end_line_indicator, $form_model[$group_id]);
                    $current_attribute_key = array_search('attribute_' . $attribute_def->id, $form_model[$group_id]);
                    if ($current_attribute_key > $current_key) {
                        /** Define limit **/
                        if (in_array('wps-attribute-end-line-' . ($end_line_indicator + 1), $form_model[$group_id])) {
                            $next_key = array_search('wps-attribute-end-line-' . ($end_line_indicator + 1), $form_model[$group_id]);
                            $fields_limit_per_line = $next_key - $current_key - 1;
                            $fields_limit_per_line = $fields_limit_per_line > 6 ? 6 : $fields_limit_per_line;
                        } else {
                            $current_key = array_search('wps-attribute-end-line-' . $end_line_indicator, $form_model[$group_id]);
                            $end_tab = count($form_model[$group_id]) - 1;
                            $fields_limit_per_line = $end_tab - $current_key - 1;
                            $fields_limit_per_line = $fields_limit_per_line > 6 ? 6 : $fields_limit_per_line;
                        }
                        if (!empty($fields_limit_per_line) && $fields_limit_per_line != -1) {
                            if ($fields_limit_per_line == 1) {
                                $output_form_fields .= '<div class="wps-row">';
                            } else {
                                $output_form_fields .= '<div class="wps-row wps-gridwrapper' . $fields_limit_per_line . '-padded">';
                            }
                        }
                    }
                }
                if (empty($options['field_to_hide']) || !is_array($options['field_to_hide']) || !in_array($key, $options['field_to_hide'])) {
                    $attributeInputDomain = 'attribute[' . $type . '][' . $field['data_type'] . ']';
                    // Test if there is POST var or if user have already fill his address infos and fill the fields with these infos
                    if (!empty($_POST)) {
                        $referer = !empty($_POST['referer']) ? $_POST['referer'] : '';
                        if (!empty($form['id']) && !empty($field['name']) && isset($_POST[$form['id'] . "_" . $field['name']])) {
                            $value = $_POST[$form['id'] . "_" . $field['name']];
                        }
                    }
                    // Fill Automaticly some fields when it's an address creation
                    switch ($field['name']) {
                        case 'address_title':
                            if (empty($field['value'])) {
                                /** Count Billing and shipping address **/
                                $billing_address_count = $shipping_address_count = 1;
                                if (get_current_user_id() != 0) {
                                    $addresses = get_posts(array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, 'post_parent' => get_current_user_id(), 'post_status' => 'draft'));
                                    if (!empty($addresses)) {
                                        foreach ($addresses as $address) {
                                            $address_type = get_post_meta($address->ID, '_wpshop_address_attribute_set_id', true);
                                            if (!empty($address_type)) {
                                                if (!empty($shipping_address_choice['choice']) && $address_type == $shipping_address_choice['choice']) {
                                                    $shipping_address_count++;
                                                } else {
                                                    $billing_address_count++;
                                                }
                                            }
                                        }
                                    }
                                }
                                $field['value'] = $type == $choosen_address['choice'] ? __('Billing address', 'wpshop') . ($billing_address_count > 1 ? ' ' . $billing_address_count : '') : __('Shipping address', 'wpshop') . ($shipping_address_count > 1 ? ' ' . $shipping_address_count : '');
                            }
                            break;
                        case 'address_last_name':
                            if (empty($field['value'])) {
                                $usermeta_last_name = get_user_meta($user_id, 'last_name', true);
                                $field['value'] = !empty($usermeta_last_name) ? $usermeta_last_name : '';
                            }
                            break;
                        case 'address_first_name':
                            if (empty($field['value'])) {
                                $usermeta_first_name = get_user_meta($user_id, 'first_name', true);
                                $field['value'] = !empty($usermeta_first_name) ? $usermeta_first_name : '';
                            }
                            break;
                        case 'address_user_email':
                            if (empty($field['value'])) {
                                $user_infos = get_userdata($user_id);
                                $field['value'] = !empty($user_infos) && !empty($user_infos->user_email) ? $user_infos->user_email : '';
                            }
                            break;
                        default:
                            $field['value'] = !empty($field['value']) ? $field['value'] : '';
                            break;
                    }
                    /** Fill fields if $_POST exist **/
                    if (!empty($_POST['attribute'][$type][$field['data_type']][$field['name']])) {
                        $field['value'] = $_POST['attribute'][$type][$field['data_type']][$field['name']];
                    }
                    if ($field['name'] == 'address_title' && !empty($first) && $type == __('Billing address', 'wpshop')) {
                        $value = __('Billing address', 'wpshop');
                    } elseif ($field['name'] == 'address_title' && !empty($first) && $type == __('Shipping address', 'wpshop')) {
                        $value = __('Shipping address', 'wpshop');
                    }
                    if (!empty($special_values[$field['name']])) {
                        $field['value'] = $special_values[$field['name']];
                    }
                    $template = 'wpshop_account_form_input';
                    if ($field['type'] == 'hidden') {
                        $template = 'wpshop_account_form_hidden_input';
                    }
                    if ($field['frontend_verification'] == 'country') {
                        $field['type'] = 'select';
                        /** display a country list **/
                        $countries_list = unserialize(WPSHOP_COUNTRY_LIST);
                        $possible_values = array_merge(array('' => __('Choose a country')), $countries_list);
                        $limit_countries_list = get_option('wpshop_limit_country_list');
                        $default_country_choice = get_option('wpshop_country_default_choice');
                        if (!empty($limit_countries_list)) {
                            $possible_values = array();
                            if (count($limit_countries_list) > 1) {
                                $possible_values[''] = __('Choose a country');
                            }
                            foreach ($limit_countries_list as $country_code) {
                                if (!empty($countries_list) && !empty($countries_list[$country_code])) {
                                    $possible_values[$country_code] = $countries_list[$country_code];
                                }
                            }
                        }
                        $field['value'] = !empty($default_country_choice) && array_key_exists($default_country_choice, $possible_values) ? $default_country_choice : '';
                        $field['possible_value'] = $possible_values;
                        $field['valueToPut'] = 'index';
                    }
                    $element_simple_class = str_replace('"', '', str_replace('class="', '', str_replace('wpshop_input_datetime', '', $field['option'])));
                    $input_tpl_component = array();
                    //$input_tpl_component['CUSTOMER_FORM_INPUT_MAIN_CONTAINER_CLASS'] = ' wsphop_customer_account_form_container wsphop_customer_account_form_container_' . $field['name'] . $element_simple_class;
                    $input_tpl_component['CUSTOMER_FORM_INPUT_LABEL'] = $field['type'] != 'hidden' ? stripslashes(__($field['label'], 'wpshop')) . ($field['required'] == 'yes' ? ' <em>*</em>' : '') : '';
                    $input_tpl_component['CUSTOMER_FORM_INPUT_LABEL_OPTIONS'] = ' for="' . $field['id'] . '"';
                    $input_tpl_component['CUSTOMER_FORM_INPUT_FIELD'] = wpshop_form::check_input_type($field, $attributeInputDomain);
                    //$output_form_fields .= wpshop_display::display_template_element($template, $input_tpl_component);
                    $output_form_fields .= wpshop_display::display_template_element('wps_address_field', $input_tpl_component, array(), 'wpshop');
                    unset($input_tpl_component);
                    if ($field['_need_verification'] == 'yes') {
                        $field['name'] = $field['name'] . '2';
                        $field['id'] = $field['id'] . '2';
                        $element_simple_class = str_replace('"', '', str_replace('class="', '', str_replace('wpshop_input_datetime', '', $field['option'])));
                        $input_tpl_component = array();
                        $input_tpl_component['CUSTOMER_FORM_INPUT_LABEL'] = __($field['label'], 'wpshop') . ($field['required'] == 'yes' && !is_admin() || $field['name'] == 'address_user_email' && is_admin() ? ' <span class="required">*</span>' : '');
                        $input_tpl_component['CUSTOMER_FORM_INPUT_LABEL_OPTIONS'] = ' for="' . $field['id'] . '"';
                        $input_tpl_component['CUSTOMER_FORM_INPUT_MAIN_CONTAINER_CLASS'] = ' wsphop_customer_account_form_container wsphop_customer_account_form_container_' . $field['name'] . $element_simple_class;
                        $input_tpl_component['CUSTOMER_FORM_INPUT_LABEL'] = sprintf(__('Confirm %s', 'wpshop'), strtolower(__($field['label'], 'wpshop'))) . ($field['required'] == 'yes' && !is_admin() ? ' <span class="required">*</span>' : '');
                        $input_tpl_component['CUSTOMER_FORM_INPUT_FIELD'] = wpshop_form::check_input_type($field, $attributeInputDomain) . $field['options'];
                        //$output_form_fields .= wpshop_display::display_template_element($template, $input_tpl_component);
                        $output_form_fields .= wpshop_display::display_template_element('wps_address_field', $input_tpl_component, array(), 'wpshop');
                        unset($input_tpl_component);
                    }
                }
                /** Grid closing **/
                if ($fields_limit_per_line != -1 && !empty($fields_limit_per_line)) {
                    $fields_limit_per_line--;
                    if ($fields_limit_per_line == 0) {
                        $output_form_fields .= '</div>';
                        $fields_limit_per_line = -1;
                        $end_line_indicator++;
                    }
                }
            }
        }
        if ($type == $choosen_address['choice']) {
            $output_form_fields .= '<input type="hidden" name="billing_address" value="' . $choosen_address['choice'] . '" />';
        }
        $shipping_address_options = get_option('wpshop_shipping_address_choice');
        if ($type == $shipping_address_options['choice']) {
            $output_form_fields .= '<input type="hidden" name="shipping_address" value="' . $shipping_address_options['choice'] . '" />';
        }
        $output_form_fields .= '<input type="hidden" name="edit_other_thing" value="' . false . '" /><input type="hidden" name="referer" value="' . $referer . '" />
								<input type="hidden" name="type_of_form" value="' . $type . '" /><input type="hidden" name="attribute[' . $type . '][item_id]" value="' . $current_item_edited . '" />';
        $output_form_fields .= $user_id != get_current_user_id() ? '<input type="hidden" name="user[customer_id]" value="' . $user_id . '" />' : '';
        if (empty($first)) {
            $output_form_fields = wpshop_display::display_template_element('wpshop_customer_addresses_form', array('CUSTOMER_ADDRESSES_FORM_CONTENT' => $output_form_fields, 'CUSTOMER_ADDRESSES_FORM_BUTTONS' => ''));
        }
        return $output_form_fields;
    }
Exemplo n.º 8
0
 public static function list_table_filters()
 {
     if (isset($_GET['post_type'])) {
         $post_type = $_GET['post_type'];
         if (post_type_exists($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) {
             $filter_possibilities = array();
             $filter_possibilities['all'] = __('-- Select Filter --', 'wpshop');
             $filter_possibilities['only_orders'] = __('List orders only', 'wpshop');
             $filter_possibilities['quotations'] = __('List quotations only', 'wpshop');
             $filter_possibilities['free_orders'] = __('List orders free', 'wpshop');
             echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, !empty($_GET['entity_filter']) ? $_GET['entity_filter'] : '', '', 'index');
             $min = !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ? $_GET['entity_filter_btpf'] : '';
             $max = !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ? $_GET['entity_filter_btps'] : '';
             echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> ';
             echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null);
             echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null);
         }
     }
 }
 /**
  * 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;
 }
Exemplo n.º 10
0
 public static function wpshop_cart_product_added_to_quotation_behaviour_field()
 {
     $cart_option = get_option('wpshop_cart_option', array('dialog_msg'));
     $output = '';
     $input_def = array();
     $input_def['name'] = '';
     $input_def['id'] = 'wpshop_cart_option_action_after_product_added_to_quotation';
     $input_def['type'] = 'radio';
     $input_def['valueToPut'] = 'index';
     $input_def['value'] = !empty($cart_option['product_added_to_quotation']) ? $cart_option['product_added_to_quotation'] : null;
     $input_def['possible_value'] = array('dialog_msg' => __('Display the dialog allowing to choose between continue shopping or go to cart', 'wpshop'), 'cart_page' => __('Automaticaly send user to cart page', 'wpshop'));
     $input_def['options_label']['original'] = true;
     $input_def['options_label']['container'] = true;
     $output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[product_added_to_quotation]');
     echo $output;
 }
<?php

if (current_user_can('wpshop_edit_options')) {
    ?>
 
	<?php 
    $value = $wpshop_display_option[$field_identifier] <= 0 ? WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE : $wpshop_display_option[$field_identifier];
    ?>
	<div id="<?php 
    echo $field_identifier;
    ?>
slider" class="slider_variable wpshop_options_slider wpshop_options_slider_display wpshop_options_slider_display_grid_element_number"></div>
	<?php 
    echo wpshop_form::form_input('wpshop_display_option[' . $field_identifier . ']', $field_identifier, $wpshop_display_option[$field_identifier], 'text', ' readonly class="sliderValue" ');
    ?>

<script type="text/javascript" >
	wpshop(document).ready(function(){
		jQuery('#<?php 
    echo $field_identifier;
    ?>
slider').slider({
			value : <?php 
    echo $value;
    ?>
,
			min: <?php 
    echo WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE;
    ?>
,
			max: <?php 
 /**
  * FIELDS - Display admin options Shortcode layout display
  */
 function wpshop_admin_display_shortcode_in_product_page()
 {
     global $product_page_layout_types;
     $field_identifier = 'wpshop_admin_product_shortcode_display';
     $wpshop_admin_display_option = get_option('wpshop_admin_display_option', array());
     if (current_user_can('wpshop_edit_options')) {
         $option_field_output = wpshop_form::form_input_select('wpshop_admin_display_option[' . $field_identifier . ']', $field_identifier, $product_page_layout_types, WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE, '', 'index');
     } else {
         $option_field_output = $wpshop_admin_display_option[$field_identifier];
     }
     echo $option_field_output . ' <a href="#" title="' . __('Define how to display the shortcode summary in product edition page', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
 }
    /**
     *	Return the page content to add a new item
     *
     *	@return string The html code that output the interface for adding a nem item
     */
    function unit_group_edition($itemToEdit = '')
    {
        global $attribute_displayed_field;
        $dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
        $editedItem = '';
        $_REQUEST['action'] = 'save_new_attribute_unit_group';
        if ($itemToEdit != '') {
            $editedItem = self::get_unit_group($itemToEdit);
            $_REQUEST['action'] = 'update_attribute_unit_group';
        }
        $the_form_content_hidden = $the_form_general_content = $the_form_option_content = '';
        foreach ($dbFieldList as $input_key => $input_def) {
            $pageAction = isset($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) : '';
            $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['name']]) : '';
            $currentFieldValue = $input_def['value'];
            if (is_object($editedItem)) {
                $currentFieldValue = $editedItem->{$input_def}['name'];
            } elseif ($pageAction != '' && $requestFormValue != '') {
                $currentFieldValue = $requestFormValue;
            }
            $input_def['value'] = $currentFieldValue;
            $input_def['value'] = __(str_replace("\\", "", $input_def['value']), 'wpshop');
            $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
            if ($input_def['type'] != 'hidden') {
                $label = 'for="' . $input_def['name'] . '"';
                if ($input_def['type'] == 'radio' || $input_def['type'] == 'checkbox') {
                    $label = '';
                }
                $input = '
	<div class="wpshop_cls" >
		<div class="wpshop_form_label wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_label alignleft" >
			<label ' . $label . ' >' . __($input_def['name'], 'wpshop') . '</label>
		</div>
		<div class="wpshop_form_input wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_input alignleft" >
			' . $the_input . '
		</div>
	</div>';
                if (substr($input_def['name'], 0, 3) == 'is_') {
                    $the_form_option_content .= $input;
                } else {
                    $the_form_general_content .= $input;
                }
            } else {
                $the_form_content_hidden .= '
	' . $the_input;
            }
        }
        $the_form = '
<form name="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" id="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" method="post" action="' . WPSHOP_AJAX_FILE_URL . '" >
' . wpshop_form::form_input('action', 'action', $_REQUEST['action'], 'hidden') . '
' . wpshop_form::form_input('post', 'post', 'true', 'hidden') . '
' . wpshop_form::form_input('elementCode', 'elementCode', 'attribute_unit_management', 'hidden') . '
' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . '
	' . $the_form_content_hidden . '' . $the_form_general_content . '
	<input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" />
	<input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit_group" id="save_new_unit_group" />
</form>
<script type="text/javascript" >
	wpshop(document).ready(function(){
		wpshopMainInterface("' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this unit group?', 'wpshop') . '");

		jQuery("#wpshop_unit_list_tab").hide();

		jQuery("#cancel_unit_group_edition").click(function(){
			jQuery("#wpshop_unit_group_list").load(WPSHOP_AJAX_FILE_URL, {
				"post": "true",
				"elementCode": "attribute_unit_management",
				"action": "load_attribute_unit_groups"
			});
		});

		jQuery("#' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form").ajaxForm({
			target: "#wpshop_unit_group_list"
		});
	});
</script>';
        return $the_form;
    }
Exemplo n.º 14
0
        function wpshop_billing_address_choice_field()
        {
            global $wpdb;
            $output = '';
            $wpshop_billing_address = get_option('wpshop_billing_address');
            $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
            $entity_id = $wpdb->get_var($query);
            $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
            $content = $wpdb->get_results($query);
            /*	Field for billing address type choice	*/
            $input_def['name'] = 'wpshop_billing_address[choice]';
            $input_def['id'] = 'wpshop_billing_address_choice';
            $input_def['possible_value'] = $content;
            $input_def['type'] = 'select';
            $input_def['value'] = $wpshop_billing_address['choice'];
            $output .= '<div>' . wpshop_form::check_input_type($input_def) . '</div>';
            /*	Field for integrate billign form into register form	*/
            $input_def = array();
            $input_def['name'] = 'wpshop_billing_address[integrate_into_register_form]';
            $input_def['id'] = 'wpshop_billing_address_integrate_into_register_form';
            $input_def['possible_value'] = array('yes' => __('Integrate billing form into register form', 'wpshop'));
            $input_def['valueToPut'] = 'index';
            $input_def['options_label']['original'] = true;
            $input_def['option'] = ' class="wpshop_billing_address_integrate_into_register_form" ';
            $input_def['type'] = 'checkbox';
            $input_def['value'] = array(!empty($wpshop_billing_address['integrate_into_register_form']) ? $wpshop_billing_address['integrate_into_register_form'] : '');
            $output .= '
<div class="wpshop_include_billing_form_into_register_container" >
	' . wpshop_form::check_input_type($input_def) . '
	<input type="hidden" name="wpshop_ajax_integrate_billin_into_register" id="wpshop_ajax_integrate_billin_into_register" value="' . wp_create_nonce('wpshop_ajax_integrate_billin_into_register') . '" />
	<input type="hidden" name="wpshop_include_billing_form_into_register_where_value" id="wpshop_include_billing_form_into_register_where_value" value="' . (!empty($wpshop_billing_address['integrate_into_register_form_after_field']) ? $wpshop_billing_address['integrate_into_register_form_after_field'] : '') . '" />
	<div class="wpshop_include_billing_form_into_register_where" ></div>
</div>';
            echo $output;
        }
Exemplo n.º 15
0
/**
 * Display opttions for including user address into account form
 */
function ajax_integrate_billing_into_register()
{
    check_ajax_referer('wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce');
    global $wpshop_account;
    $wpshop_billing_address = get_option('wpshop_billing_address');
    $current_billing_address = isset($_POST['current_billing_address']) ? intval(wpshop_tools::varSanitizer($_POST['current_billing_address'])) : null;
    $selected_field = isset($_POST['selected_field']) ? wpshop_tools::varSanitizer($_POST['selected_field']) : null;
    $billing_form_fields = wps_address::get_addresss_form_fields_by_type($current_billing_address);
    $possible_values_for_billing = array('' => __('No corresponding field', 'wpshop'));
    foreach ($billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) {
        foreach ($attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) {
            $possible_values_for_billing[$attribute_build_code] = $attribute_definition['label'];
        }
    }
    $account_form_field = !empty($wpshop_account->personal_info_fields) ? $wpshop_account->personal_info_fields : array();
    $possible_values = array();
    $matching_field = '';
    foreach ($account_form_field as $attribute_code => $attribute_detail) {
        $possible_values[$attribute_code] = $attribute_detail['label'];
        $input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_matching_field][' . $attribute_code . ']';
        $input_def['id'] = 'wpshop_billing_address_integrate_into_register_form_after_field';
        $input_def['possible_value'] = $possible_values_for_billing;
        $input_def['type'] = 'select';
        $input_def['valueToPut'] = 'index';
        $input_def['value'] = !empty($wpshop_billing_address['integrate_into_register_form_matching_field']) && array_key_exists($attribute_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) ? $wpshop_billing_address['integrate_into_register_form_matching_field'][$attribute_code] : null;
        $matching_field .= '<div>' . $attribute_detail['label'] . ' : ' . wpshop_form::check_input_type($input_def) . '</div>';
    }
    $input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_after_field]';
    $input_def['id'] = 'wpshop_billing_address_integrate_into_register_form_after_field';
    $input_def['possible_value'] = $possible_values;
    $input_def['type'] = 'select';
    $input_def['valueToPut'] = 'index';
    $input_def['value'] = $selected_field;
    $output = '<div>' . wpshop_form::check_input_type($input_def) . '</div>';
    $output .= '<div><div>' . __('If some fields are twice, you can hide them into billing address by matching them with account field below. Left fields are account form, right fields are for billing address', 'wpshop') . '</div>' . $matching_field . '</div>';
    echo $output;
    die;
}
    /**
     * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option
     *
     * @param string $column_name The column name for output type definition
     * @param string $post_type The current
     *
     */
    function bulk_edit($column_name, $entity)
    {
        switch ($entity) {
            case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
                $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code');
                if (!empty($attribute_def)) {
                    $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input'));
                    $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']);
                    ?>
	<div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php 
                    echo $column_name;
                    ?>
_container">
		<span class="wpshop_bulk_and_quick_edit_column_label wpshop_bulk_and_quick_edit_column_<?php 
                    echo $column_name;
                    ?>
_label"><?php 
                    _e($attribute_def->frontend_label, 'wpshop');
                    ?>
</span>
		<?php 
                    echo str_replace('chosen_select', '', str_replace('alignleft', '', $input));
                    ?>
		<!-- <input class="wpshop_bulk_and_quick_edit_input wpshop_bulk_and_quick_edit_input_data_type_<?php 
                    echo $attribute_def->data_type;
                    ?>
 wpshop_bulk_and_quick_edit_input_data_code_<?php 
                    echo $attribute_def->code;
                    ?>
" type="text" name="<?php 
                    echo $entity;
                    ?>
_-code-_<?php 
                    echo $attribute_def->code;
                    ?>
" value="" />  -->
	</div>
<?php 
                }
                break;
        }
    }
    /**
     *	Return the page content to add a new item
     *
     *	@return string The html code that output the interface for adding a nem item
     */
    function elementEdition($itemToEdit = '')
    {
        global $attribute_hidden_field;
        $dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
        $form_more_content = $the_form_content_hidden = $the_form_general_content = '';
        $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add';
        $bloc_list = array();
        $editedItem = '';
        if ($itemToEdit != '') {
            $editedItem = self::getElement($itemToEdit);
        }
        foreach ($dbFieldList as $input_key => $input_def) {
            $input_name = $input_def['name'];
            $input_value = $input_def['value'];
            $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_name;
            $attributeAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : '';
            $attributeFormValue = isset($_REQUEST[self::getDbTable()][$input_name]) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable()][$input_name]) : '';
            /*	Get value by checking current object type	*/
            $currentFieldValue = $input_value;
            if (is_object($editedItem)) {
                $currentFieldValue = $editedItem->{$input_name};
            } elseif ($attributeAction != '' && $attributeFormValue != '') {
                $currentFieldValue = $attributeFormValue;
            }
            /*	Check if the field must be hidden	*/
            if (in_array($input_name, $attribute_hidden_field)) {
                $input_def['type'] = 'hidden';
            }
            if ($input_name == 'entity_id') {
                $input_def['type'] = 'select';
                $input_def['possible_value'] = wpshop_entities::get_entities_list();
                $input_def['valueToPut'] = 'index';
                if (is_object($editedItem) || count($input_def['possible_value']) == 1) {
                    $input_def['type'] = 'hidden';
                    $currentFieldValue = count($input_def['possible_value']) == 1 ? $input_def['possible_value'][0]->id : $currentFieldValue;
                }
                $input_def['name'] = $input_name;
                $input_def['value'] = $currentFieldValue;
                $i = 0;
                foreach ($input_def['possible_value'] as $entity_id => $entity_name) {
                    if ($i <= 0) {
                        $current_entity_id = $entity_id;
                    }
                    $i++;
                }
                $the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
            } else {
                if (in_array($input_name, array('status', 'default_set'))) {
                    $input_def['type'] = 'checkbox';
                    switch ($input_name) {
                        case 'status':
                            $input_name = __('Use this attribute group', 'wpshop');
                            $input_def['possible_value'] = array('valid');
                            $input_def_id .= '_valid';
                            $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
                            break;
                        case 'default_set':
                            $input_def['possible_value'] = array('yes');
                            $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group as default group in selected element', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
                            $input_def_id .= '_yes';
                            break;
                    }
                }
                $input_def['value'] = $currentFieldValue;
                $the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
            }
            if ($input_def['type'] != 'hidden') {
                $the_form_general_content .= '
		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_name . '" >
			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_name . '" ><label for="' . $input_def_id . '" >' . __($input_name, 'wpshop') . '</label></td>
			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_name . '" >' . $the_input . '</td>
		</tr>';
            } else {
                $the_form_content_hidden .= '
		' . $the_input;
            }
        }
        if (empty($itemToEdit)) {
            $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false);
            $the_form_general_content .= '
			<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_existing_attribute_set_copy_from" >
				<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="' . $input_def_id . '" >' . __('Create the new group from an existing', 'wpshop') . '</label></td>
				<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_existing_attribute_set_copy_from" >' . $the_input . '</td>
			</tr>';
        }
        $the_form_general_content = '
<table class="wpshop_' . self::currentPageCode . '_edition_table wpshop_' . self::currentPageCode . '_edition_table_main_info" >
' . $the_form_general_content . '
</table>';
        /*	Default content for the current page	*/
        $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop');
        $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content;
        if (is_object($editedItem)) {
            $bloc_list[self::currentPageCode]['detail']['title'] = __('Attribute group section details', 'wpshop');
            $bloc_list[self::currentPageCode]['detail']['content'] = self::attributeSetDetailsManagement($itemToEdit);
        }
        $the_form = '
<form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" >
' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', !empty($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'save', 'hidden') . '
' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . '
	<div class="wpshop_edition_button wpshop_edition_button_' . self::currentPageCode . '" >';
        if ($action == 'add' && current_user_can('wpshop_add_attribute_set')) {
            $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
        } elseif (current_user_can('wpshop_edit_attribute_set')) {
            $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
        }
        if (current_user_can('wpshop_delete_attribute_set') && $action != 'add') {
            $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
        }
        $the_form .= '
	</div>
</form>
<script type="text/javascript" >
	wpshop(document).ready(function(){
		wpshopMainInterface("' . self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");

		jQuery("#wpshop_attribute_set_edition_table_field_id_entity_id").change(function(){
			jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html(jQuery("#wpshopLoadingPicture").html());

			var data = {
				action: "attribute_set_entity_selection",
				current_entity_id: jQuery(this).val(),
				wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_set_entity_selection") . '"
			};
			jQuery.post(ajaxurl, data, function(response) {
				jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html( response );
			}, "json");
		});
	});
</script>';
        return $the_form;
    }