@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | 29 | public static function declare_options() { |
| 30 | - add_settings_section('wpshop_emails', '<span class="dashicons dashicons-email"></span>'.__('Email addresses', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_emails'); |
|
| 30 | + add_settings_section('wpshop_emails', '<span class="dashicons dashicons-email"></span>' . __('Email addresses', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_emails'); |
|
| 31 | 31 | register_setting('wpshop_options', 'wpshop_emails', array('wpshop_email_options', 'wpshop_options_validate_emails')); |
| 32 | 32 | add_settings_field('wpshop_noreply_email', __('Mails answers address email', 'wpshop'), array('wpshop_email_options', 'wpshop_noreply_email_field'), 'wpshop_emails', 'wpshop_emails'); |
| 33 | 33 | add_settings_field('wpshop_contact_email', __('Contact email', 'wpshop'), array('wpshop_email_options', 'wpshop_contact_email_field'), 'wpshop_emails', 'wpshop_emails'); |
| 34 | 34 | add_settings_field('wpshop_send_confirmation_order_email', '', array('wpshop_email_options', 'wpshop_send_confirmation_order_message_field'), 'wpshop_emails', 'wpshop_emails'); |
| 35 | 35 | |
| 36 | 36 | /** Define the settings section for message */ |
| 37 | - add_settings_section('wpshop_messages', '<span class="dashicons dashicons-email-alt"></span>'.__('Messages', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_messages' ); |
|
| 37 | + add_settings_section('wpshop_messages', '<span class="dashicons dashicons-email-alt"></span>' . __('Messages', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_messages'); |
|
| 38 | 38 | |
| 39 | 39 | /** Get default messages defined into xml files */ |
| 40 | - $xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' ); |
|
| 41 | - $default_emails = new SimpleXMLElement( $xml_default_emails ); |
|
| 40 | + $xml_default_emails = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml'); |
|
| 41 | + $default_emails = new SimpleXMLElement($xml_default_emails); |
|
| 42 | 42 | /** Read default emails for options creation */ |
| 43 | - foreach ( $default_emails->xpath( '//emails/email' ) as $email ) { |
|
| 44 | - if ( ( WPSHOP_DEFINED_SHOP_TYPE == (string)$email->attributes()->shop_type ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) { |
|
| 45 | - register_setting( 'wpshop_options', (string)$email->attributes()->code, array( 'wpshop_email_options', 'wps_options_validate_emails' ) ); |
|
| 46 | - add_settings_field( (string)$email->attributes()->code, __( (string)$email->description, 'wpshop' ), array( 'wpshop_email_options', 'wps_options_emails_field' ), 'wpshop_messages', 'wpshop_messages', array( 'code' => (string)$email->attributes()->code, ) ); |
|
| 43 | + foreach ($default_emails->xpath('//emails/email') as $email) { |
|
| 44 | + if ((WPSHOP_DEFINED_SHOP_TYPE == (string)$email->attributes()->shop_type) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) { |
|
| 45 | + register_setting('wpshop_options', (string)$email->attributes()->code, array('wpshop_email_options', 'wps_options_validate_emails')); |
|
| 46 | + add_settings_field((string)$email->attributes()->code, __((string)$email->description, 'wpshop'), array('wpshop_email_options', 'wps_options_emails_field'), 'wpshop_messages', 'wpshop_messages', array('code' => (string)$email->attributes()->code,)); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -62,26 +62,26 @@ discard block |
||
| 62 | 62 | $admin_email = get_bloginfo('admin_email'); |
| 63 | 63 | $emails = get_option('wpshop_emails', null); |
| 64 | 64 | $email = empty($emails['noreply_email']) ? $admin_email : $emails['noreply_email']; |
| 65 | - echo '<input name="wpshop_emails[noreply_email]" type="text" value="'.$email.'" /> |
|
| 66 | - <a href="#" title="'.__('This is the no reply email','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 65 | + echo '<input name="wpshop_emails[noreply_email]" type="text" value="' . $email . '" /> |
|
| 66 | + <a href="#" title="'.__('This is the no reply email', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 67 | 67 | } |
| 68 | 68 | public static function wpshop_contact_email_field() { |
| 69 | 69 | $admin_email = get_bloginfo('admin_email'); |
| 70 | 70 | $emails = get_option('wpshop_emails', null); |
| 71 | 71 | $email = empty($emails['contact_email']) ? $admin_email : $emails['contact_email']; |
| 72 | - echo '<input name="wpshop_emails[contact_email]" type="text" value="'.$email.'" /> |
|
| 73 | - <a href="#" title="'.__('This is the email on which customers can contact you','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 72 | + echo '<input name="wpshop_emails[contact_email]" type="text" value="' . $email . '" /> |
|
| 73 | + <a href="#" title="'.__('This is the email on which customers can contact you', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 74 | 74 | } |
| 75 | - public static function wpshop_options_validate_emails($input) {return $input;} |
|
| 75 | + public static function wpshop_options_validate_emails($input) {return $input; } |
|
| 76 | 76 | |
| 77 | 77 | public static function wpshop_send_confirmation_order_message_field() { |
| 78 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 79 | - $output = '<input type="checkbox" name="wpshop_emails[send_confirmation_order_message]" id="wpshop_emails_send_confirmation_order_message" ' . ( ( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ) ? 'checked="checked"' : '') . '/> '; |
|
| 80 | - $output .= '<label for="wpshop_emails_send_confirmation_order_message">'.__('Send confirmation order message when order is totally paid', 'wpshop').'</label>'; |
|
| 78 | + $email_option = get_option('wpshop_emails'); |
|
| 79 | + $output = '<input type="checkbox" name="wpshop_emails[send_confirmation_order_message]" id="wpshop_emails_send_confirmation_order_message" ' . ((!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) ? 'checked="checked"' : '') . '/> '; |
|
| 80 | + $output .= '<label for="wpshop_emails_send_confirmation_order_message">' . __('Send confirmation order message when order is totally paid', 'wpshop') . '</label>'; |
|
| 81 | 81 | echo $output; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - function wpshop_send_confirmation_order_message_validate( $input ) { |
|
| 84 | + function wpshop_send_confirmation_order_message_validate($input) { |
|
| 85 | 85 | return $input; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param unknown_type $input |
| 94 | 94 | * @return unknown |
| 95 | 95 | */ |
| 96 | - public static function wps_options_validate_emails( $input ) { |
|
| 96 | + public static function wps_options_validate_emails($input) { |
|
| 97 | 97 | return $input; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @param unknown_type $args |
| 103 | 103 | */ |
| 104 | - public static function wps_options_emails_field( $args ) { |
|
| 104 | + public static function wps_options_emails_field($args) { |
|
| 105 | 105 | $content = ''; |
| 106 | 106 | |
| 107 | - $current_message_id = get_option( $args['code'], '' ); |
|
| 107 | + $current_message_id = get_option($args['code'], ''); |
|
| 108 | 108 | $wps_message = new wps_message_ctr(); |
| 109 | - $options = $wps_message->getMessageListOption( $current_message_id ); |
|
| 109 | + $options = $wps_message->getMessageListOption($current_message_id); |
|
| 110 | 110 | |
| 111 | - if ( !empty( $options ) ) { |
|
| 111 | + if (!empty($options)) { |
|
| 112 | 112 | $content .= '<select name="' . $args['code'] . '" class="chosen_select" >'; |
| 113 | 113 | $content .= $options; |
| 114 | - $content .= '</select> <a id="wps-email-' . $current_message_id . '" title="' . __( 'Edit current selected message', 'wpshop' ) . '" href="' . admin_url( 'post.php?post=' . $current_message_id . '&action=edit' ) . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>'; |
|
| 114 | + $content .= '</select> <a id="wps-email-' . $current_message_id . '" title="' . __('Edit current selected message', 'wpshop') . '" href="' . admin_url('post.php?post=' . $current_message_id . '&action=edit') . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>'; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | echo $content; |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
| 4 | 6 | * |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -140,8 +142,7 @@ discard block |
||
| 140 | 142 | $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"'); |
| 141 | 143 | $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"'); |
| 142 | 144 | $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"'); |
| 143 | - } |
|
| 144 | - elseif ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) ) { |
|
| 145 | + } elseif ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) ) { |
|
| 145 | 146 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['id'])); |
| 146 | 147 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['id'])); |
| 147 | 148 | |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | class wpshop_advanced_settings{ |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * |
|
| 27 | - */ |
|
| 26 | + * |
|
| 27 | + */ |
|
| 28 | 28 | function declare_options(){ |
| 29 | 29 | add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options'); |
| 30 | 30 | register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options')); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * |
| 27 | 27 | */ |
| 28 | - public static function declare_options(){ |
|
| 29 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
| 28 | + public static function declare_options() { |
|
| 29 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
| 30 | 30 | |
| 31 | - if ( isset($page) && ( substr($page, 0, 13 ) == 'wpshop_option' || $page == 'wps-installer' ) ) { |
|
| 31 | + if (isset($page) && (substr($page, 0, 13) == 'wpshop_option' || $page == 'wps-installer')) { |
|
| 32 | 32 | wp_enqueue_media(); |
| 33 | 33 | } |
| 34 | - add_settings_section('wpshop_general_config','<span class="dashicons dashicons-info"></span>'. __('Shop main configuration', 'wpshop'), array('wpshop_general_options', 'plugin_section_text'), 'wpshop_general_config'); |
|
| 34 | + add_settings_section('wpshop_general_config', '<span class="dashicons dashicons-info"></span>' . __('Shop main configuration', 'wpshop'), array('wpshop_general_options', 'plugin_section_text'), 'wpshop_general_config'); |
|
| 35 | 35 | |
| 36 | 36 | register_setting('wpshop_options', 'wpshop_shop_type', array('wpshop_general_options', 'wpshop_options_validate_wpshop_shop_type')); |
| 37 | 37 | add_settings_field('wpshop_shop_type', __('Shop type', 'wpshop'), array('wpshop_general_options', 'wpshop_shop_type'), 'wpshop_general_config', 'wpshop_general_config'); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | /* Default currecy for the entire shop */ |
| 62 | 62 | public static function wpshop_shop_default_currency_field() { |
| 63 | - echo wpshop_attributes_unit::wpshop_shop_currency_list_field() . '<a href="#" title="'.__('This is the currency the shop will use','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 63 | + echo wpshop_attributes_unit::wpshop_shop_currency_list_field() . '<a href="#" title="' . __('This is the currency the shop will use', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public static function wpshop_default_weight_unity_field() { |
@@ -70,16 +70,16 @@ discard block |
||
| 70 | 70 | $current_weight = get_option('wpshop_shop_default_weight_unity'); |
| 71 | 71 | |
| 72 | 72 | $weight_options = ''; |
| 73 | - if ( !empty ($weight_group) ) { |
|
| 74 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE group_id = %d', $weight_group); |
|
| 73 | + if (!empty ($weight_group)) { |
|
| 74 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id = %d', $weight_group); |
|
| 75 | 75 | $weight_units = $wpdb->get_results($query); |
| 76 | - foreach ( $weight_units as $weight_unit) { |
|
| 77 | - $weight_options .= '<option value="'.$weight_unit->id.'"'.( ($weight_unit->id == $current_weight) ? ' selected="selected"' : null).'>'.$weight_unit->name.' ('.$weight_unit->unit.')</option>'; |
|
| 76 | + foreach ($weight_units as $weight_unit) { |
|
| 77 | + $weight_options .= '<option value="' . $weight_unit->id . '"' . (($weight_unit->id == $current_weight) ? ' selected="selected"' : null) . '>' . $weight_unit->name . ' (' . $weight_unit->unit . ')</option>'; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - echo '<select name="wpshop_shop_default_weight_unity">'.$weight_options.'</select> |
|
| 82 | - <a href="#" title="'.__('This is the weight unity the shop will use','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 81 | + echo '<select name="wpshop_shop_default_weight_unity">' . $weight_options . '</select> |
|
| 82 | + <a href="#" title="'.__('This is the weight unity the shop will use', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public static function wpshop_options_validate_default_currency($input) { |
@@ -94,30 +94,30 @@ discard block |
||
| 94 | 94 | $current_piloting = get_option('wpshop_shop_price_piloting', WPSHOP_PRODUCT_PRICE_PILOT); |
| 95 | 95 | |
| 96 | 96 | $piloting_options = ''; |
| 97 | - foreach($wpshop_price_piloting_types as $price_type) { |
|
| 98 | - $piloting_options .= '<option value="'.$price_type.'"'.(($price_type==$current_piloting) ? ' selected="selected"' : null).'>'.$price_type.'</option>'; |
|
| 97 | + foreach ($wpshop_price_piloting_types as $price_type) { |
|
| 98 | + $piloting_options .= '<option value="' . $price_type . '"' . (($price_type == $current_piloting) ? ' selected="selected"' : null) . '>' . $price_type . '</option>'; |
|
| 99 | 99 | } |
| 100 | - echo '<select name="wpshop_shop_price_piloting">'.$piloting_options.'</select> |
|
| 101 | - <a href="#" title=\''. __('You can choose if the price you will enter in each product is the "all tax include" price or the "tax free price"','wpshop') .'\' class="wpshop_infobulle_marker">?</a>'; |
|
| 100 | + echo '<select name="wpshop_shop_price_piloting">' . $piloting_options . '</select> |
|
| 101 | + <a href="#" title=\''. __('You can choose if the price you will enter in each product is the "all tax include" price or the "tax free price"', 'wpshop') . '\' class="wpshop_infobulle_marker">?</a>'; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | public static function wpshop_ga_account_id_field() { |
| 106 | 106 | $ga_account_id = get_option('wpshop_ga_account_id'); |
| 107 | - echo '<input type="text" name="wpshop_ga_account_id" value="'.$ga_account_id.'" />'; |
|
| 107 | + echo '<input type="text" name="wpshop_ga_account_id" value="' . $ga_account_id . '" />'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function wpshop_options_validate_ga_account_id ($input) { |
|
| 110 | + public static function wpshop_options_validate_ga_account_id($input) { |
|
| 111 | 111 | return $input; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public static function wpshop_options_validate_default_weight_unity ($input) { |
|
| 114 | + public static function wpshop_options_validate_default_weight_unity($input) { |
|
| 115 | 115 | return $input; |
| 116 | 116 | } |
| 117 | 117 | public static function wpshop_options_validate_price_piloting($input) { |
| 118 | 118 | global $wpdb; |
| 119 | 119 | |
| 120 | - $price_pilot_attribute_code = constant('WPSHOP_PRODUCT_PRICE_'.$input); |
|
| 120 | + $price_pilot_attribute_code = constant('WPSHOP_PRODUCT_PRICE_' . $input); |
|
| 121 | 121 | |
| 122 | 122 | $query = $wpdb->prepare( |
| 123 | 123 | "SELECT ATTRIBUTE.code, ATTR_SET_SECTION_DETAILS.id, ATTR_SET_SECTION_DETAILS.attribute_group_id, ATTR_SET_SECTION_DETAILS.position |
@@ -134,23 +134,23 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $new_def = array(); |
| 136 | 136 | foreach ($attributes_order as $attribute_group_id => $attribute_price_def) : |
| 137 | - if ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_TTC) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) ) { |
|
| 137 | + if (($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_TTC) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'])) { |
|
| 138 | 138 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['id'])); |
| 139 | 139 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['id'])); |
| 140 | 140 | |
| 141 | 141 | /** Update entries for quick add and variations */ |
| 142 | - $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"'); |
|
| 143 | - $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"'); |
|
| 144 | - $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"'); |
|
| 142 | + $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"'); |
|
| 143 | + $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"'); |
|
| 144 | + $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"'); |
|
| 145 | 145 | } |
| 146 | - elseif ( ($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']) ) { |
|
| 146 | + elseif (($price_pilot_attribute_code == WPSHOP_PRODUCT_PRICE_HT) && (!empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']) && !empty($attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) && ($attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position'] > $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position'])) { |
|
| 147 | 147 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['id'])); |
| 148 | 148 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'position' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_HT]['position']), array('id' => $attribute_price_def[WPSHOP_PRODUCT_PRICE_TTC]['id'])); |
| 149 | 149 | |
| 150 | 150 | /** Update entries for quick add and variations */ |
| 151 | - $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"'); |
|
| 152 | - $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"'); |
|
| 153 | - $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"'); |
|
| 151 | + $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"'); |
|
| 152 | + $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"'); |
|
| 153 | + $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"'); |
|
| 154 | 154 | } |
| 155 | 155 | endforeach; |
| 156 | 156 | |
@@ -161,37 +161,37 @@ discard block |
||
| 161 | 161 | public static function wpshop_shop_type() { |
| 162 | 162 | $shop_types = unserialize(WPSHOP_SHOP_TYPES); |
| 163 | 163 | $shop_types_options = ''; |
| 164 | - foreach($shop_types as $type) { |
|
| 165 | - $shop_types_options .= '<option value="'.$type.'"'.(($type==WPSHOP_DEFINED_SHOP_TYPE) ? ' selected="selected"' : null).'>'.__($type, 'wpshop').'</option>'; |
|
| 164 | + foreach ($shop_types as $type) { |
|
| 165 | + $shop_types_options .= '<option value="' . $type . '"' . (($type == WPSHOP_DEFINED_SHOP_TYPE) ? ' selected="selected"' : null) . '>' . __($type, 'wpshop') . '</option>'; |
|
| 166 | 166 | } |
| 167 | - echo '<select name="wpshop_shop_type">'.$shop_types_options.'</select><input type="hidden" name="old_wpshop_shop_type" value="'.WPSHOP_DEFINED_SHOP_TYPE.'" /> |
|
| 168 | - <a href="#" title="'.__('Define if you have a shop to sale item or just for item showing','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 167 | + echo '<select name="wpshop_shop_type">' . $shop_types_options . '</select><input type="hidden" name="old_wpshop_shop_type" value="' . WPSHOP_DEFINED_SHOP_TYPE . '" /> |
|
| 168 | + <a href="#" title="'.__('Define if you have a shop to sale item or just for item showing', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public static function wpshop_logo_field () { |
|
| 171 | + public static function wpshop_logo_field() { |
|
| 172 | 172 | $logo_option = get_option('wpshop_logo'); |
| 173 | 173 | |
| 174 | - $output = '<a href="#" id="wps-add-logo-picture" class="wps-bton-first-mini-rounded">' .__( 'Upload your logo', 'wpshop' ). '</a><br/>'; |
|
| 175 | - $output .= '<img id="wpshop_logo_thumbnail" src="' .( ( !empty($logo_option) ) ? $logo_option : WPSHOP_DEFAULT_CATEGORY_PICTURE ). '" alt="Logo" style="height : 40px; width : auto; border : 5px solid #E8E8E8; margin-top : 8px;" />'; |
|
| 176 | - $output .= '<input type="hidden" name="wpshop_logo" id="wpshop_logo_field" value="' .$logo_option. '" />'; |
|
| 177 | - $output .= '<br/><a href="#" id="wps-delete-shop-logo" '.( empty($logo_option) ? 'class="wpshopHide"' : '' ) .'>' . __( 'Delete this logo', 'wpshop' ) . '</a>'; |
|
| 174 | + $output = '<a href="#" id="wps-add-logo-picture" class="wps-bton-first-mini-rounded">' . __('Upload your logo', 'wpshop') . '</a><br/>'; |
|
| 175 | + $output .= '<img id="wpshop_logo_thumbnail" src="' . ((!empty($logo_option)) ? $logo_option : WPSHOP_DEFAULT_CATEGORY_PICTURE) . '" alt="Logo" style="height : 40px; width : auto; border : 5px solid #E8E8E8; margin-top : 8px;" />'; |
|
| 176 | + $output .= '<input type="hidden" name="wpshop_logo" id="wpshop_logo_field" value="' . $logo_option . '" />'; |
|
| 177 | + $output .= '<br/><a href="#" id="wps-delete-shop-logo" ' . (empty($logo_option) ? 'class="wpshopHide"' : '') . '>' . __('Delete this logo', 'wpshop') . '</a>'; |
|
| 178 | 178 | |
| 179 | 179 | echo $output; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - public static function wpshop_options_validate_logo ($input) { |
|
| 182 | + public static function wpshop_options_validate_logo($input) { |
|
| 183 | 183 | return $input; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | public static function wpshop_options_validate_wpshop_shop_type($input) { |
| 187 | 187 | global $current_db_version; |
| 188 | 188 | |
| 189 | - $current_installation_step = get_option( 'wps-installation-current-step', 1 ); |
|
| 190 | - if ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) ) { |
|
| 189 | + $current_installation_step = get_option('wps-installation-current-step', 1); |
|
| 190 | + if (WPSINSTALLER_STEPS_COUNT <= $current_installation_step || (!empty($current_db_version) && !empty($current_db_version['db_version']) && (51 < $current_db_version['db_version']))) { |
|
| 191 | 191 | $current_db_version['installation_state'] = 'completed'; |
| 192 | 192 | update_option('wpshop_db_options', $current_db_version); |
| 193 | - if ( $input == 'sale' ) { |
|
| 194 | - wpshop_install::wpshop_insert_default_pages( $input ); |
|
| 193 | + if ($input == 'sale') { |
|
| 194 | + wpshop_install::wpshop_insert_default_pages($input); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | return $input; |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | class wpshop_advanced_settings{ |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * |
|
| 27 | - */ |
|
| 26 | + * |
|
| 27 | + */ |
|
| 28 | 28 | function declare_options(){ |
| 29 | 29 | add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options'); |
| 30 | 30 | register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options')); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | * @package wpshop |
| 21 | 21 | * @subpackage librairies |
| 22 | 22 | */ |
| 23 | -class wpshop_advanced_settings{ |
|
| 23 | +class wpshop_advanced_settings { |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * |
| 27 | 27 | */ |
| 28 | - function declare_options(){ |
|
| 29 | - add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options'); |
|
| 28 | + function declare_options() { |
|
| 29 | + add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>' . __('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options'); |
|
| 30 | 30 | register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options')); |
| 31 | 31 | add_settings_field('wpshop_advanced_settings_field', '', array('wpshop_advanced_settings', 'advanced_settings_field'), 'wpshop_extra_options', 'wpshop_extra_options'); |
| 32 | 32 | } |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | echo __('This options screen allows you to add functionnalities to the plugin by adding some parameters we defined', 'wpshop'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public static function validate_options($input){ |
|
| 39 | + public static function validate_options($input) { |
|
| 40 | 40 | $new_input = array(); |
| 41 | - if ( !empty($input['new']) && !empty($input['new']['key']) && !empty($input['new']['value']) ) { |
|
| 41 | + if (!empty($input['new']) && !empty($input['new']['key']) && !empty($input['new']['value'])) { |
|
| 42 | 42 | $new_input[$input['new']['key']] = $input['new']['value']; |
| 43 | 43 | } |
| 44 | - if ( !empty($input['existing']) ) { |
|
| 45 | - foreach ( $input['existing'] as $extra_params_to_update ) { |
|
| 46 | - if ( !empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']) ) |
|
| 44 | + if (!empty($input['existing'])) { |
|
| 45 | + foreach ($input['existing'] as $extra_params_to_update) { |
|
| 46 | + if (!empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value'])) |
|
| 47 | 47 | $new_input[$extra_params_to_update['key']] = $extra_params_to_update['value']; |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | return $new_input; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public static function advanced_settings_field($input){ |
|
| 54 | + public static function advanced_settings_field($input) { |
|
| 55 | 55 | /* |
| 56 | 56 | WPSHOP_DEBUG_MODE_ALLOWED_IP |
| 57 | 57 | WPSHOP_DEBUG_MODE |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | <ul>'; |
| 70 | 70 | $wpshop_advanced_settings = get_option('wpshop_extra_options', array()); |
| 71 | 71 | |
| 72 | - if ( !empty($wpshop_advanced_settings) ) { |
|
| 73 | - $i=0; |
|
| 72 | + if (!empty($wpshop_advanced_settings)) { |
|
| 73 | + $i = 0; |
|
| 74 | 74 | |
| 75 | - foreach($wpshop_advanced_settings as $setting_name => $setting_value){ |
|
| 76 | - $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>'; |
|
| 75 | + foreach ($wpshop_advanced_settings as $setting_name => $setting_value) { |
|
| 76 | + $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>'; |
|
| 77 | 77 | $i++; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $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> |
|
| 81 | + $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> |
|
| 82 | 82 | </ul>'; |
| 83 | 83 | |
| 84 | 84 | echo $advanced_settings_output; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -43,8 +45,9 @@ discard block |
||
| 43 | 45 | } |
| 44 | 46 | if ( !empty($input['existing']) ) { |
| 45 | 47 | foreach ( $input['existing'] as $extra_params_to_update ) { |
| 46 | - if ( !empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']) ) |
|
| 47 | - $new_input[$extra_params_to_update['key']] = $extra_params_to_update['value']; |
|
| 48 | + if ( !empty($extra_params_to_update['key']) && !empty($extra_params_to_update['value']) ) { |
|
| 49 | + $new_input[$extra_params_to_update['key']] = $extra_params_to_update['value']; |
|
| 50 | + } |
|
| 48 | 51 | } |
| 49 | 52 | } |
| 50 | 53 | |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * Declare options |
| 27 | 27 | */ |
| 28 | 28 | public static function declare_options() { |
| 29 | - add_settings_section('wpshop_pages_option', '<span class="dashicons dashicons-welcome-write-blog"></span>'.__('WPShop pages configuration', 'wpshop'), array('wpshop_page_options', 'plugin_section_text'), 'wpshop_pages_option'); |
|
| 29 | + add_settings_section('wpshop_pages_option', '<span class="dashicons dashicons-welcome-write-blog"></span>' . __('WPShop pages configuration', 'wpshop'), array('wpshop_page_options', 'plugin_section_text'), 'wpshop_pages_option'); |
|
| 30 | 30 | |
| 31 | 31 | /** Get default messages defined into xml files */ |
| 32 | - $default_pages = new SimpleXMLElement( file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml' ) ); |
|
| 32 | + $default_pages = new SimpleXMLElement(file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml')); |
|
| 33 | 33 | /** Read default emails for options creation */ |
| 34 | - foreach ( $default_pages->xpath( '//pages/page' ) as $page ) { |
|
| 35 | - if ( ( WPSHOP_DEFINED_SHOP_TYPE == (string)$page->attributes()->shop_type ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) { |
|
| 36 | - register_setting( 'wpshop_options', (string)$page->attributes()->code, array( 'wpshop_page_options', 'wpshop_options_validate_wpshop_shop_pages' ) ); |
|
| 37 | - add_settings_field( (string)$page->attributes()->code, __( (string)$page->description, 'wpshop' ), array( 'wpshop_page_options', 'wps_pages_field' ), 'wpshop_pages_option', 'wpshop_pages_option', array( 'code' => (string)$page->attributes()->code, ) ); |
|
| 34 | + foreach ($default_pages->xpath('//pages/page') as $page) { |
|
| 35 | + if ((WPSHOP_DEFINED_SHOP_TYPE == (string)$page->attributes()->shop_type) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) { |
|
| 36 | + register_setting('wpshop_options', (string)$page->attributes()->code, array('wpshop_page_options', 'wpshop_options_validate_wpshop_shop_pages')); |
|
| 37 | + add_settings_field((string)$page->attributes()->code, __((string)$page->description, 'wpshop'), array('wpshop_page_options', 'wps_pages_field'), 'wpshop_pages_option', 'wpshop_pages_option', array('code' => (string)$page->attributes()->code,)); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -43,26 +43,26 @@ discard block |
||
| 43 | 43 | * Common section description |
| 44 | 44 | */ |
| 45 | 45 | public static function plugin_section_text() { |
| 46 | - printf( __( 'We define default pages content and layout, however you have possibility to %sedit them%s', 'wpshop' ), '<a href="' . admin_url( 'edit.php?post_type=page' ) . '" target="_wps_content_customisation" >', '</a>'); |
|
| 46 | + printf(__('We define default pages content and layout, however you have possibility to %sedit them%s', 'wpshop'), '<a href="' . admin_url('edit.php?post_type=page') . '" target="_wps_content_customisation" >', '</a>'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Shop pages configurations |
| 51 | 51 | */ |
| 52 | - public static function wps_pages_field( $args ) { |
|
| 52 | + public static function wps_pages_field($args) { |
|
| 53 | 53 | $content = ''; |
| 54 | 54 | |
| 55 | - $current_page_id = get_option( $args['code'], '' ); |
|
| 55 | + $current_page_id = get_option($args['code'], ''); |
|
| 56 | 56 | $post_list = get_pages(); |
| 57 | 57 | if (!empty($post_list)) { |
| 58 | 58 | $content .= '<select name="' . $args['code'] . '" class="chosen_select shop-content-customisation" ><option value="" >' . __('Choose a page to associate', 'wpshop') . '</option>'; |
| 59 | - $p=1; |
|
| 59 | + $p = 1; |
|
| 60 | 60 | $error = false; |
| 61 | 61 | foreach ($post_list as $post) { |
| 62 | 62 | $selected = (!empty($current_page_id) && ($current_page_id == $post->ID)) ? ' selected="selected"' : ''; |
| 63 | - $content .= '<option'.$selected.' value="' . $post->ID . '" >' . $post->post_title . '</option>'; |
|
| 63 | + $content .= '<option' . $selected . ' value="' . $post->ID . '" >' . $post->post_title . '</option>'; |
|
| 64 | 64 | } |
| 65 | - $content .= '</select> <a id="wps-page-' . $current_page_id . '" title="' . __( 'Edit current selected page', 'wpshop' ) . '" href="' . admin_url( 'post.php?post=' . $current_page_id . '&action=edit' ) . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-page dashicons dashicons-edit"></a>'; |
|
| 65 | + $content .= '</select> <a id="wps-page-' . $current_page_id . '" title="' . __('Edit current selected page', 'wpshop') . '" href="' . admin_url('post.php?post=' . $current_page_id . '&action=edit') . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-page dashicons dashicons-edit"></a>'; |
|
| 66 | 66 | } |
| 67 | 67 | wp_reset_query(); |
| 68 | 68 | |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
| 4 | 6 | * |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | 403 | * Delete a variation |
| 404 | - */ |
|
| 404 | + */ |
|
| 405 | 405 | function ajax_delete_variation() { |
| 406 | 406 | check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
| 407 | 407 | $result = false; |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * Delete a variation defintion into head product |
| 425 | - */ |
|
| 425 | + */ |
|
| 426 | 426 | function ajax_wpshop_delete_head_product_variation_def() { |
| 427 | 427 | check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
| 428 | 428 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Ajax request management file |
| 4 | 6 | * |
@@ -463,12 +465,10 @@ discard block |
||
| 463 | 465 | wpshop_payment::set_payment_transaction_number($order_id, $transaction_id); |
| 464 | 466 | } |
| 465 | 467 | $result = json_encode(array(true,'')); |
| 466 | - } |
|
| 467 | - else { |
|
| 468 | + } else { |
|
| 468 | 469 | $result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop'))); |
| 469 | 470 | } |
| 470 | - } |
|
| 471 | - else { |
|
| 471 | + } else { |
|
| 472 | 472 | $result = json_encode(array(false,__('Bad order identifier', 'wpshop'))); |
| 473 | 473 | } |
| 474 | 474 | echo json_encode($result); |
@@ -485,8 +485,7 @@ discard block |
||
| 485 | 485 | if ( !empty($order_id) ) { |
| 486 | 486 | $result = (array(true, '<h1>'.__('Tracking number','wpshop').'</h1><p>'.__('Enter a tracking number, or leave blank:','wpshop').'</p><input type="hidden" value="'.$order_id.'" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>'.__('Enter a tracking link, or leave blank: (http included)','wpshop').'</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />')); |
| 487 | 487 | |
| 488 | - } |
|
| 489 | - else { |
|
| 488 | + } else { |
|
| 490 | 489 | $result = json_encode(array(false, __('Order reference error', 'wpshop'))); |
| 491 | 490 | } |
| 492 | 491 | echo json_encode($result); |
@@ -524,16 +523,14 @@ discard block |
||
| 524 | 523 | $output_shipping_box .= '<li><strong>'.__('Tracking link','wpshop').' :</strong> '.$order['order_trackingLink'].'</li>'; |
| 525 | 524 | |
| 526 | 525 | $result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content ); |
| 527 | - } |
|
| 528 | - else { |
|
| 526 | + } else { |
|
| 529 | 527 | wpshop_payment::setOrderPaymentStatus($order_id, $order_state); |
| 530 | 528 | |
| 531 | 529 | $result = array(true, $order_state, __($order_status[$order_state], 'wpshop')); |
| 532 | 530 | } |
| 533 | 531 | update_post_meta($order_id, '_order_postmeta', $order); |
| 534 | 532 | update_post_meta($order_id, '_wpshop_order_status', $order_state); |
| 535 | - } |
|
| 536 | - else { |
|
| 533 | + } else { |
|
| 537 | 534 | $result = array(false, __('Incorrect order request', 'wpshop')); |
| 538 | 535 | } |
| 539 | 536 | |
@@ -619,8 +616,7 @@ discard block |
||
| 619 | 616 | unset($tpl_component); |
| 620 | 617 | |
| 621 | 618 | echo json_encode(array(true, str_replace('optionsUpdate', 'options', $output))); |
| 622 | - } |
|
| 623 | - else { |
|
| 619 | + } else { |
|
| 624 | 620 | echo json_encode(array(false, __('The value you entered already exist', 'wpshop'))); |
| 625 | 621 | } |
| 626 | 622 | die(); |
@@ -665,13 +661,11 @@ discard block |
||
| 665 | 661 | ); |
| 666 | 662 | $new_option_id = wp_insert_post($new_post); |
| 667 | 663 | $input_def['valueToPut'] = 'index'; |
| 668 | - } |
|
| 669 | - else { |
|
| 664 | + } else { |
|
| 670 | 665 | $result_status = false; |
| 671 | 666 | $result = __('This value already exist for this attribute', 'wpshop'); |
| 672 | 667 | } |
| 673 | - } |
|
| 674 | - else { |
|
| 668 | + } else { |
|
| 675 | 669 | /** Check if the given value does not exist */ |
| 676 | 670 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE (label = %s OR value = %s) AND attribute_id = %d AND status = 'valid'", str_replace(",", ".", $attribute_options_label), $attribute_options_value, $attribute->id); |
| 677 | 671 | $existing_values = $wpdb->get_results($query); |
@@ -687,8 +681,7 @@ discard block |
||
| 687 | 681 | /** Add the new value into database */ |
| 688 | 682 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $attribute->id, 'position' => $position, 'label' => str_replace(",", ".", stripslashes($attribute_options_label)), 'value' => stripslashes($attribute_options_value))); |
| 689 | 683 | $new_option_id = $wpdb->insert_id; |
| 690 | - } |
|
| 691 | - else { |
|
| 684 | + } else { |
|
| 692 | 685 | $result_status = false; |
| 693 | 686 | $result = __('This value already exist for this attribute', 'wpshop'); |
| 694 | 687 | } |
@@ -839,8 +832,7 @@ discard block |
||
| 839 | 832 | $combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 840 | 833 | $result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="'.sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')).'" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">'.$combo_wp_type.'</div>'; |
| 841 | 834 | $result .= '<input type="hidden" value="no" name="delete_items_of_entity" id="delete_items_of_entity" /><input type="hidden" value="no" name="delete_entity" id="delete_entity" />'; |
| 842 | - } |
|
| 843 | - else { |
|
| 835 | + } else { |
|
| 844 | 836 | $result .= '<input type="hidden" value="' . $attribute->default_value . '" name="internal_data" id="internal_data" />'; |
| 845 | 837 | |
| 846 | 838 | unset($input_def); |
@@ -897,8 +889,7 @@ discard block |
||
| 897 | 889 | } |
| 898 | 890 | } |
| 899 | 891 | } |
| 900 | - } |
|
| 901 | - else { |
|
| 892 | + } else { |
|
| 902 | 893 | $post_list = query_posts(array('post_type' => $internal_data_type)); |
| 903 | 894 | if (!empty($post_list)) { |
| 904 | 895 | $p=1; |
@@ -907,8 +898,7 @@ discard block |
||
| 907 | 898 | $last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title)); |
| 908 | 899 | if(is_int($last_insert) && $delete_items_of_entity){ |
| 909 | 900 | wp_delete_post($post->ID, true); |
| 910 | - } |
|
| 911 | - else{ |
|
| 901 | + } else{ |
|
| 912 | 902 | $error = true; |
| 913 | 903 | } |
| 914 | 904 | $p++; |
@@ -972,13 +962,11 @@ discard block |
||
| 972 | 962 | } |
| 973 | 963 | $result = true; |
| 974 | 964 | $result_output = '<p class="wpshop_duplicate_attribute_result" ><a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&action=edit&id=' . $new_attribute_id) . '" >' . __('Edit the new attribute', 'wpshop') . '</a></p>'; |
| 975 | - } |
|
| 976 | - else { |
|
| 965 | + } else { |
|
| 977 | 966 | $result = false; |
| 978 | 967 | $result_output = __('An error occured while duplicating attribute', 'wpshop'); |
| 979 | 968 | } |
| 980 | - } |
|
| 981 | - else { |
|
| 969 | + } else { |
|
| 982 | 970 | $result = false; |
| 983 | 971 | $result_output = __('This attribute has already been duplicate to this entity', 'wpshop'); |
| 984 | 972 | } |
@@ -1008,8 +996,7 @@ discard block |
||
| 1008 | 996 | /* Test if we want display the group unit list OR the unit list */ |
| 1009 | 997 | if ( $selected_list == 'group unit' ) { |
| 1010 | 998 | $list = wpshop_attributes_unit::get_unit_group(); |
| 1011 | - } |
|
| 1012 | - else { |
|
| 999 | + } else { |
|
| 1013 | 1000 | $list = wpshop_attributes_unit::get_unit_list_for_group($group); |
| 1014 | 1001 | } |
| 1015 | 1002 | |
@@ -1017,8 +1004,7 @@ discard block |
||
| 1017 | 1004 | $response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>'; |
| 1018 | 1005 | } |
| 1019 | 1006 | $result = array(true, $response); |
| 1020 | - } |
|
| 1021 | - else { |
|
| 1007 | + } else { |
|
| 1022 | 1008 | $result = array(false, __('Incorrect order request', 'wpshop')); |
| 1023 | 1009 | } |
| 1024 | 1010 | |
@@ -1055,14 +1041,12 @@ discard block |
||
| 1055 | 1041 | $sub_modif .= $column_name; |
| 1056 | 1042 | if( !empty($columns->Field) && ($columns->Field == $column_name) ){ |
| 1057 | 1043 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />'; |
| 1058 | - } |
|
| 1059 | - else{ |
|
| 1044 | + } else{ |
|
| 1060 | 1045 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />'; |
| 1061 | 1046 | $error_nb++; |
| 1062 | 1047 | if ( !empty($error_list[$plugin_db_version]) ) { |
| 1063 | 1048 | $error_list[$plugin_db_version] += 1; |
| 1064 | - } |
|
| 1065 | - else { |
|
| 1049 | + } else { |
|
| 1066 | 1050 | $error_list[$plugin_db_version] = 1; |
| 1067 | 1051 | } |
| 1068 | 1052 | } |
@@ -1080,8 +1064,7 @@ discard block |
||
| 1080 | 1064 | $sub_modif .= $column_name; |
| 1081 | 1065 | if(empty($columns) || ($columns->Field != $column_name)){ |
| 1082 | 1066 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been deleted', 'wpshop') . '" title="' . __('Field has been deleted', 'wpshop') . '" class="db_deleted_field_check" />'; |
| 1083 | - } |
|
| 1084 | - else{ |
|
| 1067 | + } else{ |
|
| 1085 | 1068 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />'; |
| 1086 | 1069 | $error_nb++; |
| 1087 | 1070 | $error_list[$plugin_db_version] += 1; |
@@ -1103,8 +1086,7 @@ discard block |
||
| 1103 | 1086 | $changed_key = 'type'; |
| 1104 | 1087 | if($columns->Type == $field_infos['type']){ |
| 1105 | 1088 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />'; |
| 1106 | - } |
|
| 1107 | - else{ |
|
| 1089 | + } else{ |
|
| 1108 | 1090 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />'; |
| 1109 | 1091 | $error_nb++; |
| 1110 | 1092 | $error_list[$plugin_db_version] += 1; |
@@ -1116,8 +1098,7 @@ discard block |
||
| 1116 | 1098 | $changed_key = 'original_name'; |
| 1117 | 1099 | if($columns->Field == $field_infos['field']){ |
| 1118 | 1100 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />'; |
| 1119 | - } |
|
| 1120 | - else{ |
|
| 1101 | + } else{ |
|
| 1121 | 1102 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />'; |
| 1122 | 1103 | $error_nb++; |
| 1123 | 1104 | $error_list[$plugin_db_version] += 1; |
@@ -1140,8 +1121,7 @@ discard block |
||
| 1140 | 1121 | $sub_modif .= $column_name; |
| 1141 | 1122 | if((empty($columns)) || ($columns->Column_name != $column_name)){ |
| 1142 | 1123 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been deleted', 'wpshop') . '" title="' . __('Index has been deleted', 'wpshop') . '" class="db_deleted_index_check" />'; |
| 1143 | - } |
|
| 1144 | - else{ |
|
| 1124 | + } else{ |
|
| 1145 | 1125 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exists', 'wpshop') . '" title="' . __('Index does not exists', 'wpshop') . '" class="db_deleted_index_check" />'; |
| 1146 | 1126 | $error_nb++; |
| 1147 | 1127 | $error_list[$plugin_db_version] += 1; |
@@ -1160,8 +1140,7 @@ discard block |
||
| 1160 | 1140 | $sub_modif .= $column_name; |
| 1161 | 1141 | if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){ |
| 1162 | 1142 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been created', 'wpshop') . '" title="' . __('Index has been created', 'wpshop') . '" class="db_added_index_check" />'; |
| 1163 | - } |
|
| 1164 | - else{ |
|
| 1143 | + } else{ |
|
| 1165 | 1144 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exist', 'wpshop') . '" title="' . __('Index does not exist', 'wpshop') . '" class="db_added_index_check" />'; |
| 1166 | 1145 | $error_nb++; |
| 1167 | 1146 | $error_list[$plugin_db_version] += 1; |
@@ -1180,14 +1159,12 @@ discard block |
||
| 1180 | 1159 | $table_exists = $wpdb->query($query); |
| 1181 | 1160 | if($table_exists == 1){ |
| 1182 | 1161 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been created', 'wpshop') . '" title="' . __('Table has been created', 'wpshop') . '" class="db_table_check" />'; |
| 1183 | - } |
|
| 1184 | - else{ |
|
| 1162 | + } else{ |
|
| 1185 | 1163 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been created', 'wpshop') . '" title="' . __('Table has not been created', 'wpshop') . '" class="db_table_check" />'; |
| 1186 | 1164 | $error_nb++; |
| 1187 | 1165 | if ( !empty($error_list[$plugin_db_version]) ) { |
| 1188 | 1166 | $error_list[$plugin_db_version] += 1; |
| 1189 | - } |
|
| 1190 | - else { |
|
| 1167 | + } else { |
|
| 1191 | 1168 | $error_list[$plugin_db_version] = 1; |
| 1192 | 1169 | } |
| 1193 | 1170 | } |
@@ -1208,21 +1185,17 @@ discard block |
||
| 1208 | 1185 | $error_nb++; |
| 1209 | 1186 | if ( !empty($error_list[$plugin_db_version]) ) { |
| 1210 | 1187 | $error_list[$plugin_db_version] += 1; |
| 1211 | - } |
|
| 1212 | - else { |
|
| 1188 | + } else { |
|
| 1213 | 1189 | $error_list[$plugin_db_version] = 1; |
| 1214 | 1190 | } |
| 1215 | - } |
|
| 1216 | - elseif($table_exists == 1){ |
|
| 1191 | + } elseif($table_exists == 1){ |
|
| 1217 | 1192 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been renamed', 'wpshop') . '" title="' . __('Table has been renamed', 'wpshop') . '" class="db_rename_table_check" />'; |
| 1218 | - } |
|
| 1219 | - else{ |
|
| 1193 | + } else{ |
|
| 1220 | 1194 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_rename_table_check" />'; |
| 1221 | 1195 | $error_nb++; |
| 1222 | 1196 | if ( !empty($error_list[$plugin_db_version]) ) { |
| 1223 | 1197 | $error_list[$plugin_db_version] += 1; |
| 1224 | - } |
|
| 1225 | - else { |
|
| 1198 | + } else { |
|
| 1226 | 1199 | $error_list[$plugin_db_version] = 1; |
| 1227 | 1200 | } |
| 1228 | 1201 | } |
@@ -1244,24 +1217,20 @@ discard block |
||
| 1244 | 1217 | $error_nb++; |
| 1245 | 1218 | if ( !empty($error_list[$plugin_db_version]) ) { |
| 1246 | 1219 | $error_list[$plugin_db_version] += 1; |
| 1247 | - } |
|
| 1248 | - else { |
|
| 1220 | + } else { |
|
| 1249 | 1221 | $error_list[$plugin_db_version] = 1; |
| 1250 | 1222 | } |
| 1251 | - } |
|
| 1252 | - else{ |
|
| 1223 | + } else{ |
|
| 1253 | 1224 | $deleted_table_result = '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Table has not been deleted', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />'; |
| 1254 | 1225 | $warning_nb++; |
| 1255 | 1226 | if ( !empty($warning_list[$plugin_db_version]) ) { |
| 1256 | 1227 | $warning_list[$plugin_db_version] += 1; |
| 1257 | - } |
|
| 1258 | - else { |
|
| 1228 | + } else { |
|
| 1259 | 1229 | $warning_list[$plugin_db_version] = 1; |
| 1260 | 1230 | } |
| 1261 | 1231 | } |
| 1262 | 1232 | $sub_modif .= $deleted_table_result; |
| 1263 | - } |
|
| 1264 | - else{ |
|
| 1233 | + } else{ |
|
| 1265 | 1234 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been deleted', 'wpshop') . '" title="' . __('Table has been deleted', 'wpshop') . '" class="db_deleted_table_check" />'; |
| 1266 | 1235 | } |
| 1267 | 1236 | $sub_modif .= ' / '; |
@@ -1359,8 +1328,7 @@ discard block |
||
| 1359 | 1328 | |
| 1360 | 1329 | if ( $has_error ) { |
| 1361 | 1330 | $output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin'); |
| 1362 | - } |
|
| 1363 | - else { |
|
| 1331 | + } else { |
|
| 1364 | 1332 | $output_ok .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin'); |
| 1365 | 1333 | } |
| 1366 | 1334 | } |
@@ -1525,8 +1493,7 @@ discard block |
||
| 1525 | 1493 | if ( $last_histo === false ) { |
| 1526 | 1494 | $has_error = true; |
| 1527 | 1495 | $error_count++; |
| 1528 | - } |
|
| 1529 | - else { |
|
| 1496 | + } else { |
|
| 1530 | 1497 | $wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) ); |
| 1531 | 1498 | } |
| 1532 | 1499 | } |
@@ -1545,8 +1512,7 @@ discard block |
||
| 1545 | 1512 | if ( $new_value === false ) { |
| 1546 | 1513 | $has_error = true; |
| 1547 | 1514 | $error_count++; |
| 1548 | - } |
|
| 1549 | - else { |
|
| 1515 | + } else { |
|
| 1550 | 1516 | /** Save new atribute values in product metadata */ |
| 1551 | 1517 | $current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true); |
| 1552 | 1518 | $current_product_metadata[$to_attribute->code] = $element->value; |
@@ -1562,23 +1528,19 @@ discard block |
||
| 1562 | 1528 | if ( !$has_error ) { |
| 1563 | 1529 | $response['status'] = true; |
| 1564 | 1530 | $response['error'] = __('Transfert between attribute is done', 'wpshop'); |
| 1565 | - } |
|
| 1566 | - else { |
|
| 1531 | + } else { |
|
| 1567 | 1532 | $response['status'] = false; |
| 1568 | 1533 | $response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count); |
| 1569 | 1534 | } |
| 1570 | - } |
|
| 1571 | - else { |
|
| 1535 | + } else { |
|
| 1572 | 1536 | $response['status'] = false; |
| 1573 | 1537 | $response['error'] = __('There are no element corresponding to attribute choosen to copy from', 'wpshop'); |
| 1574 | 1538 | } |
| 1575 | - } |
|
| 1576 | - else { |
|
| 1539 | + } else { |
|
| 1577 | 1540 | $response['status'] = false; |
| 1578 | 1541 | $response['error'] = __('Both attribute must have same data type to be updated', 'wpshop'); |
| 1579 | 1542 | } |
| 1580 | - } |
|
| 1581 | - else { |
|
| 1543 | + } else { |
|
| 1582 | 1544 | $response['status'] = false; |
| 1583 | 1545 | $response['error'] = __('You have to choose attributes in order to update values', 'wpshop'); |
| 1584 | 1546 | } |
@@ -1670,8 +1632,7 @@ discard block |
||
| 1670 | 1632 | if ( !empty($_POST['wps_update_att_for_variation_required_state']) && ($_POST['wps_update_att_for_variation_required_state'] != 'no_changes') ) { |
| 1671 | 1633 | if ( $_POST['wps_update_att_for_variation_required_state'] == 'yes') { |
| 1672 | 1634 | $meta_value['options']['required_attributes'][$attribute->code] = $attribute->code; |
| 1673 | - } |
|
| 1674 | - else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) { |
|
| 1635 | + } else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) { |
|
| 1675 | 1636 | unset($meta_value['options']['required_attributes'][$attribute->code]); |
| 1676 | 1637 | } |
| 1677 | 1638 | } |
@@ -1680,8 +1641,7 @@ discard block |
||
| 1680 | 1641 | if ( !empty($_POST['wps_update_att_for_variation']['text_from']) && ($_POST['wps_update_att_for_variation']['text_from'] != 'no_changes') ) { |
| 1681 | 1642 | if ( $_POST['wps_update_att_for_variation']['text_from'] == 'yes' ) { |
| 1682 | 1643 | $meta_value['options']['price_display']['text_from'] = 'on'; |
| 1683 | - } |
|
| 1684 | - else if( !empty($meta_value['options']['price_display']['text_from']) ) { |
|
| 1644 | + } else if( !empty($meta_value['options']['price_display']['text_from']) ) { |
|
| 1685 | 1645 | unset($meta_value['options']['price_display']['text_from']); |
| 1686 | 1646 | } |
| 1687 | 1647 | } |
@@ -1689,8 +1649,7 @@ discard block |
||
| 1689 | 1649 | if ( !empty($_POST['wps_update_att_for_variation']['lower_price']) && ($_POST['wps_update_att_for_variation']['lower_price'] != 'no_changes') ) { |
| 1690 | 1650 | if ( $_POST['wps_update_att_for_variation']['lower_price'] == 'yes' ) { |
| 1691 | 1651 | $meta_value['options']['price_display']['lower_price'] = 'on'; |
| 1692 | - } |
|
| 1693 | - else if( !empty($meta_value['options']['price_display']['lower_price']) ) { |
|
| 1652 | + } else if( !empty($meta_value['options']['price_display']['lower_price']) ) { |
|
| 1694 | 1653 | unset($meta_value['options']['price_display']['lower_price']); |
| 1695 | 1654 | } |
| 1696 | 1655 | } |
@@ -1769,20 +1728,16 @@ discard block |
||
| 1769 | 1728 | $activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3])); |
| 1770 | 1729 | } |
| 1771 | 1730 | $state = true; |
| 1772 | - } |
|
| 1773 | - else { |
|
| 1731 | + } else { |
|
| 1774 | 1732 | $result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop')); |
| 1775 | 1733 | } |
| 1776 | - } |
|
| 1777 | - else { |
|
| 1734 | + } else { |
|
| 1778 | 1735 | $result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop')); |
| 1779 | 1736 | } |
| 1780 | - } |
|
| 1781 | - else { |
|
| 1737 | + } else { |
|
| 1782 | 1738 | $result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop')); |
| 1783 | 1739 | } |
| 1784 | - } |
|
| 1785 | - else { |
|
| 1740 | + } else { |
|
| 1786 | 1741 | $result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop')); |
| 1787 | 1742 | } |
| 1788 | 1743 | $activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS); |
@@ -1810,12 +1765,10 @@ discard block |
||
| 1810 | 1765 | if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) { |
| 1811 | 1766 | $result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop')); |
| 1812 | 1767 | $state = false; |
| 1813 | - } |
|
| 1814 | - else { |
|
| 1768 | + } else { |
|
| 1815 | 1769 | $result = array(false, __('An error occured','wpshop'), __('Activated','wpshop')); |
| 1816 | 1770 | } |
| 1817 | - } |
|
| 1818 | - else { |
|
| 1771 | + } else { |
|
| 1819 | 1772 | $result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop')); |
| 1820 | 1773 | } |
| 1821 | 1774 | } |
@@ -1853,8 +1806,7 @@ discard block |
||
| 1853 | 1806 | if(!empty($attribute->id)) { |
| 1854 | 1807 | if( !empty($_POST['submitOrderInfos']) ) { |
| 1855 | 1808 | $value = $_POST['attribute'][$attribute->data_type][$attribute->code]; |
| 1856 | - } |
|
| 1857 | - else { |
|
| 1809 | + } else { |
|
| 1858 | 1810 | $value = ''; |
| 1859 | 1811 | if ( $attribute->code != 'user_pass') { |
| 1860 | 1812 | $code = $attribute->code; |
@@ -1925,16 +1877,14 @@ discard block |
||
| 1925 | 1877 | |
| 1926 | 1878 | if ( $wpshop_format_result ) { |
| 1927 | 1879 | $data = empty($data) ? __('No match', 'wpshop') : $data; |
| 1928 | - } |
|
| 1929 | - else { |
|
| 1880 | + } else { |
|
| 1930 | 1881 | if ( !empty($data) ) { |
| 1931 | 1882 | $temp_data = $data; |
| 1932 | 1883 | unset( $data ); |
| 1933 | 1884 | foreach ( $temp_data as $post) { |
| 1934 | 1885 | $data[$post->ID] = $post->ID . ' - ' . $post->post_title; |
| 1935 | 1886 | } |
| 1936 | - } |
|
| 1937 | - else { |
|
| 1887 | + } else { |
|
| 1938 | 1888 | $data = array(); |
| 1939 | 1889 | } |
| 1940 | 1890 | } |
@@ -1996,8 +1946,7 @@ discard block |
||
| 1996 | 1946 | $product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : ''; |
| 1997 | 1947 | $product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : ''; |
| 1998 | 1948 | $product_img = ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : ''; |
| 1999 | - } |
|
| 2000 | - else { |
|
| 1949 | + } else { |
|
| 2001 | 1950 | $product_title = $product->post_title; |
| 2002 | 1951 | $product_description = $product->post_content; |
| 2003 | 1952 | $product_img = get_the_post_thumbnail( $product_id, 'thumbnail'); |
@@ -2011,8 +1960,7 @@ discard block |
||
| 2011 | 1960 | |
| 2012 | 1961 | echo json_encode( array(true) ); |
| 2013 | 1962 | die(); |
| 2014 | - } |
|
| 2015 | - else { |
|
| 1963 | + } else { |
|
| 2016 | 1964 | $return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type ); |
| 2017 | 1965 | } |
| 2018 | 1966 | |
@@ -2029,8 +1977,7 @@ discard block |
||
| 2029 | 1977 | require_once(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 2030 | 1978 | $succes_message_box = ob_get_contents(); |
| 2031 | 1979 | ob_end_clean(); |
| 2032 | - } |
|
| 2033 | - else { |
|
| 1980 | + } else { |
|
| 2034 | 1981 | $succes_message_box = wpshop_display::display_template_element($template_part, array('PRODUCT_ID' => $product_id)); |
| 2035 | 1982 | } |
| 2036 | 1983 | unset($tpl_component); |
@@ -2047,12 +1994,10 @@ discard block |
||
| 2047 | 1994 | |
| 2048 | 1995 | if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) { |
| 2049 | 1996 | $idp = $product_to_add_to_cart[$new_pid]['variations'][0]; |
| 2050 | - } |
|
| 2051 | - else { |
|
| 1997 | + } else { |
|
| 2052 | 1998 | if( strstr( $new_pid, '__') ) { |
| 2053 | 1999 | $idp = $new_pid; |
| 2054 | - } |
|
| 2055 | - else { |
|
| 2000 | + } else { |
|
| 2056 | 2001 | $idp = $product_to_add_to_cart[$new_pid]['id']; |
| 2057 | 2002 | } |
| 2058 | 2003 | } |
@@ -2077,8 +2022,7 @@ discard block |
||
| 2077 | 2022 | if ( !empty($related_products) ) { |
| 2078 | 2023 | // $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>'; |
| 2079 | 2024 | $linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>'; |
| 2080 | - } |
|
| 2081 | - else { |
|
| 2025 | + } else { |
|
| 2082 | 2026 | $linked_products = ''; |
| 2083 | 2027 | } |
| 2084 | 2028 | |
@@ -2088,8 +2032,7 @@ discard block |
||
| 2088 | 2032 | $modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array() ); |
| 2089 | 2033 | |
| 2090 | 2034 | $response = array( true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content ); |
| 2091 | - } |
|
| 2092 | - else { |
|
| 2035 | + } else { |
|
| 2093 | 2036 | $response = array( false, $return ); |
| 2094 | 2037 | } |
| 2095 | 2038 | |
@@ -2133,8 +2076,7 @@ discard block |
||
| 2133 | 2076 | } |
| 2134 | 2077 | $return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid ); |
| 2135 | 2078 | $response[] = $return; |
| 2136 | - } |
|
| 2137 | - else { |
|
| 2079 | + } else { |
|
| 2138 | 2080 | $response[] = false; |
| 2139 | 2081 | $response[] = __('Parameters error.','wpshop'); |
| 2140 | 2082 | } |
@@ -2278,16 +2220,13 @@ discard block |
||
| 2278 | 2220 | $permalink_option = get_option('permalink_structure'); |
| 2279 | 2221 | if ( !empty($permalink_option) ) { |
| 2280 | 2222 | $cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok'; |
| 2281 | - } |
|
| 2282 | - else { |
|
| 2223 | + } else { |
|
| 2283 | 2224 | $cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok'; |
| 2284 | 2225 | } |
| 2285 | - } |
|
| 2286 | - else { |
|
| 2226 | + } else { |
|
| 2287 | 2227 | if ( !empty($_SESSION['cart']) ) { |
| 2288 | 2228 | $cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) ); |
| 2289 | - } |
|
| 2290 | - else { |
|
| 2229 | + } else { |
|
| 2291 | 2230 | $cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) ); |
| 2292 | 2231 | } |
| 2293 | 2232 | } |
@@ -2347,9 +2286,7 @@ discard block |
||
| 2347 | 2286 | $retour .= '<div class="wpshop_cls"></div>'; |
| 2348 | 2287 | $result = json_encode( array(true, $retour) ); |
| 2349 | 2288 | |
| 2350 | - } |
|
| 2351 | - |
|
| 2352 | - elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) { |
|
| 2289 | + } elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) { |
|
| 2353 | 2290 | $order_info_postmeta = get_post_meta($_REQUEST['order_id'], '_order_info', true); |
| 2354 | 2291 | |
| 2355 | 2292 | $billing_id_attribute_set = get_option('wpshop_billing_address'); |
@@ -2364,8 +2301,7 @@ discard block |
||
| 2364 | 2301 | } |
| 2365 | 2302 | |
| 2366 | 2303 | $result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) ); |
| 2367 | - } |
|
| 2368 | - else { |
|
| 2304 | + } else { |
|
| 2369 | 2305 | // Check the attribute set id of Billing Address |
| 2370 | 2306 | $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', ''); |
| 2371 | 2307 | $attribute_set_id = $wpdb->get_var($query); |
@@ -2426,8 +2362,7 @@ discard block |
||
| 2426 | 2362 | $user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) ); |
| 2427 | 2363 | $query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id ); |
| 2428 | 2364 | $attribute_option_id = $wpdb->get_var( $query ); |
| 2429 | - } |
|
| 2430 | - else { |
|
| 2365 | + } else { |
|
| 2431 | 2366 | $entity_args = array( |
| 2432 | 2367 | 'post_type' => $attribute_default_value['default_value'], |
| 2433 | 2368 | 'post_title' => $value, |
@@ -2436,8 +2371,7 @@ discard block |
||
| 2436 | 2371 | ); |
| 2437 | 2372 | $attribute_option_id = wp_insert_post($entity_args); |
| 2438 | 2373 | } |
| 2439 | - } |
|
| 2440 | - else { |
|
| 2374 | + } else { |
|
| 2441 | 2375 | $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value) ); |
| 2442 | 2376 | $attribute_option_id = $wpdb->insert_id; |
| 2443 | 2377 | } |
@@ -2521,8 +2455,7 @@ discard block |
||
| 2521 | 2455 | } |
| 2522 | 2456 | |
| 2523 | 2457 | echo json_encode( array( true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) ); |
| 2524 | - } |
|
| 2525 | - else { |
|
| 2458 | + } else { |
|
| 2526 | 2459 | echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) ); |
| 2527 | 2460 | } |
| 2528 | 2461 | |
@@ -2559,20 +2492,17 @@ discard block |
||
| 2559 | 2492 | if ( !empty($available_payement_method[0]) ) { |
| 2560 | 2493 | if ( $cart_type=='quotation' ) { |
| 2561 | 2494 | $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() ); |
| 2562 | - } |
|
| 2563 | - else { |
|
| 2495 | + } else { |
|
| 2564 | 2496 | $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() ); |
| 2565 | 2497 | } |
| 2566 | 2498 | } |
| 2567 | - } |
|
| 2568 | - else { |
|
| 2499 | + } else { |
|
| 2569 | 2500 | $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array()); |
| 2570 | 2501 | } |
| 2571 | 2502 | if( $address_type == 'billing_address') { |
| 2572 | 2503 | $billing_option = get_option( 'wpshop_billing_address' ); |
| 2573 | 2504 | $address_option = $billing_option['choice']; |
| 2574 | - } |
|
| 2575 | - else { |
|
| 2505 | + } else { |
|
| 2576 | 2506 | $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
| 2577 | 2507 | $address_option = $shipping_address_option['choice']; |
| 2578 | 2508 | } |
@@ -2584,8 +2514,7 @@ discard block |
||
| 2584 | 2514 | |
| 2585 | 2515 | $edit_link = '<a href="' .get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?')===false ? '?' : '&') . 'action=editAddress&id='.$address_id.'" title="' .__('Edit', 'wpshop'). '">' .__('Edit', 'wpshop'). '</a>'; |
| 2586 | 2516 | $result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) ); |
| 2587 | - } |
|
| 2588 | - else { |
|
| 2517 | + } else { |
|
| 2589 | 2518 | $result = json_encode( array(false, 'missing_informations') ); |
| 2590 | 2519 | } |
| 2591 | 2520 | echo $result; |
@@ -2648,13 +2577,11 @@ discard block |
||
| 2648 | 2577 | wps_address::save_address_infos( $_REQUEST['shipping_address'] ); |
| 2649 | 2578 | } |
| 2650 | 2579 | $result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) ); |
| 2651 | - } |
|
| 2652 | - else { |
|
| 2580 | + } else { |
|
| 2653 | 2581 | $result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) ); |
| 2654 | 2582 | } |
| 2655 | 2583 | |
| 2656 | - } |
|
| 2657 | - else { |
|
| 2584 | + } else { |
|
| 2658 | 2585 | $result = json_encode( array(false, __('An email address is required', 'wpshop')) ); |
| 2659 | 2586 | } |
| 2660 | 2587 | echo $result; |
@@ -2681,8 +2608,7 @@ discard block |
||
| 2681 | 2608 | $wps_message = new wps_message_ctr(); |
| 2682 | 2609 | $wps_message->wpshop_prepared_email( $email, $model_name, array('order_id' => $order_id, 'order_key' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_key']) ) ? $order_post_meta['order_key'] : '' ), 'order_date' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_date']) ) ? $order_post_meta['order_date'] : '' ),'customer_first_name' => $first_name, 'customer_last_name' => $last_name) ); |
| 2683 | 2610 | $result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) ); |
| 2684 | - } |
|
| 2685 | - else { |
|
| 2611 | + } else { |
|
| 2686 | 2612 | $result = array('status' => false, 'response' => __('An error occured', 'wpshop') ); |
| 2687 | 2613 | } |
| 2688 | 2614 | echo json_encode($result); |
@@ -2705,8 +2631,7 @@ discard block |
||
| 2705 | 2631 | $n = WPSHOP_UPLOAD_URL.'/'.$name; |
| 2706 | 2632 | update_post_meta( $_POST['element_identifer'], 'attribute_option_is_downloadable_', array('file_url' => $n)); |
| 2707 | 2633 | $result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>'; |
| 2708 | - } |
|
| 2709 | - else { |
|
| 2634 | + } else { |
|
| 2710 | 2635 | $result = ''; |
| 2711 | 2636 | } |
| 2712 | 2637 | echo $result; |
@@ -2775,8 +2700,7 @@ discard block |
||
| 2775 | 2700 | if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') ) ) { |
| 2776 | 2701 | $manage_stock_checking_bool = true; |
| 2777 | 2702 | } |
| 2778 | - } |
|
| 2779 | - else { |
|
| 2703 | + } else { |
|
| 2780 | 2704 | if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
| 2781 | 2705 | $parent_product = wpshop_products::get_parent_variation( $item['item_id'] ); |
| 2782 | 2706 | if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) { |
@@ -2799,8 +2723,7 @@ discard block |
||
| 2799 | 2723 | /** Checking stock **/ |
| 2800 | 2724 | if ( empty($item_meta['manage_stock']) || ( !empty($item_meta['manage_stock']) && !$manage_stock_checking_bool )|| ( !empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty ) ) { |
| 2801 | 2725 | $_SESSION['cart']['order_items'][ $item_key ] = $item; |
| 2802 | - } |
|
| 2803 | - else { |
|
| 2726 | + } else { |
|
| 2804 | 2727 | $add_to_cart_checking = true; |
| 2805 | 2728 | $add_to_cart_checking_message = __('Some products cannot be added to cart because they are out of stock', 'wpshop'); |
| 2806 | 2729 | } |
@@ -2917,12 +2840,10 @@ discard block |
||
| 2917 | 2840 | |
| 2918 | 2841 | $response = __( 'Direct payment link has been send', 'wpshop' ); |
| 2919 | 2842 | $status = true; |
| 2920 | - } |
|
| 2921 | - else { |
|
| 2843 | + } else { |
|
| 2922 | 2844 | $response = __( 'An error was occured', 'wpshop' ); |
| 2923 | 2845 | } |
| 2924 | - } |
|
| 2925 | - else { |
|
| 2846 | + } else { |
|
| 2926 | 2847 | $response = __( 'An error was occured, no Order ID defined', 'wpshop' ); |
| 2927 | 2848 | } |
| 2928 | 2849 | echo json_encode( array( 'status' => $status, 'response' => $response) ); |
@@ -3005,8 +2926,7 @@ discard block |
||
| 3005 | 2926 | $wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) ); |
| 3006 | 2927 | $wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) ); |
| 3007 | 2928 | $wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) ); |
| 3008 | - } |
|
| 3009 | - else { |
|
| 2929 | + } else { |
|
| 3010 | 2930 | $common_datas = array( |
| 3011 | 2931 | 'value_id' => null, |
| 3012 | 2932 | 'entity_type_id' => 5, |
@@ -3174,8 +3094,7 @@ discard block |
||
| 3174 | 3094 | if( !empty($element_definition['content'][$att]) ) { |
| 3175 | 3095 | $formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att]; |
| 3176 | 3096 | $controller_rows_array[ $att ] = true; |
| 3177 | - } |
|
| 3178 | - else { |
|
| 3097 | + } else { |
|
| 3179 | 3098 | $formatted_datas[$element_id]['content'][$att] = array(); |
| 3180 | 3099 | } |
| 3181 | 3100 | } |
@@ -3205,8 +3124,7 @@ discard block |
||
| 3205 | 3124 | if( $current_attribute->data_type_to_use == 'internal' ) { |
| 3206 | 3125 | $current_val = get_the_title($current_val); |
| 3207 | 3126 | $old_val = get_the_title($old_val); |
| 3208 | - } |
|
| 3209 | - else { |
|
| 3127 | + } else { |
|
| 3210 | 3128 | $query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val); |
| 3211 | 3129 | $old_val = $wpdb->get_var( $query ); |
| 3212 | 3130 | $query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val); |
@@ -3259,12 +3177,10 @@ discard block |
||
| 3259 | 3177 | update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option ); |
| 3260 | 3178 | $response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>'; |
| 3261 | 3179 | $status = true; |
| 3262 | - } |
|
| 3263 | - else { |
|
| 3180 | + } else { |
|
| 3264 | 3181 | $response = __( 'Category options are not defined', 'wpshop'); |
| 3265 | 3182 | } |
| 3266 | - } |
|
| 3267 | - else { |
|
| 3183 | + } else { |
|
| 3268 | 3184 | $response = __( 'Category ID is not defined', 'wpshop'); |
| 3269 | 3185 | } |
| 3270 | 3186 | echo json_encode( array( 'status' => $status, 'response' => $response) ); |
@@ -3293,9 +3209,9 @@ discard block |
||
| 3293 | 3209 | if ( $attributeSetSectionCreation == 'done' ) { |
| 3294 | 3210 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop'); |
| 3295 | 3211 | $more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")'; |
| 3212 | + } else { |
|
| 3213 | + $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop'); |
|
| 3296 | 3214 | } |
| 3297 | - else |
|
| 3298 | - $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop'); |
|
| 3299 | 3215 | echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshop(document).ready(function(){ jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>'; |
| 3300 | 3216 | } |
| 3301 | 3217 | add_action( 'wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection' ); |
@@ -3318,10 +3234,11 @@ discard block |
||
| 3318 | 3234 | $attributeSetInfos['backend_display_type'] = $backend_display_type; |
| 3319 | 3235 | $attributeSetInfos['display_on_frontend'] = $display_on_frontend; |
| 3320 | 3236 | $attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP); |
| 3321 | - if ( $attributeSetSectionCreation == 'done' ) |
|
| 3322 | - $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop'); |
|
| 3323 | - else |
|
| 3324 | - $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop'); |
|
| 3237 | + if ( $attributeSetSectionCreation == 'done' ) { |
|
| 3238 | + $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop'); |
|
| 3239 | + } else { |
|
| 3240 | + $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop'); |
|
| 3241 | + } |
|
| 3325 | 3242 | echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>'; |
| 3326 | 3243 | } |
| 3327 | 3244 | add_action( 'wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection' ); |
@@ -3339,9 +3256,9 @@ discard block |
||
| 3339 | 3256 | if ( $attributeSetSectionCreation == 'done' ) { |
| 3340 | 3257 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop'); |
| 3341 | 3258 | $more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();'; |
| 3259 | + } else { |
|
| 3260 | + $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop'); |
|
| 3342 | 3261 | } |
| 3343 | - else |
|
| 3344 | - $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop'); |
|
| 3345 | 3262 | echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>'; |
| 3346 | 3263 | } |
| 3347 | 3264 | add_action( 'wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection' ); |
@@ -3396,8 +3313,7 @@ discard block |
||
| 3396 | 3313 | if($save_unit_result == 'done'){ |
| 3397 | 3314 | $save_output = wpshop_attributes_unit::elementList(); |
| 3398 | 3315 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop'); |
| 3399 | - } |
|
| 3400 | - else{ |
|
| 3316 | + } else{ |
|
| 3401 | 3317 | $save_output = wpshop_attributes_unit::elementEdition(); |
| 3402 | 3318 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop'); |
| 3403 | 3319 | } |
@@ -3431,8 +3347,7 @@ discard block |
||
| 3431 | 3347 | if ( $save_unit_result == 'done' ) { |
| 3432 | 3348 | $save_output = wpshop_attributes_unit::elementList(); |
| 3433 | 3349 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop'); |
| 3434 | - } |
|
| 3435 | - else { |
|
| 3350 | + } else { |
|
| 3436 | 3351 | $save_output = wpshop_attributes_unit::elementEdition($attributeUnitId); |
| 3437 | 3352 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit saving', 'wpshop'); |
| 3438 | 3353 | } |
@@ -3450,8 +3365,7 @@ discard block |
||
| 3450 | 3365 | $save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT); |
| 3451 | 3366 | if ( $save_unit_result == 'done' ) { |
| 3452 | 3367 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop'); |
| 3453 | - } |
|
| 3454 | - else { |
|
| 3368 | + } else { |
|
| 3455 | 3369 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit deletion', 'wpshop'); |
| 3456 | 3370 | } |
| 3457 | 3371 | |
@@ -3488,8 +3402,7 @@ discard block |
||
| 3488 | 3402 | if($save_unit_result == 'done'){ |
| 3489 | 3403 | $save_output = wpshop_attributes_unit::unit_group_list(); |
| 3490 | 3404 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop'); |
| 3491 | - } |
|
| 3492 | - else{ |
|
| 3405 | + } else{ |
|
| 3493 | 3406 | $save_output = wpshop_attributes_unit::unit_group_edition(); |
| 3494 | 3407 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop'); |
| 3495 | 3408 | } |
@@ -3510,8 +3423,7 @@ discard block |
||
| 3510 | 3423 | if($save_unit_result == 'done'){ |
| 3511 | 3424 | $save_output = wpshop_attributes_unit::unit_group_list(); |
| 3512 | 3425 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop'); |
| 3513 | - } |
|
| 3514 | - else{ |
|
| 3426 | + } else{ |
|
| 3515 | 3427 | $save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId); |
| 3516 | 3428 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop'); |
| 3517 | 3429 | } |
@@ -3529,8 +3441,7 @@ discard block |
||
| 3529 | 3441 | $save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 3530 | 3442 | if($save_unit_result == 'done'){ |
| 3531 | 3443 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop'); |
| 3532 | - } |
|
| 3533 | - else{ |
|
| 3444 | + } else{ |
|
| 3534 | 3445 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop'); |
| 3535 | 3446 | } |
| 3536 | 3447 | |
@@ -3556,7 +3467,9 @@ discard block |
||
| 3556 | 3467 | ); |
| 3557 | 3468 | if($data[0]) { |
| 3558 | 3469 | echo json_encode(array(true, do_shortcode($data[1]))); |
| 3559 | - } else echo json_encode(array(false,__('No product found','wpshop'))); |
|
| 3470 | + } else { |
|
| 3471 | + echo json_encode(array(false,__('No product found','wpshop'))); |
|
| 3472 | + } |
|
| 3560 | 3473 | } |
| 3561 | 3474 | add_action( 'wp_ajax_wps_products_by_criteria', 'products_by_criteria' ); |
| 3562 | 3475 | |
@@ -3577,10 +3490,10 @@ discard block |
||
| 3577 | 3490 | if (!empty($user_info->user_email)) { |
| 3578 | 3491 | $wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$_REQUEST['postid'], $object=array()); |
| 3579 | 3492 | $array = array('result' => true, 'message' => ''); |
| 3493 | + } else { |
|
| 3494 | + $array = array('result' => true, 'message' => __('An error occured','wpshop')); |
|
| 3580 | 3495 | } |
| 3581 | - else $array = array('result' => true, 'message' => __('An error occured','wpshop')); |
|
| 3582 | - } |
|
| 3583 | - else { |
|
| 3496 | + } else { |
|
| 3584 | 3497 | $array = array('result' => false, 'message' => __('An error occured','wpshop')); |
| 3585 | 3498 | } |
| 3586 | 3499 | |
@@ -3607,12 +3520,10 @@ discard block |
||
| 3607 | 3520 | $wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array()); |
| 3608 | 3521 | |
| 3609 | 3522 | $array = array('result' => true, 'message' => ''); |
| 3610 | - } |
|
| 3611 | - else { |
|
| 3523 | + } else { |
|
| 3612 | 3524 | $array = array('result' => false, 'message' => __('An error occured','wpshop')); |
| 3613 | 3525 | } |
| 3614 | - } |
|
| 3615 | - else { |
|
| 3526 | + } else { |
|
| 3616 | 3527 | $array = array('result' => false, 'message' => __('An error occured','wpshop')); |
| 3617 | 3528 | } |
| 3618 | 3529 | |
@@ -3638,7 +3549,9 @@ discard block |
||
| 3638 | 3549 | $order = $wps_cart_ctr->calcul_cart_information(array()); |
| 3639 | 3550 | $wps_cart_ctr->store_cart_in_session($order); |
| 3640 | 3551 | echo json_encode(array(true, '')); |
| 3641 | - } else echo json_encode(array(false, $result['message'])); |
|
| 3552 | + } else { |
|
| 3553 | + echo json_encode(array(false, $result['message'])); |
|
| 3554 | + } |
|
| 3642 | 3555 | } |
| 3643 | 3556 | add_action( 'wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon' ); |
| 3644 | 3557 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Ajax request management file |
| 4 | 4 | * |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /* Check if file is include. No direct access possible with file url */ |
| 12 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 13 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 12 | +if (!defined('WPSHOP_VERSION')) { |
|
| 13 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /* Products */ |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function ajax_duplicate_product() { |
| 21 | 21 | |
| 22 | - check_ajax_referer( 'wpshop_product_duplication', 'wpshop_ajax_nonce' ); |
|
| 22 | + check_ajax_referer('wpshop_product_duplication', 'wpshop_ajax_nonce'); |
|
| 23 | 23 | |
| 24 | 24 | $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; |
| 25 | 25 | |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | * Delete an attachmant from a product |
| 35 | 35 | */ |
| 36 | 36 | function ajax_delete_product_thumbnail() { |
| 37 | - check_ajax_referer( 'wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce' ); |
|
| 37 | + check_ajax_referer('wpshop_delete_product_thumbnail', 'wpshop_ajax_nonce'); |
|
| 38 | 38 | |
| 39 | 39 | $bool = false; |
| 40 | 40 | $attachement_id = isset($_POST['attachement_id']) ? intval(wpshop_tools::varSanitizer($_POST['attachement_id'])) : null; |
| 41 | 41 | |
| 42 | - if ( !empty($attachement_id) ) { |
|
| 42 | + if (!empty($attachement_id)) { |
|
| 43 | 43 | $deletion_result = wp_delete_attachment($attachement_id, false); |
| 44 | 44 | $bool = !empty($deletion_result); |
| 45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Reload attachment container |
| 53 | 53 | */ |
| 54 | 54 | function ajax_reload_attachment_boxes() { |
| 55 | - check_ajax_referer( 'wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce' ); |
|
| 55 | + check_ajax_referer('wpshop_reload_product_attachment_part', 'wpshop_ajax_nonce'); |
|
| 56 | 56 | |
| 57 | 57 | $bool = false; |
| 58 | 58 | $current_post_id = isset($_POST['current_post_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_post_id'])) : null; |
@@ -70,25 +70,25 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function ajax_product_bulk_edit_save() { |
| 72 | 72 | global $wpdb; |
| 73 | - check_ajax_referer( 'product_bulk_edit_save', 'wpshop_ajax_nonce' ); |
|
| 73 | + check_ajax_referer('product_bulk_edit_save', 'wpshop_ajax_nonce'); |
|
| 74 | 74 | |
| 75 | - $post_ids = ( isset( $_POST[ 'post_ids' ] ) && !empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array(); |
|
| 76 | - $post_attributes = ( isset( $_POST[ 'attribute' ] ) && !empty( $_POST[ 'attribute' ] ) ) ? $_POST[ 'attribute' ] : array(); |
|
| 75 | + $post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
| 76 | + $post_attributes = (isset($_POST['attribute']) && !empty($_POST['attribute'])) ? $_POST['attribute'] : array(); |
|
| 77 | 77 | |
| 78 | - if ( !empty( $post_ids ) && is_array( $post_ids ) && !empty( $post_attributes ) && is_array( $post_attributes ) ) { |
|
| 78 | + if (!empty($post_ids) && is_array($post_ids) && !empty($post_attributes) && is_array($post_attributes)) { |
|
| 79 | 79 | $attribute_to_save = array(); |
| 80 | - foreach ( $post_attributes as $attribute ) { |
|
| 80 | + foreach ($post_attributes as $attribute) { |
|
| 81 | 81 | $attribute_component = explode('_-val-_', $attribute); |
| 82 | 82 | $attribute_definition = explode('[', $attribute_component[0]); |
| 83 | 83 | $attribute_data_type = substr($attribute_definition[1], 0, -1); |
| 84 | 84 | $attribute_code = substr($attribute_definition[2], 0, -1); |
| 85 | 85 | |
| 86 | - if ( !empty($attribute_component[1]) ) { |
|
| 86 | + if (!empty($attribute_component[1])) { |
|
| 87 | 87 | $attribute_to_save[$attribute_data_type][$attribute_code] = $attribute_component[1]; |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - foreach ( $post_ids as $post_id ) { |
|
| 91 | + foreach ($post_ids as $post_id) { |
|
| 92 | 92 | $query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = (SELECT language_code FROM " . $wpdb->prefix . "icl_translations WHERE element_id = %d )", $post_id); |
| 93 | 93 | $lang_wpml = $wpdb->get_var($query); |
| 94 | 94 | $lang = !empty($lang_wpml) ? $lang_wpml : WPSHOP_CURRENT_LOCALE; |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | /* Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working */ |
| 102 | 102 | $productMetaDatas = get_post_meta($post_id, '_wpshop_product_metadata', true); |
| 103 | - if ( !empty($productMetaDatas) ) { |
|
| 103 | + if (!empty($productMetaDatas)) { |
|
| 104 | 104 | $attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), $post_id); |
| 105 | - if ( !empty($attributes_list)) { |
|
| 105 | + if (!empty($attributes_list)) { |
|
| 106 | 106 | foreach ($attributes_list as $attribute) { |
| 107 | - $value_key = 'attribute_value_'.$attribute->data_type; |
|
| 107 | + $value_key = 'attribute_value_' . $attribute->data_type; |
|
| 108 | 108 | $productMetaDatas[$attribute->code] = $attribute->$value_key; |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | - foreach($attribute_to_save as $attributeType => $attributeValues){ |
|
| 113 | - foreach($attributeValues as $attributeCode => $attributeValue){ |
|
| 114 | - if ( $attributeCode == 'product_attribute_set_id' ) { |
|
| 112 | + foreach ($attribute_to_save as $attributeType => $attributeValues) { |
|
| 113 | + foreach ($attributeValues as $attributeCode => $attributeValue) { |
|
| 114 | + if ($attributeCode == 'product_attribute_set_id') { |
|
| 115 | 115 | /* Update the attribute set id for the current product */ |
| 116 | 116 | update_post_meta($post_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $attributeValue); |
| 117 | 117 | } |
@@ -123,18 +123,18 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | /* If the product have some variations */ |
| 126 | - $query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION); |
|
| 126 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_parent = %d AND post_type = %s', $post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION); |
|
| 127 | 127 | $product_variations = $wpdb->get_results($query); |
| 128 | - if ( !empty($product_variations) ) { |
|
| 129 | - foreach( $product_variations as $product_variation ) { |
|
| 128 | + if (!empty($product_variations)) { |
|
| 129 | + foreach ($product_variations as $product_variation) { |
|
| 130 | 130 | $variation_post_meta = get_post_meta($product_variation->ID, '_wpshop_product_metadata', true); |
| 131 | 131 | $common_attributes = unserialize(WPSHOP_COMMON_ATTRIBUTES_PARENT_VARIATION_PRODUCT); |
| 132 | - if ( !empty($common_attributes) ) { |
|
| 133 | - if ( !empty($parent_product_metadata) ) { |
|
| 134 | - foreach( $parent_product_metadata as $key => $value ) { |
|
| 135 | - if ( in_array($key, $common_attributes) ) { |
|
| 132 | + if (!empty($common_attributes)) { |
|
| 133 | + if (!empty($parent_product_metadata)) { |
|
| 134 | + foreach ($parent_product_metadata as $key => $value) { |
|
| 135 | + if (in_array($key, $common_attributes)) { |
|
| 136 | 136 | $variation_post_meta[$key] = $value; |
| 137 | - update_post_meta($product_variation->ID, '_'.$key, $value); |
|
| 137 | + update_post_meta($product_variation->ID, '_' . $key, $value); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | update_post_meta($product_variation->ID, '_wpshop_product_metadata', $variation_post_meta); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | die(); |
| 152 | 152 | } |
| 153 | - add_action( 'wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save' ); |
|
| 153 | + add_action('wp_ajax_product_bulk_edit_save', 'ajax_product_bulk_edit_save'); |
|
| 154 | 154 | /* Products */ |
| 155 | 155 | |
| 156 | 156 | /* Variations */ |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * Variation list creation |
| 159 | 159 | */ |
| 160 | 160 | function ajax_add_new_variation_list() { |
| 161 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 161 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 162 | 162 | global $wpdb; |
| 163 | 163 | |
| 164 | 164 | $attributes_for_variation = isset($_POST['wpshop_attribute_to_use_for_variation']) ? ($_POST['wpshop_attribute_to_use_for_variation']) : null; |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | /** Get the list of values of the attribute to affect to a variation */ |
| 168 | 168 | $var = array(); |
| 169 | 169 | |
| 170 | - foreach ( $attributes_for_variation as $attribute_code ) { |
|
| 170 | + foreach ($attributes_for_variation as $attribute_code) { |
|
| 171 | 171 | $query = $wpdb->prepare("SELECT data_type_to_use FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_code); |
| 172 | - $var[$attribute_code] = wpshop_attributes::get_affected_value_for_list( $attribute_code, $current_post_id, $wpdb->get_var($query)); |
|
| 172 | + $var[$attribute_code] = wpshop_attributes::get_affected_value_for_list($attribute_code, $current_post_id, $wpdb->get_var($query)); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $possible_variations = wpshop_tools::search_all_possibilities( $var ); |
|
| 175 | + $possible_variations = wpshop_tools::search_all_possibilities($var); |
|
| 176 | 176 | |
| 177 | - wpshop_products::creation_variation_callback( $possible_variations, $current_post_id ); |
|
| 177 | + wpshop_products::creation_variation_callback($possible_variations, $current_post_id); |
|
| 178 | 178 | |
| 179 | - $output = wpshop_products::display_variation_admin( $current_post_id ); |
|
| 179 | + $output = wpshop_products::display_variation_admin($current_post_id); |
|
| 180 | 180 | |
| 181 | 181 | echo $output; |
| 182 | 182 | die(); |
@@ -187,19 +187,19 @@ discard block |
||
| 187 | 187 | * Variation uniq item creation |
| 188 | 188 | */ |
| 189 | 189 | function ajax_new_single_variation_definition() { |
| 190 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 190 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 191 | 191 | $output = ''; |
| 192 | 192 | |
| 193 | 193 | $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; |
| 194 | 194 | |
| 195 | 195 | /* Get the list of values of the attribute to affect to a variation */ |
| 196 | - $attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id, 'single' ); |
|
| 196 | + $attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id, 'single'); |
|
| 197 | 197 | $output = $attribute_for_variation[0]; |
| 198 | 198 | |
| 199 | 199 | /** Display specific element for variation */ |
| 200 | 200 | $tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = ''; |
| 201 | 201 | $tpl_component['VARIATION_IDENTIFIER'] = 'new'; |
| 202 | - $tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute( array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']','page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => '') ); |
|
| 202 | + $tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' new_variation_specific_values', 'field_name' => wpshop_products::current_page_variation_code . '[' . $tpl_component['VARIATION_IDENTIFIER'] . ']', 'page_code' => wpshop_products::current_page_variation_code, 'field_id' => wpshop_products::current_page_variation_code . '_' . $tpl_component['VARIATION_IDENTIFIER'], 'variation_dif_values' => '')); |
|
| 203 | 203 | $output .= wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $current_post_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $tpl_component['VARIATION_IDENTIFIER']), 'admin'); |
| 204 | 204 | |
| 205 | 205 | $tpl_component = array(); |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | * Combined variation list creation |
| 218 | 218 | */ |
| 219 | 219 | function ajax_new_combined_variation_list_definition() { |
| 220 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 220 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 221 | 221 | $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; |
| 222 | 222 | $output = ''; |
| 223 | 223 | |
| 224 | - $attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display( $current_post_id ); |
|
| 224 | + $attribute_for_variation = wpshop_attributes::get_variation_available_attribute_display($current_post_id); |
|
| 225 | 225 | $output = $attribute_for_variation[0]; |
| 226 | 226 | |
| 227 | 227 | echo $output; |
@@ -233,43 +233,43 @@ discard block |
||
| 233 | 233 | * Product variaitons parameters |
| 234 | 234 | */ |
| 235 | 235 | function wpshop_ajax_admin_variation_parameters() { |
| 236 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 236 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 237 | 237 | |
| 238 | 238 | $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; |
| 239 | 239 | $output = ''; |
| 240 | 240 | |
| 241 | 241 | /* Display variation options */ |
| 242 | 242 | $options_tpl_component = array(); |
| 243 | - $head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true ); |
|
| 244 | - $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"' : ''; |
|
| 245 | - $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"' : ''; |
|
| 246 | - $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"' : ''; |
|
| 247 | - $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"' : ''; |
|
| 243 | + $head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true); |
|
| 244 | + $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"' : ''; |
|
| 245 | + $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"' : ''; |
|
| 246 | + $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"' : ''; |
|
| 247 | + $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"' : ''; |
|
| 248 | 248 | |
| 249 | - $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"' : ''; |
|
| 250 | - $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"' : ''; |
|
| 249 | + $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"' : ''; |
|
| 250 | + $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"' : ''; |
|
| 251 | 251 | |
| 252 | 252 | $options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_PRODUCT_ID'] = $current_post_id; |
| 253 | 253 | $options_tpl_component['ADMIN_VARIATION_PARAMETERS_FORM_HEAD_NOUNCE'] = wp_create_nonce("wpshop_variation_parameters"); |
| 254 | 254 | |
| 255 | 255 | $options_tpl_component['ADMIN_MORE_OPTIONS_FOR_VARIATIONS'] = ''; |
| 256 | 256 | |
| 257 | - $attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute( $current_post_id ); |
|
| 257 | + $attribute_list_for_variations = wpshop_attributes::get_variation_available_attribute($current_post_id); |
|
| 258 | 258 | |
| 259 | 259 | $default_value_for_attributes = $required_attributes = ''; |
| 260 | 260 | |
| 261 | - $attribute_user_defined = wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => get_post_type($current_post_id)) ); |
|
| 262 | - if ( !empty($attribute_user_defined) ) { |
|
| 263 | - foreach ( $attribute_user_defined as $attribute_def ) { |
|
| 261 | + $attribute_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => get_post_type($current_post_id))); |
|
| 262 | + if (!empty($attribute_user_defined)) { |
|
| 263 | + foreach ($attribute_user_defined as $attribute_def) { |
|
| 264 | 264 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; |
| 265 | 265 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
| 266 | 266 | |
| 267 | 267 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_def->code; |
| 268 | 268 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_def->code; |
| 269 | - $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_def->frontend_label, 'wpshop' ); |
|
| 269 | + $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_def->frontend_label, 'wpshop'); |
|
| 270 | 270 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ''; |
| 271 | 271 | |
| 272 | - $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"' : ''; |
|
| 272 | + $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"' : ''; |
|
| 273 | 273 | |
| 274 | 274 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_def->code; |
| 275 | 275 | |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( !empty($attribute_list_for_variations['available']) ) { |
|
| 281 | - $head_wpshop_variation_definition = get_post_meta( $current_post_id, '_wpshop_variation_defining', true ); |
|
| 282 | - foreach ( $attribute_list_for_variations['available'] as $attribute_code => $attribute_definition ) { |
|
| 280 | + if (!empty($attribute_list_for_variations['available'])) { |
|
| 281 | + $head_wpshop_variation_definition = get_post_meta($current_post_id, '_wpshop_variation_defining', true); |
|
| 282 | + foreach ($attribute_list_for_variations['available'] as $attribute_code => $attribute_definition) { |
|
| 283 | 283 | /** Default value for attribute */ |
| 284 | 284 | $tpl_component = array(); |
| 285 | 285 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ' variation_attribute_container_default_value_' . $attribute_code; |
| 286 | 286 | |
| 287 | 287 | $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')); |
| 288 | - switch ( $attribute_for_default_value['type'] ) { |
|
| 288 | + switch ($attribute_for_default_value['type']) { |
|
| 289 | 289 | case 'select': |
| 290 | 290 | case 'multiple-select': |
| 291 | 291 | case 'radio': |
@@ -297,17 +297,17 @@ discard block |
||
| 297 | 297 | break; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if ( !empty($attribute_for_default_value['possible_value']) ) { |
|
| 300 | + if (!empty($attribute_for_default_value['possible_value'])) { |
|
| 301 | 301 | $attribute_for_default_value['possible_value']['none'] = __('No default value', 'wpshop'); |
| 302 | - foreach( $attribute_for_default_value['possible_value'] as $value_id => $value ){ |
|
| 303 | - if ( !empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values']) ) { |
|
| 302 | + foreach ($attribute_for_default_value['possible_value'] as $value_id => $value) { |
|
| 303 | + if (!empty($value_id) && ($value_id != 'none') && !in_array($value_id, $attribute_definition['values'])) { |
|
| 304 | 304 | unset($attribute_for_default_value['possible_value'][$value_id]); |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | ksort($attribute_for_default_value['possible_value']); |
| 308 | 308 | |
| 309 | 309 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = $attribute_for_default_value['id']; |
| 310 | - $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf( __('Default value for %s', 'wpshop'), $attribute_for_default_value['label'] ); |
|
| 310 | + $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_DEFAULT_VALUE_LABEL'] = sprintf(__('Default value for %s', 'wpshop'), $attribute_for_default_value['label']); |
|
| 311 | 311 | $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]'); |
| 312 | 312 | $default_value_for_attributes .= wpshop_display::display_template_element('wpshop_admin_attribute_for_variation_item_for_default', $tpl_component, array(), 'admin'); |
| 313 | 313 | } |
@@ -318,10 +318,10 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_CODE'] = $attribute_code; |
| 320 | 320 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code; |
| 321 | - $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __( $attribute_definition['label'], 'wpshop' ); |
|
| 321 | + $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL'] = __($attribute_definition['label'], 'wpshop'); |
|
| 322 | 322 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CONTAINER_CLASS'] = ''; |
| 323 | 323 | |
| 324 | - $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"' : ''; |
|
| 324 | + $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"' : ''; |
|
| 325 | 325 | |
| 326 | 326 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_ID'] = 'required_' . $attribute_code; |
| 327 | 327 | $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'))); |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | * Save product variation paramters |
| 345 | 345 | */ |
| 346 | 346 | function wpshop_ajax_admin_variation_parameters_save() { |
| 347 | - check_ajax_referer( 'wpshop_variation_parameters', 'wpshop_ajax_nonce' ); |
|
| 347 | + check_ajax_referer('wpshop_variation_parameters', 'wpshop_ajax_nonce'); |
|
| 348 | 348 | |
| 349 | 349 | $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; |
| 350 | 350 | |
| 351 | - if ( !empty($_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options']) ) { |
|
| 351 | + if (!empty($_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options'])) { |
|
| 352 | 352 | $variation_post_meta = get_post_meta($current_post_id, '_wpshop_variation_defining', true); |
| 353 | 353 | $variation_post_meta['options'] = $_POST[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]['options']; |
| 354 | - unset( $variation_post_meta['follow_general_config'] ); |
|
| 354 | + unset($variation_post_meta['follow_general_config']); |
|
| 355 | 355 | update_post_meta($current_post_id, '_wpshop_variation_defining', $variation_post_meta); |
| 356 | 356 | } |
| 357 | 357 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * Variation uniq item creation |
| 364 | 364 | */ |
| 365 | 365 | function ajax_add_new_single_variation() { |
| 366 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 366 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 367 | 367 | $output = ''; |
| 368 | 368 | |
| 369 | 369 | $attributes_for_variation = isset($_POST['variation_attr']) ? ($_POST['variation_attr']) : null; |
@@ -372,28 +372,28 @@ discard block |
||
| 372 | 372 | $current_post_id = isset($_POST['wpshop_head_product_id']) ? wpshop_tools::varSanitizer($_POST['wpshop_head_product_id']) : null; |
| 373 | 373 | |
| 374 | 374 | $attribute_to_use_for_creation = array(); |
| 375 | - foreach ( $attributes_for_variation as $attribute_code => $attribute_value) { |
|
| 376 | - if ( array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox) ) { |
|
| 375 | + foreach ($attributes_for_variation as $attribute_code => $attribute_value) { |
|
| 376 | + if (array_key_exists($attribute_code, $wpshop_admin_use_attribute_for_single_variation_checkbox)) { |
|
| 377 | 377 | $attribute_to_use_for_creation[0][$attribute_code] = $attributes_for_variation[$attribute_code]; |
| 378 | 378 | $attr_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); |
| 379 | 379 | $variation_specific_definition[$attr_def->data_type][$attribute_code] = $attributes_for_variation[$attribute_code]; |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | - $new_variation_identifier = wpshop_products::creation_variation_callback( $attribute_to_use_for_creation, $current_post_id ); |
|
| 382 | + $new_variation_identifier = wpshop_products::creation_variation_callback($attribute_to_use_for_creation, $current_post_id); |
|
| 383 | 383 | |
| 384 | 384 | /* Save variation specific element */ |
| 385 | - foreach ( unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) { |
|
| 385 | + foreach (unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) { |
|
| 386 | 386 | $head_product_price_attribute_value = wpshop_attributes::get_attribute_value_content($price_attribute_code, $current_post_id, wpshop_products::currentPageCode); |
| 387 | 387 | $price_attr_def = wpshop_attributes::getElement($price_attribute_code, "'valid'", 'code'); |
| 388 | - if ( !empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) { |
|
| 388 | + if (!empty($price_attr_def) && !empty($price_attr_def->data_type) && (empty($variation_specific_definition[$price_attr_def->data_type]) || !array_key_exists($price_attribute_code, $variation_specific_definition[$price_attr_def->data_type]))) { |
|
| 389 | 389 | $variation_specific_definition[$price_attr_def->data_type][$price_attribute_code] = !empty($head_product_price_attribute_value->value) ? $head_product_price_attribute_value->value : 1; |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | wpshop_attributes::saveAttributeForEntity($variation_specific_definition, wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $new_variation_identifier, WPSHOP_CURRENT_LOCALE); |
| 394 | - wpshop_products::calculate_price( $new_variation_identifier ); |
|
| 394 | + wpshop_products::calculate_price($new_variation_identifier); |
|
| 395 | 395 | |
| 396 | - $output = wpshop_products::display_variation_admin( $current_post_id ); |
|
| 396 | + $output = wpshop_products::display_variation_admin($current_post_id); |
|
| 397 | 397 | |
| 398 | 398 | echo $output; |
| 399 | 399 | die(); |
@@ -404,14 +404,14 @@ discard block |
||
| 404 | 404 | * Delete a variation |
| 405 | 405 | */ |
| 406 | 406 | function ajax_delete_variation() { |
| 407 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 407 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 408 | 408 | $result = false; |
| 409 | 409 | $list_to_remove = ''; |
| 410 | 410 | |
| 411 | 411 | $current_post_id = isset($_POST['current_post_id']) && is_array($_POST['current_post_id']) ? $_POST['current_post_id'] : null; |
| 412 | - foreach ( $current_post_id as $variation_id) { |
|
| 412 | + foreach ($current_post_id as $variation_id) { |
|
| 413 | 413 | $result = wp_delete_post($variation_id, false); |
| 414 | - if ( $result ) { |
|
| 414 | + if ($result) { |
|
| 415 | 415 | $list_to_remove[] = $variation_id; |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * Delete a variation defintion into head product |
| 426 | 426 | */ |
| 427 | 427 | function ajax_wpshop_delete_head_product_variation_def() { |
| 428 | - check_ajax_referer( 'wpshop_variation_management', 'wpshop_ajax_nonce' ); |
|
| 428 | + check_ajax_referer('wpshop_variation_management', 'wpshop_ajax_nonce'); |
|
| 429 | 429 | |
| 430 | 430 | $current_post_id = isset($_POST['current_post_id']) ? wpshop_tools::varSanitizer($_POST['current_post_id']) : null; |
| 431 | 431 | $current_variation_def = get_post_meta($current_post_id, '_wpshop_variation_defining', true); |
@@ -439,20 +439,20 @@ discard block |
||
| 439 | 439 | /* Orders */ |
| 440 | 440 | /* Validate the payment transaction number */ |
| 441 | 441 | function wpshop_ajax_validate_payment_method() { |
| 442 | - check_ajax_referer( 'wpshop_validate_payment_method', 'wpshop_ajax_nonce' ); |
|
| 443 | - $order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? $_POST[ 'order_id' ] : null; |
|
| 444 | - $payment_method = ( isset( $_POST[ 'payment_method' ] ) && !empty( $_POST[ 'payment_method' ] ) ) ? $_POST[ 'payment_method' ] : null; |
|
| 445 | - $transaction_id = ( isset( $_POST[ 'transaction_id' ] ) && !empty( $_POST[ 'transaction_id' ] ) ) ? $_POST[ 'transaction_id' ] : null; |
|
| 442 | + check_ajax_referer('wpshop_validate_payment_method', 'wpshop_ajax_nonce'); |
|
| 443 | + $order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? $_POST['order_id'] : null; |
|
| 444 | + $payment_method = (isset($_POST['payment_method']) && !empty($_POST['payment_method'])) ? $_POST['payment_method'] : null; |
|
| 445 | + $transaction_id = (isset($_POST['transaction_id']) && !empty($_POST['transaction_id'])) ? $_POST['transaction_id'] : null; |
|
| 446 | 446 | |
| 447 | - if ( !empty($order_id) ) { |
|
| 448 | - if( !empty($payment_method) && !empty($transaction_id) ) { |
|
| 447 | + if (!empty($order_id)) { |
|
| 448 | + if (!empty($payment_method) && !empty($transaction_id)) { |
|
| 449 | 449 | /* Update he payment method */ |
| 450 | 450 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 451 | 451 | $order['payment_method'] = $payment_method; |
| 452 | 452 | update_post_meta($order_id, '_order_postmeta', $order); |
| 453 | 453 | |
| 454 | 454 | // Update Transaction identifier regarding the payment method |
| 455 | - if ( !empty($transaction_id) ) { |
|
| 455 | + if (!empty($transaction_id)) { |
|
| 456 | 456 | // $transaction_key = ''; |
| 457 | 457 | // switch($payment_method) { |
| 458 | 458 | // case 'check': |
@@ -462,28 +462,28 @@ discard block |
||
| 462 | 462 | // if ( !empty($transaction_key) ) update_post_meta($order_id, $transaction_key, $transaction_id); |
| 463 | 463 | wpshop_payment::set_payment_transaction_number($order_id, $transaction_id); |
| 464 | 464 | } |
| 465 | - $result = json_encode(array(true,'')); |
|
| 465 | + $result = json_encode(array(true, '')); |
|
| 466 | 466 | } |
| 467 | 467 | else { |
| 468 | - $result = json_encode(array(false,__('Choose a payment method and/or type a transaction number', 'wpshop'))); |
|
| 468 | + $result = json_encode(array(false, __('Choose a payment method and/or type a transaction number', 'wpshop'))); |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | else { |
| 472 | - $result = json_encode(array(false,__('Bad order identifier', 'wpshop'))); |
|
| 472 | + $result = json_encode(array(false, __('Bad order identifier', 'wpshop'))); |
|
| 473 | 473 | } |
| 474 | 474 | echo json_encode($result); |
| 475 | 475 | die(); |
| 476 | 476 | } |
| 477 | - add_action( 'wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method' ); |
|
| 477 | + add_action('wp_ajax_validate_payment_method', 'wpshop_ajax_validate_payment_method'); |
|
| 478 | 478 | |
| 479 | 479 | |
| 480 | 480 | /* Display a dialog box to inform a shipping tracking number */ |
| 481 | 481 | function wpshop_ajax_dialog_inform_shipping_number() { |
| 482 | - check_ajax_referer( 'wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce' ); |
|
| 483 | - $order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? $_POST[ 'order_id' ] : null; |
|
| 482 | + check_ajax_referer('wpshop_dialog_inform_shipping_number', 'wpshop_ajax_nonce'); |
|
| 483 | + $order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? $_POST['order_id'] : null; |
|
| 484 | 484 | |
| 485 | - if ( !empty($order_id) ) { |
|
| 486 | - $result = (array(true, '<h1>'.__('Tracking number','wpshop').'</h1><p>'.__('Enter a tracking number, or leave blank:','wpshop').'</p><input type="hidden" value="'.$order_id.'" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>'.__('Enter a tracking link, or leave blank: (http included)','wpshop').'</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="'.__('Send','wpshop').'" /> <input type="button" class="button-secondary closeAlert" value="'.__('Cancel','wpshop').'" />')); |
|
| 485 | + if (!empty($order_id)) { |
|
| 486 | + $result = (array(true, '<h1>' . __('Tracking number', 'wpshop') . '</h1><p>' . __('Enter a tracking number, or leave blank:', 'wpshop') . '</p><input type="hidden" value="' . $order_id . '" name="oid" /><input type="text" name="trackingNumber" /><br /><br /><p>' . __('Enter a tracking link, or leave blank: (http included)', 'wpshop') . '</p><input type="text" name="trackingLink" /><br /><br /><input type="submit" class="button-primary sendTrackingNumber" value="' . __('Send', 'wpshop') . '" /> <input type="button" class="button-secondary closeAlert" value="' . __('Cancel', 'wpshop') . '" />')); |
|
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | else { |
@@ -492,23 +492,23 @@ discard block |
||
| 492 | 492 | echo json_encode($result); |
| 493 | 493 | die(); |
| 494 | 494 | } |
| 495 | - add_action( 'wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number' ); |
|
| 495 | + add_action('wp_ajax_dialog_inform_shipping_number', 'wpshop_ajax_dialog_inform_shipping_number'); |
|
| 496 | 496 | |
| 497 | 497 | function wpshop_ajax_change_order_state() { |
| 498 | 498 | global $order_status; |
| 499 | - check_ajax_referer( 'wpshop_change_order_state', 'wpshop_ajax_nonce' ); |
|
| 499 | + check_ajax_referer('wpshop_change_order_state', 'wpshop_ajax_nonce'); |
|
| 500 | 500 | |
| 501 | - $order_id = ( isset( $_POST[ 'order_id' ] ) && !empty( $_POST[ 'order_id' ] ) ) ? $_POST[ 'order_id' ] : null; |
|
| 502 | - $order_state = ( isset( $_POST[ 'order_state' ] ) && !empty( $_POST[ 'order_state' ] ) ) ? $_POST[ 'order_state' ] : null; |
|
| 503 | - $order_shipped_number = ( isset( $_POST[ 'order_shipped_number' ] ) && !empty( $_POST[ 'order_shipped_number' ] ) ) ? $_POST[ 'order_shipped_number' ] : null; |
|
| 504 | - $order_shipped_link = ( isset( $_POST[ 'order_shipped_link' ] ) && !empty( $_POST[ 'order_shipped_link' ] ) ) ? $_POST[ 'order_shipped_link' ] : null; |
|
| 501 | + $order_id = (isset($_POST['order_id']) && !empty($_POST['order_id'])) ? $_POST['order_id'] : null; |
|
| 502 | + $order_state = (isset($_POST['order_state']) && !empty($_POST['order_state'])) ? $_POST['order_state'] : null; |
|
| 503 | + $order_shipped_number = (isset($_POST['order_shipped_number']) && !empty($_POST['order_shipped_number'])) ? $_POST['order_shipped_number'] : null; |
|
| 504 | + $order_shipped_link = (isset($_POST['order_shipped_link']) && !empty($_POST['order_shipped_link'])) ? $_POST['order_shipped_link'] : null; |
|
| 505 | 505 | |
| 506 | - if ( !empty($order_id) ) { |
|
| 506 | + if (!empty($order_id)) { |
|
| 507 | 507 | /* Update the oder state */ |
| 508 | 508 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 509 | 509 | $order['order_status'] = $order_state; |
| 510 | 510 | |
| 511 | - if ( $order_state == 'shipped' ) { |
|
| 511 | + if ($order_state == 'shipped') { |
|
| 512 | 512 | $order['order_shipping_date'] = current_time('mysql', 0); |
| 513 | 513 | $order['order_trackingNumber'] = $order_shipped_number; |
| 514 | 514 | $order['order_trackingLink'] = $order_shipped_link; |
@@ -519,11 +519,11 @@ discard block |
||
| 519 | 519 | $output_payment_box_class = 'wpshop_order_status_shipped'; |
| 520 | 520 | $output_payment_box_content = __('Shipped', 'wpshop'); |
| 521 | 521 | |
| 522 | - $output_shipping_box = '<li><strong>'.__('Order shipping date','wpshop').' :</strong>'.$order['order_shipping_date'].'</li>'; |
|
| 523 | - $output_shipping_box .= '<li><strong>'.__('Tracking number','wpshop').' :</strong> '.$order['order_trackingNumber'].'</li>'; |
|
| 524 | - $output_shipping_box .= '<li><strong>'.__('Tracking link','wpshop').' :</strong> '.$order['order_trackingLink'].'</li>'; |
|
| 522 | + $output_shipping_box = '<li><strong>' . __('Order shipping date', 'wpshop') . ' :</strong>' . $order['order_shipping_date'] . '</li>'; |
|
| 523 | + $output_shipping_box .= '<li><strong>' . __('Tracking number', 'wpshop') . ' :</strong> ' . $order['order_trackingNumber'] . '</li>'; |
|
| 524 | + $output_shipping_box .= '<li><strong>' . __('Tracking link', 'wpshop') . ' :</strong> ' . $order['order_trackingLink'] . '</li>'; |
|
| 525 | 525 | |
| 526 | - $result = array( true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content ); |
|
| 526 | + $result = array(true, $order_state, $output_shipping_box, $output_payment_box_class, $output_payment_box_content); |
|
| 527 | 527 | } |
| 528 | 528 | else { |
| 529 | 529 | wpshop_payment::setOrderPaymentStatus($order_id, $order_state); |
@@ -540,39 +540,39 @@ discard block |
||
| 540 | 540 | echo json_encode($result); |
| 541 | 541 | die(); |
| 542 | 542 | } |
| 543 | - add_action( 'wp_ajax_change_order_state', 'wpshop_ajax_change_order_state' ); |
|
| 543 | + add_action('wp_ajax_change_order_state', 'wpshop_ajax_change_order_state'); |
|
| 544 | 544 | |
| 545 | 545 | |
| 546 | 546 | /* Send a confirmation e-mail to the customer */ |
| 547 | - function wpshop_send_confirmation_shipping_email($order_id){ |
|
| 547 | + function wpshop_send_confirmation_shipping_email($order_id) { |
|
| 548 | 548 | $wps_message = new wps_message_ctr(); |
| 549 | - if ( !empty($order_id) ) { |
|
| 549 | + if (!empty($order_id)) { |
|
| 550 | 550 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 551 | 551 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 552 | - $email = ( !empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : ''); |
|
| 552 | + $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : ''); |
|
| 553 | 553 | $first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
| 554 | - $last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 554 | + $last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 555 | 555 | |
| 556 | - if( empty($email) && !empty($order['customer_id']) ) { |
|
| 557 | - $user_data = get_userdata( $order['customer_id'] ); |
|
| 556 | + if (empty($email) && !empty($order['customer_id'])) { |
|
| 557 | + $user_data = get_userdata($order['customer_id']); |
|
| 558 | 558 | $email = $user_data->user_email; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 562 | - $shipping_method = ( !empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order['order_payment']['shipping_method'] : '' ); |
|
| 561 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 562 | + $shipping_method = (!empty($order['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order['order_payment']['shipping_method'] : ''); |
|
| 563 | 563 | |
| 564 | 564 | |
| 565 | - $wps_message->wpshop_prepared_email ( |
|
| 565 | + $wps_message->wpshop_prepared_email( |
|
| 566 | 566 | $email, |
| 567 | 567 | 'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE', |
| 568 | 568 | array( |
| 569 | 569 | 'order_id' => $order_id, |
| 570 | - 'order_key' => ( !empty($order['order_key']) ? $order['order_key'] : '' ), |
|
| 570 | + 'order_key' => (!empty($order['order_key']) ? $order['order_key'] : ''), |
|
| 571 | 571 | 'customer_first_name' => $first_name, |
| 572 | 572 | 'customer_last_name' => $last_name, |
| 573 | - 'order_date' => ( !empty($order['order_date']) ? $order['order_date'] : '' ), |
|
| 574 | - 'order_trackingNumber' => ( !empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : '' ), |
|
| 575 | - 'order_trackingLink' => ( !empty($order['order_trackingLink']) ? $order['order_trackingLink'] : '' ), |
|
| 573 | + 'order_date' => (!empty($order['order_date']) ? $order['order_date'] : ''), |
|
| 574 | + 'order_trackingNumber' => (!empty($order['order_trackingNumber']) ? $order['order_trackingNumber'] : ''), |
|
| 575 | + 'order_trackingLink' => (!empty($order['order_trackingLink']) ? $order['order_trackingLink'] : ''), |
|
| 576 | 576 | 'order_addresses' => '', |
| 577 | 577 | 'order_billing_address' => '', |
| 578 | 578 | 'order_shipping_address' => '', |
@@ -591,10 +591,10 @@ discard block |
||
| 591 | 591 | * @return string The html output for the new value |
| 592 | 592 | */ |
| 593 | 593 | function ajax_new_option_for_select_callback() { |
| 594 | - check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' ); |
|
| 594 | + check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce'); |
|
| 595 | 595 | global $wpdb; |
| 596 | 596 | |
| 597 | - $option_id=$option_default_value=$option_value_id=$options_value=''; |
|
| 597 | + $option_id = $option_default_value = $option_value_id = $options_value = ''; |
|
| 598 | 598 | $attribute_identifier = isset($_GET['attribute_identifier']) ? wpshop_tools::varSanitizer($_GET['attribute_identifier']) : '0'; |
| 599 | 599 | $option_name = (!empty($_REQUEST['attribute_new_label']) ? $_REQUEST['attribute_new_label'] : ''); |
| 600 | 600 | $options_value = sanitize_title($option_name); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | $existing_values = $wpdb->get_results($query); |
| 605 | 605 | |
| 606 | 606 | /* If given value does not exist: display result. If value exist alert a error message */ |
| 607 | - if( empty($existing_values) ) { |
|
| 607 | + if (empty($existing_values)) { |
|
| 608 | 608 | $tpl_component = array(); |
| 609 | 609 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_ID'] = $option_id; |
| 610 | 610 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_NAME'] = stripslashes($option_name); |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", stripslashes($options_value)); |
| 613 | 613 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = ''; |
| 614 | 614 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = ''; |
| 615 | - if ( current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0) ) : |
|
| 615 | + if (current_user_can('wpshop_delete_attributes_select_values') && ($option_id >= 0)) : |
|
| 616 | 616 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin'); |
| 617 | 617 | endif; |
| 618 | 618 | $output = wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_identifier), 'admin'); |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | * Add a new value to an attribute from select type directly from an entity element edition interface |
| 632 | 632 | */ |
| 633 | 633 | function ajax_new_option_for_select_from_product_edition_callback() { |
| 634 | - check_ajax_referer( 'wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce' ); |
|
| 634 | + check_ajax_referer('wpshop_new_option_for_attribute_creation', 'wpshop_ajax_nonce'); |
|
| 635 | 635 | |
| 636 | 636 | global $wpdb; |
| 637 | 637 | $result = ''; |
@@ -648,13 +648,13 @@ discard block |
||
| 648 | 648 | $attribute_options_label = isset($_POST['attribute_new_label']) ? wpshop_tools::varSanitizer($_POST['attribute_new_label']) : null; |
| 649 | 649 | $attribute_options_value = sanitize_title($attribute_options_label); |
| 650 | 650 | |
| 651 | - if ( $type == 'internal' ) { |
|
| 651 | + if ($type == 'internal') { |
|
| 652 | 652 | /** Check if the given value does not exist */ |
| 653 | 653 | $query = $wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE post_title = %s AND post_status = 'publish'", $attribute_options_label); |
| 654 | 654 | $existing_values = $wpdb->get_results($query); |
| 655 | 655 | |
| 656 | 656 | /** If the value does not exist, we create it and output, in case it exists alert an error message */ |
| 657 | - if ( count($existing_values) <= 0 ) { |
|
| 657 | + if (count($existing_values) <= 0) { |
|
| 658 | 658 | $result_status = true; |
| 659 | 659 | /** Create the new value as an entity into post database */ |
| 660 | 660 | $new_post = array( |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | $existing_values = $wpdb->get_results($query); |
| 678 | 678 | |
| 679 | 679 | /** If the value does not exist, we create it and output, in case it exists alert an error message */ |
| 680 | - if( count($existing_values) <= 0 ) { |
|
| 680 | + if (count($existing_values) <= 0) { |
|
| 681 | 681 | $result_status = true; |
| 682 | 682 | $position = 1; |
| 683 | 683 | /** Get the last value position for adding the new at the end */ |
@@ -696,15 +696,15 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | if ($result_status) { |
| 698 | 698 | $tmp_selection_for_output = array(); |
| 699 | - foreach ( $attribute_selected_values as $value ) { |
|
| 699 | + foreach ($attribute_selected_values as $value) { |
|
| 700 | 700 | $tmp_selection_for_output[]['value'] = $value; |
| 701 | 701 | } |
| 702 | 702 | $tmp_selection_for_output[]['value'] = $new_option_id; |
| 703 | - foreach ( $tmp_selection_for_output as $tmp_value ) { |
|
| 703 | + foreach ($tmp_selection_for_output as $tmp_value) { |
|
| 704 | 704 | $selection_for_output[] = (object)$tmp_value; |
| 705 | 705 | } |
| 706 | 706 | $attribute_selected_values[] = $new_option_id; |
| 707 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display) ); |
|
| 707 | + $input = wpshop_attributes::get_attribute_field_definition($attribute, $selection_for_output, array('page_code' => $current_page_code, 'from' => $attribute_place_display)); |
|
| 708 | 708 | $result = $input['output'] . $input['options']; |
| 709 | 709 | } |
| 710 | 710 | |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * Delete a value for a select list attribute |
| 718 | 718 | */ |
| 719 | 719 | function ajax_delete_option_for_select_callback() { |
| 720 | - check_ajax_referer( 'wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce' ); |
|
| 720 | + check_ajax_referer('wpshop_new_option_for_attribute_deletion', 'wpshop_ajax_nonce'); |
|
| 721 | 721 | |
| 722 | 722 | $attribute_value_id = isset($_POST['attribute_value_id']) ? wpshop_tools::varSanitizer($_POST['attribute_value_id']) : '0'; |
| 723 | 723 | |
@@ -741,18 +741,18 @@ discard block |
||
| 741 | 741 | * Display the field for the selected attribute type |
| 742 | 742 | */ |
| 743 | 743 | function ajax_attribute_output_type_callback() { |
| 744 | - check_ajax_referer( 'wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce' ); |
|
| 744 | + check_ajax_referer('wpshop_attribute_output_type_selection', 'wpshop_ajax_nonce'); |
|
| 745 | 745 | |
| 746 | 746 | $data_type_to_use = isset($_POST['data_type_to_use']) ? str_replace('_data', '', wpshop_tools::varSanitizer($_POST['data_type_to_use'], '')) : 'custom'; |
| 747 | 747 | $current_type = isset($_POST['current_type']) ? wpshop_tools::varSanitizer($_POST['current_type']) : 'short_text'; |
| 748 | - $elementIdentifier = isset($_POST['elementIdentifier']) ? intval( wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null; |
|
| 748 | + $elementIdentifier = isset($_POST['elementIdentifier']) ? intval(wpshop_tools::varSanitizer($_POST['elementIdentifier'])) : null; |
|
| 749 | 749 | $the_input = __('An error occured while getting field type', 'wpshop'); |
| 750 | 750 | $input_def = array(); |
| 751 | 751 | $input_def['name'] = 'default_value'; |
| 752 | 752 | $input_def['id'] = 'wpshop_attributes_edition_table_field_id_default_value'; |
| 753 | 753 | $input_label = __('Default value', 'wpshop'); |
| 754 | 754 | |
| 755 | - switch($current_type){ |
|
| 755 | + switch ($current_type) { |
|
| 756 | 756 | case 'short_text': |
| 757 | 757 | case 'float_field': |
| 758 | 758 | $input_def['type'] = 'text'; |
@@ -763,13 +763,13 @@ discard block |
||
| 763 | 763 | case 'multiple-select': |
| 764 | 764 | case 'radio': |
| 765 | 765 | case 'checkbox': |
| 766 | - $input_label=__('Options list for attribute', 'wpshop'); |
|
| 766 | + $input_label = __('Options list for attribute', 'wpshop'); |
|
| 767 | 767 | $the_input = wpshop_attributes::get_select_options_list($elementIdentifier, $data_type_to_use); |
| 768 | 768 | break; |
| 769 | 769 | case 'date_field': |
| 770 | - $input_label=__('Date field configuration', 'wpshop'); |
|
| 770 | + $input_label = __('Date field configuration', 'wpshop'); |
|
| 771 | 771 | |
| 772 | - $the_input = wpshop_attributes::attribute_type_date_config( array() ); |
|
| 772 | + $the_input = wpshop_attributes::attribute_type_date_config(array()); |
|
| 773 | 773 | break; |
| 774 | 774 | case 'textarea': |
| 775 | 775 | $input_def['type'] = 'textarea'; |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | * Get the attribute set list when creating a new attribute for direct affectation |
| 788 | 788 | */ |
| 789 | 789 | function ajax_attribute_entity_set_selection_callback() { |
| 790 | - check_ajax_referer( 'wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce' ); |
|
| 790 | + check_ajax_referer('wpshop_attribute_entity_set_selection', 'wpshop_ajax_nonce'); |
|
| 791 | 791 | |
| 792 | 792 | $current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null; |
| 793 | 793 | |
| 794 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode); |
|
| 794 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes::getDbTable(), wpshop_attributes::currentPageCode); |
|
| 795 | 795 | |
| 796 | 796 | echo json_encode($the_input); |
| 797 | 797 | die(); |
@@ -801,11 +801,11 @@ discard block |
||
| 801 | 801 | * Get the attribute set list when creating a new attribute for direct affectation |
| 802 | 802 | */ |
| 803 | 803 | function ajax_attribute_set_entity_selection_callback() { |
| 804 | - check_ajax_referer( 'wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce' ); |
|
| 804 | + check_ajax_referer('wpshop_attribute_set_entity_selection', 'wpshop_ajax_nonce'); |
|
| 805 | 805 | |
| 806 | 806 | $current_entity_id = isset($_POST['current_entity_id']) ? intval(wpshop_tools::varSanitizer($_POST['current_entity_id'])) : null; |
| 807 | 807 | |
| 808 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false); |
|
| 808 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, wpshop_attributes_set::getDbTable(), wpshop_attributes::currentPageCode, false); |
|
| 809 | 809 | |
| 810 | 810 | echo json_encode($the_input); |
| 811 | 811 | die(); |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | * Dialog box allowing to change attribute data type from custom to internal |
| 817 | 817 | */ |
| 818 | 818 | function ajax_attribute_select_data_type_callback() { |
| 819 | - check_ajax_referer( 'wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce' ); |
|
| 819 | + check_ajax_referer('wpshop_attribute_change_select_data_type', 'wpshop_ajax_nonce'); |
|
| 820 | 820 | $result = ''; |
| 821 | 821 | |
| 822 | 822 | $current_attribute = isset($_POST['current_attribute']) ? intval(wpshop_tools::varSanitizer($_POST['current_attribute'])) : null; |
@@ -824,12 +824,12 @@ discard block |
||
| 824 | 824 | |
| 825 | 825 | $types_toggled = unserialize(WPSHOP_ATTR_SELECT_TYPE_TOGGLED); |
| 826 | 826 | $result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_current_attribute" >' . sprintf(__('Selected attribute %s', 'wpshop'), $attribute->frontend_label) . '</p>'; |
| 827 | - $result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use.'_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>'; |
|
| 827 | + $result .= '<p class="wpshop_change_select_data_type_change wpshop_change_select_data_type_change_types" >' . sprintf(__('Actual data type is %s. After current operation: %s', 'wpshop'), __($attribute->data_type_to_use . '_data', 'wpshop'), __($types_toggled[$attribute->data_type_to_use], 'wpshop')) . '</p>'; |
|
| 828 | 828 | |
| 829 | - if ( $attribute->data_type_to_use == 'custom' ) { |
|
| 830 | - $sub_output=''; |
|
| 829 | + if ($attribute->data_type_to_use == 'custom') { |
|
| 830 | + $sub_output = ''; |
|
| 831 | 831 | $wp_types = unserialize(WPSHOP_INTERNAL_TYPES); |
| 832 | - unset($input_def);$input_def=array(); |
|
| 832 | + unset($input_def); $input_def = array(); |
|
| 833 | 833 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 834 | 834 | $input_def['type'] = 'select'; |
| 835 | 835 | $input_def['name'] = 'internal_data'; |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | $input_def['possible_value'] = $wp_types; |
| 838 | 838 | $input_def['value'] = !empty($attribute_select_options[0]->default_value) ? $attribute_select_options[0]->default_value : null; |
| 839 | 839 | $combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 840 | - $result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="'.sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')).'" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">'.$combo_wp_type.'</div>'; |
|
| 840 | + $result .= __('Choose the data type to use for this attribute', 'wpshop') . '<a href="#" title="' . sprintf(__('If the type you want to use is not in the list below. You have to create it by using %s menu', 'wpshop'), __('Entities', 'wpshop')) . '" class="wpshop_infobulle_marker">?</a><div class="wpshop_cls wpshop_attribute_select_data_type_internal_list">' . $combo_wp_type . '</div>'; |
|
| 841 | 841 | $result .= '<input type="hidden" value="no" name="delete_items_of_entity" id="delete_items_of_entity" /><input type="hidden" value="no" name="delete_entity" id="delete_entity" />'; |
| 842 | 842 | } |
| 843 | 843 | else { |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | function ajax_attribute_select_data_type_change_callback() { |
| 872 | 872 | global $wpdb; |
| 873 | - check_ajax_referer( 'wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce' ); |
|
| 873 | + check_ajax_referer('wpshop_attribute_change_select_data_type_change', 'wpshop_ajax_nonce'); |
|
| 874 | 874 | $result = ''; |
| 875 | 875 | |
| 876 | 876 | $current_attribute = isset($_POST['attribute_id']) ? intval(wpshop_tools::varSanitizer($_POST['attribute_id'])) : null; |
@@ -880,10 +880,10 @@ discard block |
||
| 880 | 880 | $delete_entity = isset($_POST['delete_entity']) ? wpshop_tools::varSanitizer($_POST['delete_entity']) : false; |
| 881 | 881 | |
| 882 | 882 | |
| 883 | - if ( $data_type == 'internal' ) { |
|
| 883 | + if ($data_type == 'internal') { |
|
| 884 | 884 | $options_list = wpshop_attributes::get_select_option_list_($current_attribute); |
| 885 | - if(!empty($options_list)){ |
|
| 886 | - foreach($options_list as $option){ |
|
| 885 | + if (!empty($options_list)) { |
|
| 886 | + foreach ($options_list as $option) { |
|
| 887 | 887 | /* Creat the new entity */ |
| 888 | 888 | $new_post = array( |
| 889 | 889 | 'post_title' => $option->name, |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | 'post_type' => $internal_data_type |
| 893 | 893 | ); |
| 894 | 894 | $new_option_id = wp_insert_post($new_post); |
| 895 | - if(!empty($new_option_id)){ |
|
| 895 | + if (!empty($new_option_id)) { |
|
| 896 | 896 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'deleted'), array('attribute_id'=>$current_attribute)); |
| 897 | 897 | } |
| 898 | 898 | } |
@@ -901,19 +901,19 @@ discard block |
||
| 901 | 901 | else { |
| 902 | 902 | $post_list = query_posts(array('post_type' => $internal_data_type)); |
| 903 | 903 | if (!empty($post_list)) { |
| 904 | - $p=1; |
|
| 904 | + $p = 1; |
|
| 905 | 905 | $error = false; |
| 906 | 906 | foreach ($post_list as $post) { |
| 907 | - $last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title)); |
|
| 908 | - if(is_int($last_insert) && $delete_items_of_entity){ |
|
| 907 | + $last_insert = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'attribute_id'=>$current_attribute, 'position'=>$p, 'value'=>$post->post_name, 'label'=>$post->post_title)); |
|
| 908 | + if (is_int($last_insert) && $delete_items_of_entity) { |
|
| 909 | 909 | wp_delete_post($post->ID, true); |
| 910 | 910 | } |
| 911 | - else{ |
|
| 911 | + else { |
|
| 912 | 912 | $error = true; |
| 913 | 913 | } |
| 914 | 914 | $p++; |
| 915 | 915 | } |
| 916 | - if(!$error && $delete_entity){ |
|
| 916 | + if (!$error && $delete_entity) { |
|
| 917 | 917 | $post = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type=%s AND post_name=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, $internal_data_type); |
| 918 | 918 | wp_delete_post($wpdb->get_var($post), true); |
| 919 | 919 | } |
@@ -933,8 +933,8 @@ discard block |
||
| 933 | 933 | /** |
| 934 | 934 | * Duplicate an existing attribute from an entity to another |
| 935 | 935 | */ |
| 936 | - function ajax_wpshop_duplicate_attribute_callback (){ |
|
| 937 | - check_ajax_referer( 'wpshop_duplicate_attribute', 'wpshop_ajax_nonce' ); |
|
| 936 | + function ajax_wpshop_duplicate_attribute_callback() { |
|
| 937 | + check_ajax_referer('wpshop_duplicate_attribute', 'wpshop_ajax_nonce'); |
|
| 938 | 938 | global $wpdb; |
| 939 | 939 | |
| 940 | 940 | $result = ''; |
@@ -954,16 +954,16 @@ discard block |
||
| 954 | 954 | /* Check if the attribute to duplicate does not exist for the selected entity */ |
| 955 | 955 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']); |
| 956 | 956 | $check_existing_attribute = $wpdb->get_var($query); |
| 957 | - if ( empty($check_existing_attribute) ) { |
|
| 957 | + if (empty($check_existing_attribute)) { |
|
| 958 | 958 | /* Save new attribut for the selected entity */ |
| 959 | 959 | $new_attribute = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE, $attribute_def); |
| 960 | 960 | $new_attribute_id = $wpdb->insert_id; |
| 961 | 961 | |
| 962 | 962 | if ($new_attribute) { |
| 963 | - if ( in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom') ) { |
|
| 963 | + if (in_array($attribute_def['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox')) && ($attribute_def['data_type_to_use'] == 'custom')) { |
|
| 964 | 964 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d", $current_attribute); |
| 965 | 965 | $attribute_options_list = $wpdb->get_results($query, ARRAY_A); |
| 966 | - foreach ( $attribute_options_list as $option ) { |
|
| 966 | + foreach ($attribute_options_list as $option) { |
|
| 967 | 967 | $option['id'] = ''; |
| 968 | 968 | $option['creation_date'] = current_time('mysql', 0); |
| 969 | 969 | $option['attribute_id'] = $new_attribute_id; |
@@ -994,27 +994,27 @@ discard block |
||
| 994 | 994 | /** |
| 995 | 995 | * Load comboBox of unit or group of unit |
| 996 | 996 | */ |
| 997 | - function wpshop_ajax_load_attribute_unit_list(){ |
|
| 998 | - check_ajax_referer( 'wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce' ); |
|
| 997 | + function wpshop_ajax_load_attribute_unit_list() { |
|
| 998 | + check_ajax_referer('wpshop_load_attribute_unit_list', 'wpshop_ajax_nonce'); |
|
| 999 | 999 | $response = ''; |
| 1000 | 1000 | |
| 1001 | - $current_group = ( isset( $_POST[ 'current_group' ] ) && !empty( $_POST[ 'current_group' ] ) ) ? $_POST[ 'current_group' ] : null; |
|
| 1002 | - $selected_list = ( isset( $_POST[ 'selected_list' ] ) && !empty( $_POST[ 'selected_list' ] ) ) ? $_POST[ 'selected_list' ] : null; |
|
| 1001 | + $current_group = (isset($_POST['current_group']) && !empty($_POST['current_group'])) ? $_POST['current_group'] : null; |
|
| 1002 | + $selected_list = (isset($_POST['selected_list']) && !empty($_POST['selected_list'])) ? $_POST['selected_list'] : null; |
|
| 1003 | 1003 | |
| 1004 | 1004 | $group = wpshop_tools::varSanitizer($current_group); |
| 1005 | 1005 | $selected_list = wpshop_tools::varSanitizer($selected_list); |
| 1006 | 1006 | |
| 1007 | - if ( !empty($group) && !empty($selected_list)) { |
|
| 1007 | + if (!empty($group) && !empty($selected_list)) { |
|
| 1008 | 1008 | /* Test if we want display the group unit list OR the unit list */ |
| 1009 | - if ( $selected_list == 'group unit' ) { |
|
| 1009 | + if ($selected_list == 'group unit') { |
|
| 1010 | 1010 | $list = wpshop_attributes_unit::get_unit_group(); |
| 1011 | 1011 | } |
| 1012 | 1012 | else { |
| 1013 | 1013 | $list = wpshop_attributes_unit::get_unit_list_for_group($group); |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - foreach( $list as $unit ) { |
|
| 1017 | - $response .= '<option value="' . $unit->id . '" '. ( ($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '' ).'>' . $unit->name . '</option>'; |
|
| 1016 | + foreach ($list as $unit) { |
|
| 1017 | + $response .= '<option value="' . $unit->id . '" ' . (($current_group == $unit->id && $selected_list == 'group unit') ? 'selected="selected"' : '') . '>' . $unit->name . '</option>'; |
|
| 1018 | 1018 | } |
| 1019 | 1019 | $result = array(true, $response); |
| 1020 | 1020 | } |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | |
| 1031 | 1031 | /** Tools page */ |
| 1032 | 1032 | function wpshop_ajax_db_check_tool() { |
| 1033 | - check_ajax_referer( 'wpshop_ajax_db_check_tool', '_wpnonce' ); |
|
| 1033 | + check_ajax_referer('wpshop_ajax_db_check_tool', '_wpnonce'); |
|
| 1034 | 1034 | |
| 1035 | 1035 | global $wpdb, $wpshop_db_table_operation_list, $wpshop_db_table, $wpshop_update_way; |
| 1036 | 1036 | $current_db_version = get_option('wpshop_db_options', 0); |
@@ -1046,22 +1046,22 @@ discard block |
||
| 1046 | 1046 | </div> |
| 1047 | 1047 | <div class="tools_db_modif_list_version_details" > |
| 1048 | 1048 | <ul>'; |
| 1049 | - foreach($plugin_db_modification as $modif_name => $modif_list){ |
|
| 1050 | - switch($modif_name){ |
|
| 1049 | + foreach ($plugin_db_modification as $modif_name => $modif_list) { |
|
| 1050 | + switch ($modif_name) { |
|
| 1051 | 1051 | case 'FIELD_ADD':{ |
| 1052 | - foreach($modif_list as $table_name => $field_list){ |
|
| 1052 | + foreach ($modif_list as $table_name => $field_list) { |
|
| 1053 | 1053 | $sub_modif = ' '; |
| 1054 | - foreach($field_list as $column_name){ |
|
| 1055 | - $query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name); |
|
| 1054 | + foreach ($field_list as $column_name) { |
|
| 1055 | + $query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name); |
|
| 1056 | 1056 | $columns = $wpdb->get_row($query); |
| 1057 | 1057 | $sub_modif .= $column_name; |
| 1058 | - if( !empty($columns->Field) && ($columns->Field == $column_name) ){ |
|
| 1058 | + if (!empty($columns->Field) && ($columns->Field == $column_name)) { |
|
| 1059 | 1059 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />'; |
| 1060 | 1060 | } |
| 1061 | - else{ |
|
| 1061 | + else { |
|
| 1062 | 1062 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />'; |
| 1063 | 1063 | $error_nb++; |
| 1064 | - if ( !empty($error_list[$plugin_db_version]) ) { |
|
| 1064 | + if (!empty($error_list[$plugin_db_version])) { |
|
| 1065 | 1065 | $error_list[$plugin_db_version] += 1; |
| 1066 | 1066 | } |
| 1067 | 1067 | else { |
@@ -1070,56 +1070,56 @@ discard block |
||
| 1070 | 1070 | } |
| 1071 | 1071 | $sub_modif .= ' / '; |
| 1072 | 1072 | } |
| 1073 | - $plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -2) . '</li>'; |
|
| 1073 | + $plugin_db_modification_content .= '<li class="added_field" >' . sprintf(__('Added field list for %s', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -2) . '</li>'; |
|
| 1074 | 1074 | } |
| 1075 | 1075 | }break; |
| 1076 | 1076 | case 'FIELD_DROP':{ |
| 1077 | - foreach($modif_list as $table_name => $field_list){ |
|
| 1077 | + foreach ($modif_list as $table_name => $field_list) { |
|
| 1078 | 1078 | $sub_modif = ' '; |
| 1079 | - foreach($field_list as $column_name){ |
|
| 1080 | - $query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $column_name); |
|
| 1079 | + foreach ($field_list as $column_name) { |
|
| 1080 | + $query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $column_name); |
|
| 1081 | 1081 | $columns = $wpdb->get_row($query); |
| 1082 | 1082 | $sub_modif .= $column_name; |
| 1083 | - if(empty($columns) || ($columns->Field != $column_name)){ |
|
| 1083 | + if (empty($columns) || ($columns->Field != $column_name)) { |
|
| 1084 | 1084 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been deleted', 'wpshop') . '" title="' . __('Field has been deleted', 'wpshop') . '" class="db_deleted_field_check" />'; |
| 1085 | 1085 | } |
| 1086 | - else{ |
|
| 1086 | + else { |
|
| 1087 | 1087 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field exists', 'wpshop') . '" title="' . __('Field exists', 'wpshop') . '" class="db_deleted_field_check" />'; |
| 1088 | 1088 | $error_nb++; |
| 1089 | 1089 | $error_list[$plugin_db_version] += 1; |
| 1090 | 1090 | } |
| 1091 | 1091 | $sub_modif .= ' / '; |
| 1092 | 1092 | } |
| 1093 | - $plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -2) . '</li>'; |
|
| 1093 | + $plugin_db_modification_content .= '<li class="deleted_field" >' . sprintf(__('Fields list deleted for the %s table', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -2) . '</li>'; |
|
| 1094 | 1094 | } |
| 1095 | 1095 | }break; |
| 1096 | 1096 | case 'FIELD_CHANGE':{ |
| 1097 | - foreach($modif_list as $table_name => $field_list){ |
|
| 1097 | + foreach ($modif_list as $table_name => $field_list) { |
|
| 1098 | 1098 | $sub_modif = ' '; |
| 1099 | - foreach($field_list as $field_infos){ |
|
| 1100 | - $query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_infos['field']); |
|
| 1099 | + foreach ($field_list as $field_infos) { |
|
| 1100 | + $query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_infos['field']); |
|
| 1101 | 1101 | $columns = $wpdb->get_row($query); |
| 1102 | 1102 | $what_is_changed = ''; |
| 1103 | - if(isset($field_infos['type'])){ |
|
| 1103 | + if (isset($field_infos['type'])) { |
|
| 1104 | 1104 | $what_is_changed = __('field type', 'wpshop'); |
| 1105 | 1105 | $changed_key = 'type'; |
| 1106 | - if($columns->Type == $field_infos['type']){ |
|
| 1106 | + if ($columns->Type == $field_infos['type']) { |
|
| 1107 | 1107 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />'; |
| 1108 | 1108 | } |
| 1109 | - else{ |
|
| 1109 | + else { |
|
| 1110 | 1110 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />'; |
| 1111 | 1111 | $error_nb++; |
| 1112 | 1112 | $error_list[$plugin_db_version] += 1; |
| 1113 | 1113 | } |
| 1114 | 1114 | $sub_modif .= sprintf(__('Change %s for field %s to %s', 'wpshop'), $what_is_changed, $field_infos['field'], $field_infos[$changed_key]); |
| 1115 | 1115 | } |
| 1116 | - if(isset($field_infos['original_name'])){ |
|
| 1116 | + if (isset($field_infos['original_name'])) { |
|
| 1117 | 1117 | $what_is_changed = __('field name', 'wpshop'); |
| 1118 | 1118 | $changed_key = 'original_name'; |
| 1119 | - if($columns->Field == $field_infos['field']){ |
|
| 1119 | + if ($columns->Field == $field_infos['field']) { |
|
| 1120 | 1120 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Field has been created', 'wpshop') . '" title="' . __('Field has been created', 'wpshop') . '" class="db_added_field_check" />'; |
| 1121 | 1121 | } |
| 1122 | - else{ |
|
| 1122 | + else { |
|
| 1123 | 1123 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />'; |
| 1124 | 1124 | $error_nb++; |
| 1125 | 1125 | $error_list[$plugin_db_version] += 1; |
@@ -1134,59 +1134,59 @@ discard block |
||
| 1134 | 1134 | }break; |
| 1135 | 1135 | |
| 1136 | 1136 | case 'DROP_INDEX':{ |
| 1137 | - foreach($modif_list as $table_name => $field_list){ |
|
| 1137 | + foreach ($modif_list as $table_name => $field_list) { |
|
| 1138 | 1138 | $sub_modif = ' '; |
| 1139 | - foreach($field_list as $column_name){ |
|
| 1140 | - $query = $wpdb->prepare("SHOW INDEX FROM " .$table_name . " WHERE Column_name = %s", $column_name); |
|
| 1139 | + foreach ($field_list as $column_name) { |
|
| 1140 | + $query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s", $column_name); |
|
| 1141 | 1141 | $columns = $wpdb->get_row($query); |
| 1142 | 1142 | $sub_modif .= $column_name; |
| 1143 | - if((empty($columns)) || ($columns->Column_name != $column_name)){ |
|
| 1143 | + if ((empty($columns)) || ($columns->Column_name != $column_name)) { |
|
| 1144 | 1144 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been deleted', 'wpshop') . '" title="' . __('Index has been deleted', 'wpshop') . '" class="db_deleted_index_check" />'; |
| 1145 | 1145 | } |
| 1146 | - else{ |
|
| 1146 | + else { |
|
| 1147 | 1147 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exists', 'wpshop') . '" title="' . __('Index does not exists', 'wpshop') . '" class="db_deleted_index_check" />'; |
| 1148 | 1148 | $error_nb++; |
| 1149 | 1149 | $error_list[$plugin_db_version] += 1; |
| 1150 | 1150 | } |
| 1151 | 1151 | $sub_modif .= ' / '; |
| 1152 | 1152 | } |
| 1153 | - $plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -3) . '</li>'; |
|
| 1153 | + $plugin_db_modification_content .= '<li class="deleted_index" >' . sprintf(__('Deleted indexes for %s table', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -3) . '</li>'; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | }break; |
| 1156 | 1156 | case 'ADD_INDEX':{ |
| 1157 | - foreach($modif_list as $table_name => $field_list){ |
|
| 1157 | + foreach ($modif_list as $table_name => $field_list) { |
|
| 1158 | 1158 | $sub_modif = ' '; |
| 1159 | - foreach($field_list as $column_name){ |
|
| 1159 | + foreach ($field_list as $column_name) { |
|
| 1160 | 1160 | $query = $wpdb->prepare("SHOW INDEX FROM " . $table_name . " WHERE Column_name = %s OR Key_name = %s", $column_name, $column_name); |
| 1161 | 1161 | $columns = $wpdb->get_row($query); |
| 1162 | 1162 | $sub_modif .= $column_name; |
| 1163 | - if(($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)){ |
|
| 1163 | + if (($columns->Column_name == $column_name) || ($columns->Key_name == $column_name)) { |
|
| 1164 | 1164 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Index has been created', 'wpshop') . '" title="' . __('Index has been created', 'wpshop') . '" class="db_added_index_check" />'; |
| 1165 | 1165 | } |
| 1166 | - else{ |
|
| 1166 | + else { |
|
| 1167 | 1167 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Index does not exist', 'wpshop') . '" title="' . __('Index does not exist', 'wpshop') . '" class="db_added_index_check" />'; |
| 1168 | 1168 | $error_nb++; |
| 1169 | 1169 | $error_list[$plugin_db_version] += 1; |
| 1170 | 1170 | } |
| 1171 | 1171 | $sub_modif .= ' / '; |
| 1172 | 1172 | } |
| 1173 | - $plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -3) . '</li>'; |
|
| 1173 | + $plugin_db_modification_content .= '<li class="added_index" >' . sprintf(__('Added indexes for %s table', 'wpshop'), $table_name) . ' : ' . substr($sub_modif, 0, -3) . '</li>'; |
|
| 1174 | 1174 | } |
| 1175 | 1175 | }break; |
| 1176 | 1176 | |
| 1177 | 1177 | case 'ADD_TABLE':{ |
| 1178 | 1178 | $sub_modif = ' '; |
| 1179 | - foreach($modif_list as $table_name){ |
|
| 1179 | + foreach ($modif_list as $table_name) { |
|
| 1180 | 1180 | $sub_modif .= $table_name; |
| 1181 | 1181 | $query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table_name); |
| 1182 | 1182 | $table_exists = $wpdb->query($query); |
| 1183 | - if($table_exists == 1){ |
|
| 1183 | + if ($table_exists == 1) { |
|
| 1184 | 1184 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been created', 'wpshop') . '" title="' . __('Table has been created', 'wpshop') . '" class="db_table_check" />'; |
| 1185 | 1185 | } |
| 1186 | - else{ |
|
| 1186 | + else { |
|
| 1187 | 1187 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been created', 'wpshop') . '" title="' . __('Table has not been created', 'wpshop') . '" class="db_table_check" />'; |
| 1188 | 1188 | $error_nb++; |
| 1189 | - if ( !empty($error_list[$plugin_db_version]) ) { |
|
| 1189 | + if (!empty($error_list[$plugin_db_version])) { |
|
| 1190 | 1190 | $error_list[$plugin_db_version] += 1; |
| 1191 | 1191 | } |
| 1192 | 1192 | else { |
@@ -1199,29 +1199,29 @@ discard block |
||
| 1199 | 1199 | }break; |
| 1200 | 1200 | case 'TABLE_RENAME':{ |
| 1201 | 1201 | $sub_modif = ' '; |
| 1202 | - foreach($modif_list as $table){ |
|
| 1202 | + foreach ($modif_list as $table) { |
|
| 1203 | 1203 | $sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']); |
| 1204 | 1204 | $query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']); |
| 1205 | 1205 | $table_exists = $wpdb->query($query); |
| 1206 | 1206 | $query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']); |
| 1207 | 1207 | $old_table_exists = $wpdb->query($query); |
| 1208 | - if(($table_exists == 1) && ($old_table_exists == 1)){ |
|
| 1208 | + if (($table_exists == 1) && ($old_table_exists == 1)) { |
|
| 1209 | 1209 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Both database table are still present', 'wpshop') . '" title="' . __('Both database table are still present', 'wpshop') . '" class="db_rename_table_check" />'; |
| 1210 | 1210 | $error_nb++; |
| 1211 | - if ( !empty($error_list[$plugin_db_version]) ) { |
|
| 1211 | + if (!empty($error_list[$plugin_db_version])) { |
|
| 1212 | 1212 | $error_list[$plugin_db_version] += 1; |
| 1213 | 1213 | } |
| 1214 | 1214 | else { |
| 1215 | 1215 | $error_list[$plugin_db_version] = 1; |
| 1216 | 1216 | } |
| 1217 | 1217 | } |
| 1218 | - elseif($table_exists == 1){ |
|
| 1218 | + elseif ($table_exists == 1) { |
|
| 1219 | 1219 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been renamed', 'wpshop') . '" title="' . __('Table has been renamed', 'wpshop') . '" class="db_rename_table_check" />'; |
| 1220 | 1220 | } |
| 1221 | - else{ |
|
| 1221 | + else { |
|
| 1222 | 1222 | $sub_modif .= '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_rename_table_check" />'; |
| 1223 | 1223 | $error_nb++; |
| 1224 | - if ( !empty($error_list[$plugin_db_version]) ) { |
|
| 1224 | + if (!empty($error_list[$plugin_db_version])) { |
|
| 1225 | 1225 | $error_list[$plugin_db_version] += 1; |
| 1226 | 1226 | } |
| 1227 | 1227 | else { |
@@ -1234,27 +1234,27 @@ discard block |
||
| 1234 | 1234 | }break; |
| 1235 | 1235 | case 'TABLE_RENAME_FOR_DELETION':{ |
| 1236 | 1236 | $sub_modif = ' '; |
| 1237 | - foreach($modif_list as $table){ |
|
| 1237 | + foreach ($modif_list as $table) { |
|
| 1238 | 1238 | $sub_modif .= sprintf(__('%s has been renammed %', 'wpshop'), $table['old_name'], $table['name']); |
| 1239 | 1239 | $query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['name']); |
| 1240 | 1240 | $table_delete_exists = $wpdb->query($query); |
| 1241 | 1241 | $query = $wpdb->prepare("SHOW TABLES FROM " . DB_NAME . " LIKE %s", $table['old_name']); |
| 1242 | 1242 | $old_table_exists = $wpdb->query($query); |
| 1243 | - if(($table_delete_exists == 1) || ($old_table_exists == 1)){ |
|
| 1244 | - if($old_table_exists == 1){ |
|
| 1243 | + if (($table_delete_exists == 1) || ($old_table_exists == 1)) { |
|
| 1244 | + if ($old_table_exists == 1) { |
|
| 1245 | 1245 | $deleted_table_result = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Table has not been renamed', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />'; |
| 1246 | 1246 | $error_nb++; |
| 1247 | - if ( !empty($error_list[$plugin_db_version]) ) { |
|
| 1247 | + if (!empty($error_list[$plugin_db_version])) { |
|
| 1248 | 1248 | $error_list[$plugin_db_version] += 1; |
| 1249 | 1249 | } |
| 1250 | 1250 | else { |
| 1251 | 1251 | $error_list[$plugin_db_version] = 1; |
| 1252 | 1252 | } |
| 1253 | 1253 | } |
| 1254 | - else{ |
|
| 1254 | + else { |
|
| 1255 | 1255 | $deleted_table_result = '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Table has not been deleted', 'wpshop') . '" title="' . __('Table has not been renamed', 'wpshop') . '" class="db_deleted_table_check" />'; |
| 1256 | 1256 | $warning_nb++; |
| 1257 | - if ( !empty($warning_list[$plugin_db_version]) ) { |
|
| 1257 | + if (!empty($warning_list[$plugin_db_version])) { |
|
| 1258 | 1258 | $warning_list[$plugin_db_version] += 1; |
| 1259 | 1259 | } |
| 1260 | 1260 | else { |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | } |
| 1264 | 1264 | $sub_modif .= $deleted_table_result; |
| 1265 | 1265 | } |
| 1266 | - else{ |
|
| 1266 | + else { |
|
| 1267 | 1267 | $sub_modif .= '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Table has been deleted', 'wpshop') . '" title="' . __('Table has been deleted', 'wpshop') . '" class="db_deleted_table_check" />'; |
| 1268 | 1268 | } |
| 1269 | 1269 | $sub_modif .= ' / '; |
@@ -1278,57 +1278,57 @@ discard block |
||
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | $db_table_field_error = ''; |
| 1281 | - foreach($wpshop_db_table as $table_name => $table_definition){ |
|
| 1282 | - if(!empty($table_definition)){ |
|
| 1281 | + foreach ($wpshop_db_table as $table_name => $table_definition) { |
|
| 1282 | + if (!empty($table_definition)) { |
|
| 1283 | 1283 | $table_line = explode(" |
| 1284 | 1284 | ", $table_definition); |
| 1285 | 1285 | |
| 1286 | 1286 | $sub_db_table_field_error = ' '; |
| 1287 | - foreach($table_line as $table_definition_line){ |
|
| 1287 | + foreach ($table_line as $table_definition_line) { |
|
| 1288 | 1288 | $def_line = trim($table_definition_line); |
| 1289 | - if(substr($def_line, 0, 1) == "`"){ |
|
| 1289 | + if (substr($def_line, 0, 1) == "`") { |
|
| 1290 | 1290 | $line_element = explode(" ", $def_line); |
| 1291 | 1291 | $field_name = str_replace("`", "", $line_element[0]); |
| 1292 | - $query = $wpdb->prepare("SHOW COLUMNS FROM " .$table_name . " WHERE Field = %s", $field_name); |
|
| 1292 | + $query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field_name); |
|
| 1293 | 1293 | $columns = $wpdb->get_row($query); |
| 1294 | - if ( !empty($columns->Field) && ($columns->Field != $field_name)) { |
|
| 1294 | + if (!empty($columns->Field) && ($columns->Field != $field_name)) { |
|
| 1295 | 1295 | $sub_db_table_field_error .= $field_name . ', '/* . ' : <img src="' . admin_url('images/no.png') . '" alt="' . __('Field does not exist', 'wpshop') . '" title="' . __('Field does not exist', 'wpshop') . '" class="db_added_field_check" />' */; |
| 1296 | 1296 | $error_nb++; |
| 1297 | 1297 | } |
| 1298 | 1298 | } |
| 1299 | 1299 | } |
| 1300 | 1300 | $sub_db_table_field_error = trim(substr($sub_db_table_field_error, 0, -2)); |
| 1301 | - if(!empty($sub_db_table_field_error)){ |
|
| 1301 | + if (!empty($sub_db_table_field_error)) { |
|
| 1302 | 1302 | $db_table_field_error .= sprintf(__('Following fields of %s don\'t exists: %s', 'wpshop'), '<span class="bold" >' . $table_name . '</span>', $sub_db_table_field_error) . '<br/>'; |
| 1303 | 1303 | } |
| 1304 | 1304 | } |
| 1305 | 1305 | } |
| 1306 | - if(!empty($db_table_field_error)){ |
|
| 1306 | + if (!empty($db_table_field_error)) { |
|
| 1307 | 1307 | $db_table_field_error = '<hr class="clear" />' . $db_table_field_error . '<hr/>'; |
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | 1310 | /* Start display */ |
| 1311 | 1311 | $plugin_install_error = '<img src="' . admin_url('images/yes.png') . '" alt="' . __('Wpshop install is ok', 'wpshop') . '" title="' . __('Wpshop install is ok', 'wpshop') . '" /> ' . __('There is no error in your wpshop installation. Please find details below', 'wpshop') . '<hr/>'; |
| 1312 | - if($error_nb > 0){ |
|
| 1312 | + if ($error_nb > 0) { |
|
| 1313 | 1313 | $plugin_install_error = '<img src="' . admin_url('images/no.png') . '" alt="' . __('Error in wpshop install', 'wpshop') . '" title="' . __('Error in wpshop install', 'wpshop') . '" /> ' . __('There are ne or more errors into your wpshop installation. Please find details below', 'wpshop') . '<br/> |
| 1314 | 1314 | <ul>'; |
| 1315 | - foreach($error_list as $version => $element_nb){ |
|
| 1316 | - $plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version . '" data-nonce="' . wp_create_nonce( 'wpshop_ajax_db_repair_tool ' ) .'" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>'; |
|
| 1315 | + foreach ($error_list as $version => $element_nb) { |
|
| 1316 | + $plugin_install_error .= '<li>' . sprintf(__('There are %d errors into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - <button id="wpshop_repair_db_version_' . $version . '" data-nonce="' . wp_create_nonce('wpshop_ajax_db_repair_tool ') . '" class="wpshop_repair_db_version" >' . __('Repair', 'wpshop') . '</button></li>'; |
|
| 1317 | 1317 | } |
| 1318 | 1318 | $plugin_install_error .= ' |
| 1319 | 1319 | </ul>'; |
| 1320 | 1320 | } |
| 1321 | - if($warning_nb > 0){ |
|
| 1321 | + if ($warning_nb > 0) { |
|
| 1322 | 1322 | $plugin_install_error .= '<img src="' . EVA_IMG_ICONES_PLUGIN_URL . 'warning_vs.gif" alt="' . __('Warning in wpshop install', 'wpshop') . '" title="' . __('Warning in wpshop install', 'wpshop') . '" /> ' . __('Some element need your attention. They have no consequences on wpshop operation. Please find details below', 'wpshop') . '<br/>'; |
| 1323 | - foreach($warning_list as $version => $element_nb){ |
|
| 1323 | + foreach ($warning_list as $version => $element_nb) { |
|
| 1324 | 1324 | $plugin_install_error .= ' ' . sprintf(__('There are %d warning into %s version', 'wpshop'), $element_nb, '<a href="#wpshop_plugin_v_' . $version . '" >' . $version . '</a>') . ' - '; |
| 1325 | 1325 | } |
| 1326 | 1326 | $plugin_install_error = substr($plugin_install_error, 0, -3) . '<hr/>'; |
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | $max_number = 0; |
| 1330 | - foreach($wpshop_update_way as $number => $operation){ |
|
| 1331 | - if($number > $max_number){ |
|
| 1330 | + foreach ($wpshop_update_way as $number => $operation) { |
|
| 1331 | + if ($number > $max_number) { |
|
| 1332 | 1332 | $max_number = $number; |
| 1333 | 1333 | } |
| 1334 | 1334 | } |
@@ -1338,30 +1338,30 @@ discard block |
||
| 1338 | 1338 | add_action('wp_ajax_wpshop_tool_db_check', 'wpshop_ajax_db_check_tool'); |
| 1339 | 1339 | |
| 1340 | 1340 | function wpshop_tool_default_datas_check() { |
| 1341 | - check_ajax_referer( 'wpshop_tool_default_datas_check' ); |
|
| 1341 | + check_ajax_referer('wpshop_tool_default_datas_check'); |
|
| 1342 | 1342 | |
| 1343 | 1343 | $output_ok = $output_error = ''; |
| 1344 | 1344 | |
| 1345 | 1345 | /** Get defined default datas type */ |
| 1346 | - $default_custom_post_type = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES ); |
|
| 1346 | + $default_custom_post_type = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES); |
|
| 1347 | 1347 | |
| 1348 | 1348 | /** Read the default data saved to check */ |
| 1349 | - if ( !empty($default_custom_post_type) ) { |
|
| 1350 | - foreach ( $default_custom_post_type as $type ) { |
|
| 1349 | + if (!empty($default_custom_post_type)) { |
|
| 1350 | + foreach ($default_custom_post_type as $type) { |
|
| 1351 | 1351 | $has_error = false; |
| 1352 | 1352 | $file_uri = WPSHOP_TEMPLATES_DIR . 'default_datas/' . $type . '.csv'; |
| 1353 | - if ( is_file( $file_uri ) ) { |
|
| 1353 | + if (is_file($file_uri)) { |
|
| 1354 | 1354 | unset($tpl_component); |
| 1355 | 1355 | $tpl_component = array(); |
| 1356 | 1356 | $tpl_component['CUSTOM_POST_TYPE_NAME'] = 'wpshop_cpt_' . $type; |
| 1357 | 1357 | |
| 1358 | 1358 | /** Launch check on custom post type */ |
| 1359 | - $check_cpt = wpshop_entities::check_default_custom_post_type( $type, $tpl_component ); |
|
| 1359 | + $check_cpt = wpshop_entities::check_default_custom_post_type($type, $tpl_component); |
|
| 1360 | 1360 | $has_error = $check_cpt[0]; |
| 1361 | 1361 | $tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER'] = $check_cpt[1]; |
| 1362 | - $tpl_component = array_merge( $tpl_component, $check_cpt[2] ); |
|
| 1362 | + $tpl_component = array_merge($tpl_component, $check_cpt[2]); |
|
| 1363 | 1363 | |
| 1364 | - if ( $has_error ) { |
|
| 1364 | + if ($has_error) { |
|
| 1365 | 1365 | $output_error .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element', $tpl_component, array(), 'admin'); |
| 1366 | 1366 | } |
| 1367 | 1367 | else { |
@@ -1377,77 +1377,77 @@ discard block |
||
| 1377 | 1377 | add_action('wp_ajax_wpshop_tool_default_datas_check', 'wpshop_tool_default_datas_check'); |
| 1378 | 1378 | |
| 1379 | 1379 | function wpshop_ajax_repair_default_datas() { |
| 1380 | - check_ajax_referer( 'wpshop_ajax_repair_default_datas' ); |
|
| 1380 | + check_ajax_referer('wpshop_ajax_repair_default_datas'); |
|
| 1381 | 1381 | |
| 1382 | 1382 | global $wpdb; |
| 1383 | 1383 | $output = ''; |
| 1384 | 1384 | $container = ''; |
| 1385 | 1385 | $result = ''; |
| 1386 | 1386 | |
| 1387 | - $selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? $_POST['type'] : null; |
|
| 1388 | - $identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? $_POST['identifier'] : null; |
|
| 1387 | + $selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? $_POST['type'] : null; |
|
| 1388 | + $identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? $_POST['identifier'] : null; |
|
| 1389 | 1389 | |
| 1390 | - switch ( $selected_type ) { |
|
| 1390 | + switch ($selected_type) { |
|
| 1391 | 1391 | case WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES: |
| 1392 | - $result = wpshop_entities::create_cpt_from_csv_file( $identifier ); |
|
| 1392 | + $result = wpshop_entities::create_cpt_from_csv_file($identifier); |
|
| 1393 | 1393 | break; |
| 1394 | 1394 | case WPSHOP_DBT_ATTRIBUTE: |
| 1395 | - $result = wpshop_entities::create_cpt_attributes_from_csv_file( $identifier ); |
|
| 1395 | + $result = wpshop_entities::create_cpt_attributes_from_csv_file($identifier); |
|
| 1396 | 1396 | break; |
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | - echo json_encode( $result ); |
|
| 1399 | + echo json_encode($result); |
|
| 1400 | 1400 | die(); |
| 1401 | 1401 | } |
| 1402 | 1402 | add_action('wp_ajax_wpshop_ajax_repair_default_datas', 'wpshop_ajax_repair_default_datas'); |
| 1403 | 1403 | |
| 1404 | 1404 | function wpshop_ajax_translate_default_datas() { |
| 1405 | - check_ajax_referer( 'wpshop_ajax_translate_default_datas' ); |
|
| 1405 | + check_ajax_referer('wpshop_ajax_translate_default_datas'); |
|
| 1406 | 1406 | global $wpdb; |
| 1407 | 1407 | $result = array('status' => true); |
| 1408 | 1408 | |
| 1409 | - $selected_type = ( isset( $_POST['type'] ) && !empty( $_POST['type'] ) ) ? $_POST['type'] : null; |
|
| 1410 | - $identifier = ( isset( $_POST['identifier'] ) && !empty( $_POST['identifier'] ) ) ? $_POST['identifier'] : null; |
|
| 1409 | + $selected_type = (isset($_POST['type']) && !empty($_POST['type'])) ? $_POST['type'] : null; |
|
| 1410 | + $identifier = (isset($_POST['identifier']) && !empty($_POST['identifier'])) ? $_POST['identifier'] : null; |
|
| 1411 | 1411 | |
| 1412 | - $entity_id = wpshop_entities::get_entity_identifier_from_code( $identifier ); |
|
| 1412 | + $entity_id = wpshop_entities::get_entity_identifier_from_code($identifier); |
|
| 1413 | 1413 | $query = $wpdb->prepare("SELECT id, frontend_label FROM " . $selected_type . " WHERE entity_id = %d", $entity_id); |
| 1414 | - $attribute_list = $wpdb->get_results( $query ); |
|
| 1415 | - if ( !empty($attribute_list) ) { |
|
| 1416 | - foreach ( $attribute_list as $attribute) { |
|
| 1417 | - $update_result = $wpdb->update( $selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id) ); |
|
| 1418 | - if ( $update_result === false ) { |
|
| 1414 | + $attribute_list = $wpdb->get_results($query); |
|
| 1415 | + if (!empty($attribute_list)) { |
|
| 1416 | + foreach ($attribute_list as $attribute) { |
|
| 1417 | + $update_result = $wpdb->update($selected_type, array('frontend_label' => __($attribute->frontend_label, 'wpshop')), array('id' => $attribute->id)); |
|
| 1418 | + if ($update_result === false) { |
|
| 1419 | 1419 | $result['status'] = false; |
| 1420 | 1420 | } |
| 1421 | 1421 | } |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - echo json_encode( $result ); |
|
| 1424 | + echo json_encode($result); |
|
| 1425 | 1425 | die(); |
| 1426 | 1426 | } |
| 1427 | 1427 | add_action('wp_ajax_wpshop_ajax_translate_default_datas', 'wpshop_ajax_translate_default_datas'); |
| 1428 | 1428 | |
| 1429 | 1429 | function wpshop_ajax_db_repair_tool() { |
| 1430 | - check_ajax_referer( 'wpshop_ajax_db_repair_tool' ); |
|
| 1430 | + check_ajax_referer('wpshop_ajax_db_repair_tool'); |
|
| 1431 | 1431 | |
| 1432 | 1432 | $version_id = isset($_POST['version_id']) ? wpshop_tools::varSanitizer($_POST['version_id']) : null; |
| 1433 | 1433 | |
| 1434 | - echo wpshop_install::alter_db_structure_on_update( $version_id ); |
|
| 1434 | + echo wpshop_install::alter_db_structure_on_update($version_id); |
|
| 1435 | 1435 | |
| 1436 | 1436 | die(); |
| 1437 | 1437 | } |
| 1438 | 1438 | add_action('wp_ajax_wpshop_ajax_db_repair_tool', 'wpshop_ajax_db_repair_tool'); |
| 1439 | 1439 | |
| 1440 | 1440 | function wps_mass_action_main_interface() { |
| 1441 | - check_ajax_referer( 'wps_mass_action_main_interface' ); |
|
| 1441 | + check_ajax_referer('wps_mass_action_main_interface'); |
|
| 1442 | 1442 | $tpl_component = array(); |
| 1443 | 1443 | |
| 1444 | 1444 | /** Copy an attribute content to another */ |
| 1445 | - $attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ), "'valid'", 'entity_id', true); |
|
| 1445 | + $attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), "'valid'", 'entity_id', true); |
|
| 1446 | 1446 | $possible_values = array('' => __('Choose an attribute', 'wpshop')); |
| 1447 | 1447 | $possible_values_for_variation = array('' => __('Choose an attribute', 'wpshop')); |
| 1448 | - foreach ( $attribute_list as $attribute ) { |
|
| 1448 | + foreach ($attribute_list as $attribute) { |
|
| 1449 | 1449 | $possible_values[$attribute->id] = $attribute->frontend_label; |
| 1450 | - if ( $attribute->is_used_for_variation == 'yes' ) { |
|
| 1450 | + if ($attribute->is_used_for_variation == 'yes') { |
|
| 1451 | 1451 | $possible_values_for_variation[$attribute->id] = $attribute->frontend_label; |
| 1452 | 1452 | } |
| 1453 | 1453 | } |
@@ -1478,18 +1478,18 @@ discard block |
||
| 1478 | 1478 | add_action('wp_ajax_wps_mass_action', 'wps_mass_action_main_interface'); |
| 1479 | 1479 | |
| 1480 | 1480 | function wps_mass_action_update_attribute_value() { |
| 1481 | - check_ajax_referer( 'wps_mass_action_update_attribute_value' ); |
|
| 1481 | + check_ajax_referer('wps_mass_action_update_attribute_value'); |
|
| 1482 | 1482 | global $wpdb; |
| 1483 | 1483 | $response = array(); |
| 1484 | 1484 | |
| 1485 | - if ( $_POST['wps_update_att_values']['from'] != $_POST['wps_update_att_values']['to'] ) { |
|
| 1485 | + if ($_POST['wps_update_att_values']['from'] != $_POST['wps_update_att_values']['to']) { |
|
| 1486 | 1486 | $from_attribute = wpshop_attributes::getElement($_POST['wps_update_att_values']['from'], "'valid'"); |
| 1487 | 1487 | $to_attribute = wpshop_attributes::getElement($_POST['wps_update_att_values']['to'], "'valid'"); |
| 1488 | - if ( $from_attribute->data_type == $to_attribute->data_type ) { |
|
| 1488 | + if ($from_attribute->data_type == $to_attribute->data_type) { |
|
| 1489 | 1489 | |
| 1490 | 1490 | /** Manage specific case */ |
| 1491 | 1491 | $query_more_args = array(); |
| 1492 | - switch( $to_attribute->code ){ |
|
| 1492 | + switch ($to_attribute->code) { |
|
| 1493 | 1493 | case "barcode": |
| 1494 | 1494 | $more_query = " |
| 1495 | 1495 | AND VAL.value NOT LIKE %s"; |
@@ -1505,22 +1505,22 @@ discard block |
||
| 1505 | 1505 | WHERE VAL.attribute_id = %d |
| 1506 | 1506 | AND P.post_type = %s |
| 1507 | 1507 | AND VAL.value != ''" . $more_query, |
| 1508 | - array_merge( array( $_POST['wps_update_att_values']['from'], $_POST['wps_entity_to_transfert'] ), $query_more_args ) |
|
| 1508 | + array_merge(array($_POST['wps_update_att_values']['from'], $_POST['wps_entity_to_transfert']), $query_more_args) |
|
| 1509 | 1509 | ); |
| 1510 | - $element_list_to_update = $wpdb->get_results( $query ); |
|
| 1510 | + $element_list_to_update = $wpdb->get_results($query); |
|
| 1511 | 1511 | |
| 1512 | - if ( !empty($element_list_to_update) ) { |
|
| 1512 | + if (!empty($element_list_to_update)) { |
|
| 1513 | 1513 | $has_error = false; |
| 1514 | 1514 | $error_count = 0; |
| 1515 | - foreach ( $element_list_to_update as $element ) { |
|
| 1515 | + foreach ($element_list_to_update as $element) { |
|
| 1516 | 1516 | |
| 1517 | 1517 | /** Historicize the old value of recevier attribute */ |
| 1518 | - if ( $to_attribute->is_historisable == 'yes' ) { |
|
| 1518 | + if ($to_attribute->is_historisable == 'yes') { |
|
| 1519 | 1519 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $to_attribute->id, $element->ID); |
| 1520 | - $attribute_histos = $wpdb->get_results( $query ); |
|
| 1521 | - if ( !empty( $attribute_histos ) ) { |
|
| 1522 | - foreach ( $attribute_histos as $attribute_histo ) { |
|
| 1523 | - if ( !empty( $attribute_histo->value ) ) { |
|
| 1520 | + $attribute_histos = $wpdb->get_results($query); |
|
| 1521 | + if (!empty($attribute_histos)) { |
|
| 1522 | + foreach ($attribute_histos as $attribute_histo) { |
|
| 1523 | + if (!empty($attribute_histo->value)) { |
|
| 1524 | 1524 | $attribute_histo_content['status'] = 'valid'; |
| 1525 | 1525 | $attribute_histo_content['creation_date'] = current_time('mysql', 0); |
| 1526 | 1526 | $attribute_histo_content['creation_date_value'] = $attribute_histo->creation_date_value; |
@@ -1533,12 +1533,12 @@ discard block |
||
| 1533 | 1533 | $attribute_histo_content['value'] = $attribute_histo->value; |
| 1534 | 1534 | $attribute_histo_content['value_type'] = WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType; |
| 1535 | 1535 | $last_histo = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO, $attribute_histo_content); |
| 1536 | - if ( $last_histo === false ) { |
|
| 1536 | + if ($last_histo === false) { |
|
| 1537 | 1537 | $has_error = true; |
| 1538 | 1538 | $error_count++; |
| 1539 | 1539 | } |
| 1540 | 1540 | else { |
| 1541 | - $wpdb->delete( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array( 'value_id' => $attribute_histo->value_id ) ); |
|
| 1541 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array('value_id' => $attribute_histo->value_id)); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
@@ -1547,36 +1547,36 @@ discard block |
||
| 1547 | 1547 | |
| 1548 | 1548 | /** */ |
| 1549 | 1549 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type . " WHERE attribute_id = %d AND entity_id = %d", $from_attribute->id, $element->ID); |
| 1550 | - $attribute_to_save = $wpdb->get_row( $query, ARRAY_A ); |
|
| 1550 | + $attribute_to_save = $wpdb->get_row($query, ARRAY_A); |
|
| 1551 | 1551 | unset($attribute_to_save['value_id']); |
| 1552 | 1552 | $attribute_to_save['attribute_id'] = $to_attribute->id; |
| 1553 | 1553 | $attribute_to_save['creation_date_value'] = current_time('mysql', 0); |
| 1554 | 1554 | $attribute_to_save['user_id'] = get_current_user_id(); |
| 1555 | - $new_value = $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save ); |
|
| 1556 | - if ( $new_value === false ) { |
|
| 1555 | + $new_value = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $to_attribute->data_type, $attribute_to_save); |
|
| 1556 | + if ($new_value === false) { |
|
| 1557 | 1557 | $has_error = true; |
| 1558 | 1558 | $error_count++; |
| 1559 | 1559 | } |
| 1560 | 1560 | else { |
| 1561 | 1561 | /** Save new atribute values in product metadata */ |
| 1562 | - $current_product_metadata = get_post_meta( $element->ID, '_wpshop_product_metadata', true); |
|
| 1562 | + $current_product_metadata = get_post_meta($element->ID, '_wpshop_product_metadata', true); |
|
| 1563 | 1563 | $current_product_metadata[$to_attribute->code] = $element->value; |
| 1564 | - update_post_meta( $element->ID, '_wpshop_product_metadata', $current_product_metadata ); |
|
| 1564 | + update_post_meta($element->ID, '_wpshop_product_metadata', $current_product_metadata); |
|
| 1565 | 1565 | |
| 1566 | 1566 | /** Save a single meta for attribute in case it will be used in specific case where meta needs to be alone */ |
| 1567 | - if ( ( ($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes')) || ( $to_attribute->is_filterable == 'yes') && !empty($element->value) ) : |
|
| 1568 | - update_post_meta( $element->ID, '_' . $to_attribute->code, $element->value ); |
|
| 1567 | + if ((($to_attribute->is_used_for_sort_by == 'yes') || ($to_attribute->is_searchable == 'yes')) || ($to_attribute->is_filterable == 'yes') && !empty($element->value)) : |
|
| 1568 | + update_post_meta($element->ID, '_' . $to_attribute->code, $element->value); |
|
| 1569 | 1569 | endif; |
| 1570 | 1570 | } |
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | - if ( !$has_error ) { |
|
| 1573 | + if (!$has_error) { |
|
| 1574 | 1574 | $response['status'] = true; |
| 1575 | 1575 | $response['error'] = __('Transfert between attribute is done', 'wpshop'); |
| 1576 | 1576 | } |
| 1577 | 1577 | else { |
| 1578 | 1578 | $response['status'] = false; |
| 1579 | - $response['error'] = sprinttf( __('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count); |
|
| 1579 | + $response['error'] = sprinttf(__('There are %d error that occured while copying value through attributes', 'wpshop'), $error_count); |
|
| 1580 | 1580 | } |
| 1581 | 1581 | } |
| 1582 | 1582 | else { |
@@ -1594,19 +1594,19 @@ discard block |
||
| 1594 | 1594 | $response['error'] = __('You have to choose attributes in order to update values', 'wpshop'); |
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | - echo json_encode( $response ); |
|
| 1597 | + echo json_encode($response); |
|
| 1598 | 1598 | die(); |
| 1599 | 1599 | } |
| 1600 | 1600 | add_action('wp_ajax_wps_mass_action_update_attribute', 'wps_mass_action_update_attribute_value'); |
| 1601 | 1601 | |
| 1602 | 1602 | function wps_tools_mass_action_load_possible_options_for_variations_attributes() { |
| 1603 | 1603 | // @TODO attribute_id est introuvable |
| 1604 | - check_ajax_referer( 'wps_tools_mass_action_load_possible_options_for_variations_attributes' ); |
|
| 1604 | + check_ajax_referer('wps_tools_mass_action_load_possible_options_for_variations_attributes'); |
|
| 1605 | 1605 | $output = ''; |
| 1606 | - $attribute = wpshop_attributes::getElement( $_POST['attribute_id'], "'valid'" ); |
|
| 1606 | + $attribute = wpshop_attributes::getElement($_POST['attribute_id'], "'valid'"); |
|
| 1607 | 1607 | |
| 1608 | 1608 | /** Define new default value */ |
| 1609 | - $attribute_possible_values_output = wpshop_attributes::get_select_output( $attribute, array() ); |
|
| 1609 | + $attribute_possible_values_output = wpshop_attributes::get_select_output($attribute, array()); |
|
| 1610 | 1610 | $attribute_possible_values_output['possible_value']['no_changes'] = __('No changes', 'wpshop'); |
| 1611 | 1611 | $attribute_possible_values_output['possible_value']['none'] = __('No default value', 'wpshop'); |
| 1612 | 1612 | ksort($attribute_possible_values_output['possible_value']); |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | $input_def['valueToPut'] = 'index'; |
| 1616 | 1616 | $input_def['name'] = 'wps_update_att_for_variation_options_values'; |
| 1617 | 1617 | $input_def['id'] = 'wps_update_att_for_variation_options_values'; |
| 1618 | - $output .= __( 'Default value to affect for this attribute to all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def ); |
|
| 1618 | + $output .= __('Default value to affect for this attribute to all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def); |
|
| 1619 | 1619 | |
| 1620 | 1620 | /** Define if attribute is required for adding product to cart */ |
| 1621 | 1621 | $input_def = array(); |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | $input_def['valueToPut'] = 'index'; |
| 1625 | 1625 | $input_def['name'] = 'wps_update_att_for_variation_required_state'; |
| 1626 | 1626 | $input_def['id'] = 'wps_update_att_for_variation_required_state'; |
| 1627 | - $output .= '<br/>' . __( 'Put this attribute as required for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def ); |
|
| 1627 | + $output .= '<br/>' . __('Put this attribute as required for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def); |
|
| 1628 | 1628 | |
| 1629 | 1629 | |
| 1630 | 1630 | $input_def = array(); |
@@ -1633,7 +1633,7 @@ discard block |
||
| 1633 | 1633 | $input_def['valueToPut'] = 'index'; |
| 1634 | 1634 | $input_def['name'] = 'wps_update_att_for_variation[price_display][text_from]'; |
| 1635 | 1635 | $input_def['id'] = 'wps_update_att_for_variation_price_display_text_from'; |
| 1636 | - $output .= '<br/>' . __( 'Display "Price from" text before price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def ); |
|
| 1636 | + $output .= '<br/>' . __('Display "Price from" text before price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def); |
|
| 1637 | 1637 | |
| 1638 | 1638 | $input_def = array(); |
| 1639 | 1639 | $input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'no' => __('No', 'wpshop'), 'yes' => __('Yes', 'wpshop')); |
@@ -1641,7 +1641,7 @@ discard block |
||
| 1641 | 1641 | $input_def['valueToPut'] = 'index'; |
| 1642 | 1642 | $input_def['name'] = 'wps_update_att_for_variation[price_display][lower_price]'; |
| 1643 | 1643 | $input_def['id'] = 'wps_update_att_for_variation_price_display_lower_price'; |
| 1644 | - $output .= '<br/>' . __( 'Display lower price for all products', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def ); |
|
| 1644 | + $output .= '<br/>' . __('Display lower price for all products', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def); |
|
| 1645 | 1645 | |
| 1646 | 1646 | $input_def = array(); |
| 1647 | 1647 | $input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'replacement' => __('Replace product price with option price', 'wpshop'), 'addition' => __('Add option price to product price', 'wpshop')); |
@@ -1649,7 +1649,7 @@ discard block |
||
| 1649 | 1649 | $input_def['valueToPut'] = 'index'; |
| 1650 | 1650 | $input_def['name'] = 'wps_update_att_for_variation[price_behaviour]'; |
| 1651 | 1651 | $input_def['id'] = 'wps_update_att_for_variation_price_behaviour'; |
| 1652 | - $output .= '<br/>' . __( 'Price calculation behaviour', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def ); |
|
| 1652 | + $output .= '<br/>' . __('Price calculation behaviour', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def); |
|
| 1653 | 1653 | |
| 1654 | 1654 | $input_def = array(); |
| 1655 | 1655 | $input_def['possible_value'] = array('no_changes' => __('No changes', 'wpshop'), 'single' => __('Priority to single options', 'wpshop'), 'combined' => __('Priority to combined options', 'wpshop')); |
@@ -1657,7 +1657,7 @@ discard block |
||
| 1657 | 1657 | $input_def['valueToPut'] = 'index'; |
| 1658 | 1658 | $input_def['name'] = 'wps_update_att_for_variation[priority]'; |
| 1659 | 1659 | $input_def['id'] = 'wps_update_att_for_variation_priority'; |
| 1660 | - $output .= '<br/>' . __( 'Choose priority combination for calculating options', 'wpshop' ) . ' ' . wpshop_form::check_input_type( $input_def ); |
|
| 1660 | + $output .= '<br/>' . __('Choose priority combination for calculating options', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def); |
|
| 1661 | 1661 | |
| 1662 | 1662 | echo $output; |
| 1663 | 1663 | die(); |
@@ -1665,61 +1665,61 @@ discard block |
||
| 1665 | 1665 | add_action('wp_ajax_wps_tools_mass_action_load_possible_options_for_variations_attributes', 'wps_tools_mass_action_load_possible_options_for_variations_attributes'); |
| 1666 | 1666 | |
| 1667 | 1667 | function wps_mass_action_change_variation_option() { |
| 1668 | - check_ajax_referer( 'wps_mass_action_change_variation_option' ); |
|
| 1668 | + check_ajax_referer('wps_mass_action_change_variation_option'); |
|
| 1669 | 1669 | global $wpdb; |
| 1670 | 1670 | |
| 1671 | - $attribute = wpshop_attributes::getElement( $_POST['attribute_id'], "'valid'" ); |
|
| 1672 | - $query = $wpdb->prepare( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code ); |
|
| 1673 | - $meta_to_update = $wpdb->get_results( $query ); |
|
| 1671 | + $attribute = wpshop_attributes::getElement($_POST['attribute_id'], "'valid'"); |
|
| 1672 | + $query = $wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE ('%%%s%%')", '_wpshop_variation_defining', $attribute->code); |
|
| 1673 | + $meta_to_update = $wpdb->get_results($query); |
|
| 1674 | 1674 | $has_error = false; |
| 1675 | - if ( !empty($meta_to_update) ) { |
|
| 1676 | - foreach ( $meta_to_update as $meta_def ) { |
|
| 1677 | - $meta_value = unserialize( $meta_def->meta_value ); |
|
| 1678 | - if ( !empty($meta_value) && !empty( $meta_value['attributes'] ) && in_array( $attribute->code, $meta_value['attributes']) ) { |
|
| 1675 | + if (!empty($meta_to_update)) { |
|
| 1676 | + foreach ($meta_to_update as $meta_def) { |
|
| 1677 | + $meta_value = unserialize($meta_def->meta_value); |
|
| 1678 | + if (!empty($meta_value) && !empty($meta_value['attributes']) && in_array($attribute->code, $meta_value['attributes'])) { |
|
| 1679 | 1679 | |
| 1680 | - if ( $_POST['wps_update_att_for_variation_options_values'] != 'no_changes' ) { |
|
| 1680 | + if ($_POST['wps_update_att_for_variation_options_values'] != 'no_changes') { |
|
| 1681 | 1681 | $meta_value['options']['attributes_default_value'][$attribute->code] = $_POST['wps_update_att_for_variation_options_values']; |
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | - if ( !empty($_POST['wps_update_att_for_variation_required_state']) && ($_POST['wps_update_att_for_variation_required_state'] != 'no_changes') ) { |
|
| 1685 | - if ( $_POST['wps_update_att_for_variation_required_state'] == 'yes') { |
|
| 1684 | + if (!empty($_POST['wps_update_att_for_variation_required_state']) && ($_POST['wps_update_att_for_variation_required_state'] != 'no_changes')) { |
|
| 1685 | + if ($_POST['wps_update_att_for_variation_required_state'] == 'yes') { |
|
| 1686 | 1686 | $meta_value['options']['required_attributes'][$attribute->code] = $attribute->code; |
| 1687 | 1687 | } |
| 1688 | - else if ( !empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code]) ) { |
|
| 1688 | + else if (!empty($meta_value['options']['required_attributes']) && !empty($meta_value['options']['required_attributes'][$attribute->code])) { |
|
| 1689 | 1689 | unset($meta_value['options']['required_attributes'][$attribute->code]); |
| 1690 | 1690 | } |
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | - if ( !empty( $_POST['wps_update_att_for_variation'] ) ) { |
|
| 1694 | - if ( !empty($_POST['wps_update_att_for_variation']['text_from']) && ($_POST['wps_update_att_for_variation']['text_from'] != 'no_changes') ) { |
|
| 1695 | - if ( $_POST['wps_update_att_for_variation']['text_from'] == 'yes' ) { |
|
| 1693 | + if (!empty($_POST['wps_update_att_for_variation'])) { |
|
| 1694 | + if (!empty($_POST['wps_update_att_for_variation']['text_from']) && ($_POST['wps_update_att_for_variation']['text_from'] != 'no_changes')) { |
|
| 1695 | + if ($_POST['wps_update_att_for_variation']['text_from'] == 'yes') { |
|
| 1696 | 1696 | $meta_value['options']['price_display']['text_from'] = 'on'; |
| 1697 | 1697 | } |
| 1698 | - else if( !empty($meta_value['options']['price_display']['text_from']) ) { |
|
| 1698 | + else if (!empty($meta_value['options']['price_display']['text_from'])) { |
|
| 1699 | 1699 | unset($meta_value['options']['price_display']['text_from']); |
| 1700 | 1700 | } |
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | - if ( !empty($_POST['wps_update_att_for_variation']['lower_price']) && ($_POST['wps_update_att_for_variation']['lower_price'] != 'no_changes') ) { |
|
| 1704 | - if ( $_POST['wps_update_att_for_variation']['lower_price'] == 'yes' ) { |
|
| 1703 | + if (!empty($_POST['wps_update_att_for_variation']['lower_price']) && ($_POST['wps_update_att_for_variation']['lower_price'] != 'no_changes')) { |
|
| 1704 | + if ($_POST['wps_update_att_for_variation']['lower_price'] == 'yes') { |
|
| 1705 | 1705 | $meta_value['options']['price_display']['lower_price'] = 'on'; |
| 1706 | 1706 | } |
| 1707 | - else if( !empty($meta_value['options']['price_display']['lower_price']) ) { |
|
| 1707 | + else if (!empty($meta_value['options']['price_display']['lower_price'])) { |
|
| 1708 | 1708 | unset($meta_value['options']['price_display']['lower_price']); |
| 1709 | 1709 | } |
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | - if ( !empty($_POST['wps_update_att_for_variation']['price_behaviour']) && ($_POST['wps_update_att_for_variation']['price_behaviour'] != 'no_changes') ) { |
|
| 1712 | + if (!empty($_POST['wps_update_att_for_variation']['price_behaviour']) && ($_POST['wps_update_att_for_variation']['price_behaviour'] != 'no_changes')) { |
|
| 1713 | 1713 | $meta_value['options']['price_behaviour'][0] = $_POST['wps_update_att_for_variation']['price_behaviour']; |
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | - if ( !empty($_POST['wps_update_att_for_variation']['priority']) && ($_POST['wps_update_att_for_variation']['priority'] != 'no_changes') ) { |
|
| 1716 | + if (!empty($_POST['wps_update_att_for_variation']['priority']) && ($_POST['wps_update_att_for_variation']['priority'] != 'no_changes')) { |
|
| 1717 | 1717 | $meta_value['options']['priority'][0] = $_POST['wps_update_att_for_variation']['priority']; |
| 1718 | 1718 | } |
| 1719 | 1719 | } |
| 1720 | 1720 | |
| 1721 | - $meta_save = update_meta( $meta_def->meta_id, '_wpshop_variation_defining', $meta_value); |
|
| 1722 | - if ( $meta_save === false ) { |
|
| 1721 | + $meta_save = update_meta($meta_def->meta_id, '_wpshop_variation_defining', $meta_value); |
|
| 1722 | + if ($meta_save === false) { |
|
| 1723 | 1723 | $has_error = true; |
| 1724 | 1724 | } |
| 1725 | 1725 | |
@@ -1727,7 +1727,7 @@ discard block |
||
| 1727 | 1727 | } |
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | - echo json_encode( array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters'))) ); |
|
| 1730 | + echo json_encode(array('status' => $has_error, 'error' => (!$has_error ? __('Product variation parameters have been updated', 'wpshop') : __('An error occured while changing products variations options parameters')))); |
|
| 1731 | 1731 | die(); |
| 1732 | 1732 | } |
| 1733 | 1733 | add_action('wp_ajax_wps_mass_action_change_variation_option', 'wps_mass_action_change_variation_option'); |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | */ |
| 1740 | 1740 | function ajax_activate_addons() { |
| 1741 | 1741 | global $wpdb; |
| 1742 | - check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' ); |
|
| 1742 | + check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce'); |
|
| 1743 | 1743 | |
| 1744 | 1744 | $addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null; |
| 1745 | 1745 | $addon_code = isset($_POST['code']) ? wpshop_tools::varSanitizer($_POST['code']) : null; |
@@ -1748,56 +1748,56 @@ discard block |
||
| 1748 | 1748 | if (!empty($addon_name) && !empty($addon_code)) { |
| 1749 | 1749 | $addons_list = (unserialize(WPSHOP_ADDONS_LIST)); |
| 1750 | 1750 | if (in_array($addon_name, array_keys($addons_list))) { |
| 1751 | - $plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' ); |
|
| 1751 | + $plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php'); |
|
| 1752 | 1752 | $code_part = array(); |
| 1753 | - $code_part[] = substr(hash ( "sha256" , $addons_list[$addon_name][0] ), $addons_list[$addon_name][1], 5); |
|
| 1754 | - $code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 1755 | - $code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 1753 | + $code_part[] = substr(hash("sha256", $addons_list[$addon_name][0]), $addons_list[$addon_name][1], 5); |
|
| 1754 | + $code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 1755 | + $code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 1756 | 1756 | $code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0]; |
| 1757 | 1757 | |
| 1758 | 1758 | $current_web_site = site_url('/'); |
| 1759 | 1759 | |
| 1760 | - if ( $addons_list[$addon_name][2] == 'per_site') { |
|
| 1761 | - $code .= '-' . substr(hash ( "sha256" , $current_web_site ), $addons_list[$addon_name][1], 5); |
|
| 1760 | + if ($addons_list[$addon_name][2] == 'per_site') { |
|
| 1761 | + $code .= '-' . substr(hash("sha256", $current_web_site), $addons_list[$addon_name][1], 5); |
|
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | - if ( !empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') { |
|
| 1765 | - $admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' ); |
|
| 1766 | - if ( empty($admin_new_quotation_message) ) { |
|
| 1767 | - wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' ); |
|
| 1764 | + if (!empty($addons_list[$addon_name][4]) && $addons_list[$addon_name][4] == 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE') { |
|
| 1765 | + $admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE'); |
|
| 1766 | + if (empty($admin_new_quotation_message)) { |
|
| 1767 | + wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE'); |
|
| 1768 | 1768 | } |
| 1769 | - $admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' ); |
|
| 1770 | - if ( empty($admin_new_quotation_confirm_message) ) { |
|
| 1771 | - wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' ); |
|
| 1769 | + $admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE'); |
|
| 1770 | + if (empty($admin_new_quotation_confirm_message)) { |
|
| 1771 | + wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE'); |
|
| 1772 | 1772 | } |
| 1773 | 1773 | } |
| 1774 | 1774 | |
| 1775 | 1775 | if ($code == $addon_code) { |
| 1776 | - $extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array() ); |
|
| 1776 | + $extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array()); |
|
| 1777 | 1777 | $extra_options[$addon_name]['activate'] = true; |
| 1778 | 1778 | $extra_options[$addon_name]['activation_date'] = current_time('mysql', 0); |
| 1779 | 1779 | $extra_options[$addon_name]['activation_code'] = $addon_code; |
| 1780 | - if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) { |
|
| 1781 | - $result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated','wpshop')); |
|
| 1782 | - if( !empty($addons_list[$addon_name][3]) ) { |
|
| 1780 | + if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) { |
|
| 1781 | + $result = array(true, __('The addon has been activated successfully', 'wpshop'), __('Activated', 'wpshop')); |
|
| 1782 | + if (!empty($addons_list[$addon_name][3])) { |
|
| 1783 | 1783 | $activate_attribute_for_addon = $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => $addons_list[$addon_name][3])); |
| 1784 | 1784 | } |
| 1785 | 1785 | $state = true; |
| 1786 | 1786 | } |
| 1787 | 1787 | else { |
| 1788 | - $result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop')); |
|
| 1788 | + $result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop')); |
|
| 1789 | 1789 | } |
| 1790 | 1790 | } |
| 1791 | 1791 | else { |
| 1792 | - $result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated','wpshop')); |
|
| 1792 | + $result = array(false, __('The activating code is invalid', 'wpshop'), __('Desactivated', 'wpshop')); |
|
| 1793 | 1793 | } |
| 1794 | 1794 | } |
| 1795 | 1795 | else { |
| 1796 | - $result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated','wpshop')); |
|
| 1796 | + $result = array(false, __('The addon to activate is invalid', 'wpshop'), __('Desactivated', 'wpshop')); |
|
| 1797 | 1797 | } |
| 1798 | 1798 | } |
| 1799 | 1799 | else { |
| 1800 | - $result = array(false, __('An error occured','wpshop'), __('Desactivated','wpshop')); |
|
| 1800 | + $result = array(false, __('An error occured', 'wpshop'), __('Desactivated', 'wpshop')); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | $activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS); |
| 1803 | 1803 | |
@@ -1810,27 +1810,27 @@ discard block |
||
| 1810 | 1810 | * Addons desactivate |
| 1811 | 1811 | */ |
| 1812 | 1812 | function ajax_desactivate_wpshop_addons() { |
| 1813 | - check_ajax_referer( 'wpshop_ajax_activate_addons', 'wpshop_ajax_nonce' ); |
|
| 1813 | + check_ajax_referer('wpshop_ajax_activate_addons', 'wpshop_ajax_nonce'); |
|
| 1814 | 1814 | |
| 1815 | 1815 | $addon_name = isset($_POST['addon']) ? wpshop_tools::varSanitizer($_POST['addon']) : null; |
| 1816 | 1816 | $state = true; |
| 1817 | 1817 | |
| 1818 | - if ( !empty($addon_name) ) { |
|
| 1818 | + if (!empty($addon_name)) { |
|
| 1819 | 1819 | $addons_list = array_keys(unserialize(WPSHOP_ADDONS_LIST)); |
| 1820 | 1820 | if (in_array($addon_name, $addons_list)) { |
| 1821 | 1821 | $extra_options = get_option(WPSHOP_ADDONS_OPTION_NAME, array()); |
| 1822 | 1822 | $extra_options[$addon_name]['activate'] = false; |
| 1823 | 1823 | $extra_options[$addon_name]['deactivation_date'] = current_time('mysql', 0); |
| 1824 | - if ( update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options) ) { |
|
| 1825 | - $result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated','wpshop')); |
|
| 1824 | + if (update_option(WPSHOP_ADDONS_OPTION_NAME, $extra_options)) { |
|
| 1825 | + $result = array(true, __('The addon has been desactivated successfully', 'wpshop'), __('Desactivated', 'wpshop')); |
|
| 1826 | 1826 | $state = false; |
| 1827 | 1827 | } |
| 1828 | 1828 | else { |
| 1829 | - $result = array(false, __('An error occured','wpshop'), __('Activated','wpshop')); |
|
| 1829 | + $result = array(false, __('An error occured', 'wpshop'), __('Activated', 'wpshop')); |
|
| 1830 | 1830 | } |
| 1831 | 1831 | } |
| 1832 | 1832 | else { |
| 1833 | - $result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated','wpshop')); |
|
| 1833 | + $result = array(false, __('The addon to desactivate is invalid', 'wpshop'), __('Activated', 'wpshop')); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | } |
| 1836 | 1836 | $activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS); |
@@ -1844,38 +1844,38 @@ discard block |
||
| 1844 | 1844 | * Display opttions for including user address into account form |
| 1845 | 1845 | */ |
| 1846 | 1846 | function ajax_integrate_billing_into_register() { |
| 1847 | - check_ajax_referer( 'wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce' ); |
|
| 1847 | + check_ajax_referer('wpshop_ajax_integrate_billin_into_register', 'wpshop_ajax_nonce'); |
|
| 1848 | 1848 | global $wpshop_account; |
| 1849 | 1849 | $wpshop_billing_address = get_option('wpshop_billing_address'); |
| 1850 | 1850 | $current_billing_address = isset($_POST['current_billing_address']) ? intval(wpshop_tools::varSanitizer($_POST['current_billing_address'])) : null; |
| 1851 | 1851 | $selected_field = isset($_POST['selected_field']) ? wpshop_tools::varSanitizer($_POST['selected_field']) : null; |
| 1852 | 1852 | |
| 1853 | - $billing_form_fields = wps_address::get_addresss_form_fields_by_type ( $current_billing_address ); |
|
| 1853 | + $billing_form_fields = wps_address::get_addresss_form_fields_by_type($current_billing_address); |
|
| 1854 | 1854 | $possible_values_for_billing = array('' => __('No corresponding field', 'wpshop')); |
| 1855 | - foreach ( $billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) { |
|
| 1856 | - foreach ( $attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) { |
|
| 1855 | + foreach ($billing_form_fields[$current_billing_address] as $attribute_group_id => $attribute_group_detail) { |
|
| 1856 | + foreach ($attribute_group_detail['content'] as $attribute_build_code => $attribute_definition) { |
|
| 1857 | 1857 | $possible_values_for_billing[$attribute_build_code] = $attribute_definition['label']; |
| 1858 | 1858 | } |
| 1859 | 1859 | } |
| 1860 | - $attributes_set = wpshop_attributes_set::getElement( 'yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS)); |
|
| 1860 | + $attributes_set = wpshop_attributes_set::getElement('yes', "'valid'", 'is_default', '', wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS)); |
|
| 1861 | 1861 | /* Get the attribute set details in order to build the product interface */ |
| 1862 | - $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'"); |
|
| 1863 | - if(!empty($productAttributeSetDetails)){ |
|
| 1864 | - foreach($productAttributeSetDetails as $productAttributeSetDetail){ |
|
| 1865 | - if(count($productAttributeSetDetail['attribut']) >= 1){ |
|
| 1866 | - foreach($productAttributeSetDetail['attribut'] as $attribute) { |
|
| 1867 | - if(!empty($attribute->id)) { |
|
| 1868 | - if( !empty($_POST['submitOrderInfos']) ) { |
|
| 1862 | + $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 1863 | + if (!empty($productAttributeSetDetails)) { |
|
| 1864 | + foreach ($productAttributeSetDetails as $productAttributeSetDetail) { |
|
| 1865 | + if (count($productAttributeSetDetail['attribut']) >= 1) { |
|
| 1866 | + foreach ($productAttributeSetDetail['attribut'] as $attribute) { |
|
| 1867 | + if (!empty($attribute->id)) { |
|
| 1868 | + if (!empty($_POST['submitOrderInfos'])) { |
|
| 1869 | 1869 | $value = $_POST['attribute'][$attribute->data_type][$attribute->code]; |
| 1870 | 1870 | } |
| 1871 | 1871 | else { |
| 1872 | 1872 | $value = ''; |
| 1873 | - if ( $attribute->code != 'user_pass') { |
|
| 1873 | + if ($attribute->code != 'user_pass') { |
|
| 1874 | 1874 | $code = $attribute->code; |
| 1875 | 1875 | $value = $user->$code; |
| 1876 | 1876 | } |
| 1877 | 1877 | } |
| 1878 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute, $value, array() ); |
|
| 1878 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute, $value, array()); |
|
| 1879 | 1879 | $account_form_field[$attribute->code] = $attribute_output_def; |
| 1880 | 1880 | } |
| 1881 | 1881 | } |
@@ -1885,7 +1885,7 @@ discard block |
||
| 1885 | 1885 | |
| 1886 | 1886 | $possible_values = array(); |
| 1887 | 1887 | $matching_field = ''; |
| 1888 | - foreach ( $account_form_field as $attribute_code => $attribute_detail) { |
|
| 1888 | + foreach ($account_form_field as $attribute_code => $attribute_detail) { |
|
| 1889 | 1889 | $possible_values[$attribute_code] = $attribute_detail['label']; |
| 1890 | 1890 | |
| 1891 | 1891 | $input_def['name'] = 'wpshop_billing_address[integrate_into_register_form_matching_field][' . $attribute_code . ']'; |
@@ -1917,13 +1917,13 @@ discard block |
||
| 1917 | 1917 | * Search element in database for shortcode insertion interface |
| 1918 | 1918 | */ |
| 1919 | 1919 | function ajax_wpshop_element_search() { |
| 1920 | - check_ajax_referer( 'wpshop_element_search', 'wpshop_ajax_nonce' ); |
|
| 1920 | + check_ajax_referer('wpshop_element_search', 'wpshop_ajax_nonce'); |
|
| 1921 | 1921 | |
| 1922 | 1922 | $wpshop_element_searched = isset($_REQUEST['wpshop_element_searched']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_searched']) : null; |
| 1923 | 1923 | $wpshop_element_type = isset($_REQUEST['wpshop_element_type']) ? wpshop_tools::varSanitizer($_REQUEST['wpshop_element_type']) : null; |
| 1924 | 1924 | $wpshop_format_result = isset($_REQUEST['wpshop_format_result']) ? (bool)wpshop_tools::varSanitizer($_REQUEST['wpshop_format_result']) : true; |
| 1925 | 1925 | |
| 1926 | - switch ( $wpshop_element_type ) { |
|
| 1926 | + switch ($wpshop_element_type) { |
|
| 1927 | 1927 | case 'product': |
| 1928 | 1928 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 1929 | 1929 | $data = wpshop_products::product_list($wpshop_format_result, $wpshop_element_searched); |
@@ -1933,18 +1933,18 @@ discard block |
||
| 1933 | 1933 | break; |
| 1934 | 1934 | case WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS: |
| 1935 | 1935 | $wps_provider_ctr = new wps_provider_ctr(); |
| 1936 | - $data = $wps_provider_ctr->read( array( 's' => $wpshop_element_searched ) ); |
|
| 1936 | + $data = $wps_provider_ctr->read(array('s' => $wpshop_element_searched)); |
|
| 1937 | 1937 | break; |
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | - if ( $wpshop_format_result ) { |
|
| 1940 | + if ($wpshop_format_result) { |
|
| 1941 | 1941 | $data = empty($data) ? __('No match', 'wpshop') : $data; |
| 1942 | 1942 | } |
| 1943 | 1943 | else { |
| 1944 | - if ( !empty($data) ) { |
|
| 1944 | + if (!empty($data)) { |
|
| 1945 | 1945 | $temp_data = $data; |
| 1946 | - unset( $data ); |
|
| 1947 | - foreach ( $temp_data as $post) { |
|
| 1946 | + unset($data); |
|
| 1947 | + foreach ($temp_data as $post) { |
|
| 1948 | 1948 | $data[$post->ID] = $post->ID . ' - ' . $post->post_title; |
| 1949 | 1949 | } |
| 1950 | 1950 | } |
@@ -1965,34 +1965,34 @@ discard block |
||
| 1965 | 1965 | * Add product to the end user cart |
| 1966 | 1966 | */ |
| 1967 | 1967 | function ajax_wpshop_add_to_cart() { |
| 1968 | - check_ajax_referer( 'ajax_pos_product_variation_selection' ); |
|
| 1968 | + check_ajax_referer('ajax_pos_product_variation_selection'); |
|
| 1969 | 1969 | |
| 1970 | 1970 | global $wpdb; |
| 1971 | 1971 | $wpshop_cart = new wps_cart(); |
| 1972 | 1972 | |
| 1973 | 1973 | $product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null; |
| 1974 | 1974 | $product_qty = isset($_POST['wpshop_pdt_qty']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt_qty'])) : 1; |
| 1975 | - $cart_option = get_option('wpshop_cart_option', array() ); |
|
| 1975 | + $cart_option = get_option('wpshop_cart_option', array()); |
|
| 1976 | 1976 | $wpshop_variation_selected = !empty($_POST['wps_pdt_variations']) ? $_POST['wps_pdt_variations'] : array(); |
| 1977 | - $from_administration = ( !empty($_POST['from_admin']) ) ? true : false; |
|
| 1978 | - $order_id = ( !empty($_POST['wps_orders_order_id']) ) ? wpshop_tools::varSanitizer( $_POST['wps_orders_order_id'] ) : null; |
|
| 1977 | + $from_administration = (!empty($_POST['from_admin'])) ? true : false; |
|
| 1978 | + $order_id = (!empty($_POST['wps_orders_order_id'])) ? wpshop_tools::varSanitizer($_POST['wps_orders_order_id']) : null; |
|
| 1979 | 1979 | |
| 1980 | 1980 | |
| 1981 | 1981 | // Check Cart Animation |
| 1982 | - $cart_animation_choice = ( !empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null); |
|
| 1983 | - if ( !empty($cart_option['total_nb_of_item_allowed']) && ($cart_option['total_nb_of_item_allowed'][0] == 'yes') ) { |
|
| 1982 | + $cart_animation_choice = (!empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null); |
|
| 1983 | + if (!empty($cart_option['total_nb_of_item_allowed']) && ($cart_option['total_nb_of_item_allowed'][0] == 'yes')) { |
|
| 1984 | 1984 | $wpshop_cart->empty_cart(); |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | // Prepare Product to be added to cart |
| 1988 | - $formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $wpshop_variation_selected ); |
|
| 1988 | + $formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected); |
|
| 1989 | 1989 | $product_to_add_to_cart = $formatted_product[0]; |
| 1990 | 1990 | $new_pid = $formatted_product[1]; |
| 1991 | 1991 | |
| 1992 | 1992 | // Check cart Type |
| 1993 | 1993 | $cart_type_for_adding = 'normal'; |
| 1994 | - if (!empty($_POST['wpshop_cart_type']) ) { |
|
| 1995 | - switch(wpshop_tools::varSanitizer($_POST['wpshop_cart_type'])){ |
|
| 1994 | + if (!empty($_POST['wpshop_cart_type'])) { |
|
| 1995 | + switch (wpshop_tools::varSanitizer($_POST['wpshop_cart_type'])) { |
|
| 1996 | 1996 | case 'quotation': |
| 1997 | 1997 | $wpshop_cart_type = 'quotation'; |
| 1998 | 1998 | break; |
@@ -2003,43 +2003,43 @@ discard block |
||
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | 2005 | // Check Product image |
| 2006 | - $product = get_post( $product_id ); |
|
| 2007 | - $product_img = '<img src="' .WPSHOP_DEFAULT_PRODUCT_PICTURE. '" alt="no picture" />'; |
|
| 2008 | - if ( !empty($product_id) ) { |
|
| 2009 | - if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 2010 | - $parent_def = wpshop_products::get_parent_variation( $product_id ); |
|
| 2011 | - $parent_post = ( !empty($parent_def['parent_post']) ) ? $parent_def['parent_post'] : array(); |
|
| 2012 | - $product_title = ( !empty($parent_post) && !empty($parent_post->post_title) ) ? $parent_post->post_title : ''; |
|
| 2013 | - $product_description = ( !empty($parent_post) && !empty($parent_post->post_content) ) ? $parent_post->post_content : ''; |
|
| 2014 | - $product_img = ( !empty($parent_post->ID) ) ? get_the_post_thumbnail( $parent_post->ID, 'thumbnail') : ''; |
|
| 2006 | + $product = get_post($product_id); |
|
| 2007 | + $product_img = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="no picture" />'; |
|
| 2008 | + if (!empty($product_id)) { |
|
| 2009 | + if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 2010 | + $parent_def = wpshop_products::get_parent_variation($product_id); |
|
| 2011 | + $parent_post = (!empty($parent_def['parent_post'])) ? $parent_def['parent_post'] : array(); |
|
| 2012 | + $product_title = (!empty($parent_post) && !empty($parent_post->post_title)) ? $parent_post->post_title : ''; |
|
| 2013 | + $product_description = (!empty($parent_post) && !empty($parent_post->post_content)) ? $parent_post->post_content : ''; |
|
| 2014 | + $product_img = (!empty($parent_post->ID)) ? get_the_post_thumbnail($parent_post->ID, 'thumbnail') : ''; |
|
| 2015 | 2015 | } |
| 2016 | 2016 | else { |
| 2017 | 2017 | $product_title = $product->post_title; |
| 2018 | 2018 | $product_description = $product->post_content; |
| 2019 | - $product_img = get_the_post_thumbnail( $product_id, 'thumbnail'); |
|
| 2019 | + $product_img = get_the_post_thumbnail($product_id, 'thumbnail'); |
|
| 2020 | 2020 | } |
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | 2023 | |
| 2024 | - if ( !empty($_POST['wps_orders_from_admin']) && $_POST['wps_orders_from_admin'] == true) { |
|
| 2024 | + if (!empty($_POST['wps_orders_from_admin']) && $_POST['wps_orders_from_admin'] == true) { |
|
| 2025 | 2025 | $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
| 2026 | - $return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type, array(), true, $order_meta, $order_id ); |
|
| 2026 | + $return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type, array(), true, $order_meta, $order_id); |
|
| 2027 | 2027 | |
| 2028 | - echo json_encode( array(true) ); |
|
| 2028 | + echo json_encode(array(true)); |
|
| 2029 | 2029 | die(); |
| 2030 | 2030 | } |
| 2031 | 2031 | else { |
| 2032 | - $return = $wpshop_cart->add_to_cart( $product_to_add_to_cart, array( $new_pid => $product_qty ), $wpshop_cart_type ); |
|
| 2032 | + $return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type); |
|
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | - if ( $return == 'success' ) { |
|
| 2036 | - $cart_page_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_cart_page_id')) ); |
|
| 2035 | + if ($return == 'success') { |
|
| 2036 | + $cart_page_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))); |
|
| 2037 | 2037 | /** Template parameters */ |
| 2038 | 2038 | $template_part = 'product_added_to_cart_message'; |
| 2039 | 2039 | |
| 2040 | 2040 | /** Build template */ |
| 2041 | 2041 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2042 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2042 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2043 | 2043 | /* Include the old way template part */ |
| 2044 | 2044 | ob_start(); |
| 2045 | 2045 | require_once(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2058,14 +2058,14 @@ discard block |
||
| 2058 | 2058 | |
| 2059 | 2059 | /** Product Price **/ |
| 2060 | 2060 | $product_price = ''; |
| 2061 | - if ( !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart) ) { |
|
| 2061 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart)) { |
|
| 2062 | 2062 | $idp = ''; |
| 2063 | 2063 | |
| 2064 | - if ( !empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2 ) { |
|
| 2064 | + if (!empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2) { |
|
| 2065 | 2065 | $idp = $product_to_add_to_cart[$new_pid]['variations'][0]; |
| 2066 | 2066 | } |
| 2067 | 2067 | else { |
| 2068 | - if( strstr( $new_pid, '__') ) { |
|
| 2068 | + if (strstr($new_pid, '__')) { |
|
| 2069 | 2069 | $idp = $new_pid; |
| 2070 | 2070 | } |
| 2071 | 2071 | else { |
@@ -2073,43 +2073,43 @@ discard block |
||
| 2073 | 2073 | } |
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | - if( !empty($idp) ) { |
|
| 2077 | - $default_currency = wpshop_tools::wpshop_get_currency( false ); |
|
| 2078 | - $price_piloting_option = get_option( 'wpshop_shop_price_piloting' ); |
|
| 2076 | + if (!empty($idp)) { |
|
| 2077 | + $default_currency = wpshop_tools::wpshop_get_currency(false); |
|
| 2078 | + $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
|
| 2079 | 2079 | |
| 2080 | 2080 | $real_price = null; |
| 2081 | - if ( !empty( $_SESSION[ 'cart' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ][$new_pid]['item_amount_to_pay_now'] ) ) { |
|
| 2082 | - $real_price = ( $_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty ); |
|
| 2081 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($_SESSION['cart']['order_items'][$new_pid]) && !empty($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'])) { |
|
| 2082 | + $real_price = ($_SESSION['cart']['order_items'][$new_pid]['item_amount_to_pay_now'] * $product_qty); |
|
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | - $pr = empty( $real_price ) ? ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ht'] * $product_qty ) : ( $_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty ) : $real_price; |
|
| 2086 | - $product_price = wpshop_tools::formate_number( $pr ).$default_currency; |
|
| 2085 | + $pr = empty($real_price) ? (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ht'] * $product_qty) : ($_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty) : $real_price; |
|
| 2086 | + $product_price = wpshop_tools::formate_number($pr) . $default_currency; |
|
| 2087 | 2087 | } |
| 2088 | 2088 | } |
| 2089 | 2089 | /** Check if there are linked products **/ |
| 2090 | - $related_products = get_post_meta( $product_id, '_wpshop_product_related_products', true); |
|
| 2090 | + $related_products = get_post_meta($product_id, '_wpshop_product_related_products', true); |
|
| 2091 | 2091 | $tpl_component = array(); |
| 2092 | 2092 | $linked_products = ''; |
| 2093 | - if ( !empty($related_products) ) { |
|
| 2093 | + if (!empty($related_products)) { |
|
| 2094 | 2094 | // $linked_products = '<h2>'.__('Linked products', 'wpshop').'</h2>'; |
| 2095 | - $linked_products .= '<div class="modal_product_related">' .do_shortcode( '[wpshop_related_products pid="' .$product_id. '" sorting="no"]' ).'</div>'; |
|
| 2095 | + $linked_products .= '<div class="modal_product_related">' . do_shortcode('[wpshop_related_products pid="' . $product_id . '" sorting="no"]') . '</div>'; |
|
| 2096 | 2096 | } |
| 2097 | 2097 | else { |
| 2098 | 2098 | $linked_products = ''; |
| 2099 | 2099 | } |
| 2100 | 2100 | |
| 2101 | - $message_confirmation = sprintf( __('%s has been add to the cart', 'wpshop'), $product->post_title ); |
|
| 2101 | + $message_confirmation = sprintf(__('%s has been add to the cart', 'wpshop'), $product->post_title); |
|
| 2102 | 2102 | |
| 2103 | - $modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array( 'RELATED_PRODUCTS' => $linked_products , 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description) ); |
|
| 2104 | - $modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array() ); |
|
| 2103 | + $modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array('RELATED_PRODUCTS' => $linked_products, 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description)); |
|
| 2104 | + $modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array()); |
|
| 2105 | 2105 | |
| 2106 | - $response = array( true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content ); |
|
| 2106 | + $response = array(true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | else { |
| 2109 | - $response = array( false, $return ); |
|
| 2109 | + $response = array(false, $return); |
|
| 2110 | 2110 | } |
| 2111 | 2111 | |
| 2112 | - wp_die( json_encode( $response ) ); |
|
| 2112 | + wp_die(json_encode($response)); |
|
| 2113 | 2113 | } |
| 2114 | 2114 | add_action('wp_ajax_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart'); |
| 2115 | 2115 | add_action('wp_ajax_nopriv_wpshop_add_product_to_cart', 'ajax_wpshop_add_to_cart'); |
@@ -2119,44 +2119,44 @@ discard block |
||
| 2119 | 2119 | * Set product qty into customer cart |
| 2120 | 2120 | */ |
| 2121 | 2121 | function ajax_wpshop_set_qty_for_product_into_cart() { |
| 2122 | - check_ajax_referer( 'ajax_wpshop_set_qty_for_product_into_cart' ); |
|
| 2122 | + check_ajax_referer('ajax_wpshop_set_qty_for_product_into_cart'); |
|
| 2123 | 2123 | $response = array(); |
| 2124 | 2124 | $wpshop_cart = new wps_cart(); |
| 2125 | 2125 | $product_id = isset($_POST['product_id']) ? wpshop_tools::varSanitizer($_POST['product_id']) : null; |
| 2126 | 2126 | $product_qty = isset($_POST['product_qty']) ? intval(wpshop_tools::varSanitizer($_POST['product_qty'])) : null; |
| 2127 | 2127 | |
| 2128 | 2128 | $pid = $product_id; |
| 2129 | - if (strpos($product_id,'__') !== false) { |
|
| 2129 | + if (strpos($product_id, '__') !== false) { |
|
| 2130 | 2130 | //$pid = $_SESSION['cart']['order_items'][$product_id]['item_id']; |
| 2131 | - foreach( $_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation ) { |
|
| 2131 | + foreach ($_SESSION['cart']['order_items'][$product_id]['item_meta']['variations'] as $variation) { |
|
| 2132 | 2132 | $pid = $variation['product_id']; |
| 2133 | 2133 | break; |
| 2134 | 2134 | } |
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | - if ( !empty($_POST['global_discount']) ) { |
|
| 2137 | + if (!empty($_POST['global_discount'])) { |
|
| 2138 | 2138 | $_SESSION['cart']['pos_global_discount'] = $_POST['global_discount']; |
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | 2141 | if (!empty($product_id)) { |
| 2142 | 2142 | if (isset($product_qty)) { |
| 2143 | - if ( $product_qty == 0 ) { |
|
| 2144 | - $variation_of_product = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1) ); |
|
| 2145 | - if ( !empty($variation_of_product) ) { |
|
| 2146 | - foreach ( $variation_of_product as $p_id) { |
|
| 2143 | + if ($product_qty == 0) { |
|
| 2144 | + $variation_of_product = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $pid, 'posts_per_page' => -1)); |
|
| 2145 | + if (!empty($variation_of_product)) { |
|
| 2146 | + foreach ($variation_of_product as $p_id) { |
|
| 2147 | 2147 | $wpshop_cart->set_product_qty($p_id->ID, $product_qty); |
| 2148 | 2148 | } |
| 2149 | 2149 | } |
| 2150 | 2150 | } |
| 2151 | - $return = $wpshop_cart->set_product_qty( $product_id, $product_qty, $pid ); |
|
| 2151 | + $return = $wpshop_cart->set_product_qty($product_id, $product_qty, $pid); |
|
| 2152 | 2152 | $response[] = $return; |
| 2153 | 2153 | } |
| 2154 | 2154 | else { |
| 2155 | 2155 | $response[] = false; |
| 2156 | - $response[] = __('Parameters error.','wpshop'); |
|
| 2156 | + $response[] = __('Parameters error.', 'wpshop'); |
|
| 2157 | 2157 | } |
| 2158 | 2158 | } |
| 2159 | - wp_die( json_encode( $response ) ); |
|
| 2159 | + wp_die(json_encode($response)); |
|
| 2160 | 2160 | } |
| 2161 | 2161 | add_action('wp_ajax_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart'); |
| 2162 | 2162 | add_action('wp_ajax_nopriv_wpshop_set_qtyfor_product_into_cart', 'ajax_wpshop_set_qty_for_product_into_cart'); |
@@ -2165,7 +2165,7 @@ discard block |
||
| 2165 | 2165 | * Display cart after doing an action on it |
| 2166 | 2166 | */ |
| 2167 | 2167 | function ajax_wpshop_display_cart() { |
| 2168 | - check_ajax_referer( 'ajax_wpshop_display_cart' ); |
|
| 2168 | + check_ajax_referer('ajax_wpshop_display_cart'); |
|
| 2169 | 2169 | ini_set('display_errors', true); |
| 2170 | 2170 | error_reporting(E_ALL); |
| 2171 | 2171 | $wps_cart_ctr = new wps_cart(); |
@@ -2179,8 +2179,8 @@ discard block |
||
| 2179 | 2179 | /** |
| 2180 | 2180 | * Display mini cart widgte after doing an action on it |
| 2181 | 2181 | */ |
| 2182 | - function ajax_wpshop_reload_mini_cart(){ |
|
| 2183 | - check_ajax_referer( 'ajax_wpshop_display_cart' ); |
|
| 2182 | + function ajax_wpshop_reload_mini_cart() { |
|
| 2183 | + check_ajax_referer('ajax_wpshop_display_cart'); |
|
| 2184 | 2184 | echo wpshop_cart::mini_cart_content(); |
| 2185 | 2185 | die(); |
| 2186 | 2186 | } |
@@ -2191,16 +2191,16 @@ discard block |
||
| 2191 | 2191 | * Refresh Price in complete product sheet and Cart summary display |
| 2192 | 2192 | */ |
| 2193 | 2193 | function wpshop_ajax_wpshop_variation_selection() { |
| 2194 | - check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' ); |
|
| 2194 | + check_ajax_referer('wpshop_ajax_wpshop_variation_selection'); |
|
| 2195 | 2195 | $product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null; |
| 2196 | 2196 | $wpshop_variation_selected = isset($_POST['wpshop_variation']) ? $_POST['wpshop_variation'] : null; |
| 2197 | 2197 | $wpshop_free_variation = isset($_POST['wpshop_free_variation']) ? $_POST['wpshop_free_variation'] : null; |
| 2198 | 2198 | $wpshop_current_for_display = isset($_POST['wpshop_current_for_display']) ? $_POST['wpshop_current_for_display'] : null; |
| 2199 | 2199 | $product_qty = isset($_POST['product_qty']) ? $_POST['product_qty'] : 1; |
| 2200 | 2200 | |
| 2201 | - $product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection( $product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty ); |
|
| 2201 | + $product_variation_summary = wpshop_products::wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty); |
|
| 2202 | 2202 | |
| 2203 | - wp_die( json_encode( $product_variation_summary ) ); |
|
| 2203 | + wp_die(json_encode($product_variation_summary)); |
|
| 2204 | 2204 | } |
| 2205 | 2205 | add_action('wp_ajax_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection'); |
| 2206 | 2206 | add_action('wp_ajax_nopriv_wpshop_variation_selection', 'wpshop_ajax_wpshop_variation_selection'); |
@@ -2210,23 +2210,23 @@ discard block |
||
| 2210 | 2210 | function wpshop_ajax_variation_selection_show_detail_for_value() { |
| 2211 | 2211 | global $wpdb; |
| 2212 | 2212 | |
| 2213 | - check_ajax_referer( 'wpshop_ajax_wpshop_variation_selection' ); |
|
| 2213 | + check_ajax_referer('wpshop_ajax_wpshop_variation_selection'); |
|
| 2214 | 2214 | |
| 2215 | 2215 | $display = ''; |
| 2216 | 2216 | $attribute_for_detail = isset($_POST['attribute_for_detail']) ? $_POST['attribute_for_detail'] : null; |
| 2217 | 2217 | |
| 2218 | - if ( !empty( $attribute_for_detail ) ) { |
|
| 2218 | + if (!empty($attribute_for_detail)) { |
|
| 2219 | 2219 | $selection = array(); |
| 2220 | - foreach ( $attribute_for_detail as $selected_variation ) { |
|
| 2220 | + foreach ($attribute_for_detail as $selected_variation) { |
|
| 2221 | 2221 | $variation_definition = explode('-_variation_val_-', $selected_variation); |
| 2222 | 2222 | $attribute_definition = wpshop_attributes::getElement($variation_definition[0], "'valid'", 'code'); |
| 2223 | 2223 | $post_definition = get_post($variation_definition[1]); |
| 2224 | 2224 | |
| 2225 | - if ( !empty($post_definition) ) { |
|
| 2226 | - $post_content = ( !empty($post_definition) && !empty($post_definition->post_content) ) ? $post_definition->post_content : ''; |
|
| 2227 | - if ( empty($post_content) && !empty($post_definition->post_parent) ) { |
|
| 2225 | + if (!empty($post_definition)) { |
|
| 2226 | + $post_content = (!empty($post_definition) && !empty($post_definition->post_content)) ? $post_definition->post_content : ''; |
|
| 2227 | + if (empty($post_content) && !empty($post_definition->post_parent)) { |
|
| 2228 | 2228 | $post_parent_definition = get_post($post_definition->post_parent); |
| 2229 | - if ( !empty($post_parent_definition) ) { |
|
| 2229 | + if (!empty($post_parent_definition)) { |
|
| 2230 | 2230 | $post_content = $post_parent_definition->post_content; |
| 2231 | 2231 | } |
| 2232 | 2232 | } |
@@ -2253,72 +2253,72 @@ discard block |
||
| 2253 | 2253 | * Save customer account informations |
| 2254 | 2254 | */ |
| 2255 | 2255 | function wpshop_ajax_save_customer_account() { |
| 2256 | - check_ajax_referer( 'wpshop_customer_register', 'wpshop_ajax_nonce' ); |
|
| 2256 | + check_ajax_referer('wpshop_customer_register', 'wpshop_ajax_nonce'); |
|
| 2257 | 2257 | global $wpshop, $wpshop_account, $wpdb; |
| 2258 | - $reponse=''; |
|
| 2258 | + $reponse = ''; |
|
| 2259 | 2259 | $status = false; |
| 2260 | 2260 | $validate = true; |
| 2261 | 2261 | |
| 2262 | 2262 | $user_id = get_current_user_id(); |
| 2263 | - $current_connected_user = !empty( $user_id ) ? $user_id : null; |
|
| 2263 | + $current_connected_user = !empty($user_id) ? $user_id : null; |
|
| 2264 | 2264 | $wpshop_billing_address = get_option('wpshop_billing_address'); |
| 2265 | - if ( !empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($_POST['attribute'][$wpshop_billing_address['choice']]) ) { |
|
| 2266 | - if ( !empty($wpshop_billing_address['integrate_into_register_form_matching_field']) ) { |
|
| 2267 | - $address_fields = wps_address::get_addresss_form_fields_by_type ( $wpshop_billing_address['choice'] ); |
|
| 2265 | + if (!empty($wpshop_billing_address['integrate_into_register_form']) && ($wpshop_billing_address['integrate_into_register_form'] == 'yes') && isset($_POST['attribute'][$wpshop_billing_address['choice']])) { |
|
| 2266 | + if (!empty($wpshop_billing_address['integrate_into_register_form_matching_field'])) { |
|
| 2267 | + $address_fields = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']); |
|
| 2268 | 2268 | $address_field = $address_fields[$wpshop_billing_address['choice']]; |
| 2269 | 2269 | $temp_aray_for_matching = array_flip($wpshop_billing_address['integrate_into_register_form_matching_field']); |
| 2270 | - foreach ( $address_field as $group_id => $group_detail) { |
|
| 2271 | - foreach ( $group_detail['content'] as $attribute_build_code => $attribute_def) { |
|
| 2272 | - if ( in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty( $_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] ) && !empty( $_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]] ) ) { |
|
| 2270 | + foreach ($address_field as $group_id => $group_detail) { |
|
| 2271 | + foreach ($group_detail['content'] as $attribute_build_code => $attribute_def) { |
|
| 2272 | + if (in_array($attribute_build_code, $wpshop_billing_address['integrate_into_register_form_matching_field']) && empty($_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']]) && !empty($_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]])) { |
|
| 2273 | 2273 | $_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name']] = $_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code]]; |
| 2274 | - if ( $attribute_def['_need_verification'] == 'yes' && !empty($_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2']) ) { |
|
| 2274 | + if ($attribute_def['_need_verification'] == 'yes' && !empty($_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'])) { |
|
| 2275 | 2275 | $_POST['attribute'][$wpshop_billing_address['choice']][$attribute_def['data_type']][$attribute_def['name'] . '2'] = $_POST['attribute'][$attribute_def['data_type']][$temp_aray_for_matching[$attribute_build_code] . '2']; |
| 2276 | 2276 | } |
| 2277 | 2277 | } |
| 2278 | 2278 | } |
| 2279 | 2279 | } |
| 2280 | - $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty( $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] ) ? $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop'); |
|
| 2280 | + $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] = !empty($_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title']) ? $_POST['attribute'][$wpshop_billing_address['choice']]['varchar']['address_title'] : __('Billing address', 'wpshop'); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | $group = wps_address::get_addresss_form_fields_by_type($wpshop_billing_address['choice']); |
| 2283 | 2283 | $validate = false; |
| 2284 | - foreach ( $group as $attribute_sets ) { |
|
| 2285 | - foreach ( $attribute_sets as $attribute_set_field ) { |
|
| 2284 | + foreach ($group as $attribute_sets) { |
|
| 2285 | + foreach ($attribute_sets as $attribute_set_field) { |
|
| 2286 | 2286 | $validate = $wpshop->validateForm($attribute_set_field['content'], $_POST['attribute'][$wpshop_billing_address['choice']], ''); |
| 2287 | 2287 | } |
| 2288 | 2288 | } |
| 2289 | 2289 | } |
| 2290 | - $cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') )) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))); |
|
| 2290 | + $cart_url = !empty($_SESSION['cart']['order_items']) ? get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) : get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))); |
|
| 2291 | 2291 | |
| 2292 | 2292 | |
| 2293 | - $validate_personal_form_infos = ( !empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial' ) ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields); |
|
| 2294 | - if( $validate && $validate_personal_form_infos ) { |
|
| 2295 | - $account_creation_result = $wpshop_account->save_account_form($user_id, ( ( !empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial' ) ? 'partial' : 'complete') ); |
|
| 2293 | + $validate_personal_form_infos = (!empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial') ? $wpshop->validateForm($wpshop_account->partial_personal_infos_fields, array(), '', true) : $wpshop->validateForm($wpshop_account->personal_info_fields); |
|
| 2294 | + if ($validate && $validate_personal_form_infos) { |
|
| 2295 | + $account_creation_result = $wpshop_account->save_account_form($user_id, ((!empty($_POST['account_form_type']) && $_POST['account_form_type'] == 'partial') ? 'partial' : 'complete')); |
|
| 2296 | 2296 | $status = $account_creation_result[0]; |
| 2297 | 2297 | $user_id = $account_creation_result[1]; |
| 2298 | - $is_partial_account_creation = $account_creation_result[2]; |
|
| 2299 | - if ( $is_partial_account_creation == 'partial' ) { |
|
| 2298 | + $is_partial_account_creation = $account_creation_result[2]; |
|
| 2299 | + if ($is_partial_account_creation == 'partial') { |
|
| 2300 | 2300 | $permalink_option = get_option('permalink_structure'); |
| 2301 | - if ( !empty($permalink_option) ) { |
|
| 2302 | - $cart_url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_signup_page_id') ) ).'?complete_sign_up=ok'; |
|
| 2301 | + if (!empty($permalink_option)) { |
|
| 2302 | + $cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '?complete_sign_up=ok'; |
|
| 2303 | 2303 | } |
| 2304 | 2304 | else { |
| 2305 | - $cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_signup_page_id') ) ).'&complete_sign_up=ok'; |
|
| 2305 | + $cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_signup_page_id'))) . '&complete_sign_up=ok'; |
|
| 2306 | 2306 | } |
| 2307 | 2307 | } |
| 2308 | 2308 | else { |
| 2309 | - if ( !empty($_SESSION['cart']) ) { |
|
| 2310 | - $cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')) ); |
|
| 2309 | + if (!empty($_SESSION['cart'])) { |
|
| 2310 | + $cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | else { |
| 2313 | - $cart_url = get_permalink( wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')) ); |
|
| 2313 | + $cart_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))); |
|
| 2314 | 2314 | } |
| 2315 | 2315 | } |
| 2316 | 2316 | // check if the customer have already register an address |
| 2317 | - $query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS); |
|
| 2317 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS); |
|
| 2318 | 2318 | $exist_address = $wpdb->get_results($query); |
| 2319 | 2319 | } |
| 2320 | 2320 | // If there is errors |
| 2321 | - if($wpshop->error_count()>0) { |
|
| 2321 | + if ($wpshop->error_count() > 0) { |
|
| 2322 | 2322 | $reponse = $wpshop->show_messages(); |
| 2323 | 2323 | } |
| 2324 | 2324 | |
@@ -2335,24 +2335,24 @@ discard block |
||
| 2335 | 2335 | function wpshop_ajax_order_customer_adress_load() { |
| 2336 | 2336 | global $wpshop_account; |
| 2337 | 2337 | global $wpdb; |
| 2338 | - check_ajax_referer( 'wpshop_order_customer_adress_load', 'wpshop_ajax_nonce' ); |
|
| 2339 | - $current_customer_id = !empty( $_REQUEST['customer_id'] ) ? $_REQUEST['customer_id'] : 0; |
|
| 2340 | - $order_id = !empty( $_REQUEST['order_id'] ) ? $_REQUEST['order_id'] : 0; |
|
| 2338 | + check_ajax_referer('wpshop_order_customer_adress_load', 'wpshop_ajax_nonce'); |
|
| 2339 | + $current_customer_id = !empty($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : 0; |
|
| 2340 | + $order_id = !empty($_REQUEST['order_id']) ? $_REQUEST['order_id'] : 0; |
|
| 2341 | 2341 | |
| 2342 | - $order_postmeta = get_post_meta ($order_id, '_order_postmeta', true); |
|
| 2343 | - $order_infos_postmeta = get_post_meta ($order_id, '_order_info', true); |
|
| 2342 | + $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 2343 | + $order_infos_postmeta = get_post_meta($order_id, '_order_info', true); |
|
| 2344 | 2344 | |
| 2345 | - if ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded')) ) { |
|
| 2345 | + if (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('completed', 'shipped', 'refunded'))) { |
|
| 2346 | 2346 | /** Billing address display **/ |
| 2347 | 2347 | $tpl_component['ADDRESS_COMBOBOX'] = ''; |
| 2348 | 2348 | $tpl_component['ADDRESS_BUTTONS'] = ''; |
| 2349 | 2349 | $tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Billing address', 'wpshop'); |
| 2350 | 2350 | $tpl_component['ADDRESS_TYPE'] = 'billing_address'; |
| 2351 | 2351 | $address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['billing']['id']); |
| 2352 | - $tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['billing']['address'] ); |
|
| 2352 | + $tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['billing']['address']); |
|
| 2353 | 2353 | $tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component); |
| 2354 | - $retour = wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component); |
|
| 2355 | - unset( $tpl_component ); |
|
| 2354 | + $retour = wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component); |
|
| 2355 | + unset($tpl_component); |
|
| 2356 | 2356 | |
| 2357 | 2357 | /** Shipping address display **/ |
| 2358 | 2358 | $retour .= '<div id="shipping_infos_bloc" class="wpshop_order_customer_container wpshop_order_customer_container_user_information">'; |
@@ -2361,66 +2361,66 @@ discard block |
||
| 2361 | 2361 | $tpl_component['CUSTOMER_ADDRESS_TYPE_TITLE'] = __('Shipping address', 'wpshop'); |
| 2362 | 2362 | $tpl_component['ADDRESS_TYPE'] = 'shipping_address'; |
| 2363 | 2363 | $address_fields = wps_address::get_addresss_form_fields_by_type($order_infos_postmeta['shipping']['id']); |
| 2364 | - $tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address( $address_fields, $order_infos_postmeta['shipping']['address']); |
|
| 2364 | + $tpl_component['CUSTOMER_ADDRESS_CONTENT'] = wpshop_account::display_an_address($address_fields, $order_infos_postmeta['shipping']['address']); |
|
| 2365 | 2365 | $tpl_component['CUSTOMER_CHOOSEN_ADDRESS'] = wpshop_display::display_template_element('display_address_container', $tpl_component); |
| 2366 | - $retour .= wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component); |
|
| 2367 | - unset( $tpl_component ); |
|
| 2366 | + $retour .= wpshop_display::display_template_element('display_addresses_by_type_container', $tpl_component); |
|
| 2367 | + unset($tpl_component); |
|
| 2368 | 2368 | $retour .= '</div>'; |
| 2369 | 2369 | $retour .= '<div class="wpshop_cls"></div>'; |
| 2370 | - $result = json_encode( array(true, $retour) ); |
|
| 2370 | + $result = json_encode(array(true, $retour)); |
|
| 2371 | 2371 | |
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | - elseif ( !empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) { |
|
| 2374 | + elseif (!empty($order_postmeta) && !empty($order_postmeta['order_status']) && in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) { |
|
| 2375 | 2375 | $order_info_postmeta = get_post_meta($_REQUEST['order_id'], '_order_info', true); |
| 2376 | 2376 | |
| 2377 | 2377 | $billing_id_attribute_set = get_option('wpshop_billing_address'); |
| 2378 | 2378 | $shipping_id_attribute_set = get_option('wpshop_shipping_address_choice'); |
| 2379 | 2379 | |
| 2380 | - $order_billing_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address']) ) ? $order_info_postmeta['billing']['address'] : array(); |
|
| 2381 | - $order_shipping_address = ( !empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address']) ) ? $order_info_postmeta['shipping']['address'] : array(); |
|
| 2380 | + $order_billing_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['billing']) && !empty($order_info_postmeta['billing']['address'])) ? $order_info_postmeta['billing']['address'] : array(); |
|
| 2381 | + $order_shipping_address = (!empty($order_info_postmeta) && !empty($order_info_postmeta['shipping']) && !empty($order_info_postmeta['shipping']['address'])) ? $order_info_postmeta['shipping']['address'] : array(); |
|
| 2382 | 2382 | |
| 2383 | - $billing_form = $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address ); |
|
| 2384 | - if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) { |
|
| 2385 | - $shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address ); |
|
| 2383 | + $billing_form = $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], '', '', '', array(), array(), $order_billing_address); |
|
| 2384 | + if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) { |
|
| 2385 | + $shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], '', '', '', array(), array(), $order_shipping_address); |
|
| 2386 | 2386 | } |
| 2387 | 2387 | |
| 2388 | - $result = json_encode( array(true, $billing_form, $shipping_form, $current_customer_id) ); |
|
| 2388 | + $result = json_encode(array(true, $billing_form, $shipping_form, $current_customer_id)); |
|
| 2389 | 2389 | } |
| 2390 | 2390 | else { |
| 2391 | 2391 | // Check the attribute set id of Billing Address |
| 2392 | - $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Billing address', 'wpshop'). '"', ''); |
|
| 2392 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Billing address', 'wpshop') . '"', ''); |
|
| 2393 | 2393 | $attribute_set_id = $wpdb->get_var($query); |
| 2394 | 2394 | $billing_id_attribute_set = get_option('wpshop_billing_address'); |
| 2395 | 2395 | //Check the billing address id of the customer |
| 2396 | - $query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', ''); |
|
| 2396 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', ''); |
|
| 2397 | 2397 | $post_addresses = $wpdb->get_results($query); |
| 2398 | 2398 | $address_id = ''; |
| 2399 | - foreach ( $post_addresses as $post_address ) { |
|
| 2400 | - $address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true); |
|
| 2401 | - if ( $address_type == $attribute_set_id ) { |
|
| 2399 | + foreach ($post_addresses as $post_address) { |
|
| 2400 | + $address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
|
| 2401 | + if ($address_type == $attribute_set_id) { |
|
| 2402 | 2402 | $address_id = $post_address->ID; |
| 2403 | 2403 | } |
| 2404 | 2404 | } |
| 2405 | 2405 | $shipping_id_attribute_set = get_option('wpshop_shipping_address_choice'); |
| 2406 | 2406 | $shipping_form = ''; |
| 2407 | - if ( !empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate']) ) { |
|
| 2407 | + if (!empty($shipping_id_attribute_set) && !empty($shipping_id_attribute_set['activate'])) { |
|
| 2408 | 2408 | // Check the attribute set id of Shipping Address |
| 2409 | - $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .__('Shipping address', 'wpshop'). '"', ''); |
|
| 2409 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . __('Shipping address', 'wpshop') . '"', ''); |
|
| 2410 | 2410 | $attribute_set_id = $wpdb->get_var($query); |
| 2411 | 2411 | //Check the billing address id of the customer |
| 2412 | - $query = $wpdb->prepare('SELECT * FROM ' .$wpdb->posts. ' WHERE post_author = ' .$current_customer_id. ' AND post_type = "' .WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS. '"', ''); |
|
| 2412 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_author = ' . $current_customer_id . ' AND post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '"', ''); |
|
| 2413 | 2413 | $post_addresses = $wpdb->get_results($query); |
| 2414 | 2414 | $shipping_address_id = ''; |
| 2415 | - foreach ( $post_addresses as $post_address ) { |
|
| 2416 | - $address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY,true); |
|
| 2417 | - if ( $address_type == $attribute_set_id ) { |
|
| 2415 | + foreach ($post_addresses as $post_address) { |
|
| 2416 | + $address_type = get_post_meta($post_address->ID, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
|
| 2417 | + if ($address_type == $attribute_set_id) { |
|
| 2418 | 2418 | $shipping_address_id = $post_address->ID; |
| 2419 | 2419 | } |
| 2420 | 2420 | } |
| 2421 | - $shipping_form = $wpshop_account->display_form_fields( $shipping_id_attribute_set['choice'], $shipping_address_id ); |
|
| 2421 | + $shipping_form = $wpshop_account->display_form_fields($shipping_id_attribute_set['choice'], $shipping_address_id); |
|
| 2422 | 2422 | } |
| 2423 | - $result = json_encode( array(true, $wpshop_account->display_form_fields( $billing_id_attribute_set['choice'], $address_id ), $shipping_form, $current_customer_id) ); |
|
| 2423 | + $result = json_encode(array(true, $wpshop_account->display_form_fields($billing_id_attribute_set['choice'], $address_id), $shipping_form, $current_customer_id)); |
|
| 2424 | 2424 | } |
| 2425 | 2425 | echo $result; |
| 2426 | 2426 | die(); |
@@ -2432,22 +2432,22 @@ discard block |
||
| 2432 | 2432 | */ |
| 2433 | 2433 | function ajax_wpshop_add_entity() { |
| 2434 | 2434 | global $wpdb; |
| 2435 | - check_ajax_referer( 'wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce' ); |
|
| 2435 | + check_ajax_referer('wpshop_add_new_entity_ajax_nonce', 'wpshop_ajax_nonce'); |
|
| 2436 | 2436 | |
| 2437 | 2437 | $attributes = array(); |
| 2438 | 2438 | /** Get the attribute to create */ |
| 2439 | 2439 | $attribute_to_reload = null; |
| 2440 | - if ( !empty($_POST['attribute']['new_value_creation']) && is_array( $_POST['attribute']['new_value_creation'] ) ) { |
|
| 2441 | - foreach ( $_POST['attribute']['new_value_creation'] as $attribute_code=>$value) { |
|
| 2442 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', $attribute_code); |
|
| 2440 | + if (!empty($_POST['attribute']['new_value_creation']) && is_array($_POST['attribute']['new_value_creation'])) { |
|
| 2441 | + foreach ($_POST['attribute']['new_value_creation'] as $attribute_code=>$value) { |
|
| 2442 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $attribute_code); |
|
| 2443 | 2443 | $attribute_def = $wpdb->get_row($query); |
| 2444 | - if ( $value != "" ) { |
|
| 2445 | - if ( $attribute_def->data_type_to_use == 'internal' ) { |
|
| 2444 | + if ($value != "") { |
|
| 2445 | + if ($attribute_def->data_type_to_use == 'internal') { |
|
| 2446 | 2446 | $attribute_default_value = unserialize($attribute_def->default_value); |
| 2447 | - if ( $attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
|
| 2448 | - $user_id = wp_create_user( sanitize_user( $value ), wp_generate_password( 12, false ) ); |
|
| 2449 | - $query = $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id ); |
|
| 2450 | - $attribute_option_id = $wpdb->get_var( $query ); |
|
| 2447 | + if ($attribute_default_value['default_value'] == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) { |
|
| 2448 | + $user_id = wp_create_user(sanitize_user($value), wp_generate_password(12, false)); |
|
| 2449 | + $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s AND post_author = %d", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id); |
|
| 2450 | + $attribute_option_id = $wpdb->get_var($query); |
|
| 2451 | 2451 | } |
| 2452 | 2452 | else { |
| 2453 | 2453 | $entity_args = array( |
@@ -2460,13 +2460,13 @@ discard block |
||
| 2460 | 2460 | } |
| 2461 | 2461 | } |
| 2462 | 2462 | else { |
| 2463 | - $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value) ); |
|
| 2463 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'position' => 1, 'attribute_id'=>$attribute_def->id, 'value'=>$value, 'label'=>$value)); |
|
| 2464 | 2464 | $attribute_option_id = $wpdb->insert_id; |
| 2465 | 2465 | } |
| 2466 | 2466 | |
| 2467 | - foreach ( $_POST['attribute'] as $attribute => $val) { |
|
| 2467 | + foreach ($_POST['attribute'] as $attribute => $val) { |
|
| 2468 | 2468 | foreach ($val as $k=>$v) { |
| 2469 | - if ( $k == $attribute_code) { |
|
| 2469 | + if ($k == $attribute_code) { |
|
| 2470 | 2470 | $_POST['attribute'][$attribute][$k] = $attribute_option_id; |
| 2471 | 2471 | } |
| 2472 | 2472 | } |
@@ -2475,10 +2475,10 @@ discard block |
||
| 2475 | 2475 | } |
| 2476 | 2476 | } |
| 2477 | 2477 | /** Store send attribute into a new array for save purpose */ |
| 2478 | - if ( is_array( $_POST['attribute'] ) ) { |
|
| 2479 | - foreach ( $_POST['attribute'] as $attribute_type => $attribute ) { |
|
| 2480 | - foreach ( $attribute as $attribute_code => $attribute_value ) { |
|
| 2481 | - if ( !isset( $attributes[$attribute_code] ) ) { |
|
| 2478 | + if (is_array($_POST['attribute'])) { |
|
| 2479 | + foreach ($_POST['attribute'] as $attribute_type => $attribute) { |
|
| 2480 | + foreach ($attribute as $attribute_code => $attribute_value) { |
|
| 2481 | + if (!isset($attributes[$attribute_code])) { |
|
| 2482 | 2482 | $attributes[$attribute_code] = $attribute_value; |
| 2483 | 2483 | } |
| 2484 | 2484 | } |
@@ -2486,66 +2486,66 @@ discard block |
||
| 2486 | 2486 | } |
| 2487 | 2487 | |
| 2488 | 2488 | /** Save the new entity into database */ |
| 2489 | - $result = wpshop_entities::create_new_entity( $_POST['entity_type'], $_POST['wp_fields']['post_title'], '', $attributes, array('attribute_set_id' => $_POST['attribute_set_id']) ); |
|
| 2489 | + $result = wpshop_entities::create_new_entity($_POST['entity_type'], $_POST['wp_fields']['post_title'], '', $attributes, array('attribute_set_id' => $_POST['attribute_set_id'])); |
|
| 2490 | 2490 | $new_entity_id = $result[1]; |
| 2491 | 2491 | |
| 2492 | - if ( !empty($new_entity_id) ) { |
|
| 2492 | + if (!empty($new_entity_id)) { |
|
| 2493 | 2493 | /** Save address for current entity */ |
| 2494 | - if ( !empty( $_POST['type_of_form'] ) && !empty( $_POST['attribute'][$_POST['type_of_form']] ) ) { |
|
| 2494 | + if (!empty($_POST['type_of_form']) && !empty($_POST['attribute'][$_POST['type_of_form']])) { |
|
| 2495 | 2495 | global $wpshop_account; |
| 2496 | - $result = wps_address::wps_address( $_POST['type_of_form'] ); |
|
| 2497 | - update_post_meta ($new_entity_id, '_wpshop_attached_address', $result['current_id']); |
|
| 2496 | + $result = wps_address::wps_address($_POST['type_of_form']); |
|
| 2497 | + update_post_meta($new_entity_id, '_wpshop_attached_address', $result['current_id']); |
|
| 2498 | 2498 | } |
| 2499 | 2499 | |
| 2500 | 2500 | /** Make price calculation if entity is a product */ |
| 2501 | - if ( $_POST['entity_type'] == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
| 2501 | + if ($_POST['entity_type'] == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
| 2502 | 2502 | $wpshop_prices_attribute = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 2503 | 2503 | $calculate_price = false; |
| 2504 | - foreach( $wpshop_prices_attribute as $attribute_price_code ){ |
|
| 2505 | - if ( array_key_exists($attribute_price_code, $attributes) ) { |
|
| 2504 | + foreach ($wpshop_prices_attribute as $attribute_price_code) { |
|
| 2505 | + if (array_key_exists($attribute_price_code, $attributes)) { |
|
| 2506 | 2506 | $calculate_price = true; |
| 2507 | 2507 | } |
| 2508 | 2508 | } |
| 2509 | - if ( $calculate_price ) { |
|
| 2509 | + if ($calculate_price) { |
|
| 2510 | 2510 | wpshop_products::calculate_price($new_entity_id); |
| 2511 | 2511 | } |
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | 2514 | /** Add picture if a file has been send */ |
| 2515 | - if ( !empty($_FILES) ) { |
|
| 2515 | + if (!empty($_FILES)) { |
|
| 2516 | 2516 | $wp_upload_dir = wp_upload_dir(); |
| 2517 | 2517 | $final_dir = $wp_upload_dir['path'] . '/'; |
| 2518 | - if ( !is_dir($final_dir) ) { |
|
| 2518 | + if (!is_dir($final_dir)) { |
|
| 2519 | 2519 | mkdir($final_dir, 0755, true); |
| 2520 | 2520 | } |
| 2521 | 2521 | |
| 2522 | - foreach ( $_FILES as $file ) { |
|
| 2522 | + foreach ($_FILES as $file) { |
|
| 2523 | 2523 | $tmp_name = $file['tmp_name']['post_thumbnail']; |
| 2524 | 2524 | $name = $file['name']['post_thumbnail']; |
| 2525 | 2525 | |
| 2526 | 2526 | $filename = $final_dir . $name; |
| 2527 | 2527 | @move_uploaded_file($tmp_name, $filename); |
| 2528 | 2528 | |
| 2529 | - $wp_filetype = wp_check_filetype(basename($filename), null ); |
|
| 2529 | + $wp_filetype = wp_check_filetype(basename($filename), null); |
|
| 2530 | 2530 | $attachment = array( |
| 2531 | - 'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ), |
|
| 2531 | + 'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path($filename), |
|
| 2532 | 2532 | 'post_mime_type' => $wp_filetype['type'], |
| 2533 | - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename($filename) ), |
|
| 2533 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), |
|
| 2534 | 2534 | 'post_content' => '', |
| 2535 | 2535 | 'post_status' => 'inherit' |
| 2536 | 2536 | ); |
| 2537 | - $attach_id = wp_insert_attachment( $attachment, $filename, $new_entity_id ); |
|
| 2537 | + $attach_id = wp_insert_attachment($attachment, $filename, $new_entity_id); |
|
| 2538 | 2538 | require_once(ABSPATH . 'wp-admin/includes/image.php'); |
| 2539 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); |
|
| 2540 | - wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
| 2539 | + $attach_data = wp_generate_attachment_metadata($attach_id, $filename); |
|
| 2540 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 2541 | 2541 | add_post_meta($new_entity_id, '_thumbnail_id', $attach_id, true); |
| 2542 | 2542 | } |
| 2543 | 2543 | } |
| 2544 | 2544 | |
| 2545 | - echo json_encode( array( true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id) ); |
|
| 2545 | + echo json_encode(array(true, __('Element has been saved', 'wpshop'), $attribute_to_reload, $new_entity_id)); |
|
| 2546 | 2546 | } |
| 2547 | 2547 | else { |
| 2548 | - echo json_encode( array(false, __('An error occured while adding your element', 'wpshop')) ); |
|
| 2548 | + echo json_encode(array(false, __('An error occured while adding your element', 'wpshop'))); |
|
| 2549 | 2549 | } |
| 2550 | 2550 | |
| 2551 | 2551 | die(); |
@@ -2554,46 +2554,46 @@ discard block |
||
| 2554 | 2554 | // add_action('wp_ajax_nopriv_wpshop_quick_add_entity', 'ajax_wpshop_add_entity'); |
| 2555 | 2555 | |
| 2556 | 2556 | function ajax_wpshop_reload_attribute_for_quick_add() { |
| 2557 | - check_ajax_referer( 'ajax_wpshop_reload_attribute_for_quick_add' ); |
|
| 2557 | + check_ajax_referer('ajax_wpshop_reload_attribute_for_quick_add'); |
|
| 2558 | 2558 | $output = ''; |
| 2559 | - if ( !empty($_POST['attribute_to_reload']) ) { |
|
| 2560 | - foreach ( $_POST['attribute_to_reload'] as $attribute_code ) { |
|
| 2561 | - $attr_field = wpshop_attributes::display_attribute( $attribute_code, 'frontend' ); |
|
| 2559 | + if (!empty($_POST['attribute_to_reload'])) { |
|
| 2560 | + foreach ($_POST['attribute_to_reload'] as $attribute_code) { |
|
| 2561 | + $attr_field = wpshop_attributes::display_attribute($attribute_code, 'frontend'); |
|
| 2562 | 2562 | $output[$attribute_code]['result'] = $attr_field['field_definition']['output'] . $attr_field['field_definition']['options']; |
| 2563 | 2563 | } |
| 2564 | 2564 | } |
| 2565 | - echo json_encode( array($output) ); |
|
| 2565 | + echo json_encode(array($output)); |
|
| 2566 | 2566 | die(); |
| 2567 | 2567 | } |
| 2568 | 2568 | add_action('wp_ajax_reload_attribute_for_quick_add', 'ajax_wpshop_reload_attribute_for_quick_add'); |
| 2569 | 2569 | |
| 2570 | 2570 | function ajax_wpshop_change_address() { |
| 2571 | - check_ajax_referer( 'ajax_wpshop_change_address' ); |
|
| 2572 | - $address_id = ( !empty($_POST['address_id']) ? wpshop_tools::varSanitizer($_POST['address_id']) : null); |
|
| 2573 | - $address_type = ( !empty($_POST['address_type']) ? wpshop_tools::varSanitizer($_POST['address_type']) : null); |
|
| 2574 | - $is_allowed_destination = true; |
|
| 2575 | - if ( !empty($address_id) && !empty($address_type) ) { |
|
| 2571 | + check_ajax_referer('ajax_wpshop_change_address'); |
|
| 2572 | + $address_id = (!empty($_POST['address_id']) ? wpshop_tools::varSanitizer($_POST['address_id']) : null); |
|
| 2573 | + $address_type = (!empty($_POST['address_type']) ? wpshop_tools::varSanitizer($_POST['address_type']) : null); |
|
| 2574 | + $is_allowed_destination = true; |
|
| 2575 | + if (!empty($address_id) && !empty($address_type)) { |
|
| 2576 | 2576 | //Check if it's an allowed address for shipping |
| 2577 | 2577 | $checkout_payment_button = ''; |
| 2578 | - $cart_type = (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type']=='quotation') ? 'quotation' : 'cart'; |
|
| 2579 | - $is_allowed_destination = true;//wpshop_shipping_configuration::is_allowed_country ( $address_id ); |
|
| 2580 | - if ( $is_allowed_destination ) { |
|
| 2578 | + $cart_type = (!empty($_SESSION['cart']['cart_type']) && $_SESSION['cart']['cart_type'] == 'quotation') ? 'quotation' : 'cart'; |
|
| 2579 | + $is_allowed_destination = true; //wpshop_shipping_configuration::is_allowed_country ( $address_id ); |
|
| 2580 | + if ($is_allowed_destination) { |
|
| 2581 | 2581 | $available_payement_method = wpshop_payment::display_payment_methods_choice_form(0, $cart_type); |
| 2582 | 2582 | //if(!empty($available_payement_method[1]['paypal']) || !empty($available_payement_method[1]['banktransfer']) || !empty($available_payement_method[1]['checks']) || WPSHOP_PAYMENT_METHOD_CIC || !empty($available_payement_method[1]['cic']) || ($cart_type == 'quotation')) { |
| 2583 | - if ( !empty($available_payement_method[0]) ) { |
|
| 2584 | - if ( $cart_type=='quotation' ) { |
|
| 2585 | - $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array() ); |
|
| 2583 | + if (!empty($available_payement_method[0])) { |
|
| 2584 | + if ($cart_type == 'quotation') { |
|
| 2585 | + $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_quotation_validation_button', array()); |
|
| 2586 | 2586 | } |
| 2587 | 2587 | else { |
| 2588 | - $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array() ); |
|
| 2588 | + $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_validation_button', array()); |
|
| 2589 | 2589 | } |
| 2590 | 2590 | } |
| 2591 | 2591 | } |
| 2592 | 2592 | else { |
| 2593 | 2593 | $checkout_payment_button = wpshop_display::display_template_element('wpshop_checkout_page_impossible_to_order', array()); |
| 2594 | 2594 | } |
| 2595 | - if( $address_type == 'billing_address') { |
|
| 2596 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 2595 | + if ($address_type == 'billing_address') { |
|
| 2596 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 2597 | 2597 | $address_option = $billing_option['choice']; |
| 2598 | 2598 | } |
| 2599 | 2599 | else { |
@@ -2601,16 +2601,16 @@ discard block |
||
| 2601 | 2601 | $address_option = $shipping_address_option['choice']; |
| 2602 | 2602 | } |
| 2603 | 2603 | $add = wps_address::get_addresss_form_fields_by_type($address_option); |
| 2604 | - $address_infos = get_post_meta($address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 2605 | - $retour = wpshop_account::display_an_address ( $add, $address_infos, $address_id); |
|
| 2604 | + $address_infos = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 2605 | + $retour = wpshop_account::display_an_address($add, $address_infos, $address_id); |
|
| 2606 | 2606 | |
| 2607 | 2607 | $_SESSION[$address_type] = $address_id; |
| 2608 | 2608 | |
| 2609 | - $edit_link = '<a href="' .get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?')===false ? '?' : '&') . 'action=editAddress&id='.$address_id.'" title="' .__('Edit', 'wpshop'). '">' .__('Edit', 'wpshop'). '</a>'; |
|
| 2610 | - $result = json_encode( array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button) ); |
|
| 2609 | + $edit_link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))) . (strpos(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))), '?') === false ? '?' : '&') . 'action=editAddress&id=' . $address_id . '" title="' . __('Edit', 'wpshop') . '">' . __('Edit', 'wpshop') . '</a>'; |
|
| 2610 | + $result = json_encode(array(true, $retour, $edit_link, $is_allowed_destination, $checkout_payment_button)); |
|
| 2611 | 2611 | } |
| 2612 | 2612 | else { |
| 2613 | - $result = json_encode( array(false, 'missing_informations') ); |
|
| 2613 | + $result = json_encode(array(false, 'missing_informations')); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | echo $result; |
| 2616 | 2616 | |
@@ -2620,26 +2620,26 @@ discard block |
||
| 2620 | 2620 | add_action('wp_ajax_nopriv_change_address', 'ajax_wpshop_change_address'); |
| 2621 | 2621 | |
| 2622 | 2622 | function ajax_wpshop_load_create_new_customer_interface() { |
| 2623 | - check_ajax_referer( 'ajax_wpshop_load_create_new_customer_interface' ); |
|
| 2623 | + check_ajax_referer('ajax_wpshop_load_create_new_customer_interface'); |
|
| 2624 | 2624 | $billing_address_option = get_option('wpshop_billing_address'); |
| 2625 | 2625 | $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
| 2626 | 2626 | |
| 2627 | 2627 | $tpl_component = array(); |
| 2628 | 2628 | $tpl_component['LOADING_ICON'] = WPSHOP_LOADING_ICON; |
| 2629 | - if ( !empty($billing_address) ) { |
|
| 2630 | - echo wpshop_account::get_addresses_by_type( $billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes')); |
|
| 2629 | + if (!empty($billing_address)) { |
|
| 2630 | + echo wpshop_account::get_addresses_by_type($billing_address, __('Billing address', 'wpshop'), array('only_display' => 'yes')); |
|
| 2631 | 2631 | } |
| 2632 | 2632 | $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] = wpshop_account::display_form_fields($billing_address_option['choice'], '', 'first'); |
| 2633 | 2633 | |
| 2634 | - if ( $shipping_address_option['activate'] ) { |
|
| 2635 | - $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> '.__('Use as shipping information','wpshop').'</label></p><br/>'; |
|
| 2634 | + if ($shipping_address_option['activate']) { |
|
| 2635 | + $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<p class="formField"><label><input type="checkbox" name="shiptobilling" id="shiptobilling_checkbox" checked="checked" /> ' . __('Use as shipping information', 'wpshop') . '</label></p><br/>'; |
|
| 2636 | 2636 | $display = 'display:none;'; |
| 2637 | - $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="'.$display.'">'; |
|
| 2637 | + $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '<div id="shipping_infos_bloc" style="' . $display . '">'; |
|
| 2638 | 2638 | $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= wpshop_account::display_form_fields($shipping_address_option['choice'], '', 'first'); |
| 2639 | 2639 | $tpl_component['CUSTOMER_ADDRESSES_FORM_CONTENT'] .= '</div><br/>'; |
| 2640 | 2640 | } |
| 2641 | 2641 | |
| 2642 | - $tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save','wpshop') . '" /></p>'; |
|
| 2642 | + $tpl_component['CUSTOMER_ADDRESSES_FORM_BUTTONS'] = '<p class="formField"><input type="submit" name="submitbillingAndShippingInfo" id="submitbillingAndShippingInfo" value="' . __('Save', 'wpshop') . '" /></p>'; |
|
| 2643 | 2643 | $output = wpshop_display::display_template_element('wpshop_customer_addresses_form_admin', $tpl_component, array(), 'admin'); |
| 2644 | 2644 | unset($tpl_component); |
| 2645 | 2645 | $result = json_encode(array(true, $output)); |
@@ -2649,15 +2649,15 @@ discard block |
||
| 2649 | 2649 | add_action('wp_ajax_load_create_new_customer_interface', 'ajax_wpshop_load_create_new_customer_interface'); |
| 2650 | 2650 | |
| 2651 | 2651 | function ajax_wpshop_create_new_customer() { |
| 2652 | - check_ajax_referer( 'ajax_wpshop_create_new_customer' ); |
|
| 2652 | + check_ajax_referer('ajax_wpshop_create_new_customer'); |
|
| 2653 | 2653 | $result = ''; |
| 2654 | - if ( $_POST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email'] != null ) { |
|
| 2654 | + if ($_POST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email'] != null) { |
|
| 2655 | 2655 | /** Crerate the new customer user account */ |
| 2656 | 2656 | $username = $_REQUEST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email']; |
| 2657 | - $password = wp_generate_password( $length=12, $include_standard_special_chars=false ); |
|
| 2657 | + $password = wp_generate_password($length = 12, $include_standard_special_chars = false); |
|
| 2658 | 2658 | $email = $_REQUEST['attribute'][$_REQUEST['billing_address']]['varchar']['address_user_email']; |
| 2659 | - if ( !empty($username) && !username_exists($username) && !empty($email) && !email_exists($email) ) { |
|
| 2660 | - $user_id = wp_create_user( $username, $password, $email ); |
|
| 2659 | + if (!empty($username) && !username_exists($username) && !empty($email) && !email_exists($email)) { |
|
| 2660 | + $user_id = wp_create_user($username, $password, $email); |
|
| 2661 | 2661 | $_REQUEST['user']['customer_id'] = $user_id; |
| 2662 | 2662 | /** Save addresses */ |
| 2663 | 2663 | $billing_set_infos = get_option('wpshop_billing_address'); |
@@ -2667,21 +2667,21 @@ discard block |
||
| 2667 | 2667 | wpshop_account::same_billing_and_shipping_address($_REQUEST['billing_address'], $_REQUEST['shipping_address']); |
| 2668 | 2668 | } |
| 2669 | 2669 | |
| 2670 | - if ( !empty($_POST['billing_address']) ) { |
|
| 2671 | - wps_address::save_address_infos( $_REQUEST['billing_address'] ); |
|
| 2670 | + if (!empty($_POST['billing_address'])) { |
|
| 2671 | + wps_address::save_address_infos($_REQUEST['billing_address']); |
|
| 2672 | 2672 | } |
| 2673 | - if( !empty($_POST['shipping_address']) ) { |
|
| 2674 | - wps_address::save_address_infos( $_REQUEST['shipping_address'] ); |
|
| 2673 | + if (!empty($_POST['shipping_address'])) { |
|
| 2674 | + wps_address::save_address_infos($_REQUEST['shipping_address']); |
|
| 2675 | 2675 | } |
| 2676 | - $result = json_encode( array(true, __('Customer created', 'wpshop'), $user_id) ); |
|
| 2676 | + $result = json_encode(array(true, __('Customer created', 'wpshop'), $user_id)); |
|
| 2677 | 2677 | } |
| 2678 | 2678 | else { |
| 2679 | - $result = json_encode( array(false, __('A customer account is already created with this email address', 'wpshop')) ); |
|
| 2679 | + $result = json_encode(array(false, __('A customer account is already created with this email address', 'wpshop'))); |
|
| 2680 | 2680 | } |
| 2681 | 2681 | |
| 2682 | 2682 | } |
| 2683 | 2683 | else { |
| 2684 | - $result = json_encode( array(false, __('An email address is required', 'wpshop')) ); |
|
| 2684 | + $result = json_encode(array(false, __('An email address is required', 'wpshop'))); |
|
| 2685 | 2685 | } |
| 2686 | 2686 | echo $result; |
| 2687 | 2687 | die(); |
@@ -2691,26 +2691,26 @@ discard block |
||
| 2691 | 2691 | /** |
| 2692 | 2692 | * Send a message to customer |
| 2693 | 2693 | */ |
| 2694 | - function ajax_wpshop_send_message_by_type () { |
|
| 2695 | - check_ajax_referer( 'ajax_wpshop_send_message_by_type' ); |
|
| 2694 | + function ajax_wpshop_send_message_by_type() { |
|
| 2695 | + check_ajax_referer('ajax_wpshop_send_message_by_type'); |
|
| 2696 | 2696 | global $wpdb; |
| 2697 | 2697 | $result = array(); |
| 2698 | - $message_type_id = ( !empty( $_POST['message_type_id'])) ? wpshop_tools::varSanitizer($_POST['message_type_id']) : null; |
|
| 2699 | - $customer_id = ( !empty( $_POST['customer_user_id'])) ? wpshop_tools::varSanitizer($_POST['customer_user_id']) : null; |
|
| 2700 | - $model_name = ( !empty( $_POST['message_model_name'])) ? wpshop_tools::varSanitizer($_POST['message_model_name']) : null; |
|
| 2701 | - $order_id = ( !empty( $_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : null; |
|
| 2702 | - if ( !empty($customer_id) && !empty($message_type_id) && !empty($model_name)) { |
|
| 2698 | + $message_type_id = (!empty($_POST['message_type_id'])) ? wpshop_tools::varSanitizer($_POST['message_type_id']) : null; |
|
| 2699 | + $customer_id = (!empty($_POST['customer_user_id'])) ? wpshop_tools::varSanitizer($_POST['customer_user_id']) : null; |
|
| 2700 | + $model_name = (!empty($_POST['message_model_name'])) ? wpshop_tools::varSanitizer($_POST['message_model_name']) : null; |
|
| 2701 | + $order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : null; |
|
| 2702 | + if (!empty($customer_id) && !empty($message_type_id) && !empty($model_name)) { |
|
| 2703 | 2703 | $order_post_meta = get_post_meta($order_id, '_order_postmeta', true); |
| 2704 | - $receiver_infos = get_userdata( $customer_id ); |
|
| 2704 | + $receiver_infos = get_userdata($customer_id); |
|
| 2705 | 2705 | $email = $receiver_infos->user_email; |
| 2706 | 2706 | $first_name = get_user_meta($customer_id, 'first_name', true); |
| 2707 | 2707 | $last_name = get_user_meta($customer_id, 'last_name', true); |
| 2708 | 2708 | $wps_message = new wps_message_ctr(); |
| 2709 | - $wps_message->wpshop_prepared_email( $email, $model_name, array('order_id' => $order_id, 'order_key' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_key']) ) ? $order_post_meta['order_key'] : '' ), 'order_date' => ( ( !empty($order_post_meta) && !empty($order_post_meta['order_date']) ) ? $order_post_meta['order_date'] : '' ),'customer_first_name' => $first_name, 'customer_last_name' => $last_name) ); |
|
| 2710 | - $result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id) ); |
|
| 2709 | + $wps_message->wpshop_prepared_email($email, $model_name, array('order_id' => $order_id, 'order_key' => ((!empty($order_post_meta) && !empty($order_post_meta['order_key'])) ? $order_post_meta['order_key'] : ''), 'order_date' => ((!empty($order_post_meta) && !empty($order_post_meta['order_date'])) ? $order_post_meta['order_date'] : ''), 'customer_first_name' => $first_name, 'customer_last_name' => $last_name)); |
|
| 2710 | + $result = array('status' => true, 'response' => $wps_message->get_historic_message_by_type($message_type_id)); |
|
| 2711 | 2711 | } |
| 2712 | 2712 | else { |
| 2713 | - $result = array('status' => false, 'response' => __('An error occured', 'wpshop') ); |
|
| 2713 | + $result = array('status' => false, 'response' => __('An error occured', 'wpshop')); |
|
| 2714 | 2714 | } |
| 2715 | 2715 | echo json_encode($result); |
| 2716 | 2716 | die(); |
@@ -2719,20 +2719,20 @@ discard block |
||
| 2719 | 2719 | |
| 2720 | 2720 | |
| 2721 | 2721 | function ajax_wpshop_upload_downloadable_file_action() { |
| 2722 | - check_ajax_referer( 'ajax_wpshop_upload_downloadable_file_action' ); |
|
| 2722 | + check_ajax_referer('ajax_wpshop_upload_downloadable_file_action'); |
|
| 2723 | 2723 | $result = ''; |
| 2724 | - if ( !empty( $_FILES['wpshop_file'] ) && !empty($_POST['element_identifer']) ) { |
|
| 2725 | - if(!is_dir(WPSHOP_UPLOAD_DIR)){ |
|
| 2724 | + if (!empty($_FILES['wpshop_file']) && !empty($_POST['element_identifer'])) { |
|
| 2725 | + if (!is_dir(WPSHOP_UPLOAD_DIR)) { |
|
| 2726 | 2726 | mkdir(WPSHOP_UPLOAD_DIR, 0755, true); |
| 2727 | 2727 | } |
| 2728 | 2728 | $file = $_FILES['wpshop_file']; |
| 2729 | 2729 | $tmp_name = $file['tmp_name']; |
| 2730 | - $name = sanitize_file_name( current_time( 'mysql', 0 ).'__'.$file["name"] ); |
|
| 2731 | - @move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR.$name); |
|
| 2730 | + $name = sanitize_file_name(current_time('mysql', 0) . '__' . $file["name"]); |
|
| 2731 | + @move_uploaded_file($tmp_name, WPSHOP_UPLOAD_DIR . $name); |
|
| 2732 | 2732 | |
| 2733 | - $n = WPSHOP_UPLOAD_URL.'/'.$name; |
|
| 2734 | - update_post_meta( $_POST['element_identifer'], 'attribute_option_is_downloadable_', array('file_url' => $n)); |
|
| 2735 | - $result = '<a href="' .$n. '" target="_blank" download>' .$name. '</a>'; |
|
| 2733 | + $n = WPSHOP_UPLOAD_URL . '/' . $name; |
|
| 2734 | + update_post_meta($_POST['element_identifer'], 'attribute_option_is_downloadable_', array('file_url' => $n)); |
|
| 2735 | + $result = '<a href="' . $n . '" target="_blank" download>' . $name . '</a>'; |
|
| 2736 | 2736 | } |
| 2737 | 2737 | else { |
| 2738 | 2738 | $result = ''; |
@@ -2743,81 +2743,81 @@ discard block |
||
| 2743 | 2743 | add_action('wp_ajax_upload_downloadable_file_action', 'ajax_wpshop_upload_downloadable_file_action'); |
| 2744 | 2744 | |
| 2745 | 2745 | function ajax_wpshop_fill_the_downloadable_dialog() { |
| 2746 | - check_ajax_referer( 'ajax_wpshop_fill_the_downloadable_dialog' ); |
|
| 2747 | - $output = '<form method="post" action="' .admin_url('admin-ajax.php') .'" name="" id="upload_downloadable_file" enctype="multipart/form-data" >'; |
|
| 2748 | - $output .= '<p class="formField"><label for="wpshop_file">' .__('Choose your file to send', 'wpshop'). '</label><input type="file" name="wpshop_file" /></p>'; |
|
| 2746 | + check_ajax_referer('ajax_wpshop_fill_the_downloadable_dialog'); |
|
| 2747 | + $output = '<form method="post" action="' . admin_url('admin-ajax.php') . '" name="" id="upload_downloadable_file" enctype="multipart/form-data" >'; |
|
| 2748 | + $output .= '<p class="formField"><label for="wpshop_file">' . __('Choose your file to send', 'wpshop') . '</label><input type="file" name="wpshop_file" /></p>'; |
|
| 2749 | 2749 | $output .= '<input type="hidden" name="action" value="upload_downloadable_file_action" />'; |
| 2750 | - $output .= wp_nonce_field( 'ajax_wpshop_upload_downloadable_file_action' ); |
|
| 2751 | - $output .= '<input type="hidden" name="element_identifer" id="element_identifer" value="' .$_POST['product_identifer']. '" />'; |
|
| 2752 | - $output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' .__('Send your file', 'wpshop'). '</a></p>'; |
|
| 2750 | + $output .= wp_nonce_field('ajax_wpshop_upload_downloadable_file_action'); |
|
| 2751 | + $output .= '<input type="hidden" name="element_identifer" id="element_identifer" value="' . $_POST['product_identifer'] . '" />'; |
|
| 2752 | + $output .= '<p class="formField"><a id="send_downloadable_file_button" class="wps-bton-first-mini-rounded">' . __('Send your file', 'wpshop') . '</a></p>'; |
|
| 2753 | 2753 | $output .= '</form>'; |
| 2754 | - $output .='<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({ |
|
| 2754 | + $output .= '<script type="text/javascript">jQuery("#upload_downloadable_file").ajaxForm({ |
|
| 2755 | 2755 | beforeSubmit : function() { },success: function(response) { |
| 2756 | 2756 | jQuery("#send_downloadable_file_dialog").dialog("close"); |
| 2757 | 2757 | jQuery(".statut").html( response ); |
| 2758 | 2758 | }});</script>'; |
| 2759 | 2759 | |
| 2760 | - $response = array( 'status' => true, 'response' => $output); |
|
| 2761 | - echo json_encode( $response ); |
|
| 2760 | + $response = array('status' => true, 'response' => $output); |
|
| 2761 | + echo json_encode($response); |
|
| 2762 | 2762 | die(); |
| 2763 | 2763 | } |
| 2764 | 2764 | add_action('wp_ajax_fill_the_downloadable_dialog', 'ajax_wpshop_fill_the_downloadable_dialog'); |
| 2765 | 2765 | |
| 2766 | 2766 | function ajax_wpshop_show_downloadable_interface_in_admin() { |
| 2767 | - check_ajax_referer( 'ajax_wpshop_show_downloadable_interface_in_admin' ); |
|
| 2767 | + check_ajax_referer('ajax_wpshop_show_downloadable_interface_in_admin'); |
|
| 2768 | 2768 | global $wpdb; |
| 2769 | 2769 | $status = false; |
| 2770 | - $selected_value = ( !empty($_POST['selected_value']) ) ? wpshop_tools::varSanitizer( $_POST['selected_value'] ) : ''; |
|
| 2771 | - $query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $selected_value); |
|
| 2772 | - $value = $wpdb->get_var( $query ); |
|
| 2770 | + $selected_value = (!empty($_POST['selected_value'])) ? wpshop_tools::varSanitizer($_POST['selected_value']) : ''; |
|
| 2771 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $selected_value); |
|
| 2772 | + $value = $wpdb->get_var($query); |
|
| 2773 | 2773 | |
| 2774 | - if ( !empty($value) && __( $value, 'wpshop') == __('Yes', 'wpshop') ) { |
|
| 2774 | + if (!empty($value) && __($value, 'wpshop') == __('Yes', 'wpshop')) { |
|
| 2775 | 2775 | $status = true; |
| 2776 | 2776 | } |
| 2777 | - $response = array( 'status' => $status ); |
|
| 2778 | - echo json_encode( $response ); |
|
| 2777 | + $response = array('status' => $status); |
|
| 2778 | + echo json_encode($response); |
|
| 2779 | 2779 | die(); |
| 2780 | 2780 | } |
| 2781 | - add_action( 'wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin'); |
|
| 2781 | + add_action('wp_ajax_show_downloadable_interface_in_admin', 'ajax_wpshop_show_downloadable_interface_in_admin'); |
|
| 2782 | 2782 | |
| 2783 | 2783 | function ajax_wpshop_restart_the_order() { |
| 2784 | - check_ajax_referer( 'ajax_wpshop_restart_the_order' ); |
|
| 2784 | + check_ajax_referer('ajax_wpshop_restart_the_order'); |
|
| 2785 | 2785 | |
| 2786 | 2786 | global $wpshop_cart, $wpdb; |
| 2787 | 2787 | $status = $add_to_cart_checking = $manage_stock_checking_bool = false; |
| 2788 | 2788 | $add_to_cart_checking_message = ''; |
| 2789 | 2789 | $result = __('Error, you cannot restart this order', 'wpshop'); |
| 2790 | - $order_id = ( !empty($_POST['order_id']) ) ? wpshop_tools::varSanitizer($_POST['order_id']) : null; |
|
| 2791 | - $is_make_order_again = ( !empty($_POST['make_order_again']) ) ? wpshop_tools::varSanitizer( $_POST['make_order_again'] ) : null; |
|
| 2792 | - if( !empty( $order_id ) ) { |
|
| 2790 | + $order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : null; |
|
| 2791 | + $is_make_order_again = (!empty($_POST['make_order_again'])) ? wpshop_tools::varSanitizer($_POST['make_order_again']) : null; |
|
| 2792 | + if (!empty($order_id)) { |
|
| 2793 | 2793 | $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
| 2794 | 2794 | $_SESSION['cart'] = array(); |
| 2795 | 2795 | $_SESSION['cart']['order_items'] = array(); |
| 2796 | 2796 | $wpshop_cart_type = $order_meta['cart_type']; |
| 2797 | 2797 | |
| 2798 | - if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) { |
|
| 2798 | + if (!empty($order_meta) && !empty($order_meta['order_items'])) { |
|
| 2799 | 2799 | $wpshop_cart_type = $order_meta['cart_type']; |
| 2800 | - foreach( $order_meta['order_items'] as $item_key => $item ) { |
|
| 2801 | - $item_meta = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true ); |
|
| 2802 | - $stock = $item_meta['product_stock']; |
|
| 2800 | + foreach ($order_meta['order_items'] as $item_key => $item) { |
|
| 2801 | + $item_meta = get_post_meta($item['item_id'], '_wpshop_product_metadata', true); |
|
| 2802 | + $stock = $item_meta['product_stock']; |
|
| 2803 | 2803 | $qty = $item['item_qty']; |
| 2804 | - $item_option = get_post_meta( $item['item_id'], '_wpshop_product_options', true ); |
|
| 2805 | - if( !empty($item_meta['manage_stock']) ) { |
|
| 2806 | - $query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $item_meta['manage_stock']); |
|
| 2807 | - $manage_stock_checking = $wpdb->get_var( $query ); |
|
| 2808 | - if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') ) ) { |
|
| 2804 | + $item_option = get_post_meta($item['item_id'], '_wpshop_product_options', true); |
|
| 2805 | + if (!empty($item_meta['manage_stock'])) { |
|
| 2806 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $item_meta['manage_stock']); |
|
| 2807 | + $manage_stock_checking = $wpdb->get_var($query); |
|
| 2808 | + if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) { |
|
| 2809 | 2809 | $manage_stock_checking_bool = true; |
| 2810 | 2810 | } |
| 2811 | 2811 | } |
| 2812 | 2812 | else { |
| 2813 | - if( get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 2814 | - $parent_product = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 2815 | - if( !empty($parent_product) && !empty($parent_product['parent_post_meta']) ) { |
|
| 2813 | + if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 2814 | + $parent_product = wpshop_products::get_parent_variation($item['item_id']); |
|
| 2815 | + if (!empty($parent_product) && !empty($parent_product['parent_post_meta'])) { |
|
| 2816 | 2816 | $parent_metadata = $parent_product['parent_post_meta']; |
| 2817 | - if( !empty($parent_product['parent_post_meta']['manage_stock']) ) { |
|
| 2818 | - $query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']); |
|
| 2819 | - $manage_stock_checking = $wpdb->get_var( $query ); |
|
| 2820 | - if( !empty($manage_stock_checking) && strtolower( __( $manage_stock_checking, 'wpshop') ) == strtolower( __( 'Yes', 'wpshop') ) ) { |
|
| 2817 | + if (!empty($parent_product['parent_post_meta']['manage_stock'])) { |
|
| 2818 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_product['parent_post_meta']['manage_stock']); |
|
| 2819 | + $manage_stock_checking = $wpdb->get_var($query); |
|
| 2820 | + if (!empty($manage_stock_checking) && strtolower(__($manage_stock_checking, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) { |
|
| 2821 | 2821 | $manage_stock_checking_bool = true; |
| 2822 | 2822 | $stock = $parent_product['parent_post_meta']['product_stock']; |
| 2823 | 2823 | } |
@@ -2830,8 +2830,8 @@ discard block |
||
| 2830 | 2830 | |
| 2831 | 2831 | |
| 2832 | 2832 | /** Checking stock **/ |
| 2833 | - if ( empty($item_meta['manage_stock']) || ( !empty($item_meta['manage_stock']) && !$manage_stock_checking_bool )|| ( !empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty ) ) { |
|
| 2834 | - $_SESSION['cart']['order_items'][ $item_key ] = $item; |
|
| 2833 | + if (empty($item_meta['manage_stock']) || (!empty($item_meta['manage_stock']) && !$manage_stock_checking_bool) || (!empty($item_meta['manage_stock']) && $manage_stock_checking_bool && $stock >= $qty)) { |
|
| 2834 | + $_SESSION['cart']['order_items'][$item_key] = $item; |
|
| 2835 | 2835 | } |
| 2836 | 2836 | else { |
| 2837 | 2837 | $add_to_cart_checking = true; |
@@ -2840,40 +2840,40 @@ discard block |
||
| 2840 | 2840 | } |
| 2841 | 2841 | |
| 2842 | 2842 | $wps_cart_ctr = new wps_cart(); |
| 2843 | - $order = $wps_cart_ctr->calcul_cart_information( array() ); |
|
| 2843 | + $order = $wps_cart_ctr->calcul_cart_information(array()); |
|
| 2844 | 2844 | $order['cart_type'] = $wpshop_cart_type; |
| 2845 | - $wps_cart_ctr->store_cart_in_session( $order ); |
|
| 2845 | + $wps_cart_ctr->store_cart_in_session($order); |
|
| 2846 | 2846 | } |
| 2847 | 2847 | |
| 2848 | - if ( empty($is_make_order_again) ) { |
|
| 2848 | + if (empty($is_make_order_again)) { |
|
| 2849 | 2849 | $_SESSION['order_id'] = $order_id; |
| 2850 | 2850 | } |
| 2851 | 2851 | $status = true; |
| 2852 | 2852 | |
| 2853 | - $result = get_permalink( get_option('wpshop_cart_page_id') ); |
|
| 2853 | + $result = get_permalink(get_option('wpshop_cart_page_id')); |
|
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | - $response = array( 'status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message); |
|
| 2857 | - echo json_encode( $response ); |
|
| 2856 | + $response = array('status' => $status, 'response' => $result, 'add_to_cart_checking' => $add_to_cart_checking, 'add_to_cart_checking_message' => $add_to_cart_checking_message); |
|
| 2857 | + echo json_encode($response); |
|
| 2858 | 2858 | die(); |
| 2859 | 2859 | } |
| 2860 | - add_action( 'wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order'); |
|
| 2860 | + add_action('wp_ajax_restart_the_order', 'ajax_wpshop_restart_the_order'); |
|
| 2861 | 2861 | |
| 2862 | 2862 | |
| 2863 | 2863 | |
| 2864 | 2864 | function wps_hide_notice_messages() { |
| 2865 | - check_ajax_referer( 'wps_hide_notice_messages' ); |
|
| 2865 | + check_ajax_referer('wps_hide_notice_messages'); |
|
| 2866 | 2866 | |
| 2867 | 2867 | $status = false; |
| 2868 | - $indicator = !empty($_POST['indicator'] ) ? wpshop_tools::varSanitizer($_POST['indicator']) : null; |
|
| 2869 | - if ( !empty($indicator) ) { |
|
| 2868 | + $indicator = !empty($_POST['indicator']) ? wpshop_tools::varSanitizer($_POST['indicator']) : null; |
|
| 2869 | + if (!empty($indicator)) { |
|
| 2870 | 2870 | $user_id = get_current_user_id(); |
| 2871 | - $hide_notice_meta = get_user_meta( $user_id, '_wps_hide_notice_messages_indicator', true); |
|
| 2871 | + $hide_notice_meta = get_user_meta($user_id, '_wps_hide_notice_messages_indicator', true); |
|
| 2872 | 2872 | $hide_notice_meta = !empty($hide_notice_meta) ? $hide_notice_meta : array(); |
| 2873 | 2873 | $indicators = explode(',', $indicator); |
| 2874 | - if ( !empty($indicators) && is_array($indicators) ) { |
|
| 2875 | - foreach( $indicators as $i ) { |
|
| 2876 | - if ( !empty($i) ) { |
|
| 2874 | + if (!empty($indicators) && is_array($indicators)) { |
|
| 2875 | + foreach ($indicators as $i) { |
|
| 2876 | + if (!empty($i)) { |
|
| 2877 | 2877 | $hide_notice_meta[$i] = true; |
| 2878 | 2878 | } |
| 2879 | 2879 | } |
@@ -2882,7 +2882,7 @@ discard block |
||
| 2882 | 2882 | $status = true; |
| 2883 | 2883 | } |
| 2884 | 2884 | $response = array('status' => $status); |
| 2885 | - echo json_encode( $response ); |
|
| 2885 | + echo json_encode($response); |
|
| 2886 | 2886 | die(); |
| 2887 | 2887 | } |
| 2888 | 2888 | add_action('wp_ajax_wps_hide_notice_messages', 'wps_hide_notice_messages'); |
@@ -2890,104 +2890,104 @@ discard block |
||
| 2890 | 2890 | |
| 2891 | 2891 | |
| 2892 | 2892 | function wps_update_products_prices() { |
| 2893 | - check_ajax_referer( 'wps_update_products_prices' ); |
|
| 2893 | + check_ajax_referer('wps_update_products_prices'); |
|
| 2894 | 2894 | $action = wpshop_prices::mass_update_prices(); |
| 2895 | - $response = array( 'status' => $action[0], 'response' => $action[1] ); |
|
| 2896 | - echo json_encode( $response ); |
|
| 2895 | + $response = array('status' => $action[0], 'response' => $action[1]); |
|
| 2896 | + echo json_encode($response); |
|
| 2897 | 2897 | die(); |
| 2898 | 2898 | } |
| 2899 | - add_action( 'wp_ajax_update_products_prices', 'wps_update_products_prices' ); |
|
| 2899 | + add_action('wp_ajax_update_products_prices', 'wps_update_products_prices'); |
|
| 2900 | 2900 | |
| 2901 | 2901 | /** Quotation is payable by customer **/ |
| 2902 | 2902 | function wps_quotation_is_payable_by_customer() { |
| 2903 | - check_ajax_referer( 'wps_quotation_is_payable_by_customer' ); |
|
| 2903 | + check_ajax_referer('wps_quotation_is_payable_by_customer'); |
|
| 2904 | 2904 | global $wpdb; |
| 2905 | 2905 | $status = false; $response = ''; |
| 2906 | - $order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null; |
|
| 2907 | - if( !empty($_POST['order_id']) ) { |
|
| 2908 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 2909 | - if( isset( $order_metadata['pay_quotation'] ) ) { |
|
| 2910 | - unset( $order_metadata['pay_quotation'] ); |
|
| 2906 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 2907 | + if (!empty($_POST['order_id'])) { |
|
| 2908 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 2909 | + if (isset($order_metadata['pay_quotation'])) { |
|
| 2910 | + unset($order_metadata['pay_quotation']); |
|
| 2911 | 2911 | } else { |
| 2912 | 2912 | $order_metadata['pay_quotation'] = 'on'; |
| 2913 | 2913 | } |
| 2914 | - update_post_meta( $order_id, '_order_postmeta', $order_metadata ); |
|
| 2914 | + update_post_meta($order_id, '_order_postmeta', $order_metadata); |
|
| 2915 | 2915 | |
| 2916 | - $response = wpshop_orders::display_customer_pay_quotation( isset( $order_metadata['pay_quotation'] ), $order_id ); |
|
| 2916 | + $response = wpshop_orders::display_customer_pay_quotation(isset($order_metadata['pay_quotation']), $order_id); |
|
| 2917 | 2917 | $status = true; |
| 2918 | 2918 | } else { |
| 2919 | - $response = __( 'An error was occured, no Order ID defined', 'wpshop' ); |
|
| 2919 | + $response = __('An error was occured, no Order ID defined', 'wpshop'); |
|
| 2920 | 2920 | } |
| 2921 | - echo json_encode( array( 'status' => $status, 'response' => $response) ); |
|
| 2921 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 2922 | 2922 | die(); |
| 2923 | 2923 | } |
| 2924 | - add_action( 'wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer' ); |
|
| 2924 | + add_action('wp_ajax_wps_quotation_is_payable_by_customer', 'wps_quotation_is_payable_by_customer'); |
|
| 2925 | 2925 | |
| 2926 | 2926 | /** Send a direct payment Link **/ |
| 2927 | 2927 | function wps_send_direct_payment_link() { |
| 2928 | - check_ajax_referer( 'wps_send_direct_payment_link' ); |
|
| 2928 | + check_ajax_referer('wps_send_direct_payment_link'); |
|
| 2929 | 2929 | global $wpdb; |
| 2930 | 2930 | $status = false; $response = ''; |
| 2931 | - $order_id = ( !empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null; |
|
| 2932 | - if( !empty($_POST['order_id']) ) { |
|
| 2931 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 2932 | + if (!empty($_POST['order_id'])) { |
|
| 2933 | 2933 | /** Get the customer **/ |
| 2934 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 2935 | - if( !empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment' ) { |
|
| 2936 | - $user_infos = get_userdata( $order_metadata['customer_id'] ); |
|
| 2934 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 2935 | + if (!empty($order_metadata) && !empty($order_metadata['customer_id']) && !empty($order_metadata['order_status']) && $order_metadata['order_status'] == 'awaiting_payment') { |
|
| 2936 | + $user_infos = get_userdata($order_metadata['customer_id']); |
|
| 2937 | 2937 | |
| 2938 | - $first_name = get_user_meta($user_infos->ID, 'first_name', true); |
|
| 2939 | - $last_name = get_user_meta($user_infos->ID, 'last_name', true); |
|
| 2938 | + $first_name = get_user_meta($user_infos->ID, 'first_name', true); |
|
| 2939 | + $last_name = get_user_meta($user_infos->ID, 'last_name', true); |
|
| 2940 | 2940 | |
| 2941 | 2941 | |
| 2942 | 2942 | /** Create an activation key **/ |
| 2943 | 2943 | $token = wp_generate_password(20, false); |
| 2944 | - $wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login) ); |
|
| 2944 | + $wpdb->update($wpdb->users, array('user_activation_key' => $token), array('user_login' => $user_infos->user_login)); |
|
| 2945 | 2945 | |
| 2946 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 2947 | - $link = '<a href="' .get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ).( (!empty($permalink_option)) ? '?' : '&').'action=direct_payment_link&token=' .$token. '&login=' .rawurlencode( $user_infos->user_login). '&order_id=' .$order_id. '">' .__( 'Click here to pay your order', 'wpshop' ). '</a>'; |
|
| 2946 | + $permalink_option = get_option('permalink_structure'); |
|
| 2947 | + $link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . ((!empty($permalink_option)) ? '?' : '&') . 'action=direct_payment_link&token=' . $token . '&login=' . rawurlencode($user_infos->user_login) . '&order_id=' . $order_id . '">' . __('Click here to pay your order', 'wpshop') . '</a>'; |
|
| 2948 | 2948 | |
| 2949 | 2949 | /** Send message **/ |
| 2950 | 2950 | $wps_message = new wps_message_ctr(); |
| 2951 | 2951 | $wps_message->wpshop_prepared_email($user_infos->user_email, |
| 2952 | 2952 | 'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE', |
| 2953 | - array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '' ) |
|
| 2953 | + array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'direct_payment_link' => $link, 'order_content' => '') |
|
| 2954 | 2954 | ); |
| 2955 | 2955 | |
| 2956 | - $response = __( 'Direct payment link has been send', 'wpshop' ); |
|
| 2956 | + $response = __('Direct payment link has been send', 'wpshop'); |
|
| 2957 | 2957 | $status = true; |
| 2958 | 2958 | } |
| 2959 | 2959 | else { |
| 2960 | - $response = __( 'An error was occured', 'wpshop' ); |
|
| 2960 | + $response = __('An error was occured', 'wpshop'); |
|
| 2961 | 2961 | } |
| 2962 | 2962 | } |
| 2963 | 2963 | else { |
| 2964 | - $response = __( 'An error was occured, no Order ID defined', 'wpshop' ); |
|
| 2964 | + $response = __('An error was occured, no Order ID defined', 'wpshop'); |
|
| 2965 | 2965 | } |
| 2966 | - echo json_encode( array( 'status' => $status, 'response' => $response) ); |
|
| 2966 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 2967 | 2967 | die(); |
| 2968 | 2968 | } |
| 2969 | - add_action( 'wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link' ); |
|
| 2969 | + add_action('wp_ajax_wps_send_direct_payment_link', 'wps_send_direct_payment_link'); |
|
| 2970 | 2970 | |
| 2971 | 2971 | function wps_mass_action_product() { |
| 2972 | - check_ajax_referer( 'wps_mass_action_product' ); |
|
| 2972 | + check_ajax_referer('wps_mass_action_product'); |
|
| 2973 | 2973 | $mass_actions_tools_page = ''; |
| 2974 | - $default_attributes = array( 'product_stock', 'barcode', 'product_price', 'special_price', ); |
|
| 2974 | + $default_attributes = array('product_stock', 'barcode', 'product_price', 'special_price',); |
|
| 2975 | 2975 | |
| 2976 | 2976 | /** Copy an attribute content to another */ |
| 2977 | - $attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code( WPSHOP_PRODUCT ), "'valid'", 'entity_id', true); |
|
| 2978 | - if ( !empty( $attribute_list ) ) { |
|
| 2977 | + $attribute_list = wpshop_attributes::getElement(wpshop_entities::get_entity_identifier_from_code(WPSHOP_PRODUCT), "'valid'", 'entity_id', true); |
|
| 2978 | + if (!empty($attribute_list)) { |
|
| 2979 | 2979 | $mass_actions_tools_page .= ' |
| 2980 | - <form action="' . admin_url( "admin-ajax.php" ) . '" method="POST" id="wps_mass_action_on_entity_form" > |
|
| 2980 | + <form action="' . admin_url("admin-ajax.php") . '" method="POST" id="wps_mass_action_on_entity_form" > |
|
| 2981 | 2981 | <input type="hidden" value="wps_mass_action_on_entity_launch" name="action" /> |
| 2982 | - <!--<div>' . __( 'Choose attribute to display into list', 'wpshop' ) . ' |
|
| 2982 | + <!--<div>' . __('Choose attribute to display into list', 'wpshop') . ' |
|
| 2983 | 2983 | <ul>'; |
| 2984 | - foreach ( $attribute_list as $attribute ) { |
|
| 2984 | + foreach ($attribute_list as $attribute) { |
|
| 2985 | 2985 | $mass_actions_tools_page .= ' |
| 2986 | - <li style="display:inline-block; width:10%;" ><input type="checkbox"' . checked( in_array( $attribute->code, $default_attributes ), true, false ) . ' name="wps_tools_mass_action_on_element[]" value="' . $attribute->id . '" />' . __( $attribute->frontend_label, 'wpshop' ) . '</li>'; |
|
| 2986 | + <li style="display:inline-block; width:10%;" ><input type="checkbox"' . checked(in_array($attribute->code, $default_attributes), true, false) . ' name="wps_tools_mass_action_on_element[]" value="' . $attribute->id . '" />' . __($attribute->frontend_label, 'wpshop') . '</li>'; |
|
| 2987 | 2987 | } |
| 2988 | 2988 | $mass_actions_tools_page .= ' |
| 2989 | 2989 | </ul> |
| 2990 | - <button>' . __( 'Voir la liste des produits', 'wpshop' ) . '</button> --> |
|
| 2990 | + <button>' . __('Voir la liste des produits', 'wpshop') . '</button> --> |
|
| 2991 | 2991 | </div> |
| 2992 | 2992 | </form> |
| 2993 | 2993 | <div id="wps_entity_list" >' . wps_mass_action_on_entity_launch() . '</div> |
@@ -3000,31 +3000,31 @@ discard block |
||
| 3000 | 3000 | </script>'; |
| 3001 | 3001 | } |
| 3002 | 3002 | |
| 3003 | - wp_die( $mass_actions_tools_page ); |
|
| 3003 | + wp_die($mass_actions_tools_page); |
|
| 3004 | 3004 | } |
| 3005 | - add_action( 'wp_ajax_wps_mass_action_product', 'wps_mass_action_product' ); |
|
| 3005 | + add_action('wp_ajax_wps_mass_action_product', 'wps_mass_action_product'); |
|
| 3006 | 3006 | |
| 3007 | 3007 | function wps_put_history_back() { |
| 3008 | - check_ajax_referer( 'wps_put_history_back' ); |
|
| 3008 | + check_ajax_referer('wps_put_history_back'); |
|
| 3009 | 3009 | |
| 3010 | 3010 | global $wpdb; |
| 3011 | 3011 | $upload_dir = wp_upload_dir(); |
| 3012 | - $log_dir = $upload_dir[ 'basedir' ] . '/wps_repair/'; |
|
| 3013 | - wp_mkdir_p( $log_dir ); |
|
| 3014 | - foreach ( $_POST[ 'value_to_take' ] as $product_id => $product_element ) { |
|
| 3015 | - foreach( $product_element as $attribute_id => $attribute_value_to_take ){ |
|
| 3016 | - $query = $wpdb->prepare( "SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take ); |
|
| 3017 | - $the_new_value = $wpdb->get_row( $query ); |
|
| 3018 | - if ( 6 == $attribute_id ) { |
|
| 3019 | - $query = $wpdb->prepare( "SELECT OPT.value, HISTO.value AS rate_id FROM wp_wpshop__attribute_value_options AS OPT INNER JOIN wp_wpshop__attribute_value__histo AS HISTO ON ( ( HISTO.attribute_id = OPT.attribute_id ) AND ( HISTO.value = OPT.id ) ) WHERE HISTO.attribute_id = 29 AND HISTO.entity_id = %d ORDER BY HISTO.creation_date_value DESC LIMIT 1", $product_id ); |
|
| 3020 | - $the_tax = $wpdb->get_row( $query ); |
|
| 3021 | - $pttc = number_format( $the_new_value->value, 5, ".", " " ); |
|
| 3022 | - $ht = number_format( $pttc / ( 1 + ( $the_tax->value / 100 ) ), 5, ".", " " ); |
|
| 3023 | - $tax_amount = number_format( $pttc - $ht, 5, ".", " " ); |
|
| 3024 | - $wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 6 ) ); |
|
| 3025 | - $wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 28 ) ); |
|
| 3026 | - $wpdb->delete( 'wp_wpshop__attribute_value_integer', array( "entity_id" => $product_id, "attribute_id" => 29 ) ); |
|
| 3027 | - $wpdb->delete( 'wp_wpshop__attribute_value_decimal', array( "entity_id" => $product_id, "attribute_id" => 30 ) ); |
|
| 3012 | + $log_dir = $upload_dir['basedir'] . '/wps_repair/'; |
|
| 3013 | + wp_mkdir_p($log_dir); |
|
| 3014 | + foreach ($_POST['value_to_take'] as $product_id => $product_element) { |
|
| 3015 | + foreach ($product_element as $attribute_id => $attribute_value_to_take) { |
|
| 3016 | + $query = $wpdb->prepare("SELECT value, value_type FROM wp_wpshop__attribute_value__histo WHERE value_id = %d", $attribute_value_to_take); |
|
| 3017 | + $the_new_value = $wpdb->get_row($query); |
|
| 3018 | + if (6 == $attribute_id) { |
|
| 3019 | + $query = $wpdb->prepare("SELECT OPT.value, HISTO.value AS rate_id FROM wp_wpshop__attribute_value_options AS OPT INNER JOIN wp_wpshop__attribute_value__histo AS HISTO ON ( ( HISTO.attribute_id = OPT.attribute_id ) AND ( HISTO.value = OPT.id ) ) WHERE HISTO.attribute_id = 29 AND HISTO.entity_id = %d ORDER BY HISTO.creation_date_value DESC LIMIT 1", $product_id); |
|
| 3020 | + $the_tax = $wpdb->get_row($query); |
|
| 3021 | + $pttc = number_format($the_new_value->value, 5, ".", " "); |
|
| 3022 | + $ht = number_format($pttc / (1 + ($the_tax->value / 100)), 5, ".", " "); |
|
| 3023 | + $tax_amount = number_format($pttc - $ht, 5, ".", " "); |
|
| 3024 | + $wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 6)); |
|
| 3025 | + $wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 28)); |
|
| 3026 | + $wpdb->delete('wp_wpshop__attribute_value_integer', array("entity_id" => $product_id, "attribute_id" => 29)); |
|
| 3027 | + $wpdb->delete('wp_wpshop__attribute_value_decimal', array("entity_id" => $product_id, "attribute_id" => 30)); |
|
| 3028 | 3028 | |
| 3029 | 3029 | $common_datas = array( |
| 3030 | 3030 | 'value_id' => null, |
@@ -3032,20 +3032,20 @@ discard block |
||
| 3032 | 3032 | 'entity_id' => $product_id, |
| 3033 | 3033 | 'unit_id' => null, |
| 3034 | 3034 | 'user_id' => 1, |
| 3035 | - 'creation_date_value' => current_time( "mysql", 0 ), |
|
| 3035 | + 'creation_date_value' => current_time("mysql", 0), |
|
| 3036 | 3036 | 'language' => 'fr_FR', |
| 3037 | 3037 | ); |
| 3038 | 3038 | |
| 3039 | - $content_to_write = " |
|
| 3040 | -" . mysql2date( "d/m/Y H:i", current_time( 'mysql', 0 ), true ) . ' - ' . $product_id . ' - ' . serialize( $common_datas ) . ' - ' . serialize( array( 'ttc' => $pttc, 'ht' => $ht, 'tax_rate_id' => $the_tax->rate_id, 'tax_amount' => $tax_amount, ) ). ''; |
|
| 3041 | - $fp = fopen( $log_dir . 'correction_prix.txt', 'a' ); |
|
| 3042 | - fwrite( $fp, $content_to_write ); |
|
| 3043 | - fclose( $fp ); |
|
| 3039 | + $content_to_write = " |
|
| 3040 | +" . mysql2date("d/m/Y H:i", current_time('mysql', 0), true) . ' - ' . $product_id . ' - ' . serialize($common_datas) . ' - ' . serialize(array('ttc' => $pttc, 'ht' => $ht, 'tax_rate_id' => $the_tax->rate_id, 'tax_amount' => $tax_amount,)) . ''; |
|
| 3041 | + $fp = fopen($log_dir . 'correction_prix.txt', 'a'); |
|
| 3042 | + fwrite($fp, $content_to_write); |
|
| 3043 | + fclose($fp); |
|
| 3044 | 3044 | |
| 3045 | - $wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 6, 'value' => $pttc ) ) ); |
|
| 3046 | - $wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 28, 'value' => $ht ) ) ); |
|
| 3047 | - $wpdb->insert( 'wp_wpshop__attribute_value_integer', array_merge( $common_datas, array( 'attribute_id' => 29, 'value' => $the_tax->rate_id ) ) ); |
|
| 3048 | - $wpdb->insert( 'wp_wpshop__attribute_value_decimal', array_merge( $common_datas, array( 'attribute_id' => 30, 'value' => $tax_amount ) ) ); |
|
| 3045 | + $wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 6, 'value' => $pttc))); |
|
| 3046 | + $wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 28, 'value' => $ht))); |
|
| 3047 | + $wpdb->insert('wp_wpshop__attribute_value_integer', array_merge($common_datas, array('attribute_id' => 29, 'value' => $the_tax->rate_id))); |
|
| 3048 | + $wpdb->insert('wp_wpshop__attribute_value_decimal', array_merge($common_datas, array('attribute_id' => 30, 'value' => $tax_amount))); |
|
| 3049 | 3049 | } |
| 3050 | 3050 | else { |
| 3051 | 3051 | $common_datas = array( |
@@ -3054,33 +3054,33 @@ discard block |
||
| 3054 | 3054 | 'entity_id' => $product_id, |
| 3055 | 3055 | 'unit_id' => null, |
| 3056 | 3056 | 'user_id' => 1, |
| 3057 | - 'creation_date_value' => current_time( "mysql", 0 ), |
|
| 3057 | + 'creation_date_value' => current_time("mysql", 0), |
|
| 3058 | 3058 | 'language' => 'fr_FR', |
| 3059 | 3059 | ); |
| 3060 | - $wpdb->delete( $the_new_value->value_type, array( "entity_id" => $product_id, "attribute_id" => $attribute_id ) ); |
|
| 3061 | - $wpdb->insert( $the_new_value->value_type, array_merge( $common_datas, array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ) ) ) ); |
|
| 3062 | - |
|
| 3063 | - $content_to_write = " |
|
| 3064 | -" . mysql2date( "d/m/Y H:i", current_time( 'mysql', 0 ), true ) . ' - ' . $product_id . ' - ' . serialize( $common_datas ) . ' - ' . serialize( array( 'attribute_id' => $attribute_id, 'value' => trim( $the_new_value->value ), ) ). ''; |
|
| 3065 | - $fp = fopen( $log_dir . 'correction_attribut.txt', 'a' ); |
|
| 3066 | - fwrite( $fp, $content_to_write ); |
|
| 3067 | - fclose( $fp ); |
|
| 3060 | + $wpdb->delete($the_new_value->value_type, array("entity_id" => $product_id, "attribute_id" => $attribute_id)); |
|
| 3061 | + $wpdb->insert($the_new_value->value_type, array_merge($common_datas, array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value)))); |
|
| 3062 | + |
|
| 3063 | + $content_to_write = " |
|
| 3064 | +" . mysql2date("d/m/Y H:i", current_time('mysql', 0), true) . ' - ' . $product_id . ' - ' . serialize($common_datas) . ' - ' . serialize(array('attribute_id' => $attribute_id, 'value' => trim($the_new_value->value),)) . ''; |
|
| 3065 | + $fp = fopen($log_dir . 'correction_attribut.txt', 'a'); |
|
| 3066 | + fwrite($fp, $content_to_write); |
|
| 3067 | + fclose($fp); |
|
| 3068 | 3068 | } |
| 3069 | 3069 | } |
| 3070 | 3070 | } |
| 3071 | 3071 | wp_die(); |
| 3072 | 3072 | } |
| 3073 | - add_action( 'wp_ajax_wps_put_history_back', 'wps_put_history_back' ); |
|
| 3073 | + add_action('wp_ajax_wps_put_history_back', 'wps_put_history_back'); |
|
| 3074 | 3074 | |
| 3075 | 3075 | function wps_mass_action_on_entity_launch() { |
| 3076 | 3076 | global $wpdb; |
| 3077 | 3077 | $response = ''; |
| 3078 | 3078 | $element_to_output = array(); |
| 3079 | 3079 | |
| 3080 | - $attributes_to_test = array( 'decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118' ); |
|
| 3080 | + $attributes_to_test = array('decimal' => '6,36', 'varchar' => '12', 'integer' => '85', 'text' => '120, 118'); |
|
| 3081 | 3081 | |
| 3082 | 3082 | $decimal_attribute = $attributes_to_test['decimal']; //,30,28 |
| 3083 | - $query = $wpdb->prepare( " |
|
| 3083 | + $query = $wpdb->prepare(" |
|
| 3084 | 3084 | SELECT P.ID, P.post_title, |
| 3085 | 3085 | D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value |
| 3086 | 3086 | FROM {$wpdb->posts} AS P |
@@ -3094,21 +3094,21 @@ discard block |
||
| 3094 | 3094 | AND H.value_type = 'wp_wpshop__attribute_value_decimal' |
| 3095 | 3095 | |
| 3096 | 3096 | ORDER BY H.entity_id ASC, H.value_id DESC", |
| 3097 | - array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", ) |
|
| 3097 | + array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",) |
|
| 3098 | 3098 | ); |
| 3099 | - $list_of_element = $wpdb->get_results( $query ); |
|
| 3100 | - if ( !empty( $list_of_element ) ) { |
|
| 3101 | - foreach ( $list_of_element as $element ) { |
|
| 3102 | - $element_to_output[ $element->ID ][ 'title' ] = $element->post_title; |
|
| 3103 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value; |
|
| 3104 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id; |
|
| 3105 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date; |
|
| 3106 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value; |
|
| 3099 | + $list_of_element = $wpdb->get_results($query); |
|
| 3100 | + if (!empty($list_of_element)) { |
|
| 3101 | + foreach ($list_of_element as $element) { |
|
| 3102 | + $element_to_output[$element->ID]['title'] = $element->post_title; |
|
| 3103 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value; |
|
| 3104 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id; |
|
| 3105 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date; |
|
| 3106 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value; |
|
| 3107 | 3107 | } |
| 3108 | 3108 | } |
| 3109 | 3109 | |
| 3110 | 3110 | $attribute_list = $attributes_to_test['varchar']; |
| 3111 | - $query = $wpdb->prepare( " |
|
| 3111 | + $query = $wpdb->prepare(" |
|
| 3112 | 3112 | SELECT P.ID, P.post_title, |
| 3113 | 3113 | D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value |
| 3114 | 3114 | FROM {$wpdb->posts} AS P |
@@ -3121,22 +3121,22 @@ discard block |
||
| 3121 | 3121 | AND H.value != '' |
| 3122 | 3122 | AND H.value_type = 'wp_wpshop__attribute_value_varchar' |
| 3123 | 3123 | ORDER BY H.creation_date", |
| 3124 | - array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", ) |
|
| 3124 | + array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",) |
|
| 3125 | 3125 | ); |
| 3126 | - $list_of_element = $wpdb->get_results( $query ); |
|
| 3127 | - if ( !empty( $list_of_element ) ) { |
|
| 3128 | - foreach ( $list_of_element as $element ) { |
|
| 3129 | - $element_to_output[ $element->ID ][ 'title' ] = $element->post_title; |
|
| 3130 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value; |
|
| 3131 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id; |
|
| 3132 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date; |
|
| 3133 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value; |
|
| 3126 | + $list_of_element = $wpdb->get_results($query); |
|
| 3127 | + if (!empty($list_of_element)) { |
|
| 3128 | + foreach ($list_of_element as $element) { |
|
| 3129 | + $element_to_output[$element->ID]['title'] = $element->post_title; |
|
| 3130 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value; |
|
| 3131 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id; |
|
| 3132 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date; |
|
| 3133 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value; |
|
| 3134 | 3134 | } |
| 3135 | 3135 | } |
| 3136 | 3136 | |
| 3137 | 3137 | |
| 3138 | 3138 | $attribute_list = $attributes_to_test['text']; |
| 3139 | - $query = $wpdb->prepare( " |
|
| 3139 | + $query = $wpdb->prepare(" |
|
| 3140 | 3140 | SELECT P.ID, P.post_title, |
| 3141 | 3141 | D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value |
| 3142 | 3142 | FROM {$wpdb->posts} AS P |
@@ -3149,21 +3149,21 @@ discard block |
||
| 3149 | 3149 | AND H.value != '' |
| 3150 | 3150 | AND H.value_type = 'wp_wpshop__attribute_value_text' |
| 3151 | 3151 | ORDER BY H.creation_date", |
| 3152 | - array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", ) |
|
| 3152 | + array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",) |
|
| 3153 | 3153 | ); |
| 3154 | - $list_of_element = $wpdb->get_results( $query ); |
|
| 3155 | - if ( !empty( $list_of_element ) ) { |
|
| 3156 | - foreach ( $list_of_element as $element ) { |
|
| 3157 | - $element_to_output[ $element->ID ][ 'title' ] = $element->post_title; |
|
| 3158 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value; |
|
| 3159 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id; |
|
| 3160 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date; |
|
| 3161 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value; |
|
| 3154 | + $list_of_element = $wpdb->get_results($query); |
|
| 3155 | + if (!empty($list_of_element)) { |
|
| 3156 | + foreach ($list_of_element as $element) { |
|
| 3157 | + $element_to_output[$element->ID]['title'] = $element->post_title; |
|
| 3158 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value; |
|
| 3159 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id; |
|
| 3160 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date; |
|
| 3161 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value; |
|
| 3162 | 3162 | } |
| 3163 | 3163 | } |
| 3164 | 3164 | |
| 3165 | 3165 | $attribute_list = $attributes_to_test['integer']; |
| 3166 | - $query = $wpdb->prepare( " |
|
| 3166 | + $query = $wpdb->prepare(" |
|
| 3167 | 3167 | SELECT P.ID, P.post_title, |
| 3168 | 3168 | D.value_id, H.value_id, D.attribute_id, D.entity_id, H.creation_date, D.creation_date_value, D.value AS current_value, H.value AS last_history_value |
| 3169 | 3169 | FROM {$wpdb->posts} AS P |
@@ -3176,21 +3176,21 @@ discard block |
||
| 3176 | 3176 | AND H.value != '' |
| 3177 | 3177 | AND H.value_type = 'wp_wpshop__attribute_value_integer' |
| 3178 | 3178 | ORDER BY H.creation_date", |
| 3179 | - array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish", ) |
|
| 3179 | + array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "publish",) |
|
| 3180 | 3180 | ); |
| 3181 | - $list_of_element = $wpdb->get_results( $query ); |
|
| 3182 | - if ( !empty( $list_of_element ) ) { |
|
| 3183 | - foreach ( $list_of_element as $element ) { |
|
| 3184 | - $element_to_output[ $element->ID ][ 'title' ] = $element->post_title; |
|
| 3185 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'current' ] = $element->current_value; |
|
| 3186 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_id' ] = $element->value_id; |
|
| 3187 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value_date' ] = $element->creation_date; |
|
| 3188 | - $element_to_output[ $element->ID ][ 'content' ][ $element->attribute_id ][ $element->creation_date ][ 'histo' ][ 'value' ] = $element->last_history_value; |
|
| 3181 | + $list_of_element = $wpdb->get_results($query); |
|
| 3182 | + if (!empty($list_of_element)) { |
|
| 3183 | + foreach ($list_of_element as $element) { |
|
| 3184 | + $element_to_output[$element->ID]['title'] = $element->post_title; |
|
| 3185 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['current'] = $element->current_value; |
|
| 3186 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_id'] = $element->value_id; |
|
| 3187 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value_date'] = $element->creation_date; |
|
| 3188 | + $element_to_output[$element->ID]['content'][$element->attribute_id][$element->creation_date]['histo']['value'] = $element->last_history_value; |
|
| 3189 | 3189 | } |
| 3190 | 3190 | } |
| 3191 | 3191 | |
| 3192 | 3192 | $array_done = array(); |
| 3193 | - if ( !empty( $element_to_output ) ) { |
|
| 3193 | + if (!empty($element_to_output)) { |
|
| 3194 | 3194 | $lines = ''; |
| 3195 | 3195 | $done_header = array(); |
| 3196 | 3196 | |
@@ -3198,23 +3198,23 @@ discard block |
||
| 3198 | 3198 | /** Formate informations **/ |
| 3199 | 3199 | $formatted_datas = array(); |
| 3200 | 3200 | $controller_rows_array = array(); |
| 3201 | - foreach( $attributes_to_test as $attribute_to_test ) { |
|
| 3202 | - $atts = explode( ',', $attribute_to_test ); |
|
| 3203 | - foreach( $atts as $att ) { |
|
| 3204 | - $controller_rows_array[ $att ] = false; |
|
| 3201 | + foreach ($attributes_to_test as $attribute_to_test) { |
|
| 3202 | + $atts = explode(',', $attribute_to_test); |
|
| 3203 | + foreach ($atts as $att) { |
|
| 3204 | + $controller_rows_array[$att] = false; |
|
| 3205 | 3205 | } |
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | - foreach( $element_to_output as $element_id => $element_definition ) { |
|
| 3208 | + foreach ($element_to_output as $element_id => $element_definition) { |
|
| 3209 | 3209 | $formatted_datas[$element_id]['title'] = $element_definition['title']; |
| 3210 | 3210 | $formatted_datas[$element_id]['content'] = array(); |
| 3211 | 3211 | |
| 3212 | - foreach( $attributes_to_test as $attribute_to_test ) { |
|
| 3213 | - $atts = explode( ',', $attribute_to_test ); |
|
| 3214 | - foreach( $atts as $att ) { |
|
| 3215 | - if( !empty($element_definition['content'][$att]) ) { |
|
| 3212 | + foreach ($attributes_to_test as $attribute_to_test) { |
|
| 3213 | + $atts = explode(',', $attribute_to_test); |
|
| 3214 | + foreach ($atts as $att) { |
|
| 3215 | + if (!empty($element_definition['content'][$att])) { |
|
| 3216 | 3216 | $formatted_datas[$element_id]['content'][$att] = $element_definition['content'][$att]; |
| 3217 | - $controller_rows_array[ $att ] = true; |
|
| 3217 | + $controller_rows_array[$att] = true; |
|
| 3218 | 3218 | } |
| 3219 | 3219 | else { |
| 3220 | 3220 | $formatted_datas[$element_id]['content'][$att] = array(); |
@@ -3223,39 +3223,39 @@ discard block |
||
| 3223 | 3223 | } |
| 3224 | 3224 | } |
| 3225 | 3225 | |
| 3226 | - foreach ( $formatted_datas as $element_id => $element_definition ) { |
|
| 3227 | - if ( !in_array( $element_id, $array_done ) ) { |
|
| 3228 | - $lines .= '<tr style="border:1px solid black;"><td style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition[ 'title' ] . '</td>'; |
|
| 3229 | - ksort( $element_definition[ 'content' ] ); |
|
| 3230 | - foreach ( $element_definition[ 'content' ] as $atribute_id => $value_on_date ) { |
|
| 3231 | - if( $controller_rows_array[$atribute_id] ) { |
|
| 3232 | - $current_attribute = wpshop_attributes::getElement( $atribute_id ); |
|
| 3233 | - if ( !in_array( $atribute_id, $done_header ) ) { |
|
| 3234 | - $more_header .= '<td style="border:1px solid black;" >' . __( $current_attribute->frontend_label, 'wpshop' ) . '</td>'; |
|
| 3226 | + foreach ($formatted_datas as $element_id => $element_definition) { |
|
| 3227 | + if (!in_array($element_id, $array_done)) { |
|
| 3228 | + $lines .= '<tr style="border:1px solid black;"><td style="border:1px solid black;" >#' . $element_id . ' - ' . $element_definition['title'] . '</td>'; |
|
| 3229 | + ksort($element_definition['content']); |
|
| 3230 | + foreach ($element_definition['content'] as $atribute_id => $value_on_date) { |
|
| 3231 | + if ($controller_rows_array[$atribute_id]) { |
|
| 3232 | + $current_attribute = wpshop_attributes::getElement($atribute_id); |
|
| 3233 | + if (!in_array($atribute_id, $done_header)) { |
|
| 3234 | + $more_header .= '<td style="border:1px solid black;" >' . __($current_attribute->frontend_label, 'wpshop') . '</td>'; |
|
| 3235 | 3235 | $done_header[] = $atribute_id; |
| 3236 | 3236 | } |
| 3237 | 3237 | $last_value = 'XXXXX'; |
| 3238 | 3238 | $counter_for_line = 0; |
| 3239 | 3239 | $content_line = ''; |
| 3240 | - foreach ( $value_on_date as $date => $value ) { |
|
| 3241 | - if ( $value[ 'histo' ][ 'value' ] != $last_value ) { |
|
| 3242 | - $current_val = $value[ 'current' ]; |
|
| 3243 | - $old_val = $value[ 'histo' ][ 'value' ]; |
|
| 3240 | + foreach ($value_on_date as $date => $value) { |
|
| 3241 | + if ($value['histo']['value'] != $last_value) { |
|
| 3242 | + $current_val = $value['current']; |
|
| 3243 | + $old_val = $value['histo']['value']; |
|
| 3244 | 3244 | // Test if attribute data Type is integer |
| 3245 | - if ( $current_attribute->data_type == 'integer' ) { |
|
| 3246 | - if( $current_attribute->data_type_to_use == 'internal' ) { |
|
| 3245 | + if ($current_attribute->data_type == 'integer') { |
|
| 3246 | + if ($current_attribute->data_type_to_use == 'internal') { |
|
| 3247 | 3247 | $current_val = get_the_title($current_val); |
| 3248 | 3248 | $old_val = get_the_title($old_val); |
| 3249 | 3249 | } |
| 3250 | 3250 | else { |
| 3251 | - $query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $old_val); |
|
| 3252 | - $old_val = $wpdb->get_var( $query ); |
|
| 3253 | - $query = $wpdb->prepare( 'SELECT label FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id=%d', $current_val); |
|
| 3254 | - $current_val = $wpdb->get_var( $query ); |
|
| 3251 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $old_val); |
|
| 3252 | + $old_val = $wpdb->get_var($query); |
|
| 3253 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $current_val); |
|
| 3254 | + $current_val = $wpdb->get_var($query); |
|
| 3255 | 3255 | } |
| 3256 | 3256 | } |
| 3257 | - $content_line .= '<label ><input type="radio" name="value_to_take[' . $element_id . '][' . $atribute_id . ']" value="' . $value[ 'histo' ][ 'value_id' ] . '"' . checked( ( 0 == $counter_for_line ? true : false), true, false ) . '/>' . __( 'Current value', 'wpshop' ) . ' : ' .$current_val. ' / ' . __( 'Last value', 'wpshop' ) . ' : ' .$old_val. '</label><br/>'; |
|
| 3258 | - $last_value = $value[ 'histo' ][ 'value' ]; |
|
| 3257 | + $content_line .= '<label ><input type="radio" name="value_to_take[' . $element_id . '][' . $atribute_id . ']" value="' . $value['histo']['value_id'] . '"' . checked((0 == $counter_for_line ? true : false), true, false) . '/>' . __('Current value', 'wpshop') . ' : ' . $current_val . ' / ' . __('Last value', 'wpshop') . ' : ' . $old_val . '</label><br/>'; |
|
| 3258 | + $last_value = $value['histo']['value']; |
|
| 3259 | 3259 | $counter_for_line++; |
| 3260 | 3260 | } |
| 3261 | 3261 | } |
@@ -3265,16 +3265,16 @@ discard block |
||
| 3265 | 3265 | } |
| 3266 | 3266 | } |
| 3267 | 3267 | $lines .= '</tr>'; |
| 3268 | - $array_done[ $element_id ]; |
|
| 3268 | + $array_done[$element_id]; |
|
| 3269 | 3269 | } |
| 3270 | 3270 | } |
| 3271 | 3271 | |
| 3272 | 3272 | $response = ' |
| 3273 | - <form action="' . admin_url( 'admin-ajax.php' ) . '" method="POST" id="wps_put_histo_back" > |
|
| 3273 | + <form action="' . admin_url('admin-ajax.php') . '" method="POST" id="wps_put_histo_back" > |
|
| 3274 | 3274 | <input type="text" name="action" value="wps_put_history_back" /> |
| 3275 | - ' . wp_nonce_field( 'wps_put_history_back' ) . ' |
|
| 3275 | + ' . wp_nonce_field('wps_put_history_back') . ' |
|
| 3276 | 3276 | <table style="border-collapse: collapse;border:1px solid black;" cellpadding="0" cellspacing="0" > |
| 3277 | - <tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __( 'Product', 'wpshop' ) . '</td>'.$more_header.'</tr> |
|
| 3277 | + <tr style="border:1px solid black;"><td style="border:1px solid black;" >' . __('Product', 'wpshop') . '</td>' . $more_header . '</tr> |
|
| 3278 | 3278 | ' . $lines . ' |
| 3279 | 3279 | </table> |
| 3280 | 3280 | </form><script type="text/javascript" > |
@@ -3291,69 +3291,69 @@ discard block |
||
| 3291 | 3291 | |
| 3292 | 3292 | |
| 3293 | 3293 | function wps_delete_picture_category() { |
| 3294 | - check_ajax_referer( 'wps_delete_picture_category' ); |
|
| 3294 | + check_ajax_referer('wps_delete_picture_category'); |
|
| 3295 | 3295 | $status = false; $response = ''; |
| 3296 | - $cat_id = ( !empty($_POST['cat_id']) ) ? intval( $_POST['cat_id'] ) : null; |
|
| 3297 | - if( !empty($cat_id) ) { |
|
| 3296 | + $cat_id = (!empty($_POST['cat_id'])) ? intval($_POST['cat_id']) : null; |
|
| 3297 | + if (!empty($cat_id)) { |
|
| 3298 | 3298 | // Get Category option |
| 3299 | - $category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id ); |
|
| 3300 | - if( !empty($category_option) && !empty($category_option['wpshop_category_picture']) ) { |
|
| 3301 | - unset( $category_option['wpshop_category_picture'] ); |
|
| 3302 | - update_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option ); |
|
| 3303 | - $response = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview"/>'; |
|
| 3299 | + $category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id); |
|
| 3300 | + if (!empty($category_option) && !empty($category_option['wpshop_category_picture'])) { |
|
| 3301 | + unset($category_option['wpshop_category_picture']); |
|
| 3302 | + update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $cat_id, $category_option); |
|
| 3303 | + $response = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview"/>'; |
|
| 3304 | 3304 | $status = true; |
| 3305 | 3305 | } |
| 3306 | 3306 | else { |
| 3307 | - $response = __( 'Category options are not defined', 'wpshop'); |
|
| 3307 | + $response = __('Category options are not defined', 'wpshop'); |
|
| 3308 | 3308 | } |
| 3309 | 3309 | } |
| 3310 | 3310 | else { |
| 3311 | - $response = __( 'Category ID is not defined', 'wpshop'); |
|
| 3311 | + $response = __('Category ID is not defined', 'wpshop'); |
|
| 3312 | 3312 | } |
| 3313 | - echo json_encode( array( 'status' => $status, 'response' => $response) ); |
|
| 3313 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 3314 | 3314 | wp_die(); |
| 3315 | 3315 | } |
| 3316 | - add_action( 'wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category' ); |
|
| 3316 | + add_action('wp_ajax_wps_delete_picture_category', 'wps_delete_picture_category'); |
|
| 3317 | 3317 | |
| 3318 | 3318 | /* EAV */ |
| 3319 | 3319 | |
| 3320 | 3320 | /* ATTRIBUTES SET */ |
| 3321 | 3321 | |
| 3322 | 3322 | function saveNewAttributeSetSection() { |
| 3323 | - check_ajax_referer( 'saveNewAttributeSetSection' ); |
|
| 3323 | + check_ajax_referer('saveNewAttributeSetSection'); |
|
| 3324 | 3324 | $attributeSetSectionName = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionName']); |
| 3325 | 3325 | $attributeSetInfos = array(); |
| 3326 | 3326 | $attributeSetInfos['id'] = ''; |
| 3327 | 3327 | $attributeSetInfos['status'] = 'valid'; |
| 3328 | 3328 | $attributeSetInfos['attribute_set_id'] = $elementIdentifier; |
| 3329 | - $query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM ". WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier); |
|
| 3329 | + $query = $wpdb->prepare("SELECT MAX(position) + 1 AS LAST_GROUP_POSITION FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %s", $elementIdentifier); |
|
| 3330 | 3330 | $attributeSetInfos['position'] = $wpdb->get_var($query); |
| 3331 | 3331 | $attributeSetInfos['creation_date'] = date('Y-m-d H:i:s'); |
| 3332 | 3332 | $attributeSetInfos['code'] = wpshop_tools::slugify($attributeSetSectionName, array('noAccent', 'noSpaces', 'lowerCase')); |
| 3333 | 3333 | $attributeSetInfos['name'] = $attributeSetSectionName; |
| 3334 | 3334 | |
| 3335 | - $more_script=''; |
|
| 3335 | + $more_script = ''; |
|
| 3336 | 3336 | $attributeSetSectionCreation = wpshop_database::save($attributeSetInfos, WPSHOP_DBT_ATTRIBUTE_GROUP); |
| 3337 | - if ( $attributeSetSectionCreation == 'done' ) { |
|
| 3337 | + if ($attributeSetSectionCreation == 'done') { |
|
| 3338 | 3338 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('New section has been created successfully', 'wpshop'); |
| 3339 | - $more_script = 'wpshop_go_to("#attribute_group_'.$wpdb->insert_id.'")'; |
|
| 3339 | + $more_script = 'wpshop_go_to("#attribute_group_' . $wpdb->insert_id . '")'; |
|
| 3340 | 3340 | } |
| 3341 | 3341 | else |
| 3342 | 3342 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while saving new section', 'wpshop'); |
| 3343 | - echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshop(document).ready(function(){ jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>'; |
|
| 3343 | + echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshop(document).ready(function(){ jQuery("#wpshop_new_set_section_add").dialog("close");jQuery("#wpshop_new_set_section_add").children("img").hide(); });wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>'; |
|
| 3344 | 3344 | } |
| 3345 | - add_action( 'wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection' ); |
|
| 3345 | + add_action('wp_ajax_wps_attribute_set_section_new', 'saveNewAttributeSetSection'); |
|
| 3346 | 3346 | |
| 3347 | 3347 | function editAttributeSetSection() { |
| 3348 | - check_ajax_referer( 'editAttributeSetSection' ); |
|
| 3348 | + check_ajax_referer('editAttributeSetSection'); |
|
| 3349 | 3349 | $attributeSetSectionName = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionName']); |
| 3350 | 3350 | $attributeSetSectionId = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionId']); |
| 3351 | 3351 | $attributeSetSectionDefault = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionDefault']); |
| 3352 | 3352 | $backend_display_type = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionDisplayType']); |
| 3353 | 3353 | $display_on_frontend = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionDisplayinFrontEnd']); |
| 3354 | - $backend_display_type = in_array($backend_display_type, array('movable-tab','fixed-tab')) ? $backend_display_type : 'fixed-tab'; |
|
| 3354 | + $backend_display_type = in_array($backend_display_type, array('movable-tab', 'fixed-tab')) ? $backend_display_type : 'fixed-tab'; |
|
| 3355 | 3355 | |
| 3356 | - if($attributeSetSectionDefault == 'yes'){ |
|
| 3356 | + if ($attributeSetSectionDefault == 'yes') { |
|
| 3357 | 3357 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, array('last_update_date' => current_time('mysql', 0), 'default_group' => 'no'), array('attribute_set_id' => $elementIdentifier)); |
| 3358 | 3358 | } |
| 3359 | 3359 | $attributeSetInfos = array(); |
@@ -3363,16 +3363,16 @@ discard block |
||
| 3363 | 3363 | $attributeSetInfos['backend_display_type'] = $backend_display_type; |
| 3364 | 3364 | $attributeSetInfos['display_on_frontend'] = $display_on_frontend; |
| 3365 | 3365 | $attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP); |
| 3366 | - if ( $attributeSetSectionCreation == 'done' ) |
|
| 3366 | + if ($attributeSetSectionCreation == 'done') |
|
| 3367 | 3367 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been updated successfully', 'wpshop'); |
| 3368 | 3368 | else |
| 3369 | 3369 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while updating the section', 'wpshop'); |
| 3370 | 3370 | echo wpshop_attributes_set::attributeSetDetailsManagement($elementIdentifier) . '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);</script>'; |
| 3371 | 3371 | } |
| 3372 | - add_action( 'wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection' ); |
|
| 3372 | + add_action('wp_ajax_wps_attribute_set_section_edit', 'editAttributeSetSection'); |
|
| 3373 | 3373 | |
| 3374 | 3374 | function deleteAttributeSetSection() { |
| 3375 | - check_ajax_referer( 'deleteAttributeSetSection' ); |
|
| 3375 | + check_ajax_referer('deleteAttributeSetSection'); |
|
| 3376 | 3376 | $attributeSetSectionId = wpshop_tools::varSanitizer($_REQUEST['attributeSetSectionId']); |
| 3377 | 3377 | $attributeSetInfos = array(); |
| 3378 | 3378 | $attributeSetInfos['status'] = 'deleted'; |
@@ -3382,15 +3382,15 @@ discard block |
||
| 3382 | 3382 | $attributeSetSectionCreation = wpshop_database::update($attributeSetInfos, $attributeSetSectionId, WPSHOP_DBT_ATTRIBUTE_GROUP); |
| 3383 | 3383 | |
| 3384 | 3384 | $more_script = ''; |
| 3385 | - if ( $attributeSetSectionCreation == 'done' ) { |
|
| 3385 | + if ($attributeSetSectionCreation == 'done') { |
|
| 3386 | 3386 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_SUCCES_ICON . '\' alt=\'action_success\' class=\'wpshopPageMessage_Icon\' />' . __('The section has been successfully been deleted', 'wpshop'); |
| 3387 | - $more_script.='jQuery("#attribute_group_'.$attributeSetSectionId.'").remove();'; |
|
| 3387 | + $more_script .= 'jQuery("#attribute_group_' . $attributeSetSectionId . '").remove();'; |
|
| 3388 | 3388 | } |
| 3389 | 3389 | else |
| 3390 | 3390 | $attributeSetSectionCreation_Result = '<img src=\'' . WPSHOP_ERROR_ICON . '\' alt=\'action_error\' class=\'wpshopPageMessage_Icon\' />' . __('An error occured while deleting the section', 'wpshop'); |
| 3391 | - echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);'.$more_script.'</script>'; |
|
| 3391 | + echo '<script type="text/javascript" >wpshopShowMessage("' . $attributeSetSectionCreation_Result . '");hideShowMessage(5000);' . $more_script . '</script>'; |
|
| 3392 | 3392 | } |
| 3393 | - add_action( 'wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection' ); |
|
| 3393 | + add_action('wp_ajax_wps_attribute_set_section_delete', 'deleteAttributeSetSection'); |
|
| 3394 | 3394 | |
| 3395 | 3395 | /* ATTRIBUTES UNIT */ |
| 3396 | 3396 | |
@@ -3413,22 +3413,22 @@ discard block |
||
| 3413 | 3413 | |
| 3414 | 3414 | wp_die(); |
| 3415 | 3415 | } |
| 3416 | - add_action( 'wp_ajax_wps_attribute_unit_interface', 'load_unit_interface' ); |
|
| 3416 | + add_action('wp_ajax_wps_attribute_unit_interface', 'load_unit_interface'); |
|
| 3417 | 3417 | |
| 3418 | 3418 | function load_attribute_units() { |
| 3419 | 3419 | echo wpshop_attributes_unit::elementList(); |
| 3420 | 3420 | } |
| 3421 | - add_action( 'wp_ajax_wps_attribute_unit_load', 'load_attribute_units' ); |
|
| 3421 | + add_action('wp_ajax_wps_attribute_unit_load', 'load_attribute_units'); |
|
| 3422 | 3422 | |
| 3423 | 3423 | function add_edit_attribute_unit() { |
| 3424 | 3424 | $atribute_unit = ''; |
| 3425 | - if ( $action == 'edit_attribute_unit' ) { |
|
| 3425 | + if ($action == 'edit_attribute_unit') { |
|
| 3426 | 3426 | $atribute_unit = wpshop_tools::varSanitizer($_REQUEST['elementIdentifier']); |
| 3427 | 3427 | } |
| 3428 | 3428 | echo wpshop_attributes_unit::elementEdition($atribute_unit); |
| 3429 | 3429 | } |
| 3430 | - add_action( 'wp_ajax_wps_attribute_unit_add', 'add_edit_attribute_unit' ); |
|
| 3431 | - add_action( 'wp_ajax_wps_attribute_unit_edit', 'add_edit_attribute_unit' ); |
|
| 3430 | + add_action('wp_ajax_wps_attribute_unit_add', 'add_edit_attribute_unit'); |
|
| 3431 | + add_action('wp_ajax_wps_attribute_unit_edit', 'add_edit_attribute_unit'); |
|
| 3432 | 3432 | |
| 3433 | 3433 | function save_new_attribute_unit() { |
| 3434 | 3434 | $save_output = ''; |
@@ -3441,18 +3441,18 @@ discard block |
||
| 3441 | 3441 | $attribute_unit_informations['group_id'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['group_id']); |
| 3442 | 3442 | |
| 3443 | 3443 | $save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT); |
| 3444 | - if($save_unit_result == 'done'){ |
|
| 3444 | + if ($save_unit_result == 'done') { |
|
| 3445 | 3445 | $save_output = wpshop_attributes_unit::elementList(); |
| 3446 | 3446 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit has been saved succesfully', 'wpshop'); |
| 3447 | 3447 | } |
| 3448 | - else{ |
|
| 3448 | + else { |
|
| 3449 | 3449 | $save_output = wpshop_attributes_unit::elementEdition(); |
| 3450 | 3450 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit saving', 'wpshop'); |
| 3451 | 3451 | } |
| 3452 | 3452 | |
| 3453 | 3453 | echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output; |
| 3454 | 3454 | } |
| 3455 | - add_action( 'wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit' ); |
|
| 3455 | + add_action('wp_ajax_wps_attribute_unit_new', 'save_new_attribute_unit'); |
|
| 3456 | 3456 | |
| 3457 | 3457 | function update_attribute_unit() { |
| 3458 | 3458 | $save_output = ''; |
@@ -3467,7 +3467,7 @@ discard block |
||
| 3467 | 3467 | $attribute_unit_informations['change_rate'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['change_rate']); |
| 3468 | 3468 | $attribute_unit_informations['code_iso'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT]['code_iso']); |
| 3469 | 3469 | |
| 3470 | - if ( $attribute_unit_informations['is_default_of_group'] == 'yes' ) { |
|
| 3470 | + if ($attribute_unit_informations['is_default_of_group'] == 'yes') { |
|
| 3471 | 3471 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array( |
| 3472 | 3472 | 'is_default_of_group' => 'no' |
| 3473 | 3473 | ), array( |
@@ -3475,8 +3475,8 @@ discard block |
||
| 3475 | 3475 | )); |
| 3476 | 3476 | } |
| 3477 | 3477 | |
| 3478 | - $save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT); |
|
| 3479 | - if ( $save_unit_result == 'done' ) { |
|
| 3478 | + $save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT); |
|
| 3479 | + if ($save_unit_result == 'done') { |
|
| 3480 | 3480 | $save_output = wpshop_attributes_unit::elementList(); |
| 3481 | 3481 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been saved succesfully', 'wpshop'); |
| 3482 | 3482 | } |
@@ -3487,7 +3487,7 @@ discard block |
||
| 3487 | 3487 | |
| 3488 | 3488 | echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output; |
| 3489 | 3489 | } |
| 3490 | - add_action( 'wp_ajax_wps_attribute_unit_update', 'update_attribute_unit' ); |
|
| 3490 | + add_action('wp_ajax_wps_attribute_unit_update', 'update_attribute_unit'); |
|
| 3491 | 3491 | |
| 3492 | 3492 | function delete_attribute_unit() { |
| 3493 | 3493 | $unit_id = wpshop_tools::varSanitizer($_REQUEST['elementIdentifier']); |
@@ -3496,7 +3496,7 @@ discard block |
||
| 3496 | 3496 | $attribute_unit_informations['status'] = 'deleted'; |
| 3497 | 3497 | $attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s'); |
| 3498 | 3498 | $save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT); |
| 3499 | - if ( $save_unit_result == 'done' ) { |
|
| 3499 | + if ($save_unit_result == 'done') { |
|
| 3500 | 3500 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit has been deleted succesfully', 'wpshop'); |
| 3501 | 3501 | } |
| 3502 | 3502 | else { |
@@ -3505,28 +3505,28 @@ discard block |
||
| 3505 | 3505 | |
| 3506 | 3506 | echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . wpshop_attributes_unit::elementList(); |
| 3507 | 3507 | } |
| 3508 | - add_action( 'wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit' ); |
|
| 3508 | + add_action('wp_ajax_wps_attribute_unit_delete', 'delete_attribute_unit'); |
|
| 3509 | 3509 | |
| 3510 | 3510 | /* ATTRIBUTES UNIT GROUP */ |
| 3511 | 3511 | |
| 3512 | 3512 | function load_attribute_unit_groups() { |
| 3513 | 3513 | echo wpshop_attributes_unit::unit_group_list(); |
| 3514 | 3514 | } |
| 3515 | - add_action( 'wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups' ); |
|
| 3515 | + add_action('wp_ajax_wps_attribute_group_unit_load', 'load_attribute_unit_groups'); |
|
| 3516 | 3516 | |
| 3517 | 3517 | function add_edit_attribute_unit_group() { |
| 3518 | - check_ajax_referer( 'add_edit_attribute_unit_group' ); |
|
| 3518 | + check_ajax_referer('add_edit_attribute_unit_group'); |
|
| 3519 | 3519 | $atribute_unit_group = ''; |
| 3520 | - if($action == 'edit_attribute_unit_group'){ |
|
| 3520 | + if ($action == 'edit_attribute_unit_group') { |
|
| 3521 | 3521 | $atribute_unit_group = wpshop_tools::varSanitizer($_REQUEST['elementIdentifier']); |
| 3522 | 3522 | } |
| 3523 | 3523 | echo wpshop_attributes_unit::unit_group_edition($atribute_unit_group); |
| 3524 | 3524 | } |
| 3525 | - add_action( 'wp_ajax_wps_attribute_group_unit_add', 'add_edit_attribute_unit_group' ); |
|
| 3526 | - add_action( 'wp_ajax_wps_attribute_group_unit_edit', 'add_edit_attribute_unit_group' ); |
|
| 3525 | + add_action('wp_ajax_wps_attribute_group_unit_add', 'add_edit_attribute_unit_group'); |
|
| 3526 | + add_action('wp_ajax_wps_attribute_group_unit_edit', 'add_edit_attribute_unit_group'); |
|
| 3527 | 3527 | |
| 3528 | 3528 | function save_new_attribute_unit_group() { |
| 3529 | - check_ajax_referer( 'save_new_attribute_unit_group' ); |
|
| 3529 | + check_ajax_referer('save_new_attribute_unit_group'); |
|
| 3530 | 3530 | $save_output = ''; |
| 3531 | 3531 | |
| 3532 | 3532 | $attribute_unit_informations['id'] = ''; |
@@ -3535,21 +3535,21 @@ discard block |
||
| 3535 | 3535 | $attribute_unit_informations['name'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']); |
| 3536 | 3536 | |
| 3537 | 3537 | $save_unit_result = wpshop_database::save($attribute_unit_informations, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 3538 | - if($save_unit_result == 'done'){ |
|
| 3538 | + if ($save_unit_result == 'done') { |
|
| 3539 | 3539 | $save_output = wpshop_attributes_unit::unit_group_list(); |
| 3540 | 3540 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The new unit group has been saved succesfully', 'wpshop'); |
| 3541 | 3541 | } |
| 3542 | - else{ |
|
| 3542 | + else { |
|
| 3543 | 3543 | $save_output = wpshop_attributes_unit::unit_group_edition(); |
| 3544 | 3544 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during new unit group saving', 'wpshop'); |
| 3545 | 3545 | } |
| 3546 | 3546 | |
| 3547 | 3547 | echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output; |
| 3548 | 3548 | } |
| 3549 | - add_action( 'wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group' ); |
|
| 3549 | + add_action('wp_ajax_wps_attribute_group_unit_new', 'save_new_attribute_unit_group'); |
|
| 3550 | 3550 | |
| 3551 | 3551 | function update_attribute_unit_group() { |
| 3552 | - check_ajax_referer( 'update_attribute_unit_group' ); |
|
| 3552 | + check_ajax_referer('update_attribute_unit_group'); |
|
| 3553 | 3553 | $save_output = ''; |
| 3554 | 3554 | |
| 3555 | 3555 | $attributeUnitId = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['id']); |
@@ -3557,70 +3557,70 @@ discard block |
||
| 3557 | 3557 | $attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s'); |
| 3558 | 3558 | $attribute_unit_informations['name'] = wpshop_tools::varSanitizer($_POST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP]['name']); |
| 3559 | 3559 | |
| 3560 | - $save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
|
| 3561 | - if($save_unit_result == 'done'){ |
|
| 3560 | + $save_unit_result = wpshop_database::update($attribute_unit_informations, $attributeUnitId, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
|
| 3561 | + if ($save_unit_result == 'done') { |
|
| 3562 | 3562 | $save_output = wpshop_attributes_unit::unit_group_list(); |
| 3563 | 3563 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action successful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been saved succesfully', 'wpshop'); |
| 3564 | 3564 | } |
| 3565 | - else{ |
|
| 3565 | + else { |
|
| 3566 | 3566 | $save_output = wpshop_attributes_unit::unit_group_edition($attributeUnitId); |
| 3567 | 3567 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group saving', 'wpshop'); |
| 3568 | 3568 | } |
| 3569 | 3569 | |
| 3570 | 3570 | echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . $save_output; |
| 3571 | 3571 | } |
| 3572 | - add_action( 'wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group' ); |
|
| 3572 | + add_action('wp_ajax_wps_attribute_group_unit_update', 'update_attribute_unit_group'); |
|
| 3573 | 3573 | |
| 3574 | 3574 | function delete_attribute_unit_group() { |
| 3575 | - check_ajax_referer( 'delete_attribute_unit_group' ); |
|
| 3575 | + check_ajax_referer('delete_attribute_unit_group'); |
|
| 3576 | 3576 | $unit_id = wpshop_tools::varSanitizer($_REQUEST['elementIdentifier']); |
| 3577 | 3577 | $save_output = ''; |
| 3578 | 3578 | |
| 3579 | 3579 | $attribute_unit_informations['status'] = 'deleted'; |
| 3580 | 3580 | $attribute_unit_informations['last_update_date'] = date('Y-m-d H:i:s'); |
| 3581 | 3581 | $save_unit_result = wpshop_database::update($attribute_unit_informations, $unit_id, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 3582 | - if($save_unit_result == 'done'){ |
|
| 3582 | + if ($save_unit_result == 'done') { |
|
| 3583 | 3583 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action succesful" src="' . WPSHOP_SUCCES_ICON . '" />' . __('The unit group has been deleted succesfully', 'wpshop'); |
| 3584 | 3584 | } |
| 3585 | - else{ |
|
| 3585 | + else { |
|
| 3586 | 3586 | $save_message = '<img class="wpshopPageMessage_Icon" alt="action error" src="' . WPSHOP_ERROR_ICON . '" />' . __('An error occured during unit group deletion', 'wpshop'); |
| 3587 | 3587 | } |
| 3588 | 3588 | |
| 3589 | 3589 | echo '<script type="text/javascript" >wpshop(document).ready(function(){setTimeout(function(){ wpshop("#wpshopMessage_unit").removeClass("wpshopPageMessage_Updated"); wpshop("#wpshopMessage_unit").html(""); }, 5000);});</script><div class="fade below-h2 wpshopPageMessage wpshopPageMessage_Updated" id="wpshopMessage_unit">' . $save_message . '</div>' . wpshop_attributes_unit::unit_group_list(); |
| 3590 | 3590 | } |
| 3591 | - add_action( 'wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group' ); |
|
| 3591 | + add_action('wp_ajax_wps_attribute_group_unit_delete', 'delete_attribute_unit_group'); |
|
| 3592 | 3592 | |
| 3593 | 3593 | function products_by_criteria() { |
| 3594 | 3594 | // If a filter by attribute is found, recalcul the products that matching it |
| 3595 | - if(!empty($_REQUEST['attr'])) { |
|
| 3596 | - $att = explode(':',$_REQUEST['attr']); |
|
| 3597 | - $products_id = wpshop_products::get_products_matching_attribute($att[0],$att[1]); |
|
| 3595 | + if (!empty($_REQUEST['attr'])) { |
|
| 3596 | + $att = explode(':', $_REQUEST['attr']); |
|
| 3597 | + $products_id = wpshop_products::get_products_matching_attribute($att[0], $att[1]); |
|
| 3598 | 3598 | } |
| 3599 | 3599 | $products_id = !empty($products_id) ? $products_id : $_REQUEST['pid']; |
| 3600 | 3600 | $page_number = $_REQUEST['page_number']; |
| 3601 | 3601 | |
| 3602 | 3602 | |
| 3603 | - if ( !empty($_GET['page_product']) ) { |
|
| 3603 | + if (!empty($_GET['page_product'])) { |
|
| 3604 | 3604 | $page_number = wpshop_tools::varSanitizer($_GET['page_product']); |
| 3605 | 3605 | } |
| 3606 | 3606 | $data = wpshop_products::wpshop_get_product_by_criteria( |
| 3607 | 3607 | $_REQUEST['criteria'], $_REQUEST['cid'], $products_id, $_REQUEST['display_type'], $_REQUEST['order'], $page_number, $_REQUEST['products_per_page'] |
| 3608 | 3608 | ); |
| 3609 | - if($data[0]) { |
|
| 3609 | + if ($data[0]) { |
|
| 3610 | 3610 | echo json_encode(array(true, do_shortcode($data[1]))); |
| 3611 | - } else echo json_encode(array(false,__('No product found','wpshop'))); |
|
| 3611 | + } else echo json_encode(array(false, __('No product found', 'wpshop'))); |
|
| 3612 | 3612 | } |
| 3613 | - add_action( 'wp_ajax_wps_products_by_criteria', 'products_by_criteria' ); |
|
| 3613 | + add_action('wp_ajax_wps_products_by_criteria', 'products_by_criteria'); |
|
| 3614 | 3614 | |
| 3615 | 3615 | function ajax_sendMessage() { |
| 3616 | - check_ajax_referer( 'sendMessage' ); |
|
| 3616 | + check_ajax_referer('sendMessage'); |
|
| 3617 | 3617 | |
| 3618 | 3618 | if (!empty($_REQUEST['postid']) && !empty($_REQUEST['title']) && !empty($_REQUEST['message']) && !empty($_REQUEST['recipient'])) { |
| 3619 | 3619 | |
| 3620 | 3620 | $user_info = get_userdata($_REQUEST['recipient']); |
| 3621 | 3621 | $first_name = $user_info->user_firstname; |
| 3622 | 3622 | $last_name = $user_info->user_lastname; |
| 3623 | - $data = array('customer_first_name'=>$first_name,'customer_last_name'=>$last_name); |
|
| 3623 | + $data = array('customer_first_name'=>$first_name, 'customer_last_name'=>$last_name); |
|
| 3624 | 3624 | |
| 3625 | 3625 | $wps_message_ctr = new wps_message_ctr(); |
| 3626 | 3626 | |
@@ -3629,75 +3629,75 @@ discard block |
||
| 3629 | 3629 | $message = $wps_message_ctr->customMessage($_REQUEST['message'], $data); |
| 3630 | 3630 | |
| 3631 | 3631 | if (!empty($user_info->user_email)) { |
| 3632 | - $wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save=true, $model_id=$_REQUEST['postid'], $object=array()); |
|
| 3632 | + $wps_message_ctr->wpshop_email($user_info->user_email, $title, $message, $save = true, $model_id = $_REQUEST['postid'], $object = array()); |
|
| 3633 | 3633 | $array = array('result' => true, 'message' => ''); |
| 3634 | 3634 | } |
| 3635 | - else $array = array('result' => true, 'message' => __('An error occured','wpshop')); |
|
| 3635 | + else $array = array('result' => true, 'message' => __('An error occured', 'wpshop')); |
|
| 3636 | 3636 | } |
| 3637 | 3637 | else { |
| 3638 | - $array = array('result' => false, 'message' => __('An error occured','wpshop')); |
|
| 3638 | + $array = array('result' => false, 'message' => __('An error occured', 'wpshop')); |
|
| 3639 | 3639 | } |
| 3640 | 3640 | |
| 3641 | 3641 | echo json_encode($array); |
| 3642 | 3642 | } |
| 3643 | - add_action( 'wp_ajax_wps_ajax_send_message', 'ajax_sendMessage' ); |
|
| 3643 | + add_action('wp_ajax_wps_ajax_send_message', 'ajax_sendMessage'); |
|
| 3644 | 3644 | |
| 3645 | 3645 | function ajax_resendMessage() { |
| 3646 | - check_ajax_referer( 'resendMessage' ); |
|
| 3646 | + check_ajax_referer('resendMessage'); |
|
| 3647 | 3647 | |
| 3648 | 3648 | if (!empty($_REQUEST['messageid'])) { |
| 3649 | 3649 | |
| 3650 | - $ids = explode('-',$_REQUEST['messageid']); |
|
| 3650 | + $ids = explode('-', $_REQUEST['messageid']); |
|
| 3651 | 3651 | $postid = $ids[0]; |
| 3652 | - $date = $ids[1].'-'.$ids[2]; |
|
| 3652 | + $date = $ids[1] . '-' . $ids[2]; |
|
| 3653 | 3653 | $arraykey = $ids[3]; |
| 3654 | 3654 | |
| 3655 | - $historic = get_post_meta($postid, 'wpshop_messages_histo_'.$date, true); |
|
| 3655 | + $historic = get_post_meta($postid, 'wpshop_messages_histo_' . $date, true); |
|
| 3656 | 3656 | |
| 3657 | 3657 | if (isset($historic[$arraykey])) { |
| 3658 | 3658 | $historic[$arraykey]['mess_dispatch_date'][] = current_time('mysql', 0); |
| 3659 | - update_post_meta($postid, 'wpshop_messages_histo_'.$date, $historic); |
|
| 3659 | + update_post_meta($postid, 'wpshop_messages_histo_' . $date, $historic); |
|
| 3660 | 3660 | |
| 3661 | 3661 | $data = $historic[$arraykey]; |
| 3662 | 3662 | $wps_message_ctr = new wps_message_ctr(); |
| 3663 | - $wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save=false, $object=array()); |
|
| 3663 | + $wps_message_ctr->wpshop_email($data['mess_user_email'], $data['mess_title'], $data['mess_message'], $save = false, $object = array()); |
|
| 3664 | 3664 | |
| 3665 | 3665 | $array = array('result' => true, 'message' => ''); |
| 3666 | 3666 | } |
| 3667 | 3667 | else { |
| 3668 | - $array = array('result' => false, 'message' => __('An error occured','wpshop')); |
|
| 3668 | + $array = array('result' => false, 'message' => __('An error occured', 'wpshop')); |
|
| 3669 | 3669 | } |
| 3670 | 3670 | } |
| 3671 | 3671 | else { |
| 3672 | - $array = array('result' => false, 'message' => __('An error occured','wpshop')); |
|
| 3672 | + $array = array('result' => false, 'message' => __('An error occured', 'wpshop')); |
|
| 3673 | 3673 | } |
| 3674 | 3674 | |
| 3675 | 3675 | echo json_encode($array); |
| 3676 | 3676 | } |
| 3677 | - add_action( 'wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage' ); |
|
| 3677 | + add_action('wp_ajax_wps_ajax_resend_message', 'ajax_resendMessage'); |
|
| 3678 | 3678 | |
| 3679 | 3679 | function related_products() { |
| 3680 | - check_ajax_referer( 'related_products' ); |
|
| 3680 | + check_ajax_referer('related_products'); |
|
| 3681 | 3681 | $data = wpshop_products::product_list(false, $_REQUEST['search']); |
| 3682 | - $array=array(); |
|
| 3682 | + $array = array(); |
|
| 3683 | 3683 | foreach ($data as $d) { |
| 3684 | 3684 | $array[] = array('id' => $d->ID, 'name' => $d->post_title); |
| 3685 | 3685 | } |
| 3686 | 3686 | echo json_encode($array); |
| 3687 | 3687 | } |
| 3688 | - add_action( 'wp_ajax_wps_related_products', 'related_products' ); |
|
| 3688 | + add_action('wp_ajax_wps_related_products', 'related_products'); |
|
| 3689 | 3689 | |
| 3690 | 3690 | function applyCoupon() { |
| 3691 | - check_ajax_referer( 'applyCoupon' ); |
|
| 3691 | + check_ajax_referer('applyCoupon'); |
|
| 3692 | 3692 | $wps_coupon_ctr = new wps_coupon_ctr(); |
| 3693 | 3693 | $result = $wps_coupon_ctr->applyCoupon($_REQUEST['coupon_code']); |
| 3694 | - if ($result['status']===true) { |
|
| 3694 | + if ($result['status'] === true) { |
|
| 3695 | 3695 | $wps_cart_ctr = new wps_cart(); |
| 3696 | 3696 | $order = $wps_cart_ctr->calcul_cart_information(array()); |
| 3697 | 3697 | $wps_cart_ctr->store_cart_in_session($order); |
| 3698 | 3698 | echo json_encode(array(true, '')); |
| 3699 | 3699 | } else echo json_encode(array(false, $result['message'])); |
| 3700 | 3700 | } |
| 3701 | - add_action( 'wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon' ); |
|
| 3701 | + add_action('wp_ajax_wps_cart_action_apply_coupon', 'applyCoupon'); |
|
| 3702 | 3702 | |
| 3703 | 3703 | ?> |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /*************************** LOAD THE BASE CLASS ******************************* |
| 19 | 19 | *******************************************************************************/ |
| 20 | 20 | |
| 21 | -include_once( WPSHOP_DIR . '/core/module_management/module_management.php'); |
|
| 21 | +include_once(WPSHOP_DIR . '/core/module_management/module_management.php'); |
|
| 22 | 22 | |
| 23 | 23 | include_once(WPSHOP_INCLUDES_DIR . 'wpshop_ajax.php'); |
| 24 | 24 | |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/payment.class.php'); |
| 45 | 45 | include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/paypal.class.php'); |
| 46 | 46 | // If the CIC payment method is active |
| 47 | -$wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 48 | -if ( WPSHOP_PAYMENT_METHOD_CIC && !empty($wpshop_paymentMethod) && !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) ) { |
|
| 47 | +$wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 48 | +if (WPSHOP_PAYMENT_METHOD_CIC && !empty($wpshop_paymentMethod) && !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) { |
|
| 49 | 49 | include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/cic.class.php'); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /* Display management */ |
| 53 | -if ( !class_exists('WP_List_Table') ) { |
|
| 54 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
| 53 | +if (!class_exists('WP_List_Table')) { |
|
| 54 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
| 55 | 55 | } |
| 56 | 56 | include_once(WPSHOP_LIBRAIRIES_DIR . 'display/display.class.php'); |
| 57 | 57 | |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
| 4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * WPShop Statistics bootstrap file |
| 4 | 4 | * @author Jérôme ALLEGRE - Eoxia dev team <[email protected]> |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | * @subpackage modules |
| 8 | 8 | * |
| 9 | 9 | */ |
| 10 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 11 | - die( __("You are not allowed to use this service.", 'wpshop') ); |
|
| 10 | +if (!defined('WPSHOP_VERSION')) { |
|
| 11 | + die(__("You are not allowed to use this service.", 'wpshop')); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** */ |
| 15 | -DEFINE( 'WPS_STATISTICS_VERSION', '1.0.1' ); |
|
| 16 | -DEFINE( 'WPS_STATISTICS_DIR', basename(dirname(__FILE__))); |
|
| 17 | -DEFINE( 'WPS_STATISTICS_PATH', dirname( __FILE__ ) ); |
|
| 18 | -DEFINE( 'WPS_STATISTICS_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', str_replace( "\\", "/", WPS_STATISTICS_PATH ) ) ); |
|
| 15 | +DEFINE('WPS_STATISTICS_VERSION', '1.0.1'); |
|
| 16 | +DEFINE('WPS_STATISTICS_DIR', basename(dirname(__FILE__))); |
|
| 17 | +DEFINE('WPS_STATISTICS_PATH', dirname(__FILE__)); |
|
| 18 | +DEFINE('WPS_STATISTICS_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', str_replace("\\", "/", WPS_STATISTICS_PATH))); |
|
| 19 | 19 | |
| 20 | 20 | /** Define the templates directories */ |
| 21 | -DEFINE( 'WPS_STATISTICS_TEMPLATES_MAIN_DIR', WPS_STATISTICS_PATH . '/templates/'); |
|
| 21 | +DEFINE('WPS_STATISTICS_TEMPLATES_MAIN_DIR', WPS_STATISTICS_PATH . '/templates/'); |
|
| 22 | 22 | |
| 23 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_statistics_ctr.php' ); |
|
| 24 | -include( plugin_dir_path( __FILE__ ).'/model/wps_statisticsmdl.php' ); |
|
| 23 | +include(plugin_dir_path(__FILE__) . '/controller/wps_statistics_ctr.php'); |
|
| 24 | +include(plugin_dir_path(__FILE__) . '/model/wps_statisticsmdl.php'); |
|
| 25 | 25 | |
| 26 | 26 | $wps_statistics_ctr = new wps_statistics_ctr(); |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
| 4 | 6 | * |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 2 | - if( !empty($orders_status) ) : ?> |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | + if (!empty($orders_status)) : ?> |
|
| 3 | 3 | <canvas id="wps_orders_status" width="" height=""></canvas> |
| 4 | 4 | <script type="text/javascript"> |
| 5 | 5 | jQuery( document ).ready( function() { |
| 6 | 6 | var pieData2 = [ |
| 7 | -<?php foreach( $orders_status as $status => $count ) : ?> |
|
| 7 | +<?php foreach ($orders_status as $status => $count) : ?> |
|
| 8 | 8 | {value: <?php echo $count; ?>, color:"<?php echo $colors[strtolower($status)]; ?>"}, |
| 9 | 9 | <?php endforeach; ?> |
| 10 | 10 | ]; |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | }); |
| 13 | 13 | </script> |
| 14 | 14 | <ul class="wps_statistics_legend"> |
| 15 | - <?php foreach( $orders_status as $status => $count ) : ?> |
|
| 16 | - <li><span style="background : <?php echo $colors[strtolower($status)]; ?>;" class="legend_indicator"></span><span><?php _e($payment_status[ strtolower($status) ], 'wpshop' ); ?> (<?php echo $count; ?>)</span></li> |
|
| 15 | + <?php foreach ($orders_status as $status => $count) : ?> |
|
| 16 | + <li><span style="background : <?php echo $colors[strtolower($status)]; ?>;" class="legend_indicator"></span><span><?php _e($payment_status[strtolower($status)], 'wpshop'); ?> (<?php echo $count; ?>)</span></li> |
|
| 17 | 17 | <?php endforeach; ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php else : ?> |
| 20 | -<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop' ); ?></div> |
|
| 20 | +<div class="wps-alert-info"><?php _e('No order have been created', 'wpshop'); ?></div> |
|
| 21 | 21 | <?php endif; ?> |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | if( !empty($orders_status) ) : ?> |
| 3 | 5 | <canvas id="wps_orders_status" width="" height=""></canvas> |
| 4 | 6 | <script type="text/javascript"> |
@@ -16,6 +18,9 @@ discard block |
||
| 16 | 18 | <li><span style="background : <?php echo $colors[strtolower($status)]; ?>;" class="legend_indicator"></span><span><?php _e($payment_status[ strtolower($status) ], 'wpshop' ); ?> (<?php echo $count; ?>)</span></li> |
| 17 | 19 | <?php endforeach; ?> |
| 18 | 20 | </ul> |
| 19 | -<?php else : ?> |
|
| 20 | -<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop' ); ?></div> |
|
| 21 | +<?php else { |
|
| 22 | + : ?> |
|
| 23 | +<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop' ); |
|
| 24 | +} |
|
| 25 | +?></div> |
|
| 21 | 26 | <?php endif; ?> |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | ?> |
| 3 | 3 | <script type="text/javascript"> |
| 4 | 4 | jQuery( document ).ready( function() { |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | jQuery( 'canvas' ).attr( 'height', ( parseInt( jQuery( '.meta-box-sortables' ).width() ) * 0.5 ) ); |
| 7 | 7 | }); |
| 8 | 8 | </script> |
| 9 | -<?php if( !empty($products) ) : ?> |
|
| 9 | +<?php if (!empty($products)) : ?> |
|
| 10 | 10 | <script type="text/javascript"> |
| 11 | 11 | jQuery( document ).ready( function() { |
| 12 | 12 | jQuery( 'canvas' ).attr( 'width', parseInt( jQuery( '.meta-box-sortables' ).width() ) ); |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | var pieData = [ |
| 20 | 20 | <?php |
| 21 | 21 | $i = 0; |
| 22 | - if( !empty($products) ) : |
|
| 23 | - foreach( $products as $product ) : |
|
| 24 | - if ( $i < 8 ) : |
|
| 25 | - echo '{value:' .$product. ', color:"' .$colors[$i]. '"},'; |
|
| 22 | + if (!empty($products)) : |
|
| 23 | + foreach ($products as $product) : |
|
| 24 | + if ($i < 8) : |
|
| 25 | + echo '{value:' . $product . ', color:"' . $colors[$i] . '"},'; |
|
| 26 | 26 | $i++; |
| 27 | 27 | endif; |
| 28 | 28 | endforeach; |
@@ -34,22 +34,22 @@ discard block |
||
| 34 | 34 | </script> |
| 35 | 35 | <!-- Display Legend --> |
| 36 | 36 | <ul class="wps_statistics_legend"> |
| 37 | - <?php if( !empty($products) ) : |
|
| 37 | + <?php if (!empty($products)) : |
|
| 38 | 38 | $i = 0; |
| 39 | - foreach( $products as $item_id => $product ) : |
|
| 40 | - if ( $i < 8 ) : |
|
| 41 | - $product_type = get_post_type( $item_id ); |
|
| 42 | - if ( $product_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) : |
|
| 43 | - $product_name = get_the_title( $item_id ); |
|
| 39 | + foreach ($products as $item_id => $product) : |
|
| 40 | + if ($i < 8) : |
|
| 41 | + $product_type = get_post_type($item_id); |
|
| 42 | + if ($product_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) : |
|
| 43 | + $product_name = get_the_title($item_id); |
|
| 44 | 44 | else : |
| 45 | - $parent_def = wpshop_products::get_parent_variation( $item_id ); |
|
| 46 | - if ( !empty($parent_def) && !empty($parent_def['parent_post']) ) : |
|
| 45 | + $parent_def = wpshop_products::get_parent_variation($item_id); |
|
| 46 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) : |
|
| 47 | 47 | $parent_post = $parent_def['parent_post']; |
| 48 | 48 | $product_name = $parent_post->post_title; |
| 49 | 49 | endif; |
| 50 | 50 | endif; |
| 51 | 51 | ?> |
| 52 | - <li><span style="background :<?php echo $colors[$i]; ?>;" class="legend_indicator"></span><span><a href="<?php echo admin_url('post.php?post=' . $item_id. '&action=edit'); ?>"><?php echo ( !empty($product_name) ) ? $product_name : __( 'Deleted product', 'wpshop') ; ?></a> (<?php printf( __('%s items', 'wpshop'), $product); ?>)</span></li> |
|
| 52 | + <li><span style="background :<?php echo $colors[$i]; ?>;" class="legend_indicator"></span><span><a href="<?php echo admin_url('post.php?post=' . $item_id . '&action=edit'); ?>"><?php echo (!empty($product_name)) ? $product_name : __('Deleted product', 'wpshop'); ?></a> (<?php printf(__('%s items', 'wpshop'), $product); ?>)</span></li> |
|
| 53 | 53 | <?php |
| 54 | 54 | $i++; |
| 55 | 55 | endif; |
@@ -58,5 +58,5 @@ discard block |
||
| 58 | 58 | ?> |
| 59 | 59 | </ul> |
| 60 | 60 | <?php else : ?> |
| 61 | -<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop'); ?></div> |
|
| 61 | +<div class="wps-alert-info"><?php _e('No order have been created', 'wpshop'); ?></div> |
|
| 62 | 62 | <?php endif; ?> |
| 63 | 63 | \ No newline at end of file |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | ?> |
| 3 | 5 | <script type="text/javascript"> |
| 4 | 6 | jQuery( document ).ready( function() { |
@@ -41,8 +43,10 @@ discard block |
||
| 41 | 43 | $product_type = get_post_type( $item_id ); |
| 42 | 44 | if ( $product_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) : |
| 43 | 45 | $product_name = get_the_title( $item_id ); |
| 44 | - else : |
|
| 46 | + else { |
|
| 47 | + : |
|
| 45 | 48 | $parent_def = wpshop_products::get_parent_variation( $item_id ); |
| 49 | + } |
|
| 46 | 50 | if ( !empty($parent_def) && !empty($parent_def['parent_post']) ) : |
| 47 | 51 | $parent_post = $parent_def['parent_post']; |
| 48 | 52 | $product_name = $parent_post->post_title; |
@@ -57,6 +61,9 @@ discard block |
||
| 57 | 61 | endif; |
| 58 | 62 | ?> |
| 59 | 63 | </ul> |
| 60 | -<?php else : ?> |
|
| 61 | -<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop'); ?></div> |
|
| 64 | +<?php else { |
|
| 65 | + : ?> |
|
| 66 | +<div class="wps-alert-info"><?php _e( 'No order have been created', 'wpshop'); |
|
| 67 | +} |
|
| 68 | +?></div> |
|
| 62 | 69 | <?php endif; ?> |
| 63 | 70 | \ No newline at end of file |