@@ -46,6 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Get the url listing slug of the current class |
| 48 | 48 | * |
| 49 | + * @param string $message |
|
| 49 | 50 | * @return string The table of the class |
| 50 | 51 | */ |
| 51 | 52 | function setMessage($message){ |
@@ -1244,7 +1245,7 @@ discard block |
||
| 1244 | 1245 | * |
| 1245 | 1246 | * @param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned |
| 1246 | 1247 | * @param string $element_status optionnal The status of element to get into database. Default is set to valid element |
| 1247 | - * @param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 1248 | + * @param string $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 1248 | 1249 | * |
| 1249 | 1250 | * @return object $element_list A wordpress database object containing the attribute list |
| 1250 | 1251 | */ |
@@ -1484,9 +1485,6 @@ discard block |
||
| 1484 | 1485 | * Get the existing element list into database |
| 1485 | 1486 | * |
| 1486 | 1487 | * @param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned |
| 1487 | - * @param string $elementStatus optionnal The status of element to get into database. Default is set to valid element |
|
| 1488 | - * |
|
| 1489 | - * @return object $elements A wordpress database object containing the element list |
|
| 1490 | 1488 | */ |
| 1491 | 1489 | public static function getElementWithAttributeAndValue($entityId, $elementId, $language, $keyForArray = '', $outputType = '') { |
| 1492 | 1490 | global $wpdb; |
@@ -1625,7 +1623,7 @@ discard block |
||
| 1625 | 1623 | /** |
| 1626 | 1624 | * Traduit le shortcode et affiche la valeur d'un attribut donn� |
| 1627 | 1625 | * @param array $atts : tableau de param�tre du shortcode |
| 1628 | - * @return mixed |
|
| 1626 | + * @return string|null |
|
| 1629 | 1627 | **/ |
| 1630 | 1628 | public static function wpshop_att_val_func($atts) { |
| 1631 | 1629 | global $wpdb; |
@@ -1914,7 +1912,7 @@ discard block |
||
| 1914 | 1912 | |
| 1915 | 1913 | /** |
| 1916 | 1914 | * |
| 1917 | - * @param array $attribute_list |
|
| 1915 | + * @param array $attribute_code |
|
| 1918 | 1916 | * @param string $output_from |
| 1919 | 1917 | * @return string The output for |
| 1920 | 1918 | */ |
@@ -2455,6 +2453,12 @@ discard block |
||
| 2455 | 2453 | return $affected_value; |
| 2456 | 2454 | } |
| 2457 | 2455 | |
| 2456 | + /** |
|
| 2457 | + * @param string $attr_code |
|
| 2458 | + * @param string $attr_option |
|
| 2459 | + * |
|
| 2460 | + * @return string |
|
| 2461 | + */ |
|
| 2458 | 2462 | public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') { |
| 2459 | 2463 | switch($attr_code){ |
| 2460 | 2464 | case 'is_downloadable_': |
@@ -3187,7 +3191,6 @@ discard block |
||
| 3187 | 3191 | * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option |
| 3188 | 3192 | * |
| 3189 | 3193 | * @param string $column_name The column name for output type definition |
| 3190 | - * @param string $post_type The current |
|
| 3191 | 3194 | * |
| 3192 | 3195 | */ |
| 3193 | 3196 | function quick_edit( $column_name, $entity ) { |
@@ -3212,7 +3215,6 @@ discard block |
||
| 3212 | 3215 | * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option |
| 3213 | 3216 | * |
| 3214 | 3217 | * @param string $column_name The column name for output type definition |
| 3215 | - * @param string $post_type The current |
|
| 3216 | 3218 | * |
| 3217 | 3219 | */ |
| 3218 | 3220 | public static function bulk_edit( $column_name, $entity ) { |
@@ -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,7 +20,7 @@ discard block |
||
| 20 | 20 | * @package wpshop |
| 21 | 21 | * @subpackage librairies |
| 22 | 22 | */ |
| 23 | -class wpshop_attributes{ |
|
| 23 | +class wpshop_attributes { |
|
| 24 | 24 | /* Define the database table used in the current class */ |
| 25 | 25 | const dbTable = WPSHOP_DBT_ATTRIBUTE; |
| 26 | 26 | /* Define the url listing slug used in the current class */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string The table of the class |
| 52 | 52 | */ |
| 53 | - function setMessage($message){ |
|
| 53 | + function setMessage($message) { |
|
| 54 | 54 | $this->pageMessage = $message; |
| 55 | 55 | } |
| 56 | 56 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @return string The table of the class |
| 60 | 60 | */ |
| 61 | - function getListingSlug(){ |
|
| 61 | + function getListingSlug() { |
|
| 62 | 62 | return self::urlSlugListing; |
| 63 | 63 | } |
| 64 | 64 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return string The table of the class |
| 68 | 68 | */ |
| 69 | - function getEditionSlug(){ |
|
| 69 | + function getEditionSlug() { |
|
| 70 | 70 | return self::urlSlugEdition; |
| 71 | 71 | } |
| 72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return string The table of the class |
| 76 | 76 | */ |
| 77 | - public static function getDbTable(){ |
|
| 77 | + public static function getDbTable() { |
|
| 78 | 78 | return self::dbTable; |
| 79 | 79 | } |
| 80 | 80 | /** |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return string $title The title of the page looking at the environnement |
| 84 | 84 | */ |
| 85 | - function pageTitle(){ |
|
| 85 | + function pageTitle() { |
|
| 86 | 86 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 87 | 87 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 88 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
| 88 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
| 89 | 89 | |
| 90 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 91 | - if($action != ''){ |
|
| 92 | - if(($action == 'edit') || ($action == 'delete')){ |
|
| 90 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 91 | + if ($action != '') { |
|
| 92 | + if (($action == 'edit') || ($action == 'delete')) { |
|
| 93 | 93 | $editedItem = self::getElement($objectInEdition); |
| 94 | 94 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label)); |
| 95 | 95 | } |
| 96 | - elseif($action == 'add') |
|
| 96 | + elseif ($action == 'add') |
|
| 97 | 97 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 98 | 98 | } |
| 99 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 99 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 100 | 100 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 101 | 101 | |
| 102 | 102 | return $title; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * Define the different message and action after an action is send through the element interface |
| 107 | 107 | */ |
| 108 | - function elementAction(){ |
|
| 108 | + function elementAction() { |
|
| 109 | 109 | global $wpdb, $initialEavData; |
| 110 | 110 | |
| 111 | 111 | $pageMessage = $actionResult = ''; |
@@ -118,75 +118,75 @@ discard block |
||
| 118 | 118 | $saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : ''; |
| 119 | 119 | $set_section = !empty($_REQUEST[self::getDbTable()]['set_section']) ? sanitize_text_field($_REQUEST[self::getDbTable()]['set_section']) : ''; |
| 120 | 120 | //@TODO $_REQUEST |
| 121 | - $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null; |
|
| 122 | - if(!empty($action) && ($action=='activate') ){ |
|
| 123 | - if( isset($id) ) { |
|
| 121 | + $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : null; |
|
| 122 | + if (!empty($action) && ($action == 'activate')) { |
|
| 123 | + if (isset($id)) { |
|
| 124 | 124 | $query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>$id)); |
| 125 | 125 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
|
| 128 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) { |
|
| 129 | 129 | $editedElement = self::getElement($saveditem); |
| 130 | 130 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 131 | 131 | } |
| 132 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 132 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) { |
|
| 133 | 133 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 134 | 134 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 138 | - if ( !empty($set_section) ) unset($attribute_parameter['set_section']); |
|
| 137 | + $attribute_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 138 | + if (!empty($set_section)) unset($attribute_parameter['set_section']); |
|
| 139 | 139 | |
| 140 | 140 | $wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array(); |
| 141 | 141 | // @TODO $_REQUEST |
| 142 | 142 | // unset($_REQUEST[self::getDbTable()]['wpshop_attribute_combo_values_list_order_def']); |
| 143 | 143 | |
| 144 | - if(!isset($attribute_parameter['status'])){ |
|
| 144 | + if (!isset($attribute_parameter['status'])) { |
|
| 145 | 145 | $attribute_parameter['status'] = 'moderated'; |
| 146 | 146 | } |
| 147 | - if(!isset($attribute_parameter['is_historisable'])){ |
|
| 147 | + if (!isset($attribute_parameter['is_historisable'])) { |
|
| 148 | 148 | $attribute_parameter['is_historisable'] = 'no'; |
| 149 | 149 | } |
| 150 | - if(!isset($attribute_parameter['is_required'])){ |
|
| 150 | + if (!isset($attribute_parameter['is_required'])) { |
|
| 151 | 151 | $attribute_parameter['is_required'] = 'no'; |
| 152 | 152 | } |
| 153 | - if(!isset($attribute_parameter['is_used_in_admin_listing_column'])){ |
|
| 153 | + if (!isset($attribute_parameter['is_used_in_admin_listing_column'])) { |
|
| 154 | 154 | $attribute_parameter['is_used_in_admin_listing_column'] = 'no'; |
| 155 | 155 | } |
| 156 | - if(!isset($attribute_parameter['is_used_in_quick_add_form'])){ |
|
| 156 | + if (!isset($attribute_parameter['is_used_in_quick_add_form'])) { |
|
| 157 | 157 | $attribute_parameter['is_used_in_quick_add_form'] = 'no'; |
| 158 | 158 | } |
| 159 | - if(!isset($attribute_parameter['is_intrinsic'])){ |
|
| 159 | + if (!isset($attribute_parameter['is_intrinsic'])) { |
|
| 160 | 160 | $attribute_parameter['is_intrinsic'] = 'no'; |
| 161 | 161 | } |
| 162 | - if(!isset($attribute_parameter['is_requiring_unit'])){ |
|
| 162 | + if (!isset($attribute_parameter['is_requiring_unit'])) { |
|
| 163 | 163 | $attribute_parameter['is_requiring_unit'] = 'no'; |
| 164 | 164 | } |
| 165 | - if(!isset($attribute_parameter['is_visible_in_front'])){ |
|
| 165 | + if (!isset($attribute_parameter['is_visible_in_front'])) { |
|
| 166 | 166 | $attribute_parameter['is_visible_in_front'] = 'no'; |
| 167 | 167 | } |
| 168 | - if(!isset($attribute_parameter['is_visible_in_front_listing'])){ |
|
| 168 | + if (!isset($attribute_parameter['is_visible_in_front_listing'])) { |
|
| 169 | 169 | $attribute_parameter['is_visible_in_front_listing'] = 'no'; |
| 170 | 170 | } |
| 171 | - if(!isset($attribute_parameter['is_used_for_sort_by'])){ |
|
| 171 | + if (!isset($attribute_parameter['is_used_for_sort_by'])) { |
|
| 172 | 172 | $attribute_parameter['is_used_for_sort_by'] = 'no'; |
| 173 | 173 | } |
| 174 | - if(!isset($attribute_parameter['is_visible_in_advanced_search'])){ |
|
| 174 | + if (!isset($attribute_parameter['is_visible_in_advanced_search'])) { |
|
| 175 | 175 | $attribute_parameter['is_visible_in_advanced_search'] = 'no'; |
| 176 | 176 | } |
| 177 | - if(!isset($attribute_parameter['is_searchable'])){ |
|
| 177 | + if (!isset($attribute_parameter['is_searchable'])) { |
|
| 178 | 178 | $attribute_parameter['is_searchable'] = 'no'; |
| 179 | 179 | } |
| 180 | - if(!isset($attribute_parameter['is_used_for_variation'])){ |
|
| 180 | + if (!isset($attribute_parameter['is_used_for_variation'])) { |
|
| 181 | 181 | $attribute_parameter['is_used_for_variation'] = 'no'; |
| 182 | 182 | } |
| 183 | - if(!isset($attribute_parameter['is_used_in_variation'])){ |
|
| 183 | + if (!isset($attribute_parameter['is_used_in_variation'])) { |
|
| 184 | 184 | $attribute_parameter['is_used_in_variation'] = 'no'; |
| 185 | 185 | } |
| 186 | - if(!isset($attribute_parameter['is_user_defined'])){ |
|
| 186 | + if (!isset($attribute_parameter['is_user_defined'])) { |
|
| 187 | 187 | $attribute_parameter['is_user_defined'] = 'no'; |
| 188 | 188 | } |
| 189 | - if(!isset($attribute_parameter['_display_informations_about_value'])){ |
|
| 189 | + if (!isset($attribute_parameter['_display_informations_about_value'])) { |
|
| 190 | 190 | $attribute_parameter['_display_informations_about_value'] = 'no'; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -195,58 +195,58 @@ discard block |
||
| 195 | 195 | switch ($attribute_parameter['frontend_input']) { |
| 196 | 196 | case 'short_text': |
| 197 | 197 | $attribute_parameter['frontend_input'] = 'text'; |
| 198 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 198 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 199 | 199 | $attribute_parameter['data_type'] = 'varchar'; |
| 200 | 200 | break; |
| 201 | 201 | case 'date_field': |
| 202 | 202 | $attribute_parameter['frontend_input'] = 'text'; |
| 203 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 203 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 204 | 204 | $attribute_parameter['data_type'] = 'datetime'; |
| 205 | 205 | break; |
| 206 | 206 | case 'float_field': |
| 207 | 207 | $attribute_parameter['frontend_input'] = 'text'; |
| 208 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 208 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 209 | 209 | $attribute_parameter['data_type'] = 'decimal'; |
| 210 | 210 | break; |
| 211 | 211 | case 'hidden_field': |
| 212 | 212 | $attribute_parameter['frontend_input'] = 'hidden'; |
| 213 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 213 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 214 | 214 | $attribute_parameter['data_type'] = 'varchar'; |
| 215 | 215 | break; |
| 216 | 216 | case 'pass_field': |
| 217 | 217 | $attribute_parameter['frontend_input'] = 'password'; |
| 218 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 218 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 219 | 219 | $attribute_parameter['data_type'] = 'varchar'; |
| 220 | 220 | break; |
| 221 | 221 | |
| 222 | 222 | case 'select': |
| 223 | 223 | $attribute_parameter['frontend_input'] = 'select'; |
| 224 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 224 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 225 | 225 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 226 | 226 | $attribute_parameter['data_type'] = 'integer'; |
| 227 | 227 | break; |
| 228 | 228 | case 'multiple-select': |
| 229 | 229 | $attribute_parameter['frontend_input'] = 'multiple-select'; |
| 230 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 230 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 231 | 231 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 232 | 232 | $attribute_parameter['data_type'] = 'integer'; |
| 233 | 233 | break; |
| 234 | 234 | case 'radio': |
| 235 | 235 | $attribute_parameter['frontend_input'] = 'radio'; |
| 236 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 236 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 237 | 237 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 238 | 238 | $attribute_parameter['data_type'] = 'integer'; |
| 239 | 239 | break; |
| 240 | 240 | case 'checkbox': |
| 241 | 241 | $attribute_parameter['frontend_input'] = 'checkbox'; |
| 242 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 242 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 243 | 243 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 244 | 244 | $attribute_parameter['data_type'] = 'integer'; |
| 245 | 245 | break; |
| 246 | 246 | |
| 247 | 247 | case 'textarea': |
| 248 | 248 | $attribute_parameter['frontend_input'] = 'textarea'; |
| 249 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 249 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 250 | 250 | $attribute_parameter['backend_input'] = 'textarea'; |
| 251 | 251 | $attribute_parameter['data_type'] = 'text'; |
| 252 | 252 | break; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | else { |
| 256 | 256 | $attribute_parameter['frontend_input'] = 'text'; |
| 257 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 257 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 258 | 258 | $attribute_parameter['data_type'] = 'varchar'; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -263,55 +263,55 @@ discard block |
||
| 263 | 263 | // $attribute_parameter['use_ajax_for_filling_field']='no'; |
| 264 | 264 | // } |
| 265 | 265 | $attribute_parameter['use_ajax_for_filling_field'] = 'yes'; |
| 266 | - if( $attribute_parameter['backend_input'] == 'multiple-select' ) { |
|
| 266 | + if ($attribute_parameter['backend_input'] == 'multiple-select') { |
|
| 267 | 267 | $attribute_parameter['is_used_for_variation'] = 'yes'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /* Define the database operation type from action launched by the user */ |
| 271 | 271 | $attribute_parameter['default_value'] = (!empty($attribute_parameter['default_value']) && is_array($attribute_parameter['default_value'])) ? serialize($attribute_parameter['default_value']) : (isset($attribute_parameter['default_value']) ? str_replace('"', "'", $attribute_parameter['default_value']) : ''); |
| 272 | - if ( $attribute_parameter['data_type'] == 'datetime' ) { |
|
| 272 | + if ($attribute_parameter['data_type'] == 'datetime') { |
|
| 273 | 273 | $date_default_value_trasform_into_config = array('default_value' => $attribute_parameter['default_value'], 'field_options' => (!empty($_POST[self::getDbTable() . '_options']) ? $_POST[self::getDbTable() . '_options'] : null)); |
| 274 | - $attribute_parameter['default_value'] = serialize( $date_default_value_trasform_into_config ); |
|
| 274 | + $attribute_parameter['default_value'] = serialize($date_default_value_trasform_into_config); |
|
| 275 | 275 | } |
| 276 | 276 | /***************************** GENERIC **************************/ |
| 277 | 277 | /*************************************************************************/ |
| 278 | - $pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 278 | + $pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 279 | 279 | $id = isset($attribute_parameter['id']) ? sanitize_key($attribute_parameter['id']) : ((!empty($_GET['id'])) ? $_GET['id'] : ''); |
| 280 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){ |
|
| 281 | - if(current_user_can('wpshop_edit_attributes')){ |
|
| 280 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) { |
|
| 281 | + if (current_user_can('wpshop_edit_attributes')) { |
|
| 282 | 282 | $attribute_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 283 | - if($pageAction == 'delete'){ |
|
| 283 | + if ($pageAction == 'delete') { |
|
| 284 | 284 | $attribute_code = $attribute_parameter['code']; |
| 285 | - if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){ |
|
| 285 | + if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) { |
|
| 286 | 286 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 287 | 287 | $attribute_code = $attribute->code; |
| 288 | 288 | } |
| 289 | - if(!in_array($attribute_code, $attribute_undeletable)){ |
|
| 290 | - if(current_user_can('wpshop_delete_attributes')){ |
|
| 289 | + if (!in_array($attribute_code, $attribute_undeletable)) { |
|
| 290 | + if (current_user_can('wpshop_delete_attributes')) { |
|
| 291 | 291 | $attribute_parameter['status'] = 'deleted'; |
| 292 | 292 | } |
| 293 | - else{ |
|
| 293 | + else { |
|
| 294 | 294 | $actionResult = 'userNotAllowedForActionDelete'; |
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | - else{ |
|
| 297 | + else { |
|
| 298 | 298 | $actionResult = 'unDeletableAtribute'; |
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
| 302 | 302 | } |
| 303 | - else{ |
|
| 303 | + else { |
|
| 304 | 304 | $actionResult = 'userNotAllowedForActionEdit'; |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 307 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 308 | 308 | $attribute_code = ''; |
| 309 | - if (empty( $attribute_parameter['code'])) { |
|
| 309 | + if (empty($attribute_parameter['code'])) { |
|
| 310 | 310 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id'); |
| 311 | 311 | $attribute_code = $attribute->code; |
| 312 | 312 | } |
| 313 | 313 | if (!in_array($attribute_code, $attribute_undeletable)) { |
| 314 | - if(current_user_can('wpshop_delete_attributes')){ |
|
| 314 | + if (current_user_can('wpshop_delete_attributes')) { |
|
| 315 | 315 | $attribute_parameter['last_update_date'] = current_time('mysql', 0); |
| 316 | 316 | $attribute_parameter['status'] = 'deleted'; |
| 317 | 317 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
@@ -322,21 +322,21 @@ discard block |
||
| 322 | 322 | else |
| 323 | 323 | $actionResult = 'unDeletableAtribute'; |
| 324 | 324 | } |
| 325 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 326 | - if(current_user_can('wpshop_add_attributes')){ |
|
| 325 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 326 | + if (current_user_can('wpshop_add_attributes')) { |
|
| 327 | 327 | $attribute_parameter['creation_date'] = current_time('mysql', 0); |
| 328 | - if(trim($attribute_parameter['code']) == ''){ |
|
| 328 | + if (trim($attribute_parameter['code']) == '') { |
|
| 329 | 329 | $attribute_parameter['code'] = $attribute_parameter['frontend_label']; |
| 330 | 330 | } |
| 331 | 331 | $attribute_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation')); |
| 332 | 332 | $code_exists = self::getElement($attribute_parameter['code'], "'valid', 'moderated', 'deleted'", 'code'); |
| 333 | - if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){ |
|
| 333 | + if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) { |
|
| 334 | 334 | $attribute_parameter['code'] = $attribute_parameter['code'] . '_' . (count($code_exists) + rand()); |
| 335 | 335 | } |
| 336 | 336 | $actionResult = wpshop_database::save($attribute_parameter, self::getDbTable()); |
| 337 | 337 | $id = $wpdb->insert_id; |
| 338 | 338 | } |
| 339 | - else{ |
|
| 339 | + else { |
|
| 340 | 340 | $actionResult = 'userNotAllowedForActionAdd'; |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 346 | 346 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 347 | 347 | /****************************************************************************/ |
| 348 | - if($actionResult != ''){ |
|
| 348 | + if ($actionResult != '') { |
|
| 349 | 349 | $elementIdentifierForMessage = __('the attribute', 'wpshop'); |
| 350 | - if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 350 | + if (!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 351 | 351 | if ($actionResult == 'error') {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 352 | 352 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error); |
| 353 | 353 | } |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | $done_options_value = array(); |
| 360 | 360 | $default_value = $attribute_parameter['default_value']; |
| 361 | 361 | $i = 1; |
| 362 | - $options = !empty($_REQUEST['options']) ? (array) $_REQUEST['options'] : array(); |
|
| 363 | - $optionsValue = !empty($_REQUEST['optionsValue']) ? (array) $_REQUEST['optionsValue'] : array(); |
|
| 364 | - $optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array) $_REQUEST['optionsUpdate'] : array(); |
|
| 365 | - $optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array) $_REQUEST['optionsUpdateValue'] : array(); |
|
| 366 | - if ( !empty($optionsUpdate) ) { |
|
| 362 | + $options = !empty($_REQUEST['options']) ? (array)$_REQUEST['options'] : array(); |
|
| 363 | + $optionsValue = !empty($_REQUEST['optionsValue']) ? (array)$_REQUEST['optionsValue'] : array(); |
|
| 364 | + $optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array)$_REQUEST['optionsUpdate'] : array(); |
|
| 365 | + $optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array)$_REQUEST['optionsUpdateValue'] : array(); |
|
| 366 | + if (!empty($optionsUpdate)) { |
|
| 367 | 367 | /** |
| 368 | 368 | * Check if there is an attribute code into sended request or if we have to get the code from database (Bug fix) |
| 369 | 369 | */ |
@@ -377,25 +377,25 @@ discard block |
||
| 377 | 377 | foreach ($optionsUpdate as $option_key => $option_label) { |
| 378 | 378 | $option_value = !empty($optionsUpdateValue[$option_key]) ? str_replace(",", ".", $optionsUpdateValue[$option_key]) : ''; |
| 379 | 379 | |
| 380 | - if ( empty($option_value) || !in_array($option_value, $done_options_value) ) { |
|
| 380 | + if (empty($option_value) || !in_array($option_value, $done_options_value)) { |
|
| 381 | 381 | /* Update an existing value only if the value does not exist into existing list */ |
| 382 | 382 | $label = (($option_label != '') ? $option_label : str_replace(",", ".", $option_value)); |
| 383 | 383 | $value = str_replace(",", ".", $option_value); |
| 384 | - if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ) { |
|
| 384 | + if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT) { |
|
| 385 | 385 | $label = $option_label; |
| 386 | - $value = str_replace(",", ".", $label); |
|
| 386 | + $value = str_replace(",", ".", $label); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('last_update_date' => current_time('mysql', 0), 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($value)), array('id' => $option_key)); |
| 390 | 390 | $done_options_value[] = str_replace(",", ".", $option_value); |
| 391 | 391 | |
| 392 | 392 | /* Check if this value is used for price calculation and make update on the different product using this value */ |
| 393 | - if($attribute_code == WPSHOP_PRODUCT_PRICE_TAX){ |
|
| 393 | + if ($attribute_code == WPSHOP_PRODUCT_PRICE_TAX) { |
|
| 394 | 394 | $action = wpshop_prices::mass_update_prices(); |
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if($default_value == $option_key) { |
|
| 398 | + if ($default_value == $option_key) { |
|
| 399 | 399 | /* Update an existing a only if the value does not exist into existing list */ |
| 400 | 400 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $option_key), array('id' => $id)); |
| 401 | 401 | $done_options_value[] = str_replace(",", ".", $option_value); |
@@ -403,13 +403,13 @@ discard block |
||
| 403 | 403 | $i++; |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | - if ( !empty($options) ) { |
|
| 407 | - foreach ( $options as $option_key => $option_label ) { |
|
| 406 | + if (!empty($options)) { |
|
| 407 | + foreach ($options as $option_key => $option_label) { |
|
| 408 | 408 | $option_value = !empty($optionsValue[$option_key]) ? str_replace(",", ".", $optionsValue[$option_key]) : sanitize_title($option_label); |
| 409 | 409 | |
| 410 | 410 | /* Check what value to use for the new values */ |
| 411 | 411 | $label = (!empty($option_label) ? $option_label : str_replace(",", ".", $option_value)); |
| 412 | - if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value) ) { |
|
| 412 | + if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value)) { |
|
| 413 | 413 | $label = $option_label; |
| 414 | 414 | $option_value = sanitize_title($label); |
| 415 | 415 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | // If the optionsUpdateValue is empty, set it a empty array to avoid error calling the in_array() function |
| 418 | 418 | // $_REQUEST['optionsUpdateValue'] = !empty($_REQUEST['optionsUpdateValue']) ? $_REQUEST['optionsUpdateValue'] : array(); |
| 419 | 419 | |
| 420 | - if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue) ) { |
|
| 420 | + if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue)) { |
|
| 421 | 421 | |
| 422 | 422 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $id, 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($option_value))); |
| 423 | 423 | $done_options_value[] = str_replace(",", ".", $option_value); |
@@ -435,19 +435,19 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // If the is_used_for_sort_by is mark as yes, we have to get out some attributes and save it separately |
| 438 | - if( (!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes')) ){ |
|
| 438 | + if ((!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes'))) { |
|
| 439 | 439 | $attribute_code = $attribute_parameter['code']; |
| 440 | - if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){ |
|
| 440 | + if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) { |
|
| 441 | 441 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 442 | 442 | $attribute_code = $attribute->code; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | $count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
| 446 | - for( $i = 0; $i <= $count_products->publish; $i+= 20 ) { |
|
| 447 | - $query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' ); |
|
| 448 | - $products = $wpdb->get_results( $query ); |
|
| 449 | - if ( !empty($products) ) { |
|
| 450 | - foreach( $products as $product ) { |
|
| 446 | + for ($i = 0; $i <= $count_products->publish; $i += 20) { |
|
| 447 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish'); |
|
| 448 | + $products = $wpdb->get_results($query); |
|
| 449 | + if (!empty($products)) { |
|
| 450 | + foreach ($products as $product) { |
|
| 451 | 451 | $query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute_parameter['data_type'] . " WHERE attribute_id = %d AND entity_type_id = %d AND entity_id = %d AND value != '' ORDER BY creation_date_value DESC", $id, $attribute_parameter['entity_id'], $product->ID); |
| 452 | 452 | $value = $wpdb->get_var($query); |
| 453 | 453 | update_post_meta($product->ID, '_' . $attribute_code, $value); |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | wp_reset_query(); |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( $pageAction != 'delete' ) {/* Add the new attribute in the additionnal informations attribute group */ |
|
| 461 | - if ( !empty($set_section) ) { |
|
| 460 | + if ($pageAction != 'delete') {/* Add the new attribute in the additionnal informations attribute group */ |
|
| 461 | + if (!empty($set_section)) { |
|
| 462 | 462 | $choosen_set_section = explode('_', $set_section); |
| 463 | 463 | $set_id = $choosen_set_section[0]; |
| 464 | 464 | $group_id = $choosen_set_section[1]; |
| 465 | 465 | } |
| 466 | - else{ |
|
| 466 | + else { |
|
| 467 | 467 | $attribute_current_attribute_set = 0; |
| 468 | 468 | $query = $wpdb->prepare(" |
| 469 | 469 | SELECT id |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | AND ATTRIBUTE_SET_DETAILS.entity_type_id = %d", $id, $attribute_parameter['entity_id']); |
| 474 | 474 | $attribute_current_attribute_set = $wpdb->get_results($query); |
| 475 | 475 | |
| 476 | - if ( empty($attribute_current_attribute_set) ) { |
|
| 476 | + if (empty($attribute_current_attribute_set)) { |
|
| 477 | 477 | $query = $wpdb->prepare(" |
| 478 | 478 | SELECT |
| 479 | 479 | ( |
@@ -494,12 +494,12 @@ discard block |
||
| 494 | 494 | $wpshop_default_group = $wpdb->get_row($query); |
| 495 | 495 | |
| 496 | 496 | $set_id = $wpshop_default_group->attribute_set_id; |
| 497 | - $default_group_id = ( !empty( $wpshop_default_group->default_attribute_group_id) ) ? $wpshop_default_group->default_attribute_group_id : ''; |
|
| 497 | + $default_group_id = (!empty($wpshop_default_group->default_attribute_group_id)) ? $wpshop_default_group->default_attribute_group_id : ''; |
|
| 498 | 498 | $group_id = !empty($default_group_id) ? $default_group_id : $wpshop_default_group->attribute_group_id; |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if ( !empty($set_id) && !empty($group_id) ) { |
|
| 502 | + if (!empty($set_id) && !empty($group_id)) { |
|
| 503 | 503 | $query = $wpdb->prepare( |
| 504 | 504 | "SELECT (MAX(position) + 1) AS position |
| 505 | 505 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " |
@@ -511,12 +511,12 @@ discard block |
||
| 511 | 511 | $attribute_parameter['entity_id'] |
| 512 | 512 | ); |
| 513 | 513 | $wpshopAttributePosition = $wpdb->get_var($query); |
| 514 | - if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 514 | + if ($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 515 | 515 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition)); |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( !empty($wpshop_attribute_combo_values_list_order_def) ) { |
|
| 519 | + if (!empty($wpshop_attribute_combo_values_list_order_def)) { |
|
| 520 | 520 | $post_order = explode(',', $wpshop_attribute_combo_values_list_order_def); |
| 521 | 521 | $position = 1; |
| 522 | 522 | foreach ($post_order as $post_id) { |
@@ -532,19 +532,19 @@ discard block |
||
| 532 | 532 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 533 | 533 | } |
| 534 | 534 | else */ |
| 535 | - if ( $pageAction == 'add' ) |
|
| 535 | + if ($pageAction == 'add') |
|
| 536 | 536 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 537 | - elseif ( $pageAction == 'delete' ) |
|
| 537 | + elseif ($pageAction == 'delete') |
|
| 538 | 538 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 539 | 539 | } |
| 540 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){ |
|
| 540 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) { |
|
| 541 | 541 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 542 | 542 | } |
| 543 | - elseif(($actionResult == 'unDeletableAtribute')){ |
|
| 543 | + elseif (($actionResult == 'unDeletableAtribute')) { |
|
| 544 | 544 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop'); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - if(empty($attribute_parameter['frontend_label']) && ($pageAction!='delete')){ |
|
| 547 | + if (empty($attribute_parameter['frontend_label']) && ($pageAction != 'delete')) { |
|
| 548 | 548 | $pageMessage .= __('Please enter an label for the attribut', 'wpshop'); |
| 549 | 549 | } |
| 550 | 550 | } |
@@ -562,37 +562,37 @@ discard block |
||
| 562 | 562 | //Create an instance of our package class... |
| 563 | 563 | $wpshop_list_table = new wpshop_attributes_custom_List_table(); |
| 564 | 564 | //Fetch, prepare, sort, and filter our data... |
| 565 | - $status="'valid'"; |
|
| 566 | - $attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : null; |
|
| 567 | - $s = !empty($_REQUEST['s']) ? sanitize_text_field( $_REQUEST['s'] ) : null; |
|
| 565 | + $status = "'valid'"; |
|
| 566 | + $attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : null; |
|
| 567 | + $s = !empty($_REQUEST['s']) ? sanitize_text_field($_REQUEST['s']) : null; |
|
| 568 | 568 | $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null; |
| 569 | 569 | $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : null; |
| 570 | - if(!empty($attribute_status)){ |
|
| 571 | - switch($attribute_status){ |
|
| 570 | + if (!empty($attribute_status)) { |
|
| 571 | + switch ($attribute_status) { |
|
| 572 | 572 | case 'unactive': |
| 573 | - $status="'moderated', 'notused'"; |
|
| 574 | - if(empty($order_by) && empty($order)){ |
|
| 573 | + $status = "'moderated', 'notused'"; |
|
| 574 | + if (empty($order_by) && empty($order)) { |
|
| 575 | 575 | // @TODO : REQUEST |
| 576 | 576 | // $_REQUEST['orderby']='status'; |
| 577 | 577 | // $_REQUEST['order']='asc'; |
| 578 | 578 | } |
| 579 | 579 | break; |
| 580 | 580 | default: |
| 581 | - $status="'".sanitize_text_field($_REQUEST['attribute_status'])."'"; |
|
| 581 | + $status = "'" . sanitize_text_field($_REQUEST['attribute_status']) . "'"; |
|
| 582 | 582 | break; |
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | - if ( !empty($s) ) { |
|
| 586 | - $query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') ); |
|
| 587 | - $attr_set_list = $wpdb->get_results( $query ); |
|
| 585 | + if (!empty($s)) { |
|
| 586 | + $query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop')); |
|
| 587 | + $attr_set_list = $wpdb->get_results($query); |
|
| 588 | 588 | } |
| 589 | 589 | else { |
| 590 | - $attr_set_list = self::getElement( '', $status ); |
|
| 590 | + $attr_set_list = self::getElement('', $status); |
|
| 591 | 591 | } |
| 592 | - $i=0; |
|
| 593 | - $attribute_set_list=array(); |
|
| 594 | - foreach($attr_set_list as $attr_set){ |
|
| 595 | - if(!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id') ){ |
|
| 592 | + $i = 0; |
|
| 593 | + $attribute_set_list = array(); |
|
| 594 | + foreach ($attr_set_list as $attr_set) { |
|
| 595 | + if (!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id')) { |
|
| 596 | 596 | $attribute_set_list[$i]['id'] = $attr_set->id; |
| 597 | 597 | $attribute_set_list[$i]['name'] = $attr_set->frontend_label; |
| 598 | 598 | $attribute_set_list[$i]['status'] = $attr_set->status; |
@@ -638,31 +638,31 @@ discard block |
||
| 638 | 638 | global $attribute_displayed_field, $attribute_options_group; |
| 639 | 639 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 640 | 640 | $editedItem = ''; |
| 641 | - if($itemToEdit != '') |
|
| 641 | + if ($itemToEdit != '') |
|
| 642 | 642 | $editedItem = self::getElement($itemToEdit); |
| 643 | 643 | |
| 644 | 644 | $the_form_content_hidden = $the_form_general_content = ''; |
| 645 | 645 | $the_form_option_content_list = array(); |
| 646 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 646 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 647 | 647 | |
| 648 | - if(!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)){ |
|
| 648 | + if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) { |
|
| 649 | 649 | $input_def['label'] = $input_def['name']; |
| 650 | - $input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_def['label']; |
|
| 650 | + $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label']; |
|
| 651 | 651 | |
| 652 | 652 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 653 | 653 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : ''; |
| 654 | 654 | $currentFieldValue = $input_def['value']; |
| 655 | - if(is_object($editedItem)) |
|
| 655 | + if (is_object($editedItem)) |
|
| 656 | 656 | $currentFieldValue = $editedItem->{$input_def['label']}; |
| 657 | - elseif(($pageAction != '') && ($requestFormValue != '')) |
|
| 657 | + elseif (($pageAction != '') && ($requestFormValue != '')) |
|
| 658 | 658 | $currentFieldValue = $requestFormValue; |
| 659 | 659 | |
| 660 | - if($input_def['label'] == 'status'){ |
|
| 661 | - if(in_array('notused', $input_def['possible_value'])){ |
|
| 660 | + if ($input_def['label'] == 'status') { |
|
| 661 | + if (in_array('notused', $input_def['possible_value'])) { |
|
| 662 | 662 | $key = array_keys($input_def['possible_value'], 'notused'); |
| 663 | 663 | unset($input_def['possible_value'][$key[0]]); |
| 664 | 664 | } |
| 665 | - if(in_array('dbl', $input_def['possible_value'])){ |
|
| 665 | + if (in_array('dbl', $input_def['possible_value'])) { |
|
| 666 | 666 | $key = array_keys($input_def['possible_value'], 'dbl'); |
| 667 | 667 | unset($input_def['possible_value'][$key[0]]); |
| 668 | 668 | } |
@@ -670,94 +670,94 @@ discard block |
||
| 670 | 670 | $input_def['type'] = 'checkbox'; |
| 671 | 671 | $input_def['label'] = __('Use this attribute', 'wpshop'); |
| 672 | 672 | $input_def['possible_value'] = array('valid'); |
| 673 | - $input_def_id.='_valid'; |
|
| 674 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 673 | + $input_def_id .= '_valid'; |
|
| 674 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || ( $input_def['label'] == '_display_informations_about_value') ) { |
|
| 677 | + if ((substr($input_def['label'], 0, 3) == 'is_') || ($input_def['label'] == '_display_informations_about_value')) { |
|
| 678 | 678 | $input_def['type'] = 'checkbox'; |
| 679 | 679 | $input_def['possible_value'] = 'yes'; |
| 680 | 680 | } |
| 681 | - switch($input_def['label']){ |
|
| 681 | + switch ($input_def['label']) { |
|
| 682 | 682 | case 'is_requiring_unit': |
| 683 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using unit with this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 683 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 684 | 684 | break; |
| 685 | 685 | case 'is_visible_in_front': |
| 686 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 686 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 687 | 687 | break; |
| 688 | 688 | case 'is_visible_in_front_listing': |
| 689 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in product listing in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 689 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in product listing in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 690 | 690 | break; |
| 691 | 691 | case 'is_used_for_sort_by': |
| 692 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute into sortbar', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 692 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 693 | 693 | break; |
| 694 | 694 | case 'is_searchable': |
| 695 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for including values of this attribute as search parameter', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 695 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for including values of this attribute as search parameter', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 696 | 696 | break; |
| 697 | 697 | case 'is_visible_in_advanced_search': |
| 698 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using in advanced search form', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 698 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 699 | 699 | break; |
| 700 | 700 | case 'frontend_css_class': |
| 701 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 701 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 702 | 702 | break; |
| 703 | 703 | case 'backend_css_class': |
| 704 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 704 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 705 | 705 | break; |
| 706 | 706 | case 'is_historisable': |
| 707 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 707 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 708 | 708 | break; |
| 709 | 709 | case 'is_filterable': |
| 710 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute in the filter search', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 710 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute in the filter search', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 711 | 711 | break; |
| 712 | 712 | case 'is_intrinsic': |
| 713 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is intrinsic for a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 713 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is intrinsic for a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 714 | 714 | break; |
| 715 | 715 | case 'is_used_for_variation': |
| 716 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 716 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 717 | 717 | break; |
| 718 | 718 | case 'is_used_in_variation': |
| 719 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute for variation definition', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 720 | - if ( !empty($editedItem) && ($editedItem->is_used_for_variation == 'yes') ) { |
|
| 719 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute for variation definition', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 720 | + if (!empty($editedItem) && ($editedItem->is_used_for_variation == 'yes')) { |
|
| 721 | 721 | $input_def['option'] = 'disabled="disabled"'; |
| 722 | 722 | } |
| 723 | 723 | break; |
| 724 | 724 | case 'is_user_defined': |
| 725 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 725 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 726 | 726 | break; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | $input_def['value'] = $currentFieldValue; |
| 730 | - if($input_def['label'] == 'code') |
|
| 730 | + if ($input_def['label'] == 'code') |
|
| 731 | 731 | $input_def['type'] = 'hidden'; |
| 732 | - elseif($input_def['label'] == 'entity_id'){ |
|
| 732 | + elseif ($input_def['label'] == 'entity_id') { |
|
| 733 | 733 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 734 | 734 | $input_def['valueToPut'] = 'index'; |
| 735 | 735 | $input_def['type'] = 'select'; |
| 736 | 736 | |
| 737 | - $i=0; |
|
| 738 | - foreach($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 739 | - if($i <= 0){ |
|
| 737 | + $i = 0; |
|
| 738 | + foreach ($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 739 | + if ($i <= 0) { |
|
| 740 | 740 | $current_entity_id = $entity_id; |
| 741 | 741 | } |
| 742 | 742 | $i++; |
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | - elseif($input_def['label'] == '_unit_group_id'){ |
|
| 745 | + elseif ($input_def['label'] == '_unit_group_id') { |
|
| 746 | 746 | $input_def['possible_value'] = wpshop_attributes_unit::get_unit_group(); |
| 747 | 747 | $input_def['type'] = 'select'; |
| 748 | 748 | } |
| 749 | - elseif($input_def['label'] == '_default_unit'){ |
|
| 749 | + elseif ($input_def['label'] == '_default_unit') { |
|
| 750 | 750 | $unit_group_list = wpshop_attributes_unit::get_unit_group(); |
| 751 | - $input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:'')); |
|
| 751 | + $input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id) ? $editedItem->_unit_group_id : (!empty($unit_group_list) ? $unit_group_list[0]->id : '')); |
|
| 752 | 752 | $input_def['type'] = 'select'; |
| 753 | 753 | } |
| 754 | 754 | elseif ($input_def['label'] == 'backend_input') { |
| 755 | - if ( !is_object($editedItem) ) { |
|
| 755 | + if (!is_object($editedItem)) { |
|
| 756 | 756 | $input_def['type'] = 'hidden'; |
| 757 | 757 | } |
| 758 | 758 | else { |
| 759 | 759 | $new_possible_value = array(); |
| 760 | - switch ( $editedItem->data_type) { |
|
| 760 | + switch ($editedItem->data_type) { |
|
| 761 | 761 | case 'integer': |
| 762 | 762 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 763 | 763 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 766 | 766 | break; |
| 767 | 767 | case 'varchar': |
| 768 | - switch ( $input_def['value'] ) { |
|
| 768 | + switch ($input_def['value']) { |
|
| 769 | 769 | case 'hidden': |
| 770 | 770 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 771 | 771 | break; |
@@ -793,8 +793,8 @@ discard block |
||
| 793 | 793 | elseif ($input_def['label'] == 'frontend_input') { |
| 794 | 794 | $new_possible_value = array(); |
| 795 | 795 | |
| 796 | - if ( is_object($editedItem) ) { |
|
| 797 | - switch ( $editedItem->data_type) { |
|
| 796 | + if (is_object($editedItem)) { |
|
| 797 | + switch ($editedItem->data_type) { |
|
| 798 | 798 | case 'integer': |
| 799 | 799 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 800 | 800 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 803 | 803 | break; |
| 804 | 804 | case 'varchar': |
| 805 | - switch ( $input_def['value'] ) { |
|
| 805 | + switch ($input_def['value']) { |
|
| 806 | 806 | case 'hidden': |
| 807 | 807 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 808 | 808 | break; |
@@ -840,10 +840,10 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | $input_def['possible_value'] = $new_possible_value; |
| 842 | 842 | |
| 843 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 844 | - switch ( $editedItem->frontend_input ) { |
|
| 843 | + if (!empty($editedItem->frontend_input)) { |
|
| 844 | + switch ($editedItem->frontend_input) { |
|
| 845 | 845 | case 'text': |
| 846 | - switch ( $editedItem->data_type ) { |
|
| 846 | + switch ($editedItem->data_type) { |
|
| 847 | 847 | case 'varchar': |
| 848 | 848 | $input_def['value'] = 'short_text'; |
| 849 | 849 | break; |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if(is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))){ |
|
| 871 | + if (is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))) { |
|
| 872 | 872 | // $input_def['type'] = 'hidden'; |
| 873 | 873 | $input_def['option'] = ' disabled="disabled" '; |
| 874 | 874 | $the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />'; |
@@ -879,16 +879,16 @@ discard block |
||
| 879 | 879 | $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 880 | 880 | |
| 881 | 881 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 882 | - if ( $input_def['label'] == 'default_value' ) { |
|
| 883 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 884 | - switch ( $editedItem->frontend_input ) { |
|
| 882 | + if ($input_def['label'] == 'default_value') { |
|
| 883 | + if (!empty($editedItem->frontend_input)) { |
|
| 884 | + switch ($editedItem->frontend_input) { |
|
| 885 | 885 | case 'text': |
| 886 | 886 | $input_def['type'] = 'text'; |
| 887 | - switch ( $editedItem->data_type ) { |
|
| 887 | + switch ($editedItem->data_type) { |
|
| 888 | 888 | case 'datetime': |
| 889 | - $the_input = wpshop_attributes::attribute_type_date_config( unserialize($input_def['value']) ); |
|
| 889 | + $the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value'])); |
|
| 890 | 890 | |
| 891 | - $input_def['label'] = __('Date field configuration','wpshop'); |
|
| 891 | + $input_def['label'] = __('Date field configuration', 'wpshop'); |
|
| 892 | 892 | break; |
| 893 | 893 | default: |
| 894 | 894 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | case 'multiple-select': |
| 906 | 906 | case 'radio': |
| 907 | 907 | case 'checkbox': |
| 908 | - $input_def['label'] = __('Options list for attribute','wpshop') . ' |
|
| 908 | + $input_def['label'] = __('Options list for attribute', 'wpshop') . ' |
|
| 909 | 909 | <div class="alignright wpshop_change_select_data_type" > |
| 910 | 910 | +' . __('Change data type for this attribute', 'wpshop') . ' |
| 911 | 911 | </div>'; |
@@ -919,50 +919,50 @@ discard block |
||
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | else { |
| 922 | - $input_def['type']='text'; |
|
| 922 | + $input_def['type'] = 'text'; |
|
| 923 | 923 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | - if( $input_def['label'] == '_unit_group_id') { |
|
| 926 | + if ($input_def['label'] == '_unit_group_id') { |
|
| 927 | 927 | $the_input .= '<div id="wpshop_loader_input_group_unit"></div>'; |
| 928 | - $the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage group unit', 'wpshop').'</a>'; |
|
| 928 | + $the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage group unit', 'wpshop') . '</a>'; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - if( $input_def['label'] == '_default_unit') { |
|
| 931 | + if ($input_def['label'] == '_default_unit') { |
|
| 932 | 932 | $the_input .= '<div id="wpshop_loader_input_unit"></div>'; |
| 933 | - $the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage units', 'wpshop').'</a>'; |
|
| 933 | + $the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage units', 'wpshop') . '</a>'; |
|
| 934 | 934 | $the_input .= '<input type="hidden" name="input_wpshop_load_attribute_unit_list" id="input_wpshop_load_attribute_unit_list" value="' . wp_create_nonce("wpshop_load_attribute_unit_list") . '" />'; |
| 935 | 935 | $the_input .= '<div id="wpshop_attribute_unit_manager" title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>'; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | |
| 939 | - if($input_def['type'] != 'hidden'){ |
|
| 940 | - if ( ($input_def['label'] == 'entity_id') && is_object($editedItem) ) { |
|
| 939 | + if ($input_def['type'] != 'hidden') { |
|
| 940 | + if (($input_def['label'] == 'entity_id') && is_object($editedItem)) { |
|
| 941 | 941 | $the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to . another entity', 'wpshop') . '</span>'; |
| 942 | 942 | } |
| 943 | 943 | $input = ' |
| 944 | - <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_def['name'].'" > |
|
| 945 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td> |
|
| 946 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td> |
|
| 944 | + <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" > |
|
| 945 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_def['name'] . '" ><label for="' . $input_def_id . '" >' . __($input_def['label'], 'wpshop') . '</label></td> |
|
| 946 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_def['name'] . '" >' . $the_input . '</td> |
|
| 947 | 947 | </tr>'; |
| 948 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) ) |
|
| 948 | + if ((substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize(WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS))) |
|
| 949 | 949 | $the_form_option_content_list[$input_def['label']] = $input; |
| 950 | 950 | else { |
| 951 | 951 | $the_form_general_content .= $input; |
| 952 | - if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) { |
|
| 952 | + if (($input_def['label'] == 'frontend_input') && !is_object($editedItem)) { |
|
| 953 | 953 | |
| 954 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 954 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 955 | 955 | |
| 956 | 956 | $input = ' |
| 957 | 957 | <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" > |
| 958 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="'.self::currentPageCode.'_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td> |
|
| 958 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="' . self::currentPageCode . '_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td> |
|
| 959 | 959 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_set_section" >' . $the_input . '</td> |
| 960 | 960 | </tr>'; |
| 961 | 961 | $the_form_general_content .= $input; |
| 962 | 962 | } |
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | - else{ |
|
| 965 | + else { |
|
| 966 | 966 | $the_form_content_hidden .= ' |
| 967 | 967 | ' . $the_input; |
| 968 | 968 | } |
@@ -978,17 +978,17 @@ discard block |
||
| 978 | 978 | $section_content = $the_form_general_content; |
| 979 | 979 | |
| 980 | 980 | ob_start(); |
| 981 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 981 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 982 | 982 | $the_form_general_content = ob_get_contents(); |
| 983 | 983 | ob_end_clean(); |
| 984 | 984 | |
| 985 | 985 | /** It is attribute TVA, add a button to calcilate price in mass **/ |
| 986 | - if ( !empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva' ) { |
|
| 987 | - $the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce( 'wps_update_products_prices' ) . '" id="wps_update_price_infos" value="' .__('Update all products price', 'wpshop').'" /> <img src="' .WPSHOP_LOADING_ICON. '" alt="" id="update_products_loader" /> <br/>'; |
|
| 988 | - $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop' ); |
|
| 986 | + if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') { |
|
| 987 | + $the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce('wps_update_products_prices') . '" id="wps_update_price_infos" value="' . __('Update all products price', 'wpshop') . '" /> <img src="' . WPSHOP_LOADING_ICON . '" alt="" id="update_products_loader" /> <br/>'; |
|
| 988 | + $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop'); |
|
| 989 | 989 | } |
| 990 | 990 | if (!empty($the_form_option_content_list)) { |
| 991 | - $the_form_option_content_section=''; |
|
| 991 | + $the_form_option_content_section = ''; |
|
| 992 | 992 | foreach ($attribute_options_group as $group_name => $group_content) { |
| 993 | 993 | $section_content = ''; |
| 994 | 994 | foreach ($group_content as $group_code) { |
@@ -997,23 +997,23 @@ discard block |
||
| 997 | 997 | unset($the_form_option_content_list[$group_code]); |
| 998 | 998 | } |
| 999 | 999 | } |
| 1000 | - $section_legend = __($group_name,'wpshop'); |
|
| 1000 | + $section_legend = __($group_name, 'wpshop'); |
|
| 1001 | 1001 | $section_page_code = self::currentPageCode; |
| 1002 | 1002 | |
| 1003 | 1003 | ob_start(); |
| 1004 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1004 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1005 | 1005 | $the_form_option_content_section .= ob_get_contents(); |
| 1006 | 1006 | ob_end_clean(); |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | /* Check there are other attributes to display not in defined group */ |
| 1010 | 1010 | if (!empty($the_form_option_content_list)) { |
| 1011 | - $section_legend = __('General options','wpshop'); |
|
| 1011 | + $section_legend = __('General options', 'wpshop'); |
|
| 1012 | 1012 | $section_content = implode('', $the_form_option_content_list); |
| 1013 | 1013 | $section_page_code = self::currentPageCode; |
| 1014 | 1014 | |
| 1015 | 1015 | ob_start(); |
| 1016 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1016 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1017 | 1017 | $the_form_option_content = ob_get_contents(); |
| 1018 | 1018 | ob_end_clean(); |
| 1019 | 1019 | |
@@ -1023,17 +1023,17 @@ discard block |
||
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /* Default content for the current page */ |
| 1026 | - $bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop'); |
|
| 1026 | + $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); |
|
| 1027 | 1027 | $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; |
| 1028 | 1028 | |
| 1029 | - $bloc_list[self::currentPageCode]['options']['title']=__('Options', 'wpshop'); |
|
| 1030 | - $bloc_list[self::currentPageCode]['options']['content']=$the_form_option_content; |
|
| 1029 | + $bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop'); |
|
| 1030 | + $bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content; |
|
| 1031 | 1031 | |
| 1032 | - $action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action' ] ) : ''; |
|
| 1032 | + $action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 1033 | 1033 | $the_form = ' |
| 1034 | 1034 | <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > |
| 1035 | - ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save') , 'hidden') . ' |
|
| 1036 | - ' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . ' |
|
| 1035 | + ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save'), 'hidden') . ' |
|
| 1036 | + ' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . ' |
|
| 1037 | 1037 | </form> |
| 1038 | 1038 | <div title="' . __('Change data type for selected attribute', 'wpshop') . '" id="wpshop_dialog_change_select_data_type" ><div id="wpshop_dialog_change_select_data_type_container" ></div></div>'; |
| 1039 | 1039 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | $the_form .= ' |
| 1052 | 1052 | <script type="text/javascript" > |
| 1053 | 1053 | wpshop(document).ready(function(){ |
| 1054 | - wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 1054 | + wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 1055 | 1055 | |
| 1056 | 1056 | jQuery("#wpshop_dialog_duplicate_attribute").dialog({ |
| 1057 | 1057 | autoOpen: false, |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | dialogClass: "wpshop_uidialog_box", |
| 1062 | 1062 | resizable: false, |
| 1063 | 1063 | buttons:{ |
| 1064 | - "'.__('Duplicate', 'wpshop').'": function(){ |
|
| 1064 | + "'.__('Duplicate', 'wpshop') . '": function(){ |
|
| 1065 | 1065 | var data = { |
| 1066 | 1066 | action: "wpshop_duplicate_attribute", |
| 1067 | 1067 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '", |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | } |
| 1078 | 1078 | }, "json"); |
| 1079 | 1079 | }, |
| 1080 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1080 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1081 | 1081 | jQuery(this).dialog("close"); |
| 1082 | 1082 | jQuery(".wpshop_duplicate_attribute_result").remove(); |
| 1083 | 1083 | } |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | dialogClass: "wpshop_uidialog_box", |
| 1096 | 1096 | resizable: false, |
| 1097 | 1097 | buttons:{ |
| 1098 | - "'.__('Change type', 'wpshop').'": function(){ |
|
| 1098 | + "'.__('Change type', 'wpshop') . '": function(){ |
|
| 1099 | 1099 | var delete_entity = false; |
| 1100 | 1100 | if(jQuery("#delete_entity").is(":checked")){ |
| 1101 | 1101 | var delete_entity = true; |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | jQuery("#wpshop_dialog_change_select_data_type").dialog("close"); |
| 1119 | 1119 | }, "json"); |
| 1120 | 1120 | }, |
| 1121 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1121 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1122 | 1122 | jQuery(this).dialog("close"); |
| 1123 | 1123 | } |
| 1124 | 1124 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | change_unit_list(); |
| 1159 | 1159 | });'; |
| 1160 | 1160 | |
| 1161 | - if ( !is_object($editedItem) ) { |
|
| 1161 | + if (!is_object($editedItem)) { |
|
| 1162 | 1162 | $the_form .= ' |
| 1163 | 1163 | jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){ |
| 1164 | 1164 | jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html()); |
@@ -1241,23 +1241,23 @@ discard block |
||
| 1241 | 1241 | * |
| 1242 | 1242 | * @return string $currentPageButton The html output code with the different button to add to the interface |
| 1243 | 1243 | */ |
| 1244 | - function getPageFormButton($element_id = 0){ |
|
| 1244 | + function getPageFormButton($element_id = 0) { |
|
| 1245 | 1245 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 1246 | 1246 | $currentPageButton = ''; |
| 1247 | 1247 | |
| 1248 | 1248 | //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>'; |
| 1249 | 1249 | |
| 1250 | - if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1250 | + if (($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1251 | 1251 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 1252 | 1252 | |
| 1253 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 1253 | + elseif (current_user_can('wpshop_edit_attributes')) |
|
| 1254 | 1254 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
| 1255 | 1255 | |
| 1256 | 1256 | $attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE); |
| 1257 | 1257 | $attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id'); |
| 1258 | - $attribute_code = !empty($attribute->code)?$attribute->code:''; |
|
| 1259 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1260 | - $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1258 | + $attribute_code = !empty($attribute->code) ? $attribute->code : ''; |
|
| 1259 | + if (current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1260 | + $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1261 | 1261 | |
| 1262 | 1262 | return $currentPageButton; |
| 1263 | 1263 | } |
@@ -1271,22 +1271,22 @@ discard block |
||
| 1271 | 1271 | * |
| 1272 | 1272 | * @return object $element_list A wordpress database object containing the attribute list |
| 1273 | 1273 | */ |
| 1274 | - public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false){ |
|
| 1274 | + public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false) { |
|
| 1275 | 1275 | |
| 1276 | 1276 | global $wpdb; |
| 1277 | 1277 | $element_list = array(); |
| 1278 | 1278 | $moreQuery = ""; |
| 1279 | - $moreArgs = array( 1, ); |
|
| 1279 | + $moreArgs = array(1,); |
|
| 1280 | 1280 | |
| 1281 | - $orderby = !empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
|
| 1282 | - $order = !empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
|
| 1281 | + $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : ''; |
|
| 1282 | + $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : ''; |
|
| 1283 | 1283 | |
| 1284 | - if($element_id != ''){ |
|
| 1284 | + if ($element_id != '') { |
|
| 1285 | 1285 | $moreQuery .= " |
| 1286 | 1286 | AND CURRENT_ELEMENT." . $field_to_search . " = %s "; |
| 1287 | 1287 | $moreArgs[] = $element_id; |
| 1288 | 1288 | } |
| 1289 | - if(!empty($orderby) && !empty($order)){ |
|
| 1289 | + if (!empty($orderby) && !empty($order)) { |
|
| 1290 | 1290 | $moreQuery .= " |
| 1291 | 1291 | ORDER BY " . $orderby . " " . $order; |
| 1292 | 1292 | } |
@@ -1295,15 +1295,15 @@ discard block |
||
| 1295 | 1295 | "SELECT CURRENT_ELEMENT.*, ENTITIES.post_name as entity |
| 1296 | 1296 | FROM " . self::getDbTable() . " AS CURRENT_ELEMENT |
| 1297 | 1297 | INNER JOIN {$wpdb->posts} AS ENTITIES ON (ENTITIES.ID = CURRENT_ELEMENT.entity_id) |
| 1298 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, |
|
| 1298 | + WHERE %d AND CURRENT_ELEMENT.status IN (" . $element_status . ") " . $moreQuery, |
|
| 1299 | 1299 | $moreArgs |
| 1300 | 1300 | ); |
| 1301 | 1301 | |
| 1302 | 1302 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 1303 | - if(($element_id == '') || $list){ |
|
| 1303 | + if (($element_id == '') || $list) { |
|
| 1304 | 1304 | $element_list = $wpdb->get_results($query); |
| 1305 | 1305 | } |
| 1306 | - else{ |
|
| 1306 | + else { |
|
| 1307 | 1307 | $element_list = $wpdb->get_row($query); |
| 1308 | 1308 | } |
| 1309 | 1309 | |
@@ -1325,8 +1325,8 @@ discard block |
||
| 1325 | 1325 | $user_id = function_exists('is_user_logged_in') && is_user_logged_in() ? get_current_user_id() : '0'; |
| 1326 | 1326 | $sent_attribute_list = array(); |
| 1327 | 1327 | |
| 1328 | - if ( !empty($attributeToSet) ) { |
|
| 1329 | - $attributeToSet = apply_filters( 'save_attribute_for_entity', $attributeToSet, $entityTypeId, $entityId ); |
|
| 1328 | + if (!empty($attributeToSet)) { |
|
| 1329 | + $attributeToSet = apply_filters('save_attribute_for_entity', $attributeToSet, $entityTypeId, $entityId); |
|
| 1330 | 1330 | $old_attribute_to_set = $attributeToSet; |
| 1331 | 1331 | $attribute_setted = array(); |
| 1332 | 1332 | foreach ($attributeToSet as $attributeType => $attributeTypeDetails) { |
@@ -1335,39 +1335,39 @@ discard block |
||
| 1335 | 1335 | 'entity_id' => $entityId, |
| 1336 | 1336 | 'entity_type_id' => $entityTypeId |
| 1337 | 1337 | ); |
| 1338 | - if ( WPSHOP_ATTRIBUTE_VALUE_PER_USER ) { |
|
| 1338 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER) { |
|
| 1339 | 1339 | $delete_current_attribute_values_params['user_id'] = $user_id; |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | - if(!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1343 | - $attributeTypeDetails = apply_filters( "save_attribute_for_entity_{$attributeType}", $attributeTypeDetails, $entityTypeId, $entityId ); |
|
| 1344 | - foreach($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1345 | - $attributeValue = apply_filters( "save_attribute_for_entity_{$attributeType}_{$attribute_code}", apply_filters( "save_attribute_for_entity__{$attribute_code}", $attributeValue, $entityTypeId, $entityId ), $entityTypeId, $entityId ); |
|
| 1342 | + if (!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1343 | + $attributeTypeDetails = apply_filters("save_attribute_for_entity_{$attributeType}", $attributeTypeDetails, $entityTypeId, $entityId); |
|
| 1344 | + foreach ($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1345 | + $attributeValue = apply_filters("save_attribute_for_entity_{$attributeType}_{$attribute_code}", apply_filters("save_attribute_for_entity__{$attribute_code}", $attributeValue, $entityTypeId, $entityId), $entityTypeId, $entityId); |
|
| 1346 | 1346 | $old_attribute_value = $attributeValue; |
| 1347 | 1347 | |
| 1348 | - if ( $attributeType == 'decimal' ) { |
|
| 1348 | + if ($attributeType == 'decimal') { |
|
| 1349 | 1349 | $attributeValue = str_replace(',', '.', $attributeValue); |
| 1350 | 1350 | } |
| 1351 | - if ( ($attributeType == 'integer') && !is_array($attributeValue) ) { |
|
| 1351 | + if (($attributeType == 'integer') && !is_array($attributeValue)) { |
|
| 1352 | 1352 | $attributeValue = (int)$attributeValue; |
| 1353 | 1353 | } |
| 1354 | 1354 | $more_query_params_values = array(); |
| 1355 | - if($attribute_code != 'unit') { |
|
| 1355 | + if ($attribute_code != 'unit') { |
|
| 1356 | 1356 | |
| 1357 | 1357 | $unit_id = 0; |
| 1358 | - if(isset($attributeTypeDetails['unit'][$attribute_code])){ |
|
| 1358 | + if (isset($attributeTypeDetails['unit'][$attribute_code])) { |
|
| 1359 | 1359 | $unit_id = $attributeTypeDetails['unit'][$attribute_code]; |
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | $currentAttribute = self::getElement($attribute_code, "'valid'", 'code'); |
| 1363 | - if( !empty($currentAttribute) ){ |
|
| 1363 | + if (!empty($currentAttribute)) { |
|
| 1364 | 1364 | $sent_attribute_list[] = $currentAttribute->id; |
| 1365 | 1365 | |
| 1366 | 1366 | /* Enregistrement de la valeur actuelle de l'attribut dans la table d'historique si l'option historique est activee sur l'attribut courant */ |
| 1367 | - if ( $currentAttribute->is_historisable == 'yes') { |
|
| 1367 | + if ($currentAttribute->is_historisable == 'yes') { |
|
| 1368 | 1368 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d", $entityTypeId, $currentAttribute->id, $entityId); |
| 1369 | 1369 | $attribute_histo = $wpdb->get_results($query); |
| 1370 | - if(!empty($attribute_histo)){ |
|
| 1370 | + if (!empty($attribute_histo)) { |
|
| 1371 | 1371 | $attribute_histo_content['status'] = 'valid'; |
| 1372 | 1372 | $attribute_histo_content['creation_date'] = current_time('mysql', 0); |
| 1373 | 1373 | $attribute_histo_content['creation_date_value'] = $attribute_histo[0]->creation_date_value; |
@@ -1385,8 +1385,8 @@ discard block |
||
| 1385 | 1385 | } |
| 1386 | 1386 | $attributeValue = str_replace("\\", "", $attributeValue); |
| 1387 | 1387 | |
| 1388 | - if ( empty($from) || (!empty($attributeValue)) ) { |
|
| 1389 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1388 | + if (empty($from) || (!empty($attributeValue))) { |
|
| 1389 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1390 | 1390 | |
| 1391 | 1391 | /** Insertion de la nouvelle valeur de l'attribut dans la base */ |
| 1392 | 1392 | $query_params = array( |
@@ -1400,60 +1400,60 @@ discard block |
||
| 1400 | 1400 | 'creation_date_value' => current_time('mysql', 0) |
| 1401 | 1401 | ); |
| 1402 | 1402 | /** Si l'attribut courant est contenu dans un tableau (exemple: select multiple) on lit tout le tableau et on enregistre chaque valeur separement */ |
| 1403 | - if(is_array($attributeValue)){ |
|
| 1404 | - foreach($attributeValue as $a){ |
|
| 1405 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1403 | + if (is_array($attributeValue)) { |
|
| 1404 | + foreach ($attributeValue as $a) { |
|
| 1405 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | } |
| 1408 | - else{ |
|
| 1409 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1410 | - \eoxia\log_class::exec( 'wpshop_attributes', 'wpshop_attributes', __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ), array( 'object_id' => $entityId ), 0 ); |
|
| 1408 | + else { |
|
| 1409 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1410 | + \eoxia\log_class::exec('wpshop_attributes', 'wpshop_attributes', __('Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue, 'wpshop'), array('object_id' => $entityId), 0); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | /** Dans le cas ou l'attribut courant est utilise dans l'interface permettant de trier les produits (option de l'attribut) on defini une meta specifique */ |
| 1414 | - if ( ( ($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ( $currentAttribute->is_filterable == 'yes') && !empty($attributeValue) ) : |
|
| 1415 | - update_post_meta($entityId, '_'.$attribute_code, $attributeValue); |
|
| 1414 | + if ((($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ($currentAttribute->is_filterable == 'yes') && !empty($attributeValue)) : |
|
| 1415 | + update_post_meta($entityId, '_' . $attribute_code, $attributeValue); |
|
| 1416 | 1416 | endif; |
| 1417 | 1417 | |
| 1418 | 1418 | /** Enregistrement de toutes les valeurs des attributs dans une meta du produit */ |
| 1419 | - $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array) $_POST['attribute_option'][$attribute_code] : null; |
|
| 1419 | + $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array)$_POST['attribute_option'][$attribute_code] : null; |
|
| 1420 | 1420 | if (isset($attribute_option)) { |
| 1421 | 1421 | $value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value'); |
| 1422 | 1422 | if (strtolower($value) == 'yes') : |
| 1423 | - update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option); |
|
| 1423 | + update_post_meta($entityId, 'attribute_option_' . $attribute_code, $attribute_option); |
|
| 1424 | 1424 | else : |
| 1425 | - delete_post_meta($entityId, 'attribute_option_'.$attribute_code); |
|
| 1425 | + delete_post_meta($entityId, 'attribute_option_' . $attribute_code); |
|
| 1426 | 1426 | endif; |
| 1427 | 1427 | } |
| 1428 | 1428 | } |
| 1429 | 1429 | } |
| 1430 | 1430 | } |
| 1431 | - do_action( "saved_attribute_for_entity_{$attributeType}_{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId ); |
|
| 1432 | - do_action( "saved_attribute_for_entity__{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId ); |
|
| 1433 | - if ( isset( $attribute_setted[$attributeType][$attribute_code] ) ) { |
|
| 1434 | - if( is_array( $attribute_setted[$attributeType][$attribute_code] )) { |
|
| 1431 | + do_action("saved_attribute_for_entity_{$attributeType}_{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId); |
|
| 1432 | + do_action("saved_attribute_for_entity__{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId); |
|
| 1433 | + if (isset($attribute_setted[$attributeType][$attribute_code])) { |
|
| 1434 | + if (is_array($attribute_setted[$attributeType][$attribute_code])) { |
|
| 1435 | 1435 | $attribute_setted[$attributeType][$attribute_code][] = $attributeValue; |
| 1436 | 1436 | } else { |
| 1437 | - $attribute_setted[$attributeType][$attribute_code] = array( $attribute_setted[$attributeType][$attribute_code], $attributeValue ); |
|
| 1437 | + $attribute_setted[$attributeType][$attribute_code] = array($attribute_setted[$attributeType][$attribute_code], $attributeValue); |
|
| 1438 | 1438 | } |
| 1439 | 1439 | } else { |
| 1440 | 1440 | $attribute_setted[$attributeType][$attribute_code] = $attributeValue; |
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | - if ( empty($from) ) { |
|
| 1445 | - $query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId); |
|
| 1444 | + if (empty($from)) { |
|
| 1445 | + $query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId); |
|
| 1446 | 1446 | $attr_to_delete = $wpdb->get_results($query); |
| 1447 | - if(!empty($attr_to_delete)){ |
|
| 1447 | + if (!empty($attr_to_delete)) { |
|
| 1448 | 1448 | foreach ($attr_to_delete as $value) { |
| 1449 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1450 | - \eoxia\log_class::exec( 'wpshop_attributes', 'wpshop_attributes', __( 'Remove the attribute : ' . $value->value_id, 'wpshop' ), array( 'object_id' => $entityId ), 0 ); |
|
| 1449 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1450 | + \eoxia\log_class::exec('wpshop_attributes', 'wpshop_attributes', __('Remove the attribute : ' . $value->value_id, 'wpshop'), array('object_id' => $entityId), 0); |
|
| 1451 | 1451 | } |
| 1452 | 1452 | } |
| 1453 | 1453 | } |
| 1454 | 1454 | } |
| 1455 | 1455 | } |
| 1456 | - do_action( "saved_attribute_for_entity", $attribute_setted, $old_attribute_to_set, $entityTypeId, $entityId ); |
|
| 1456 | + do_action("saved_attribute_for_entity", $attribute_setted, $old_attribute_to_set, $entityTypeId, $entityId); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | } |
| 1459 | 1459 | |
@@ -1473,7 +1473,7 @@ discard block |
||
| 1473 | 1473 | |
| 1474 | 1474 | $query_params = ""; |
| 1475 | 1475 | $query_params_values = array($attributeId, $entityTypeId, $entityId); |
| 1476 | - if(WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))){ |
|
| 1476 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))) { |
|
| 1477 | 1477 | $query_params = " |
| 1478 | 1478 | AND ATTR_VAL.user_id = %d"; |
| 1479 | 1479 | $query_params_values[] = get_current_user_id(); |
@@ -1489,20 +1489,20 @@ discard block |
||
| 1489 | 1489 | ); |
| 1490 | 1490 | $attributeValue = $wpdb->get_results($query); |
| 1491 | 1491 | |
| 1492 | - if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) { |
|
| 1492 | + if (((count($attributeValue) <= 1) && !empty($attributeValue[0])) && (empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select'))) { |
|
| 1493 | 1493 | $attributeValue = $attributeValue[0]; |
| 1494 | 1494 | } |
| 1495 | - else{ |
|
| 1495 | + else { |
|
| 1496 | 1496 | $entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true); |
| 1497 | - if ( !empty($entity_meta) ) { |
|
| 1497 | + if (!empty($entity_meta)) { |
|
| 1498 | 1498 | $query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId); |
| 1499 | 1499 | $attribute_code = $wpdb->get_var($query); |
| 1500 | 1500 | $attributeValue = !empty($entity_meta[$attribute_code]) ? $entity_meta[$attribute_code] : null; |
| 1501 | 1501 | } |
| 1502 | - if ( is_array($attributeValue) ) { |
|
| 1502 | + if (is_array($attributeValue)) { |
|
| 1503 | 1503 | $tmp_array = array(); |
| 1504 | - if ( !empty($attributeValue) ) { |
|
| 1505 | - foreach ( $attributeValue as $att ) { |
|
| 1504 | + if (!empty($attributeValue)) { |
|
| 1505 | + foreach ($attributeValue as $att) { |
|
| 1506 | 1506 | $obj = new stdClass(); |
| 1507 | 1507 | $obj->value = $att; |
| 1508 | 1508 | $obj->unit_id = 0; |
@@ -1533,9 +1533,9 @@ discard block |
||
| 1533 | 1533 | $elements = array(); |
| 1534 | 1534 | $elementsWithAttributeAndValues = self::get_attribute_list_for_item($entityId, $elementId, $language); |
| 1535 | 1535 | |
| 1536 | - foreach ( $elementsWithAttributeAndValues as $elementDefinition ) { |
|
| 1536 | + foreach ($elementsWithAttributeAndValues as $elementDefinition) { |
|
| 1537 | 1537 | $arrayKey = $elementDefinition->attribute_id; |
| 1538 | - if ( $keyForArray == 'code' ) { |
|
| 1538 | + if ($keyForArray == 'code') { |
|
| 1539 | 1539 | $arrayKey = $elementDefinition->attribute_code; |
| 1540 | 1540 | } |
| 1541 | 1541 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['code'] = $elementDefinition->attribute_set_section_code; |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_table'] = $elementDefinition->backend_table; |
| 1546 | 1546 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_input'] = $elementDefinition->backend_input; |
| 1547 | 1547 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_input'] = $elementDefinition->frontend_input; |
| 1548 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __( $elementDefinition->frontend_label, 'wpshop' ); |
|
| 1548 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __($elementDefinition->frontend_label, 'wpshop'); |
|
| 1549 | 1549 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['attribute_code'] = $elementDefinition->attribute_code; |
| 1550 | 1550 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['data_type_to_use'] = $elementDefinition->data_type_to_use; |
| 1551 | 1551 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['is_visible_in_front'] = $elementDefinition->is_visible_in_front; |
@@ -1555,29 +1555,29 @@ discard block |
||
| 1555 | 1555 | $attributeValueField = 'attribute_value_' . $elementDefinition->data_type; |
| 1556 | 1556 | |
| 1557 | 1557 | // Manage the value differently if it is an array or not |
| 1558 | - if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) { |
|
| 1558 | + if (!empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
|
| 1559 | 1559 | if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
| 1560 | 1560 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField; |
| 1561 | 1561 | } |
| 1562 | 1562 | else { |
| 1563 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField); |
|
| 1563 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'], $elementDefinition->$attributeValueField); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | } |
| 1566 | 1566 | else { |
| 1567 | 1567 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField; |
| 1568 | 1568 | } |
| 1569 | 1569 | |
| 1570 | - if ( $elementDefinition->backend_input == 'multiple-select' ) { |
|
| 1570 | + if ($elementDefinition->backend_input == 'multiple-select') { |
|
| 1571 | 1571 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['select_value'] = self::get_attribute_type_select_option_info($attributeValueField, 'value'); |
| 1572 | 1572 | } |
| 1573 | 1573 | |
| 1574 | 1574 | $attributeUnitField = 'attribute_unit_' . $elementDefinition->data_type; |
| 1575 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $elementDefinition->$attributeUnitField, 'wpshop' ); |
|
| 1576 | - if( !empty($elementDefinition->is_requiring_unit ) && ( $elementDefinition->is_requiring_unit == 'yes' ) && empty( $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] ) ) { |
|
| 1575 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($elementDefinition->$attributeUnitField, 'wpshop'); |
|
| 1576 | + if (!empty($elementDefinition->is_requiring_unit) && ($elementDefinition->is_requiring_unit == 'yes') && empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'])) { |
|
| 1577 | 1577 | $unit = ''; |
| 1578 | - $query = $wpdb->prepare( 'SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1579 | - $unit = $wpdb->get_var( $query ); |
|
| 1580 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $unit, 'wpshop' ); |
|
| 1578 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1579 | + $unit = $wpdb->get_var($query); |
|
| 1580 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($unit, 'wpshop'); |
|
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | 1583 | } |
@@ -1589,7 +1589,7 @@ discard block |
||
| 1589 | 1589 | $elementsWithAttributeAndValues = array(); |
| 1590 | 1590 | $moreQuery = ""; |
| 1591 | 1591 | |
| 1592 | - $entity_type = empty($defined_entity_type) ? get_post_type( $elementId ) : $defined_entity_type; |
|
| 1592 | + $entity_type = empty($defined_entity_type) ? get_post_type($elementId) : $defined_entity_type; |
|
| 1593 | 1593 | |
| 1594 | 1594 | $query = $wpdb->prepare( |
| 1595 | 1595 | "SELECT POST_META.*, |
@@ -1638,23 +1638,23 @@ discard block |
||
| 1638 | 1638 | * |
| 1639 | 1639 | * @return boolean The result to know if the element has to be displayed on frontend |
| 1640 | 1640 | */ |
| 1641 | - public static function check_attribute_display( $attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1642 | - if ( $attribute_main_config === 'yes' ) { |
|
| 1641 | + public static function check_attribute_display($attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1642 | + if ($attribute_main_config === 'yes') { |
|
| 1643 | 1643 | $attribute_output = true; |
| 1644 | - if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' ) |
|
| 1645 | - || empty($attribute_custom_config) ) { |
|
| 1644 | + if ((is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') |
|
| 1645 | + || empty($attribute_custom_config)) { |
|
| 1646 | 1646 | $attribute_output = true; |
| 1647 | 1647 | } |
| 1648 | - else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) ) { |
|
| 1648 | + else if (empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no'))) { |
|
| 1649 | 1649 | $attribute_output = false; |
| 1650 | 1650 | } |
| 1651 | 1651 | } |
| 1652 | - elseif ( $attribute_main_config === 'no' ) { |
|
| 1652 | + elseif ($attribute_main_config === 'no') { |
|
| 1653 | 1653 | $attribute_output = false; |
| 1654 | - if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) { |
|
| 1654 | + if (empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code])) { |
|
| 1655 | 1655 | $attribute_output = false; |
| 1656 | 1656 | } |
| 1657 | - else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') ) { |
|
| 1657 | + else if (!empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes')) { |
|
| 1658 | 1658 | $attribute_output = true; |
| 1659 | 1659 | } |
| 1660 | 1660 | } |
@@ -1671,22 +1671,22 @@ discard block |
||
| 1671 | 1671 | global $wpdb; |
| 1672 | 1672 | global $wp_query; |
| 1673 | 1673 | |
| 1674 | - $attribute = self::getElement( $atts['attid'] ); |
|
| 1675 | - if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1676 | - $attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1677 | - $output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output'; |
|
| 1674 | + $attribute = self::getElement($atts['attid']); |
|
| 1675 | + if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1676 | + $attribute_main_config = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1677 | + $output_type = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? 'complete_sheet' : 'mini_output'; |
|
| 1678 | 1678 | $product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true); |
| 1679 | - $display_attribute_value = wpshop_attributes::check_attribute_display( $attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1679 | + $display_attribute_value = wpshop_attributes::check_attribute_display($attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1680 | 1680 | |
| 1681 | - if ( !empty( $attribute->data_type ) ) { |
|
| 1681 | + if (!empty($attribute->data_type)) { |
|
| 1682 | 1682 | $attributeDefinition['unit'] = ''; |
| 1683 | 1683 | |
| 1684 | 1684 | $has_value = false; |
| 1685 | - $query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid'] ); |
|
| 1686 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) ) { |
|
| 1685 | + $query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid']); |
|
| 1686 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox'))) { |
|
| 1687 | 1687 | $list_of_value = $wpdb->get_results($query); |
| 1688 | - if ( !empty($list_of_value) ) { |
|
| 1689 | - foreach ( $list_of_value as $value ) { |
|
| 1688 | + if (!empty($list_of_value)) { |
|
| 1689 | + foreach ($list_of_value as $value) { |
|
| 1690 | 1690 | $data[] = $value->value; |
| 1691 | 1691 | } |
| 1692 | 1692 | $has_value = true; |
@@ -1694,10 +1694,10 @@ discard block |
||
| 1694 | 1694 | } |
| 1695 | 1695 | else { |
| 1696 | 1696 | $data = $wpdb->get_var($query); |
| 1697 | - if ( !empty($data) ) { |
|
| 1697 | + if (!empty($data)) { |
|
| 1698 | 1698 | $has_value = true; |
| 1699 | 1699 | } |
| 1700 | - elseif( !empty($attribute->default_value) ) { |
|
| 1700 | + elseif (!empty($attribute->default_value)) { |
|
| 1701 | 1701 | $has_value = true; |
| 1702 | 1702 | $data = $attribute->default_value; |
| 1703 | 1703 | } |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | $attributeDefinition['is_requiring_unit'] = $attribute->is_requiring_unit; |
| 1710 | 1710 | $attributeDefinition['backend_input'] = $attribute->backend_input; |
| 1711 | 1711 | $attributeDefinition['data_type_to_use'] = $attribute->data_type_to_use; |
| 1712 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 1712 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 1713 | 1713 | $attribute_value = $attribute_display[0]; |
| 1714 | 1714 | $attributeDefinition['value'] = $attribute_display[1]; |
| 1715 | 1715 | $attribute_unit_list = $attribute_display[2]; |
@@ -1729,13 +1729,13 @@ discard block |
||
| 1729 | 1729 | * @param array $specific_argument Optionnal The different parameters used for filter output |
| 1730 | 1730 | * @return array The definition for the field used to display an attribute |
| 1731 | 1731 | */ |
| 1732 | - public static function get_attribute_field_definition( $attribute, $attribute_value = '', $specific_argument = array() ) { |
|
| 1732 | + public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array()) { |
|
| 1733 | 1733 | global $wpdb; |
| 1734 | 1734 | $wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 1735 | 1735 | $wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT); |
| 1736 | 1736 | $input_def = array(); |
| 1737 | 1737 | $input_def['option'] = $input_def['field_container_class'] = ''; |
| 1738 | - $attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty')) ) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '' ) . 'attribute[' . $attribute->data_type . ']'); |
|
| 1738 | + $attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty'))) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '') . 'attribute[' . $attribute->data_type . ']'); |
|
| 1739 | 1739 | $input_def['input_domain'] = $attributeInputDomain; |
| 1740 | 1740 | $input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id; |
| 1741 | 1741 | $input_def['intrinsec'] = $attribute->is_intrinsic; |
@@ -1755,26 +1755,26 @@ discard block |
||
| 1755 | 1755 | $input_def['frontend_type'] = $attribute->frontend_input; |
| 1756 | 1756 | $input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form; |
| 1757 | 1757 | |
| 1758 | - if ( !empty($attribute_value) && !is_object($attribute_value) ) { |
|
| 1758 | + if (!empty($attribute_value) && !is_object($attribute_value)) { |
|
| 1759 | 1759 | $input_def['value'] = $attribute_value; |
| 1760 | 1760 | } |
| 1761 | - else if ( !empty($attribute_value->value) ) { |
|
| 1761 | + else if (!empty($attribute_value->value)) { |
|
| 1762 | 1762 | $input_def['value'] = stripslashes($attribute_value->value); |
| 1763 | 1763 | } |
| 1764 | - else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) { |
|
| 1764 | + else if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft')) { |
|
| 1765 | 1765 | $input_def['value'] = ''; |
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | $input_def['options'] = ''; |
| 1769 | 1769 | $input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : ''; |
| 1770 | 1770 | if ($attribute->data_type == 'datetime') { |
| 1771 | - $date_config = unserialize( $attribute->default_value ); |
|
| 1771 | + $date_config = unserialize($attribute->default_value); |
|
| 1772 | 1772 | if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) { |
| 1773 | 1773 | $input_def['value'] = date('Y-m-d'); |
| 1774 | 1774 | } |
| 1775 | 1775 | else { |
| 1776 | 1776 | /** Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/ */ |
| 1777 | - $input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' ); |
|
| 1777 | + $input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace(" 00:00:00", "", $attribute_value->value) : (!empty($attribute_value) && is_string($attribute_value) ? str_replace(" 00:00:00", "", $attribute_value) : ''); |
|
| 1778 | 1778 | } |
| 1779 | 1779 | $input_more_class .= ' wpshop_input_datetime '; |
| 1780 | 1780 | $field_script = '<script type="text/javascript" > |
@@ -1787,31 +1787,31 @@ discard block |
||
| 1787 | 1787 | wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true); |
| 1788 | 1788 | wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");'; |
| 1789 | 1789 | |
| 1790 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']) ) { |
|
| 1791 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ) { |
|
| 1790 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) { |
|
| 1791 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) { |
|
| 1792 | 1792 | $field_script .= ' |
| 1793 | 1793 | wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");'; |
| 1794 | 1794 | } |
| 1795 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ) { |
|
| 1795 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) { |
|
| 1796 | 1796 | $field_script .= ' |
| 1797 | 1797 | wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");'; |
| 1798 | 1798 | } |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | 1801 | $script_options = $script_options_params = array(); |
| 1802 | - if ( !empty($date_config['field_options']['attribute_type_date_options_day_to_show']) ) { |
|
| 1802 | + if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) { |
|
| 1803 | 1803 | $day_to_show_list = ' '; |
| 1804 | - foreach ( $date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show ) { |
|
| 1804 | + foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) { |
|
| 1805 | 1805 | $day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || '; |
| 1806 | 1806 | } |
| 1807 | 1807 | $script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )'; |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0]) ) { |
|
| 1811 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 1810 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) { |
|
| 1811 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) { |
|
| 1812 | 1812 | $available_date = ' '; |
| 1813 | - foreach ( $date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list ) { |
|
| 1814 | - if ( !empty($avalaible_date_list) ) { |
|
| 1813 | + foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) { |
|
| 1814 | + if (!empty($avalaible_date_list)) { |
|
| 1815 | 1815 | $available_date .= '"' . $avalaible_date_list . '",'; |
| 1816 | 1816 | } |
| 1817 | 1817 | } |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | } |
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | - if ( !empty( $script_options ) ) { |
|
| 1823 | + if (!empty($script_options)) { |
|
| 1824 | 1824 | $field_script .= ' |
| 1825 | 1825 | wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){ |
| 1826 | 1826 | ' . implode(' ', $script_options_params) . '; |
@@ -1848,37 +1848,37 @@ discard block |
||
| 1848 | 1848 | </script>'; |
| 1849 | 1849 | $input_def['options'] .= $field_script; |
| 1850 | 1850 | } |
| 1851 | - if ( in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1852 | - $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ' ); |
|
| 1851 | + if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1852 | + $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select '); |
|
| 1853 | 1853 | $input_def['type'] = ((!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend')) || (!is_admin() && empty($specific_argument['from'])) ? $attribute->frontend_input : $attribute->backend_input); |
| 1854 | 1854 | $input_def['valueToPut'] = 'index'; |
| 1855 | 1855 | |
| 1856 | 1856 | $select_display = self::get_select_output($attribute, $specific_argument); |
| 1857 | - if ( empty( $input_def[ 'options_label' ] ) && !empty( $specific_argument ) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend') ) ) { |
|
| 1858 | - $input_def[ 'options_label' ][ 'original' ] = true; |
|
| 1857 | + if (empty($input_def['options_label']) && !empty($specific_argument) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend'))) { |
|
| 1858 | + $input_def['options_label']['original'] = true; |
|
| 1859 | 1859 | } |
| 1860 | 1860 | $input_def['options'] .= $select_display['more_input']; |
| 1861 | 1861 | $input_def['possible_value'] = (!empty($select_display) && !empty($select_display['possible_value'])) ? $select_display['possible_value'] : ''; |
| 1862 | - if ( !is_admin() ) { |
|
| 1862 | + if (!is_admin()) { |
|
| 1863 | 1863 | $input_def['options'] .= '<input type="hidden" value="' . str_replace("\\", "", $input_def['value']) . '" name="wpshop_product_attribute_' . $attribute->code . '_current_value" id="wpshop_product_attribute_' . $attribute->code . '_current_value" />'; |
| 1864 | 1864 | } |
| 1865 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1866 | - $input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array( 'CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin'); |
|
| 1865 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1866 | + $input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array('CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin'); |
|
| 1867 | 1867 | } |
| 1868 | 1868 | } |
| 1869 | 1869 | $input_def['label_pointer'] = 'for="' . $input_def['id'] . '"'; |
| 1870 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 1870 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 1871 | 1871 | $input_def['label_pointer'] = ''; |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | 1874 | /* |
| 1875 | 1875 | * Specifc treatment for price attributes |
| 1876 | 1876 | */ |
| 1877 | - if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){ |
|
| 1877 | + if ((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC)) { |
|
| 1878 | 1878 | $input_def['option'] .= ' readonly="readonly" '; |
| 1879 | 1879 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1880 | 1880 | } |
| 1881 | - elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){ |
|
| 1881 | + elseif ((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT)) { |
|
| 1882 | 1882 | $input_def['option'] .= ' readonly="readonly" '; |
| 1883 | 1883 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1884 | 1884 | } |
@@ -1889,7 +1889,7 @@ discard block |
||
| 1889 | 1889 | |
| 1890 | 1890 | $input_def['label'] = str_replace("\\", "", $input_def['label']); |
| 1891 | 1891 | // $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 1892 | - $input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . (( is_admin() ) ? $attribute->backend_css_class : $attribute->frontend_css_class) . ( !empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '' ) . '" '; |
|
| 1892 | + $input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . ((is_admin()) ? $attribute->backend_css_class : $attribute->frontend_css_class) . (!empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '') . '" '; |
|
| 1893 | 1893 | $input_def['title'] = !empty($attribute->frontend_help_message) ? ' title="' . $attribute->frontend_help_message . '" ' : ''; |
| 1894 | 1894 | |
| 1895 | 1895 | if (($attribute->is_intrinsic == 'yes') && ((!empty($input_def['value'])) || ($input_def['value'] > 0))) { |
@@ -1900,13 +1900,13 @@ discard block |
||
| 1900 | 1900 | * Add the unit to the attribute if attribute configuration is set to yes |
| 1901 | 1901 | */ |
| 1902 | 1902 | if ($attribute->is_requiring_unit == 'yes') { |
| 1903 | - if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) { |
|
| 1903 | + if (in_array($attribute->code, $wpshop_price_attributes) || (WPSHOP_COST_OF_POSTAGE == $attribute->code)) { |
|
| 1904 | 1904 | $input_def['options'] .= ' <span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>'; |
| 1905 | 1905 | } |
| 1906 | - elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) { |
|
| 1906 | + elseif (in_array($attribute->code, $wpshop_weight_attributes)) { |
|
| 1907 | 1907 | $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
| 1908 | - $query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1909 | - $unity = $wpdb->get_var( $query ); |
|
| 1908 | + $query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1909 | + $unity = $wpdb->get_var($query); |
|
| 1910 | 1910 | $input_def['options'] .= ' <span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>'; |
| 1911 | 1911 | } |
| 1912 | 1912 | else { |
@@ -1914,11 +1914,11 @@ discard block |
||
| 1914 | 1914 | $unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id); |
| 1915 | 1915 | $unit_input_def['type'] = 'select'; |
| 1916 | 1916 | $unit_input_def['option'] = ' class="wpshop_attribute_unit_input chosen_select" '; |
| 1917 | - $unit_input_def['id'] = ( !empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null ) . '_' . ( !empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null ) . '_unit_attribute_' . $attribute->id; |
|
| 1917 | + $unit_input_def['id'] = (!empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null) . '_' . (!empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null) . '_unit_attribute_' . $attribute->id; |
|
| 1918 | 1918 | $unit_input_def['name'] = $attribute->code; |
| 1919 | 1919 | $unit_input_def['value'] = (!empty($attribute_value->unit_id) ? $attribute_value->unit_id : ''); |
| 1920 | - if($unit_input_def['value'] == ''){ |
|
| 1921 | - if ( $attribute->_default_unit > 0 ) { |
|
| 1920 | + if ($unit_input_def['value'] == '') { |
|
| 1921 | + if ($attribute->_default_unit > 0) { |
|
| 1922 | 1922 | $unit_input_def['value'] = $attribute->_default_unit; |
| 1923 | 1923 | } |
| 1924 | 1924 | else { |
@@ -1932,18 +1932,18 @@ discard block |
||
| 1932 | 1932 | /* |
| 1933 | 1933 | * Add indication on postage cost tax |
| 1934 | 1934 | */ |
| 1935 | - if ( $attribute->code == WPSHOP_COST_OF_POSTAGE ) { |
|
| 1935 | + if ($attribute->code == WPSHOP_COST_OF_POSTAGE) { |
|
| 1936 | 1936 | $input_def['options'] .= ' <span class="attribute_currency" >' . __('ATI', 'wpshop') . '</span>'; |
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | /* |
| 1940 | 1940 | * Create the field output |
| 1941 | 1941 | */ |
| 1942 | - if ( is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1943 | - $input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'),__('is_user_defined', 'wpshop')); |
|
| 1942 | + if (is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1943 | + $input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'), __('is_user_defined', 'wpshop')); |
|
| 1944 | 1944 | $input_def['options'] = ''; |
| 1945 | 1945 | $input_def['label_pointer'] = ''; |
| 1946 | - $input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1946 | + $input_def['option'] = substr($input_def['option'], 0, -2) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1947 | 1947 | $input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container'; |
| 1948 | 1948 | } |
| 1949 | 1949 | else { |
@@ -1958,7 +1958,7 @@ discard block |
||
| 1958 | 1958 | * @param string $output_from |
| 1959 | 1959 | * @return string The output for |
| 1960 | 1960 | */ |
| 1961 | - public static function display_attribute( $attribute_code, $output_from = 'admin', $output_specs = array() ) { |
|
| 1961 | + public static function display_attribute($attribute_code, $output_from = 'admin', $output_specs = array()) { |
|
| 1962 | 1962 | $output = ''; |
| 1963 | 1963 | /* Get the page code */ |
| 1964 | 1964 | $currentPageCode = !empty($output_specs['page_code']) ? $output_specs['page_code'] : ''; |
@@ -1969,17 +1969,17 @@ discard block |
||
| 1969 | 1969 | |
| 1970 | 1970 | /* Get attribute input definition */ |
| 1971 | 1971 | $current_value = (!empty($output_specs['current_value']) ? $output_specs['current_value'] : ''); |
| 1972 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)) ); |
|
| 1972 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from))); |
|
| 1973 | 1973 | |
| 1974 | 1974 | /* Create default output */ |
| 1975 | 1975 | $input_to_display = $input['output'] . $input['options']; |
| 1976 | 1976 | |
| 1977 | 1977 | /* Check if current field is linked to an addon, and if the addon is activated */ |
| 1978 | 1978 | $addons_list = unserialize(WPSHOP_ADDONS_LIST); |
| 1979 | - foreach ( $addons_list as $addon_code => $addon_def ) { |
|
| 1980 | - if ( in_array($attribute_code, $addon_def) ) { |
|
| 1981 | - if ( constant($addon_code) === false ) { |
|
| 1982 | - $input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate",'wpshop') . '</a>'; |
|
| 1979 | + foreach ($addons_list as $addon_code => $addon_def) { |
|
| 1980 | + if (in_array($attribute_code, $addon_def)) { |
|
| 1981 | + if (constant($addon_code) === false) { |
|
| 1982 | + $input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate", 'wpshop') . '</a>'; |
|
| 1983 | 1983 | } |
| 1984 | 1984 | } |
| 1985 | 1985 | } |
@@ -2004,11 +2004,11 @@ discard block |
||
| 2004 | 2004 | /* |
| 2005 | 2005 | * Display attribute option if applicable |
| 2006 | 2006 | */ |
| 2007 | - if ( $output_from == 'admin') { |
|
| 2008 | - $attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop') ) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 2007 | + if ($output_from == 'admin') { |
|
| 2008 | + $attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 2009 | 2009 | |
| 2010 | 2010 | $output['field'] .= ' |
| 2011 | - <div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($element_identifier, $attribute_def->code).'</div>'; |
|
| 2011 | + <div class="attribute_option_'.$attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($element_identifier, $attribute_def->code) . '</div>'; |
|
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | 2014 | $output['field'] .= '</div>'; |
@@ -2026,36 +2026,36 @@ discard block |
||
| 2026 | 2026 | * |
| 2027 | 2027 | * @return string The html code to output directly tabs |
| 2028 | 2028 | */ |
| 2029 | - public static function attribute_of_entity_to_tab( $element_code, $element_id, $element_definition ) { |
|
| 2029 | + public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) { |
|
| 2030 | 2030 | $attributeContentOutput = ''; |
| 2031 | 2031 | |
| 2032 | 2032 | /** Get the different attribute affected to the entity */ |
| 2033 | 2033 | $element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend'); |
| 2034 | 2034 | |
| 2035 | 2035 | |
| 2036 | - if ( is_array($element_atribute_list) && (count($element_atribute_list) > 0) ) { |
|
| 2037 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2036 | + if (is_array($element_atribute_list) && (count($element_atribute_list) > 0)) { |
|
| 2037 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2038 | 2038 | $attributeToShowNumber = 0; |
| 2039 | 2039 | $attributeOutput = ''; |
| 2040 | 2040 | |
| 2041 | - foreach ( $attributeSetContent['attributes'] as $attributeId => $attributeDefinition ) { |
|
| 2041 | + foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) { |
|
| 2042 | 2042 | |
| 2043 | 2043 | /** Check the value type to check if empty or not */ |
| 2044 | - if ( $attributeDefinition['data_type'] == 'int' ) { |
|
| 2044 | + if ($attributeDefinition['data_type'] == 'int') { |
|
| 2045 | 2045 | $attributeDefinition['value'] = (int)$attributeDefinition['value']; |
| 2046 | 2046 | } |
| 2047 | - else if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2047 | + else if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2048 | 2048 | $attributeDefinition['value'] = (float)$attributeDefinition['value']; |
| 2049 | 2049 | } |
| 2050 | 2050 | |
| 2051 | 2051 | /** Check if the attribute is set to be displayed in frontend */ |
| 2052 | - $attribute_display_state = wpshop_attributes::check_attribute_display( $attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2052 | + $attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2053 | 2053 | |
| 2054 | 2054 | /** Output the field if the value is not null */ |
| 2055 | 2055 | |
| 2056 | - if ( (is_array($attributeDefinition['value']) || ( !empty($attributeDefinition['value']) ) ) && $attribute_display_state) { |
|
| 2056 | + if ((is_array($attributeDefinition['value']) || (!empty($attributeDefinition['value']))) && $attribute_display_state) { |
|
| 2057 | 2057 | |
| 2058 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 2058 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 2059 | 2059 | $attribute_value = $attribute_display[0]; |
| 2060 | 2060 | $attributeDefinition['value'] = $attribute_display[1]; |
| 2061 | 2061 | $attribute_unit_list = $attribute_display[2]; |
@@ -2066,8 +2066,8 @@ discard block |
||
| 2066 | 2066 | $tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode; |
| 2067 | 2067 | $tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code']; |
| 2068 | 2068 | $tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop'); |
| 2069 | - $tpl_component['ATTRIBUTE_VALUE'] = ( !is_array($attribute_value) ) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2070 | - $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2069 | + $tpl_component['ATTRIBUTE_VALUE'] = (!is_array($attribute_value)) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2070 | + $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2071 | 2071 | |
| 2072 | 2072 | /** Build template */ |
| 2073 | 2073 | $attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component); |
@@ -2078,9 +2078,9 @@ discard block |
||
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | /** Check if the attribute set section is set to be displayed in frontend */ |
| 2081 | - $attribute_set_display_state = wpshop_attributes::check_attribute_display( $attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2081 | + $attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2082 | 2082 | |
| 2083 | - if ( !$attribute_set_display_state ) { |
|
| 2083 | + if (!$attribute_set_display_state) { |
|
| 2084 | 2084 | $attributeToShowNumber = 0; |
| 2085 | 2085 | $attributeOutput = ''; |
| 2086 | 2086 | } |
@@ -2090,8 +2090,8 @@ discard block |
||
| 2090 | 2090 | |
| 2091 | 2091 | /** Gestion de l'affichage */ |
| 2092 | 2092 | $tab_list = $content_list = ''; |
| 2093 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2094 | - if ( !empty($attributeSetContent['count']) > 0 ) { |
|
| 2093 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2094 | + if (!empty($attributeSetContent['count']) > 0) { |
|
| 2095 | 2095 | /** Template parameters */ |
| 2096 | 2096 | $template_part = 'product_attribute_tabs'; |
| 2097 | 2097 | $tpl_component = array(); |
@@ -2100,7 +2100,7 @@ discard block |
||
| 2100 | 2100 | |
| 2101 | 2101 | /** Build template */ |
| 2102 | 2102 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2103 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2103 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2104 | 2104 | /* Include the old way template part */ |
| 2105 | 2105 | ob_start(); |
| 2106 | 2106 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2120,7 +2120,7 @@ discard block |
||
| 2120 | 2120 | |
| 2121 | 2121 | /** Build template */ |
| 2122 | 2122 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2123 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2123 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2124 | 2124 | /* Include the old way template part */ |
| 2125 | 2125 | ob_start(); |
| 2126 | 2126 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2134,16 +2134,16 @@ discard block |
||
| 2134 | 2134 | } |
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | - if ( $tab_list != '' ) { |
|
| 2137 | + if ($tab_list != '') { |
|
| 2138 | 2138 | /** Template parameters */ |
| 2139 | 2139 | $template_part = 'product_attribute_container'; |
| 2140 | 2140 | $tpl_component = array(); |
| 2141 | - $tpl_component['PDT_TABS'] = apply_filters( 'wpshop_extra_tabs_menu_before', '' ).$tab_list.apply_filters( 'wpshop_extra_tabs_menu_after', '' ); |
|
| 2142 | - $tpl_component['PDT_TAB_DETAIL'] = apply_filters( 'wpshop_extra_tabs_content_before', '' ).$content_list.apply_filters( 'wpshop_extra_tabs_content_after', '' ); |
|
| 2141 | + $tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', ''); |
|
| 2142 | + $tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', ''); |
|
| 2143 | 2143 | |
| 2144 | 2144 | /** Build template */ |
| 2145 | 2145 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2146 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2146 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2147 | 2147 | /* Include the old way template part */ |
| 2148 | 2148 | ob_start(); |
| 2149 | 2149 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2166,9 +2166,9 @@ discard block |
||
| 2166 | 2166 | * @param unknown_type $attributeDefinition |
| 2167 | 2167 | * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <> |
| 2168 | 2168 | */ |
| 2169 | - public static function wps_attribute_values_display( $attributeDefinition ) { |
|
| 2169 | + public static function wps_attribute_values_display($attributeDefinition) { |
|
| 2170 | 2170 | $attribute_unit_list = ''; |
| 2171 | - if ( !empty($attributeDefinition['unit']) ) { |
|
| 2171 | + if (!empty($attributeDefinition['unit'])) { |
|
| 2172 | 2172 | /** Template parameters */ |
| 2173 | 2173 | $template_part = 'product_attribute_unit'; |
| 2174 | 2174 | $tpl_component = array(); |
@@ -2180,31 +2180,31 @@ discard block |
||
| 2180 | 2180 | } |
| 2181 | 2181 | |
| 2182 | 2182 | $attribute_value = $attributeDefinition['value']; |
| 2183 | - if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2184 | - $attribute_value =(is_numeric($attribute_value) ) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2185 | - if ( in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) { |
|
| 2186 | - if ( $attributeDefinition['is_requiring_unit'] == 'yes' ) { |
|
| 2183 | + if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2184 | + $attribute_value = (is_numeric($attribute_value)) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2185 | + if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) { |
|
| 2186 | + if ($attributeDefinition['is_requiring_unit'] == 'yes') { |
|
| 2187 | 2187 | $attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency(); |
| 2188 | 2188 | } |
| 2189 | 2189 | $attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']); |
| 2190 | 2190 | } |
| 2191 | 2191 | } |
| 2192 | - if ( $attributeDefinition['data_type'] == 'datetime' ) { |
|
| 2192 | + if ($attributeDefinition['data_type'] == 'datetime') { |
|
| 2193 | 2193 | $attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true); |
| 2194 | 2194 | } |
| 2195 | - if ( $attributeDefinition['backend_input'] == 'select' ) { |
|
| 2195 | + if ($attributeDefinition['backend_input'] == 'select') { |
|
| 2196 | 2196 | $attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
| 2197 | 2197 | } |
| 2198 | 2198 | /** Manage differently if its an array of values or not */ |
| 2199 | - if ( $attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2199 | + if ($attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2200 | 2200 | $attribute_value = ''; |
| 2201 | - if ( is_array($attributeDefinition['value']) ) { |
|
| 2201 | + if (is_array($attributeDefinition['value'])) { |
|
| 2202 | 2202 | foreach ($attributeDefinition['value'] as $v) { |
| 2203 | - $attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2203 | + $attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2204 | 2204 | } |
| 2205 | 2205 | } |
| 2206 | - else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2207 | - $attribute_value = substr($attribute_value,3); |
|
| 2206 | + else $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2207 | + $attribute_value = substr($attribute_value, 3); |
|
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | 2210 | return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list); |
@@ -2214,13 +2214,13 @@ discard block |
||
| 2214 | 2214 | * Manage display for the output when user uses a shortcode for attributes display |
| 2215 | 2215 | * @param array $shorcode_args The list of argument passed through the shortcode |
| 2216 | 2216 | */ |
| 2217 | - function wpshop_attributes_shortcode( $shorcode_args ) { |
|
| 2217 | + function wpshop_attributes_shortcode($shorcode_args) { |
|
| 2218 | 2218 | $output = ''; |
| 2219 | 2219 | /* |
| 2220 | 2220 | * Read the attribute list |
| 2221 | 2221 | */ |
| 2222 | - foreach ( explode(', ', $shorcode_args['attributes']) as $attribute_code ) { |
|
| 2223 | - $attribute_output_def = wpshop_attributes::display_attribute( $attribute_code, $shorcode_args['from'] ); |
|
| 2222 | + foreach (explode(', ', $shorcode_args['attributes']) as $attribute_code) { |
|
| 2223 | + $attribute_output_def = wpshop_attributes::display_attribute($attribute_code, $shorcode_args['from']); |
|
| 2224 | 2224 | $output .= $attribute_output_def['field']; |
| 2225 | 2225 | } |
| 2226 | 2226 | |
@@ -2242,7 +2242,7 @@ discard block |
||
| 2242 | 2242 | $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid','deleted'"); |
| 2243 | 2243 | $attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_'); |
| 2244 | 2244 | |
| 2245 | - if ( count($productAttributeSetDetails) > 0 ) { |
|
| 2245 | + if (count($productAttributeSetDetails) > 0) { |
|
| 2246 | 2246 | /* Read the attribute list in order to output */ |
| 2247 | 2247 | $shortcodes_attr = ''; |
| 2248 | 2248 | $shortcodes_to_display = false; |
@@ -2252,80 +2252,80 @@ discard block |
||
| 2252 | 2252 | |
| 2253 | 2253 | $shortcodes = $currentTabContent = ''; |
| 2254 | 2254 | $output_nb = 0; |
| 2255 | - if(count($productAttributeSetDetail['attribut']) >= 1){ |
|
| 2256 | - foreach($productAttributeSetDetail['attribut'] as $attribute){ |
|
| 2255 | + if (count($productAttributeSetDetail['attribut']) >= 1) { |
|
| 2256 | + foreach ($productAttributeSetDetail['attribut'] as $attribute) { |
|
| 2257 | 2257 | |
| 2258 | - if ( !empty($attribute->id) ) { |
|
| 2259 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2258 | + if (!empty($attribute->id)) { |
|
| 2259 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2260 | 2260 | $attribute_set_id_is_present = true; |
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /** Generic part for attribute field output */ |
| 2264 | 2264 | $value = wpshop_attributes::getAttributeValueForEntityInSet($attribute->data_type, $attribute->id, wpshop_entities::get_entity_identifier_from_code($currentPageCode), $itemToEdit, array('intrinsic' => $attribute->is_intrinsic, 'backend_input' => $attribute->backend_input)); |
| 2265 | - $product_meta = get_post_meta( $itemToEdit, '_wpshop_product_metadata', true); |
|
| 2265 | + $product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true); |
|
| 2266 | 2266 | |
| 2267 | 2267 | /** Check if value is empty and get value in meta if not empty */ |
| 2268 | 2268 | $value = (empty($value) && !empty($product_meta[$attribute->code])) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null); |
| 2269 | 2269 | |
| 2270 | 2270 | /* Manage specific field as the attribute_set_id in product form */ |
| 2271 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2271 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2272 | 2272 | |
| 2273 | 2273 | $value = empty($value) ? $attributeSetId : $value; |
| 2274 | 2274 | } |
| 2275 | 2275 | $attribute_specification['current_value'] = $value; |
| 2276 | - $attribute_output_def = apply_filters( 'wpshop_attribute_output_def', wpshop_attributes::display_attribute( $attribute->code, 'admin', $attribute_specification), $itemToEdit ); |
|
| 2277 | - if ( ($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id') ) { |
|
| 2276 | + $attribute_output_def = apply_filters('wpshop_attribute_output_def', wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification), $itemToEdit); |
|
| 2277 | + if (($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id')) { |
|
| 2278 | 2278 | $currentTabContent .= $attribute_output_def['field']; |
| 2279 | - $shortcode_code_def=array(); |
|
| 2280 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2281 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2282 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2283 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2279 | + $shortcode_code_def = array(); |
|
| 2280 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2281 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2282 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2283 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2284 | 2284 | ob_start(); |
| 2285 | - wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls'); |
|
| 2286 | - $shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>'; |
|
| 2285 | + wps_shortcodes_ctr::output_shortcode('attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])) . ' wpshop_cls'); |
|
| 2286 | + $shortcodes .= '<li class="wpshop_cls" >' . sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>' . __($attribute_output_def['field_definition']['label'], 'wpshop') . '</span>') . ob_get_contents() . '</li>'; |
|
| 2287 | 2287 | ob_end_clean(); |
| 2288 | 2288 | } |
| 2289 | 2289 | else { |
| 2290 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2290 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2291 | 2291 | $attribute_output_def['field_definition']['type'] = 'hidden'; |
| 2292 | 2292 | } |
| 2293 | - $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2293 | + $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2294 | 2294 | } |
| 2295 | 2295 | $output_nb++; |
| 2296 | 2296 | } |
| 2297 | 2297 | } |
| 2298 | 2298 | |
| 2299 | - $currentTabContent = apply_filters( 'wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail ); |
|
| 2299 | + $currentTabContent = apply_filters('wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail); |
|
| 2300 | 2300 | |
| 2301 | 2301 | $shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group'; |
| 2302 | 2302 | $shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit; |
| 2303 | 2303 | $shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id']; |
| 2304 | 2304 | ob_start(); |
| 2305 | - wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_'.str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])).' cls'); |
|
| 2306 | - $attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>'; |
|
| 2305 | + wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_' . str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])) . ' cls'); |
|
| 2306 | + $attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>' . $productAttributeSetDetail['name'] . '</span>') . ob_get_contents() . '<ul class="" >' . $shortcodes . '</ul>'; |
|
| 2307 | 2307 | ob_end_clean(); |
| 2308 | 2308 | |
| 2309 | - if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) |
|
| 2310 | - $currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; |
|
| 2309 | + if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box') |
|
| 2310 | + $currentTabContent .= '<div class="wpshop_cls" ><strong>' . __('Shortcodes', 'wpshop') . '</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; |
|
| 2311 | 2311 | else |
| 2312 | 2312 | $shortcodes_attr .= $attribute_group_display; |
| 2313 | 2313 | |
| 2314 | - if ( $output_nb <= 0 ) { |
|
| 2314 | + if ($output_nb <= 0) { |
|
| 2315 | 2315 | $currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop'); |
| 2316 | 2316 | } |
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | 2319 | if ($output_nb > 0) { |
| 2320 | 2320 | $shortcodes_to_display = true; |
| 2321 | - if ( $outputType == 'box' ) { |
|
| 2321 | + if ($outputType == 'box') { |
|
| 2322 | 2322 | $box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name']; |
| 2323 | - $box['box'][$productAttributeSetDetail['code'].'_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2323 | + $box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2324 | 2324 | $box['boxContent'][$productAttributeSetDetail['code']] = ' |
| 2325 | 2325 | <div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . ' |
| 2326 | 2326 | </div><div class="wpshop_cls" ></div>'; |
| 2327 | 2327 | } |
| 2328 | - else if ( $outputType == 'column' ) { |
|
| 2328 | + else if ($outputType == 'column') { |
|
| 2329 | 2329 | $currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent); |
| 2330 | 2330 | $currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent); |
| 2331 | 2331 | |
@@ -2335,11 +2335,11 @@ discard block |
||
| 2335 | 2335 | } |
| 2336 | 2336 | } |
| 2337 | 2337 | |
| 2338 | - if( !$attribute_set_id_is_present ) { |
|
| 2338 | + if (!$attribute_set_id_is_present) { |
|
| 2339 | 2339 | /* Get attribute definition */ |
| 2340 | 2340 | $attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code'); |
| 2341 | 2341 | /* Get attribute input definition */ |
| 2342 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')) ); |
|
| 2342 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin'))); |
|
| 2343 | 2343 | $input['type'] = 'hidden'; |
| 2344 | 2344 | |
| 2345 | 2345 | $box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']); |
@@ -2350,13 +2350,13 @@ discard block |
||
| 2350 | 2350 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2351 | 2351 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2352 | 2352 | ob_start(); |
| 2353 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2353 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2354 | 2354 | $box['boxMore'] .= ob_get_contents(); |
| 2355 | 2355 | ob_end_clean(); |
| 2356 | 2356 | $box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; |
| 2357 | 2357 | |
| 2358 | - if ( $shortcodes_to_display ) { |
|
| 2359 | - switch ( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE ) { |
|
| 2358 | + if ($shortcodes_to_display) { |
|
| 2359 | + switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) { |
|
| 2360 | 2360 | case 'fixed-tab': |
| 2361 | 2361 | case 'movable-tab': |
| 2362 | 2362 | if ($outputType == 'box') { |
@@ -2364,7 +2364,7 @@ discard block |
||
| 2364 | 2364 | $box['boxContent']['shortcode'] = $shortcodes_attr; |
| 2365 | 2365 | $box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE; |
| 2366 | 2366 | } |
| 2367 | - else{ |
|
| 2367 | + else { |
|
| 2368 | 2368 | $box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop'); |
| 2369 | 2369 | $box['columnContent']['shortcode'] = $shortcodes_attr; |
| 2370 | 2370 | } |
@@ -2388,12 +2388,12 @@ discard block |
||
| 2388 | 2388 | $ouput['more_input'] = ''; |
| 2389 | 2389 | |
| 2390 | 2390 | $attribute_default_value = $attribute->default_value; |
| 2391 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2391 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2392 | 2392 | $tmp_default_value = unserialize($attribute->default_value); |
| 2393 | 2393 | $attribute_default_value = !empty($tmp_default_value["default_value"]) ? $tmp_default_value["default_value"] : null; |
| 2394 | 2394 | } |
| 2395 | 2395 | |
| 2396 | - if ( $attribute->data_type_to_use == 'custom') { |
|
| 2396 | + if ($attribute->data_type_to_use == 'custom') { |
|
| 2397 | 2397 | $query = $wpdb->prepare("SELECT id, label, value, '' as name FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' ORDER BY position", $attribute->id); |
| 2398 | 2398 | $attribute_select_options = $wpdb->get_results($query); |
| 2399 | 2399 | |
@@ -2405,11 +2405,11 @@ discard block |
||
| 2405 | 2405 | // } |
| 2406 | 2406 | endforeach; |
| 2407 | 2407 | } |
| 2408 | - elseif ( $attribute->data_type_to_use == 'internal') { |
|
| 2408 | + elseif ($attribute->data_type_to_use == 'internal') { |
|
| 2409 | 2409 | switch ($attribute_default_value) { |
| 2410 | 2410 | case 'users': |
| 2411 | 2411 | $users = get_users('orderby=nicename'); |
| 2412 | - foreach($users as $user){ |
|
| 2412 | + foreach ($users as $user) { |
|
| 2413 | 2413 | $attribute_select_options_list[$user->ID] = $user->display_name; |
| 2414 | 2414 | } |
| 2415 | 2415 | break; |
@@ -2418,11 +2418,11 @@ discard block |
||
| 2418 | 2418 | $wpshop_attr_custom_post_query = new WP_Query(array( |
| 2419 | 2419 | 'post_type' => $attribute_default_value, |
| 2420 | 2420 | 'posts_per_page' => -1, |
| 2421 | - 'post_status' => array( 'publish', 'draft', 'future' ) , |
|
| 2421 | + 'post_status' => array('publish', 'draft', 'future'), |
|
| 2422 | 2422 | )); |
| 2423 | 2423 | |
| 2424 | - if($wpshop_attr_custom_post_query->have_posts()): |
|
| 2425 | - foreach($wpshop_attr_custom_post_query->posts as $post){ |
|
| 2424 | + if ($wpshop_attr_custom_post_query->have_posts()): |
|
| 2425 | + foreach ($wpshop_attr_custom_post_query->posts as $post) { |
|
| 2426 | 2426 | $attribute_select_options_list[$post->ID] = $post->post_title; |
| 2427 | 2427 | } |
| 2428 | 2428 | endif; |
@@ -2433,27 +2433,27 @@ discard block |
||
| 2433 | 2433 | |
| 2434 | 2434 | /* There is no value existing for this value */ |
| 2435 | 2435 | if (empty($attribute_select_options_list)) : |
| 2436 | - $ouput['more_input'].=__('Nothing found for this field', 'wpshop'); |
|
| 2436 | + $ouput['more_input'] .= __('Nothing found for this field', 'wpshop'); |
|
| 2437 | 2437 | else: |
| 2438 | 2438 | /* Add a default value to the combobox list */ |
| 2439 | 2439 | $default_value_is_serial = false; |
| 2440 | 2440 | $attribute_list_first_element = $attribute->default_value; |
| 2441 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2441 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2442 | 2442 | $default_value_is_serial = true; |
| 2443 | 2443 | $tmp_default_value = unserialize($attribute->default_value); |
| 2444 | 2444 | $attribute_list_first_element = $tmp_default_value["field_options"]["label_for_first_item"]; |
| 2445 | 2445 | } |
| 2446 | 2446 | //if ( !in_array($attribute->frontend_input, array('radio', 'checkbox')) || ($attribute_list_first_element != 'none') ) $ouput['possible_value'][] = ($default_value_is_serial && !empty($attribute_list_first_element)) ? $attribute_list_first_element : __('Choose a value', 'wpshop'); |
| 2447 | - foreach ( $attribute_select_options_list as $option_key => $option_value ) { |
|
| 2447 | + foreach ($attribute_select_options_list as $option_key => $option_value) { |
|
| 2448 | 2448 | $ouput['possible_value'][$option_key] = stripslashes($option_value); |
| 2449 | 2449 | } |
| 2450 | 2450 | endif; |
| 2451 | 2451 | |
| 2452 | 2452 | /* Add a extra element to create a new element into list */ |
| 2453 | - if ( is_admin() && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) { |
|
| 2453 | + if (is_admin() && (empty($provenance['from']) || ($provenance['from'] != 'frontend'))) { |
|
| 2454 | 2454 | /** $ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />'; */ |
| 2455 | 2455 | } |
| 2456 | - else if ( 'yes' == $attribute->is_used_in_quick_add_form ) { |
|
| 2456 | + else if ('yes' == $attribute->is_used_in_quick_add_form) { |
|
| 2457 | 2457 | $tpl_component = array(); |
| 2458 | 2458 | $tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']'; |
| 2459 | 2459 | $ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component); |
@@ -2462,11 +2462,11 @@ discard block |
||
| 2462 | 2462 | return $ouput; |
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | - public static function get_affected_value_for_list( $attribute_code, $element_id, $attribute_data_type ) { |
|
| 2465 | + public static function get_affected_value_for_list($attribute_code, $element_id, $attribute_data_type) { |
|
| 2466 | 2466 | global $wpdb; |
| 2467 | 2467 | $affected_value = array(); |
| 2468 | 2468 | |
| 2469 | - if ( $attribute_data_type == 'custom' ) { |
|
| 2469 | + if ($attribute_data_type == 'custom') { |
|
| 2470 | 2470 | $query = $wpdb->prepare(" |
| 2471 | 2471 | SELECT ATT_SELECT_OPTIONS_VALUE.id AS chosen_val, ATT_SELECT_OPTIONS_VALUE.value |
| 2472 | 2472 | FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT |
@@ -2488,20 +2488,20 @@ discard block |
||
| 2488 | 2488 | } |
| 2489 | 2489 | |
| 2490 | 2490 | $attribute_values_for_variations = $wpdb->get_results($query); |
| 2491 | - foreach ( $attribute_values_for_variations as $attribute_def ) { |
|
| 2492 | - $affected_value[] = (int) $attribute_def->chosen_val; |
|
| 2491 | + foreach ($attribute_values_for_variations as $attribute_def) { |
|
| 2492 | + $affected_value[] = (int)$attribute_def->chosen_val; |
|
| 2493 | 2493 | } |
| 2494 | 2494 | |
| 2495 | 2495 | return $affected_value; |
| 2496 | 2496 | } |
| 2497 | 2497 | |
| 2498 | 2498 | public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') { |
| 2499 | - switch($attr_code){ |
|
| 2499 | + switch ($attr_code) { |
|
| 2500 | 2500 | case 'is_downloadable_': |
| 2501 | - $option = get_post_meta($item['item_id'], 'attribute_option_'.$attr_code, true); |
|
| 2502 | - switch($attr_option){ |
|
| 2501 | + $option = get_post_meta($item['item_id'], 'attribute_option_' . $attr_code, true); |
|
| 2502 | + switch ($attr_option) { |
|
| 2503 | 2503 | case 'file_url': |
| 2504 | - if(in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_'.$attr_code]) && (strtolower(__($item['item_'.$attr_code], 'wpshop')) == __('yes','wpshop'))) ){ |
|
| 2504 | + if (in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_' . $attr_code]) && (strtolower(__($item['item_' . $attr_code], 'wpshop')) == __('yes', 'wpshop')))) { |
|
| 2505 | 2505 | $file_url = isset($option[$attr_option]) ? $option[$attr_option] : false; |
| 2506 | 2506 | return $file_url; |
| 2507 | 2507 | } |
@@ -2514,17 +2514,17 @@ discard block |
||
| 2514 | 2514 | |
| 2515 | 2515 | public static function get_attribute_option_fields($postid, $code) { |
| 2516 | 2516 | |
| 2517 | - switch($code){ |
|
| 2517 | + switch ($code) { |
|
| 2518 | 2518 | case 'is_downloadable_': |
| 2519 | - $data = get_post_meta($postid, 'attribute_option_'.$code, true); |
|
| 2520 | - $data['file_url'] = !empty($data['file_url'])?$data['file_url']:__('No file selected', 'wpshop'); |
|
| 2521 | - $fields = wp_nonce_field( 'ajax_wpshop_show_downloadable_interface_in_admin'.$postid, '_show_downloadable_interface_in_admin_wpnonce', true, false ); |
|
| 2519 | + $data = get_post_meta($postid, 'attribute_option_' . $code, true); |
|
| 2520 | + $data['file_url'] = !empty($data['file_url']) ? $data['file_url'] : __('No file selected', 'wpshop'); |
|
| 2521 | + $fields = wp_nonce_field('ajax_wpshop_show_downloadable_interface_in_admin' . $postid, '_show_downloadable_interface_in_admin_wpnonce', true, false); |
|
| 2522 | 2522 | $fields .= '<div class="wpshop_form_label alignleft"> </div> |
| 2523 | 2523 | <div class="wpshop_form_input_element alignleft"> |
| 2524 | - <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid.'" title="' .__('Send the downloadable file', 'wpshop'). '"></div> |
|
| 2525 | - <a data-nonce="' . wp_create_nonce( "ajax_wpshop_fill_the_downloadable_dialog".$postid ) . '" class="send_downlodable_file wps-bton-first-mini-rounded">' .__('Send a file', 'wpshop').'</a> |
|
| 2526 | - <input type="hidden" class="product_identifer_field" value="' .( !empty($postid) ? esc_attr( $postid ) : '') . '" /><br/><u>'.__('File url','wpshop').' :</u> |
|
| 2527 | - <div class="is_downloadable_statut_'.$postid.'"><a href="' .$data['file_url']. '" target="_blank" download>'.basename($data['file_url']).'</a></div> |
|
| 2524 | + <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid . '" title="' . __('Send the downloadable file', 'wpshop') . '"></div> |
|
| 2525 | + <a data-nonce="' . wp_create_nonce("ajax_wpshop_fill_the_downloadable_dialog" . $postid) . '" class="send_downlodable_file wps-bton-first-mini-rounded">' . __('Send a file', 'wpshop') . '</a> |
|
| 2526 | + <input type="hidden" class="product_identifer_field" value="' .(!empty($postid) ? esc_attr($postid) : '') . '" /><br/><u>' . __('File url', 'wpshop') . ' :</u> |
|
| 2527 | + <div class="is_downloadable_statut_'.$postid . '"><a href="' . $data['file_url'] . '" target="_blank" download>' . basename($data['file_url']) . '</a></div> |
|
| 2528 | 2528 | </div>'; |
| 2529 | 2529 | return $fields; |
| 2530 | 2530 | break; |
@@ -2549,8 +2549,8 @@ discard block |
||
| 2549 | 2549 | $attribute_value_content = ''; |
| 2550 | 2550 | |
| 2551 | 2551 | $atributes = self::getElement($attribute_code, "'valid'", 'code'); |
| 2552 | - if ( !empty($atributes) ) { |
|
| 2553 | - $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2552 | + if (!empty($atributes)) { |
|
| 2553 | + $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | 2556 | return $attribute_value_content; |
@@ -2562,13 +2562,13 @@ discard block |
||
| 2562 | 2562 | * @param mixed $value |
| 2563 | 2563 | * @return string The complete interface allowing to manage datetime attribute field |
| 2564 | 2564 | */ |
| 2565 | - public static function attribute_type_date_config( $value ) { |
|
| 2565 | + public static function attribute_type_date_config($value) { |
|
| 2566 | 2566 | $date_config_output = ''; |
| 2567 | 2567 | $input_def['name'] = 'default_value'; |
| 2568 | 2568 | $input_def['type'] = 'checkbox'; |
| 2569 | 2569 | $input_def['possible_value'] = 'date_of_current_day'; |
| 2570 | 2570 | $input_def['value'] = !empty($value['default_value']) ? $value['default_value'] : ''; |
| 2571 | - $input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="'.__('Check this box for using date of the day as value when editing a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 2571 | + $input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="' . __('Check this box for using date of the day as value when editing a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 2572 | 2572 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2573 | 2573 | |
| 2574 | 2574 | $input_def = array(); |
@@ -2577,35 +2577,35 @@ discard block |
||
| 2577 | 2577 | $input_def['type'] = 'checkbox'; |
| 2578 | 2578 | $input_def['valueToPut'] = 'index'; |
| 2579 | 2579 | $input_def['value'] = !empty($value['field_options']['attribute_type_date_options_day_to_show']) ? $value['field_options']['attribute_type_date_options_day_to_show'] : ''; |
| 2580 | - $input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' .__('Tuesday', 'wpshop'), '3' => ' ' .__('Wednesday', 'wpshop'), '4' => ' ' .__('Thursday', 'wpshop'), '5' => ' ' .__('Friday', 'wpshop'), '6' => ' ' .__('Saturday', 'wpshop'), '0' => ' ' .__('Sunday', 'wpshop')); |
|
| 2580 | + $input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' . __('Tuesday', 'wpshop'), '3' => ' ' . __('Wednesday', 'wpshop'), '4' => ' ' . __('Thursday', 'wpshop'), '5' => ' ' . __('Friday', 'wpshop'), '6' => ' ' . __('Saturday', 'wpshop'), '0' => ' ' . __('Sunday', 'wpshop')); |
|
| 2581 | 2581 | $input_def['options_label']['original'] = true; |
| 2582 | - $date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available day in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>'; |
|
| 2582 | + $date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available day in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>'; |
|
| 2583 | 2583 | |
| 2584 | 2584 | /** Past and futur date restriction */ |
| 2585 | 2585 | $input_def = array(); |
| 2586 | 2586 | $input_def['name'] = ''; |
| 2587 | 2587 | $input_def['type'] = 'text'; |
| 2588 | - $date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="'.__('Define if the end user is allowed to choose past and/or futur date', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2588 | + $date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="' . __('Define if the end user is allowed to choose past and/or futur date', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2589 | 2589 | $available_type_input_def = array(); |
| 2590 | 2590 | $available_type_input_def['name'] = ''; |
| 2591 | 2591 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_minimum'; |
| 2592 | 2592 | $available_type_input_def['type'] = 'text'; |
| 2593 | 2593 | $available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] : ''; |
| 2594 | - $date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>'; |
|
| 2594 | + $date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>'; |
|
| 2595 | 2595 | $available_type_input_def = array(); |
| 2596 | 2596 | $available_type_input_def['name'] = ''; |
| 2597 | 2597 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_maximum'; |
| 2598 | 2598 | $available_type_input_def['type'] = 'text'; |
| 2599 | 2599 | $available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] : ''; |
| 2600 | - $date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>'; |
|
| 2600 | + $date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>'; |
|
| 2601 | 2601 | $date_config_output .= '</div>'; |
| 2602 | 2602 | |
| 2603 | 2603 | $input_def = array(); |
| 2604 | 2604 | $input_def['name'] = ''; |
| 2605 | 2605 | $input_def['type'] = 'text'; |
| 2606 | 2606 | $date_config_output .= ' |
| 2607 | -<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') .'</div> |
|
| 2608 | -<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available date in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2607 | +<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '</div> |
|
| 2608 | +<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available date in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2609 | 2609 | |
| 2610 | 2610 | $available_type_input_def = array(); |
| 2611 | 2611 | $available_type_input_def['name'] = ''; |
@@ -2618,9 +2618,9 @@ discard block |
||
| 2618 | 2618 | $date_config_output .= wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_type]') . '<br/>'; |
| 2619 | 2619 | |
| 2620 | 2620 | $existing = 0; |
| 2621 | - if ( !empty($value['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 2622 | - foreach ( $value['field_options']['attribute_type_date_options_available_date'] as $index => $value ) { |
|
| 2623 | - if ( !empty($value) ) { |
|
| 2621 | + if (!empty($value['field_options']['attribute_type_date_options_available_date'])) { |
|
| 2622 | + foreach ($value['field_options']['attribute_type_date_options_available_date'] as $index => $value) { |
|
| 2623 | + if (!empty($value)) { |
|
| 2624 | 2624 | $input_def['value'] = $value; |
| 2625 | 2625 | $input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_' . $index; |
| 2626 | 2626 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '<br/>'; |
@@ -2644,20 +2644,20 @@ discard block |
||
| 2644 | 2644 | * @param array $values Valeurs d'attributs |
| 2645 | 2645 | * @return array |
| 2646 | 2646 | */ |
| 2647 | - public static function setAttributesValuesForItem($entityId, $values=array(), $defaultValueForOthers=false, $from = 'webservice') { |
|
| 2648 | - $message=''; |
|
| 2647 | + public static function setAttributesValuesForItem($entityId, $values = array(), $defaultValueForOthers = false, $from = 'webservice') { |
|
| 2648 | + $message = ''; |
|
| 2649 | 2649 | $attribute_available = array(); |
| 2650 | 2650 | $attribute_final = array(); |
| 2651 | 2651 | $entity_type = get_post_type($entityId); |
| 2652 | - $data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2653 | - foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2652 | + $data = self::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2653 | + foreach ($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2654 | 2654 | |
| 2655 | 2655 | // Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity |
| 2656 | - foreach ( $values as $key => $value ) { |
|
| 2657 | - if ( in_array( $key, array_keys( $attribute_available ) ) ) { |
|
| 2656 | + foreach ($values as $key => $value) { |
|
| 2657 | + if (in_array($key, array_keys($attribute_available))) { |
|
| 2658 | 2658 | $attribute_final[$attribute_available[$key]['data_type']][$key] = $value; |
| 2659 | 2659 | } |
| 2660 | - else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n"; |
|
| 2660 | + else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key) . "\n"; |
|
| 2661 | 2661 | } |
| 2662 | 2662 | |
| 2663 | 2663 | // Pour les autres attributs non donné on leur affecte leur valeur par défaut |
@@ -2678,7 +2678,7 @@ discard block |
||
| 2678 | 2678 | } |
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | - switch ( $entity_type ) { |
|
| 2681 | + switch ($entity_type) { |
|
| 2682 | 2682 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 2683 | 2683 | $meta_key = WPSHOP_PRODUCT_ATTRIBUTE_META_KEY; |
| 2684 | 2684 | break; |
@@ -2708,22 +2708,22 @@ discard block |
||
| 2708 | 2708 | */ |
| 2709 | 2709 | public static function get_attribute_type_select_option_info($option_id, $field = 'label', $attribute_data_type = 'custom', $only_value = false) { |
| 2710 | 2710 | global $wpdb; |
| 2711 | - if( ! is_numeric( $option_id ) ) { |
|
| 2711 | + if (!is_numeric($option_id)) { |
|
| 2712 | 2712 | return ''; |
| 2713 | 2713 | } |
| 2714 | - $option_id = (int) $option_id; |
|
| 2715 | - switch ( $attribute_data_type ) { |
|
| 2714 | + $option_id = (int)$option_id; |
|
| 2715 | + switch ($attribute_data_type) { |
|
| 2716 | 2716 | case 'internal': |
| 2717 | 2717 | $entity_infos = get_post($option_id); |
| 2718 | - if ( !empty($entity_infos) ) { |
|
| 2719 | - if ( !$only_value ) { |
|
| 2718 | + if (!empty($entity_infos)) { |
|
| 2719 | + if (!$only_value) { |
|
| 2720 | 2720 | /** Template parameters */ |
| 2721 | 2721 | $template_part = 'product_attribute_value_internal'; |
| 2722 | 2722 | $tpl_component = array(); |
| 2723 | 2723 | $tpl_component['ATTRIBUTE_VALUE_POST_LINK'] = get_permalink($option_id); |
| 2724 | 2724 | $tpl_component['ATTRIBUTE_VALUE_POST_TITLE'] = $entity_infos->post_title; |
| 2725 | 2725 | |
| 2726 | - foreach ( $entity_infos as $post_definition_key => $post_definition_value ) { |
|
| 2726 | + foreach ($entity_infos as $post_definition_key => $post_definition_value) { |
|
| 2727 | 2727 | $tpl_component['ATTRIBUTE_VALUE_' . strtoupper($post_definition_key)] = $entity_infos->$post_definition_key; |
| 2728 | 2728 | } |
| 2729 | 2729 | |
@@ -2738,8 +2738,8 @@ discard block |
||
| 2738 | 2738 | break; |
| 2739 | 2739 | |
| 2740 | 2740 | default: |
| 2741 | - if ( ! array_key_exists( $option_id, self::$select_option_info_cache ) ) { |
|
| 2742 | - $query = $wpdb->prepare("SELECT " . $field . " FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." WHERE id=%d LIMIT 1", $option_id); |
|
| 2741 | + if (!array_key_exists($option_id, self::$select_option_info_cache)) { |
|
| 2742 | + $query = $wpdb->prepare("SELECT " . $field . " FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE id=%d LIMIT 1", $option_id); |
|
| 2743 | 2743 | self::$select_option_info_cache[$option_id] = $wpdb->get_var($query); |
| 2744 | 2744 | } |
| 2745 | 2745 | $info = self::$select_option_info_cache[$option_id]; |
@@ -2779,39 +2779,39 @@ discard block |
||
| 2779 | 2779 | * @param string $data_type optionnal Le type de donnees choisi pour cet attribut (custom | internal) |
| 2780 | 2780 | * @return string Le resultat sous forme de code html pour la liste des options |
| 2781 | 2781 | */ |
| 2782 | - function get_select_options_list($attribute_id, $data_type='custom') { |
|
| 2782 | + function get_select_options_list($attribute_id, $data_type = 'custom') { |
|
| 2783 | 2783 | global $wpdb; |
| 2784 | 2784 | $output = ''; |
| 2785 | 2785 | |
| 2786 | 2786 | $attribute_select_options = self::get_select_option_list_($attribute_id); |
| 2787 | 2787 | |
| 2788 | 2788 | /* Add possibily to choose datat type to use with list */ |
| 2789 | - if(empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))){ |
|
| 2790 | - unset($input_def);$input_def=array(); |
|
| 2789 | + if (empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))) { |
|
| 2790 | + unset($input_def); $input_def = array(); |
|
| 2791 | 2791 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2792 | 2792 | $input_def['type'] = 'radio'; |
| 2793 | 2793 | $input_def['name'] = 'data_type_to_use'; |
| 2794 | 2794 | $input_def['valueToPut'] = 'index'; |
| 2795 | 2795 | $input_def['possible_value'] = unserialize(WPSHOP_ATTR_SELECT_TYPE); |
| 2796 | 2796 | $input_def['option'] = 'class="wpshop_cls wpshop_attr_combo_data_type"'; |
| 2797 | - $input_def['value'] = $data_type.'_data'; |
|
| 2797 | + $input_def['value'] = $data_type . '_data'; |
|
| 2798 | 2798 | $input_def['options_label']['original'] = true; |
| 2799 | 2799 | $output = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2800 | 2800 | } |
| 2801 | 2801 | |
| 2802 | - if(!empty($attribute_id) || !empty($data_type)){ |
|
| 2803 | - $defaut_value = ( !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value) ) ? $attribute_select_options[0]->default_value : null; |
|
| 2802 | + if (!empty($attribute_id) || !empty($data_type)) { |
|
| 2803 | + $defaut_value = (!empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value)) ? $attribute_select_options[0]->default_value : null; |
|
| 2804 | 2804 | $default_is_serial = false; |
| 2805 | - if ( !empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute_select_options[0]->default_value ) ) ) { |
|
| 2805 | + if (!empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized($attribute_select_options[0]->default_value))) { |
|
| 2806 | 2806 | $defaut_value = unserialize($attribute_select_options[0]->default_value); |
| 2807 | 2807 | $default_is_serial = true; |
| 2808 | 2808 | } |
| 2809 | 2809 | /** Add a custom text first item of list */ |
| 2810 | - $output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes( $defaut_value["field_options"]["label_for_first_item"] ) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>'; |
|
| 2810 | + $output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes($defaut_value["field_options"]["label_for_first_item"]) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>'; |
|
| 2811 | 2811 | |
| 2812 | - if((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))){ |
|
| 2812 | + if ((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))) { |
|
| 2813 | 2813 | $sub_output = ''; |
| 2814 | - if ( !empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id) ) { |
|
| 2814 | + if (!empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id)) { |
|
| 2815 | 2815 | $sub_output .= ' |
| 2816 | 2816 | <li class="wpshop_attribute_combo_options_container ui-state-disabled" > |
| 2817 | 2817 | <input type="radio" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][default_value]" value="" id="default_value_empty" ' . (($default_is_serial && is_array($defaut_value) && empty($defaut_value["default_value"])) || empty($defaut_value) ? 'checked ' : '') . '/> <label for="default_value_empty">' . __('No default value', 'wpshop') . '</label> |
@@ -2824,7 +2824,7 @@ discard block |
||
| 2824 | 2824 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", $options->value); |
| 2825 | 2825 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = (!empty($options->id) && (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"]) && ($defaut_value["default_value"] == $options->id))) ? ' checked="checked"' : ''); |
| 2826 | 2826 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = ''; |
| 2827 | - if( current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0) ): |
|
| 2827 | + if (current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0)): |
|
| 2828 | 2828 | $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_id), 'admin'); |
| 2829 | 2829 | endif; |
| 2830 | 2830 | $sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin'); |
@@ -2832,13 +2832,13 @@ discard block |
||
| 2832 | 2832 | } |
| 2833 | 2833 | } |
| 2834 | 2834 | $add_button = $add_dialog_box = $user_more_script = ''; |
| 2835 | - if( current_user_can('wpshop_add_attributes_select_values') ) { |
|
| 2835 | + if (current_user_can('wpshop_add_attributes_select_values')) { |
|
| 2836 | 2836 | |
| 2837 | 2837 | $dialog_title = __('New value for attribute', 'wpshop'); |
| 2838 | 2838 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2839 | 2839 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2840 | 2840 | ob_start(); |
| 2841 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2841 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2842 | 2842 | $add_dialog_box = ob_get_contents(); |
| 2843 | 2843 | ob_end_clean(); |
| 2844 | 2844 | |
@@ -2846,23 +2846,23 @@ discard block |
||
| 2846 | 2846 | $add_button_parent_class = 'wpshop_attribute_option_value_add'; |
| 2847 | 2847 | $add_button_name = 'wpshop_add_option_to_select'; |
| 2848 | 2848 | ob_start(); |
| 2849 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2849 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2850 | 2850 | $add_button = ob_get_contents(); |
| 2851 | 2851 | ob_end_clean(); |
| 2852 | 2852 | |
| 2853 | 2853 | $user_more_script = ' |
| 2854 | - jQuery("#'.$dialog_identifier.'").dialog({ |
|
| 2854 | + jQuery("#'.$dialog_identifier . '").dialog({ |
|
| 2855 | 2855 | modal: true, |
| 2856 | 2856 | dialogClass: "wpshop_uidialog_box", |
| 2857 | 2857 | autoOpen:false, |
| 2858 | 2858 | show: "blind", |
| 2859 | 2859 | resizable: false, |
| 2860 | 2860 | buttons:{ |
| 2861 | - "'.__('Add', 'wpshop').'": function(){ |
|
| 2861 | + "'.__('Add', 'wpshop') . '": function(){ |
|
| 2862 | 2862 | var data = { |
| 2863 | 2863 | action: "new_option_for_select", |
| 2864 | 2864 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '", |
| 2865 | - attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(), |
|
| 2865 | + attribute_new_label: jQuery("#'.$dialog_input_identifier . '").val(), |
|
| 2866 | 2866 | attribute_identifier: "' . $attribute_id . '" |
| 2867 | 2867 | }; |
| 2868 | 2868 | jQuery.post(ajaxurl, data, function(response) { |
@@ -2878,21 +2878,21 @@ discard block |
||
| 2878 | 2878 | |
| 2879 | 2879 | jQuery(this).children("img").show(); |
| 2880 | 2880 | }, |
| 2881 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 2881 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 2882 | 2882 | jQuery(this).dialog("close"); |
| 2883 | 2883 | } |
| 2884 | 2884 | }, |
| 2885 | 2885 | close:function(){ |
| 2886 | - jQuery("#'.$dialog_input_identifier.'").val(""); |
|
| 2886 | + jQuery("#'.$dialog_input_identifier . '").val(""); |
|
| 2887 | 2887 | } |
| 2888 | 2888 | }); |
| 2889 | - jQuery(".'.$add_button_parent_class.' input").click(function(){ |
|
| 2890 | - jQuery("#'.$dialog_identifier.'").dialog("open"); |
|
| 2889 | + jQuery(".'.$add_button_parent_class . ' input").click(function(){ |
|
| 2890 | + jQuery("#'.$dialog_identifier . '").dialog("open"); |
|
| 2891 | 2891 | });'; |
| 2892 | 2892 | |
| 2893 | 2893 | } |
| 2894 | 2894 | $output .= $add_dialog_box . ' |
| 2895 | - <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.' |
|
| 2895 | + <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options) > 5 ? $add_button : '') . $sub_output . $add_button . ' |
|
| 2896 | 2896 | </ul> |
| 2897 | 2897 | <input type="hidden" value="' . wp_create_nonce("wpshop_new_option_for_attribute_deletion") . '" name="wpshop_new_option_for_attribute_deletion_nonce" id="wpshop_new_option_for_attribute_deletion_nonce" /> |
| 2898 | 2898 | <script type="text/javascript" > |
@@ -2908,7 +2908,7 @@ discard block |
||
| 2908 | 2908 | var data = { |
| 2909 | 2909 | action: "attribute_output_type", |
| 2910 | 2910 | current_type: jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").val(), |
| 2911 | - elementIdentifier: "'.$attribute_id.'", |
|
| 2911 | + elementIdentifier: "'.$attribute_id . '", |
|
| 2912 | 2912 | data_type_to_use: jQuery(this).val(), |
| 2913 | 2913 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '" |
| 2914 | 2914 | }; |
@@ -2923,10 +2923,10 @@ discard block |
||
| 2923 | 2923 | }); |
| 2924 | 2924 | </script>'; |
| 2925 | 2925 | } |
| 2926 | - elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){ |
|
| 2927 | - $sub_output=''; |
|
| 2926 | + elseif ((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))) { |
|
| 2927 | + $sub_output = ''; |
|
| 2928 | 2928 | $wp_types = unserialize(WPSHOP_INTERNAL_TYPES); |
| 2929 | - unset($input_def);$input_def=array(); |
|
| 2929 | + unset($input_def); $input_def = array(); |
|
| 2930 | 2930 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2931 | 2931 | $input_def['type'] = 'select'; |
| 2932 | 2932 | $input_def['name'] = 'default_value][default_value'; |
@@ -2935,20 +2935,20 @@ discard block |
||
| 2935 | 2935 | $input_def['possible_value'] = $wp_types; |
| 2936 | 2936 | $input_def['value'] = (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"])) ? $defaut_value["default_value"] : (!empty($defaut_value) ? $defaut_value : null)); |
| 2937 | 2937 | $combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2938 | - $output .= '<div class="wpshop_cls">'.$combo_wp_type.'</div>'; |
|
| 2939 | - if ( !empty($attribute_id) ) { |
|
| 2938 | + $output .= '<div class="wpshop_cls">' . $combo_wp_type . '</div>'; |
|
| 2939 | + if (!empty($attribute_id)) { |
|
| 2940 | 2940 | $option_list = '<div>' . __('You can reorder element for display them in the order you want into frontend part', 'wpshop') . '</div>'; |
| 2941 | - $options_for_current_attribute = query_posts( array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ) ); |
|
| 2942 | - if ( !empty($options_for_current_attribute) ) { |
|
| 2941 | + $options_for_current_attribute = query_posts(array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); |
|
| 2942 | + if (!empty($options_for_current_attribute)) { |
|
| 2943 | 2943 | $option_list .= '<ul class="wpshop_attribute_combo_values_list_container" >'; |
| 2944 | 2944 | $current_order = ' '; |
| 2945 | - foreach ( $options_for_current_attribute as $options_def ) { |
|
| 2945 | + foreach ($options_for_current_attribute as $options_def) { |
|
| 2946 | 2946 | $current_order .= 'post_' . $options_def->ID . ','; |
| 2947 | 2947 | $option_list .= '<li id="post_' . $options_def->ID . '" class="wpshop_attribute_combo_values_list_item wpshop_attribute_combo_values_list_item_' . $options_def->ID . '" ><span class="wpshop_internal_value_for_option_list_identifier" >#' . $options_def->ID . '</span> ' . $options_def->post_title . '</li>'; |
| 2948 | 2948 | } |
| 2949 | 2949 | $option_list .= '</ul><input type="hidden" value="' . substr($current_order, 0, -1) . '" name="' . WPSHOP_DBT_ATTRIBUTE . '[wpshop_attribute_combo_values_list_order_def]" id="wpshop_attribute_combo_values_list_order_def" />'; |
| 2950 | 2950 | } |
| 2951 | - $output .= '<div class="wpshop_cls">'.$option_list.'</div>'; |
|
| 2951 | + $output .= '<div class="wpshop_cls">' . $option_list . '</div>'; |
|
| 2952 | 2952 | } |
| 2953 | 2953 | } |
| 2954 | 2954 | } |
@@ -2976,8 +2976,8 @@ discard block |
||
| 2976 | 2976 | $attribute_list_for_entity = self::getElement($entity_id, "'valid'", 'entity_id', true); |
| 2977 | 2977 | |
| 2978 | 2978 | /* Read the list */ |
| 2979 | - if ( !empty ($attribute_list_for_entity ) ) { |
|
| 2980 | - foreach ( $attribute_list_for_entity as $attribute) { |
|
| 2979 | + if (!empty ($attribute_list_for_entity)) { |
|
| 2980 | + foreach ($attribute_list_for_entity as $attribute) { |
|
| 2981 | 2981 | switch ($list_for) { |
| 2982 | 2982 | case 'attribute_value': |
| 2983 | 2983 | $checkbox_state = ' '; |
@@ -2986,8 +2986,8 @@ discard block |
||
| 2986 | 2986 | <select id="wpshop_shortcode_element_attribute_value_product_list_' . $attribute->id . '" class="wpshop_shortcode_element_attribute_value_product_list" >'; |
| 2987 | 2987 | |
| 2988 | 2988 | global $post; |
| 2989 | - $posts = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1) ); |
|
| 2990 | - foreach( $posts as $post ) : |
|
| 2989 | + $posts = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1)); |
|
| 2990 | + foreach ($posts as $post) : |
|
| 2991 | 2991 | setup_postdata($post); |
| 2992 | 2992 | $attribute_possible_values .= '<option value="' . get_the_ID() . '" >' . get_the_ID() . ' - ' . get_the_title() . '</option>'; |
| 2993 | 2993 | endforeach; |
@@ -3003,23 +3003,23 @@ discard block |
||
| 3003 | 3003 | |
| 3004 | 3004 | $checkbox_state = 'disabled '; |
| 3005 | 3005 | $attribute_possible_values = ''; |
| 3006 | - if ( !empty($attribute_values) ) { |
|
| 3006 | + if (!empty($attribute_values)) { |
|
| 3007 | 3007 | $checkbox_state = ''; |
| 3008 | 3008 | $attribute_possible_values = ' |
| 3009 | 3009 | <div class="wpshop_shortcode_element_product_listing_per_attribute_value wpshop_shortcode_element_prodcut_listing_per_attribute_value_' . $attribute->code . '_container" > |
| 3010 | 3010 | <select id="wpshop_attribute_value_for_shortcode_generation_' . $attribute->id . '" class="wpshop_shortcode_element_prodcut_listing_per_attribute_value hidden" >'; |
| 3011 | 3011 | |
| 3012 | - if ( ($attribute->data_type == 'integer') && ( ($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select') ) ) { |
|
| 3012 | + if (($attribute->data_type == 'integer') && (($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select'))) { |
|
| 3013 | 3013 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id=%d ORDER BY position", $attribute->id); |
| 3014 | 3014 | $possible_values = $wpdb->get_results($query); |
| 3015 | 3015 | $already_selected_values = array(); |
| 3016 | 3016 | foreach ($attribute_values as $attribute_value) { |
| 3017 | - if ( !empty($attribute_value->value) ) { |
|
| 3017 | + if (!empty($attribute_value->value)) { |
|
| 3018 | 3018 | $already_selected_values[] = $attribute_value->value; |
| 3019 | 3019 | } |
| 3020 | 3020 | } |
| 3021 | 3021 | foreach ($possible_values as $value) { |
| 3022 | - if ( in_array( $value->id, $already_selected_values ) ) { |
|
| 3022 | + if (in_array($value->id, $already_selected_values)) { |
|
| 3023 | 3023 | $attribute_possible_values .= ' |
| 3024 | 3024 | <option value="' . $value->value . '" >' . $value->label . '</option>'; |
| 3025 | 3025 | } |
@@ -3027,7 +3027,7 @@ discard block |
||
| 3027 | 3027 | } |
| 3028 | 3028 | else { |
| 3029 | 3029 | foreach ($attribute_values as $attribute_value) { |
| 3030 | - if ( !empty($attribute_value->value) ) { |
|
| 3030 | + if (!empty($attribute_value->value)) { |
|
| 3031 | 3031 | $attribute_possible_values .= ' |
| 3032 | 3032 | <option value="' . $attribute_value->value . '" >' . $attribute_value->value . '</option>'; |
| 3033 | 3033 | } |
@@ -3056,23 +3056,23 @@ discard block |
||
| 3056 | 3056 | * |
| 3057 | 3057 | * @return object The attribute list as a wordpress database object |
| 3058 | 3058 | */ |
| 3059 | - function get_attribute_list_in_same_set_section( $attribute_code ) { |
|
| 3059 | + function get_attribute_list_in_same_set_section($attribute_code) { |
|
| 3060 | 3060 | global $wpdb; |
| 3061 | 3061 | |
| 3062 | 3062 | $attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); |
| 3063 | 3063 | |
| 3064 | 3064 | /** Get the entire list of attribute in price set section for display */ |
| 3065 | - $query = $wpdb->prepare( "SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id); |
|
| 3065 | + $query = $wpdb->prepare("SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id); |
|
| 3066 | 3066 | $attribute_attribution_def = $wpdb->get_row($query); |
| 3067 | 3067 | |
| 3068 | - $query = $wpdb->prepare( " |
|
| 3068 | + $query = $wpdb->prepare(" |
|
| 3069 | 3069 | SELECT ATTR.code, is_visible_in_front_listing, is_visible_in_front |
| 3070 | 3070 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS SET_SECTION_DETAIL |
| 3071 | 3071 | INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = SET_SECTION_DETAIL.attribute_id) |
| 3072 | 3072 | WHERE entity_type_id = %d |
| 3073 | 3073 | AND attribute_set_id = %d |
| 3074 | 3074 | AND attribute_group_id = %d", |
| 3075 | - $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id ); |
|
| 3075 | + $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id); |
|
| 3076 | 3076 | $atribute_list = $wpdb->get_results($query); |
| 3077 | 3077 | |
| 3078 | 3078 | return $atribute_list; |
@@ -3083,7 +3083,7 @@ discard block |
||
| 3083 | 3083 | * @param unknown_type $current_entity_id |
| 3084 | 3084 | * @return Ambigous <multitype:, multitype:NULL > |
| 3085 | 3085 | */ |
| 3086 | - public static function get_variation_available_attribute( $current_entity_id ) { |
|
| 3086 | + public static function get_variation_available_attribute($current_entity_id) { |
|
| 3087 | 3087 | global $wpdb; |
| 3088 | 3088 | $final_list = array(); |
| 3089 | 3089 | |
@@ -3091,7 +3091,7 @@ discard block |
||
| 3091 | 3091 | $query = $wpdb->prepare( |
| 3092 | 3092 | "SELECT ATT.*, ENTITY_META.meta_value |
| 3093 | 3093 | FROM " . self::getDbTable() . " AS ATT |
| 3094 | - INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS. " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid')) |
|
| 3094 | + INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid')) |
|
| 3095 | 3095 | INNER JOIN " . $wpdb->postmeta . " AS ENTITY_META ON ((ENTITY_META.meta_key = %s) AND (ENTITY_META.meta_value = ATT_DETAILS.attribute_set_id)) |
| 3096 | 3096 | WHERE ATT.status IN ('valid') |
| 3097 | 3097 | AND ATT.is_used_for_variation = %s |
@@ -3101,10 +3101,10 @@ discard block |
||
| 3101 | 3101 | ); |
| 3102 | 3102 | $attribute_list = $wpdb->get_results($query); |
| 3103 | 3103 | foreach ($attribute_list as $attribute) { |
| 3104 | - if ( !in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select')) ) { |
|
| 3105 | - $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list( $attribute->code, $current_entity_id, $attribute->data_type_to_use ); |
|
| 3104 | + if (!in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select'))) { |
|
| 3105 | + $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list($attribute->code, $current_entity_id, $attribute->data_type_to_use); |
|
| 3106 | 3106 | |
| 3107 | - if ( empty($attribute_values_for_variations) ) { |
|
| 3107 | + if (empty($attribute_values_for_variations)) { |
|
| 3108 | 3108 | $final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label; |
| 3109 | 3109 | $final_list['unavailable'][$attribute->code]['values'] = array(); |
| 3110 | 3110 | $final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute; |
@@ -3124,16 +3124,16 @@ discard block |
||
| 3124 | 3124 | * @param integer $current_entity_id The current element edited |
| 3125 | 3125 | * @return Ambigous <string, string, mixed> |
| 3126 | 3126 | */ |
| 3127 | - public static function get_variation_available_attribute_display( $current_entity_id, $variation_type = 'multiple' ) { |
|
| 3127 | + public static function get_variation_available_attribute_display($current_entity_id, $variation_type = 'multiple') { |
|
| 3128 | 3128 | $attribute_list = wpshop_attributes::get_variation_available_attribute($current_entity_id); |
| 3129 | 3129 | |
| 3130 | 3130 | $attribute_defined_as_available_for_variation = ''; |
| 3131 | - if ( !empty($attribute_list) ) { |
|
| 3131 | + if (!empty($attribute_list)) { |
|
| 3132 | 3132 | foreach ($attribute_list as $list_type => $attribute_list_by_type) { |
| 3133 | 3133 | $sub_attribute_list = ''; |
| 3134 | 3134 | foreach ($attribute_list_by_type as $attribute_code => $attribute_def) { |
| 3135 | 3135 | $tpl_component = array(); |
| 3136 | - if ( $list_type == 'available' ) { |
|
| 3136 | + if ($list_type == 'available') { |
|
| 3137 | 3137 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; |
| 3138 | 3138 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ''; |
| 3139 | 3139 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
@@ -3147,13 +3147,13 @@ discard block |
||
| 3147 | 3147 | $tpl_component['ADMIN_ATTRIBUTE_CODE_FOR_VARIATION'] = $attribute_code; |
| 3148 | 3148 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code; |
| 3149 | 3149 | $tpl_component['ADMIN_VARIATION_ATTRIBUTE_CONTAINER_CLASS'] = ' wpshop_attribute_for_variation_' . $attribute_code; |
| 3150 | - $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __( $attribute_def['label'], 'wpshop' ); |
|
| 3150 | + $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __($attribute_def['label'], 'wpshop'); |
|
| 3151 | 3151 | $tpl_component['ADMIN_VARIATION_NEW_SINGLE_INPUT'] = ''; |
| 3152 | - if ( $variation_type == 'single' ) { |
|
| 3153 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input') ); |
|
| 3154 | - if ( !empty($attribute_output_def['possible_value']) ) { |
|
| 3155 | - foreach( $attribute_output_def['possible_value'] as $value_id => $value ){ |
|
| 3156 | - if ( !in_array($value_id, $attribute_def['values']) ) { |
|
| 3152 | + if ($variation_type == 'single') { |
|
| 3153 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input')); |
|
| 3154 | + if (!empty($attribute_output_def['possible_value'])) { |
|
| 3155 | + foreach ($attribute_output_def['possible_value'] as $value_id => $value) { |
|
| 3156 | + if (!in_array($value_id, $attribute_def['values'])) { |
|
| 3157 | 3157 | unset($attribute_output_def['possible_value'][$value_id]); |
| 3158 | 3158 | } |
| 3159 | 3159 | } |
@@ -3168,7 +3168,7 @@ discard block |
||
| 3168 | 3168 | } |
| 3169 | 3169 | } |
| 3170 | 3170 | |
| 3171 | - return array($attribute_defined_as_available_for_variation, ( (!empty($attribute_list['available']) ) ? $attribute_list['available'] : ''), ( ( !empty($attribute_list['unavailable']) ) ? $attribute_list['unavailable'] : '')); |
|
| 3171 | + return array($attribute_defined_as_available_for_variation, ((!empty($attribute_list['available'])) ? $attribute_list['available'] : ''), ((!empty($attribute_list['unavailable'])) ? $attribute_list['unavailable'] : '')); |
|
| 3172 | 3172 | } |
| 3173 | 3173 | |
| 3174 | 3174 | /** |
@@ -3177,18 +3177,18 @@ discard block |
||
| 3177 | 3177 | * @param array $variations_attribute_parameters Allows to give some parameters for customize list |
| 3178 | 3178 | * @return string The output for all specific attribute in each product with option |
| 3179 | 3179 | */ |
| 3180 | - public static function get_variation_attribute( $variations_attribute_parameters ) { |
|
| 3180 | + public static function get_variation_attribute($variations_attribute_parameters) { |
|
| 3181 | 3181 | $output = ''; |
| 3182 | 3182 | |
| 3183 | 3183 | $attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_in_variation", true); |
| 3184 | - if ( !empty( $attribute_list ) ) { |
|
| 3184 | + if (!empty($attribute_list)) { |
|
| 3185 | 3185 | $tpl_component = array(); |
| 3186 | 3186 | $tpl_component['ADMIN_VARIATION_DETAIL'] = ''; |
| 3187 | 3187 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
| 3188 | - foreach ( $attribute_list as $attribute_def ) { |
|
| 3188 | + foreach ($attribute_list as $attribute_def) { |
|
| 3189 | 3189 | |
| 3190 | 3190 | $variations_attribute_parameters['field_custom_name_prefix'] = $variations_attribute_parameters['field_name'] . '[attribute][' . $attribute_def->data_type . ']'; |
| 3191 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters ); |
|
| 3191 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters); |
|
| 3192 | 3192 | |
| 3193 | 3193 | $field_output = $attribute_output_def['output']; |
| 3194 | 3194 | |
@@ -3200,9 +3200,9 @@ discard block |
||
| 3200 | 3200 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_ID'] = $attribute_output_def['id']; |
| 3201 | 3201 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_LABEL'] = $attribute_output_def['label']; |
| 3202 | 3202 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] = $field_output; |
| 3203 | - if( isset( $variations_attribute_parameters['post_id'] ) ) { |
|
| 3204 | - $attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop') ) == strtolower( __('yes', 'wpshop') )) ? '' : ' wpshopHide'; |
|
| 3205 | - $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code).'</div>'; |
|
| 3203 | + if (isset($variations_attribute_parameters['post_id'])) { |
|
| 3204 | + $attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 3205 | + $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_' . $attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code) . '</div>'; |
|
| 3206 | 3206 | } |
| 3207 | 3207 | $tpl_component['ADMIN_VARIATION_DETAIL'] .= wpshop_display::display_template_element('wpshop_admin_variation_item_details_line', $sub_tpl_component, array(), 'admin'); |
| 3208 | 3208 | unset($sub_tpl_component); |
@@ -3213,7 +3213,7 @@ discard block |
||
| 3213 | 3213 | return $output; |
| 3214 | 3214 | } |
| 3215 | 3215 | |
| 3216 | - public static function get_attribute_user_defined( $use_defined_parameters, $status = "'publish'" ) { |
|
| 3216 | + public static function get_attribute_user_defined($use_defined_parameters, $status = "'publish'") { |
|
| 3217 | 3217 | global $wpdb; |
| 3218 | 3218 | $attribute_user_defined_list = array(); |
| 3219 | 3219 | |
@@ -3240,12 +3240,12 @@ discard block |
||
| 3240 | 3240 | * @param string $post_type The current |
| 3241 | 3241 | * |
| 3242 | 3242 | */ |
| 3243 | - function quick_edit( $column_name, $entity ) { |
|
| 3244 | - switch ( $entity ) { |
|
| 3243 | + function quick_edit($column_name, $entity) { |
|
| 3244 | + switch ($entity) { |
|
| 3245 | 3245 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3246 | 3246 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3247 | - if ( !empty($attribute_def) ) { |
|
| 3248 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3247 | + if (!empty($attribute_def)) { |
|
| 3248 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3249 | 3249 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3250 | 3250 | ?> |
| 3251 | 3251 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -3265,12 +3265,12 @@ discard block |
||
| 3265 | 3265 | * @param string $post_type The current |
| 3266 | 3266 | * |
| 3267 | 3267 | */ |
| 3268 | - public static function bulk_edit( $column_name, $entity ) { |
|
| 3269 | - switch ( $entity ) { |
|
| 3268 | + public static function bulk_edit($column_name, $entity) { |
|
| 3269 | + switch ($entity) { |
|
| 3270 | 3270 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3271 | 3271 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3272 | - if ( !empty($attribute_def) ) { |
|
| 3273 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3272 | + if (!empty($attribute_def)) { |
|
| 3273 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3274 | 3274 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3275 | 3275 | ?> |
| 3276 | 3276 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * Build an array with the different items to add to an order |
| 126 | 126 | * |
| 127 | - * @param array $products The item list to add to the order |
|
| 127 | + * @param array $product The item list to add to the order |
|
| 128 | 128 | * |
| 129 | 129 | * @return array $item_list The item to add to order |
| 130 | 130 | */ |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * |
| 419 | 419 | * @method wps_token_order_customer |
| 420 | 420 | * @param int $order_id OrderID. |
| 421 | - * @return mixed sha1 or false. |
|
| 421 | + * @return false|string sha1 or false. |
|
| 422 | 422 | */ |
| 423 | 423 | public static function wps_token_order_customer( $order_id, $date = null ) { |
| 424 | 424 | $date = isset( $date ) ? $date : date( 'Ym' ); |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | class wps_orders_ctr { |
| 4 | 4 | |
@@ -20,24 +20,24 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | /** Template Load */ |
| 22 | 22 | // add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) ); |
| 23 | - add_shortcode( 'order_customer_informations', array( &$this, 'display_order_customer_informations' ) ); |
|
| 24 | - add_shortcode( 'wps_orders_in_customer_account', array( $this, 'shortcode_callback_display_orders_in_account' ) ); |
|
| 25 | - add_action( 'wp_enqueue_scripts', array( $this, 'wps_orders_scripts' ) ); |
|
| 23 | + add_shortcode('order_customer_informations', array(&$this, 'display_order_customer_informations')); |
|
| 24 | + add_shortcode('wps_orders_in_customer_account', array($this, 'shortcode_callback_display_orders_in_account')); |
|
| 25 | + add_action('wp_enqueue_scripts', array($this, 'wps_orders_scripts')); |
|
| 26 | 26 | /** Include the different javascript */ |
| 27 | - add_action( 'admin_init', array( &$this, 'admin_js' ) ); |
|
| 27 | + add_action('admin_init', array(&$this, 'admin_js')); |
|
| 28 | 28 | |
| 29 | 29 | /** Ajax Actions */ |
| 30 | 30 | // add_action( 'wp_ajax_wps_add_product_to_quotation', array( &$this, 'wps_add_product_to_quotation') ); |
| 31 | 31 | // add_action( 'wap_ajax_wps_change_product_list', array( &$this, 'wps_change_product_list') ); |
| 32 | 32 | // add_action( 'wap_ajax_wps_orders_load_variations_container', array( &$this, 'wps_orders_load_variations_container') ); |
| 33 | 33 | // add_action( 'wap_ajax_wps_order_refresh_in_admin', array( &$this, 'wps_order_refresh_in_admin') ); |
| 34 | - add_action( 'wp_ajax_wps_orders_load_details', array( $this, 'wps_orders_load_details' ) ); |
|
| 34 | + add_action('wp_ajax_wps_orders_load_details', array($this, 'wps_orders_load_details')); |
|
| 35 | 35 | // Add a product sale historic in administration product panel |
| 36 | - add_action( 'wp_ajax_wps_order_choose_customer', array( $this, 'wps_order_choose_customer' ) ); |
|
| 36 | + add_action('wp_ajax_wps_order_choose_customer', array($this, 'wps_order_choose_customer')); |
|
| 37 | 37 | /** For delete order */ |
| 38 | - add_action( 'wp_ajax_wps_delete_order', array( $this, 'wps_delete_order' ) ); |
|
| 38 | + add_action('wp_ajax_wps_delete_order', array($this, 'wps_delete_order')); |
|
| 39 | 39 | /** Invoice Page */ |
| 40 | - add_action( 'admin_post_wps_invoice', array( $this, 'wps_invoice_output' ) ); |
|
| 40 | + add_action('admin_post_wps_invoice', array($this, 'wps_invoice_output')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function wps_orders_scripts() { |
| 56 | 56 | |
| 57 | - wp_enqueue_script( 'wps_orders_fronend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/frontend/js/wps_orders.js' ); |
|
| 57 | + wp_enqueue_script('wps_orders_fronend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/frontend/js/wps_orders.js'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function display_order_customer_informations() { |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | global $post_id; |
| 63 | 63 | global $wpdb; |
| 64 | 64 | $output = ''; |
| 65 | - if ( ! empty( $post_id ) ) { |
|
| 66 | - $order_postmeta = get_post_meta( $post_id, '_order_postmeta', true ); |
|
| 67 | - $order_info = get_post_meta( $post_id, '_order_info', true ); |
|
| 65 | + if (!empty($post_id)) { |
|
| 66 | + $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
|
| 67 | + $order_info = get_post_meta($post_id, '_order_info', true); |
|
| 68 | 68 | /** Check the order status */ |
| 69 | - if ( ! empty( $order_postmeta ) ) { |
|
| 70 | - if ( ! empty( $order_postmeta['order_status'] ) && $order_postmeta['order_status'] != 'awaiting_payment' ) { |
|
| 71 | - $output = wps_address::display_an_address( $order_info['billing']['address'] ); |
|
| 72 | - $output .= wps_address::display_an_address( $order_info['shipping']['address'] ); |
|
| 69 | + if (!empty($order_postmeta)) { |
|
| 70 | + if (!empty($order_postmeta['order_status']) && $order_postmeta['order_status'] != 'awaiting_payment') { |
|
| 71 | + $output = wps_address::display_an_address($order_info['billing']['address']); |
|
| 72 | + $output .= wps_address::display_an_address($order_info['shipping']['address']); |
|
| 73 | 73 | } else { |
| 74 | - $output = wps_address::display_an_address( $order_info['billing']['address'] ); |
|
| 74 | + $output = wps_address::display_an_address($order_info['billing']['address']); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } else { |
| 78 | 78 | /** Display "Choose customer or create one" Interface */ |
| 79 | 79 | $tpl_component = array(); |
| 80 | 80 | $args = array( |
| 81 | - 'show_option_all' => __( 'Choose a customer', 'wpshop' ), |
|
| 81 | + 'show_option_all' => __('Choose a customer', 'wpshop'), |
|
| 82 | 82 | 'orderby' => 'display_name', |
| 83 | 83 | 'order' => 'ASC', |
| 84 | 84 | 'include' => null, // string |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | 'id' => null, // integer |
| 93 | 93 | 'class' => 'chosen_select', // string |
| 94 | 94 | 'blog_id' => $GLOBALS['blog_id'], |
| 95 | - 'who' => null,// string |
|
| 95 | + 'who' => null, // string |
|
| 96 | 96 | ); |
| 97 | - $tpl_component['CUSTOMERS_LIST'] = wp_dropdown_users( $args ); |
|
| 98 | - $output = wpshop_display::display_template_element( 'wps_orders_choose_customer_interface', $tpl_component, array(), 'admin' ); |
|
| 97 | + $tpl_component['CUSTOMERS_LIST'] = wp_dropdown_users($args); |
|
| 98 | + $output = wpshop_display::display_template_element('wps_orders_choose_customer_interface', $tpl_component, array(), 'admin'); |
|
| 99 | 99 | } |
| 100 | 100 | return $output; |
| 101 | 101 | } |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @param array $args Les arguments passés au shortcode. |
| 109 | 109 | */ |
| 110 | - function shortcode_callback_display_orders_in_account( $args ) { |
|
| 111 | - $customer_id = ! empty( $args ) && ! empty( $args['cid'] ) ? (int) $args['cid'] : wps_customer_ctr::get_customer_id_by_author_id( get_current_user_id() ); |
|
| 112 | - return $this->display_orders_in_account( $customer_id ); |
|
| 110 | + function shortcode_callback_display_orders_in_account($args) { |
|
| 111 | + $customer_id = !empty($args) && !empty($args['cid']) ? (int)$args['cid'] : wps_customer_ctr::get_customer_id_by_author_id(get_current_user_id()); |
|
| 112 | + return $this->display_orders_in_account($customer_id); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -119,18 +119,18 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | - function display_orders_in_account( $customer_id = '' ) { |
|
| 122 | + function display_orders_in_account($customer_id = '') { |
|
| 123 | 123 | $output = ''; |
| 124 | - $customer_id = ( ! empty( $customer_id ) ) ? $customer_id : wps_customer_ctr::get_customer_id_by_author_id( get_current_user_id() ); |
|
| 124 | + $customer_id = (!empty($customer_id)) ? $customer_id : wps_customer_ctr::get_customer_id_by_author_id(get_current_user_id()); |
|
| 125 | 125 | $wps_orders_mdl = new wps_orders_mdl(); |
| 126 | - $orders = $wps_orders_mdl->get_customer_orders( $customer_id ); |
|
| 126 | + $orders = $wps_orders_mdl->get_customer_orders($customer_id); |
|
| 127 | 127 | |
| 128 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 128 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
| 129 | 129 | // Vérification de l'activation ou non des livraisons pour l'affichage des adresses correspondantes / Check shipping addresses state in order to display or not addresses. |
| 130 | - $shipping_addresses_activated = ( ! empty( $shipping_address_option ) && ! empty( $shipping_address_option['activate'] ) ) ? true : false; |
|
| 130 | + $shipping_addresses_activated = (!empty($shipping_address_option) && !empty($shipping_address_option['activate'])) ? true : false; |
|
| 131 | 131 | |
| 132 | 132 | ob_start(); |
| 133 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'orders_list_in_account' ) ); |
|
| 133 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'orders_list_in_account')); |
|
| 134 | 134 | $output = ob_get_contents(); |
| 135 | 135 | ob_end_clean(); |
| 136 | 136 | |
@@ -144,41 +144,41 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return array $item_list The item to add to order |
| 146 | 146 | */ |
| 147 | - function add_product_to_order( $product ) { |
|
| 147 | + function add_product_to_order($product) { |
|
| 148 | 148 | |
| 149 | 149 | global $wpdb; |
| 150 | - if ( ! empty( $product ) && empty( $product['price_ttc_before_discount'] ) && empty( $product['price_ht_before_discount'] ) ) { |
|
| 151 | - $price_infos = wpshop_prices::check_product_price( $product, true ); |
|
| 152 | - $product['price_ht'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et']; |
|
| 153 | - $product['product_price'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati']; |
|
| 154 | - $product['tva'] = ( ! empty( $price_infos['discount'] ) && ! empty( $price_infos['discount']['discount_exist'] ) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva']; |
|
| 150 | + if (!empty($product) && empty($product['price_ttc_before_discount']) && empty($product['price_ht_before_discount'])) { |
|
| 151 | + $price_infos = wpshop_prices::check_product_price($product, true); |
|
| 152 | + $product['price_ht'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et']; |
|
| 153 | + $product['product_price'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati']; |
|
| 154 | + $product['tva'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva']; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - $price_piloting = get_option( 'wpshop_shop_price_piloting' ); |
|
| 158 | - if ( ! empty( $price_piloting ) && $price_piloting == 'HT' ) { |
|
| 157 | + $price_piloting = get_option('wpshop_shop_price_piloting'); |
|
| 158 | + if (!empty($price_piloting) && $price_piloting == 'HT') { |
|
| 159 | 159 | $total_ht = $product['price_ht'] * $product['product_qty']; |
| 160 | - $tva_total_amount = $total_ht * ( $product['tx_tva'] / 100 ); |
|
| 160 | + $tva_total_amount = $total_ht * ($product['tx_tva'] / 100); |
|
| 161 | 161 | $total_ttc = $total_ht + $tva_total_amount; |
| 162 | 162 | } else { |
| 163 | 163 | $total_ttc = $product['product_price'] * $product['product_qty']; |
| 164 | - $total_ht = $total_ttc / ( 1 + ( $product['tx_tva'] / 100 ) ); |
|
| 164 | + $total_ht = $total_ttc / (1 + ($product['tx_tva'] / 100)); |
|
| 165 | 165 | $tva_total_amount = $total_ttc - $total_ht; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $tva = ! empty( $product[ WPSHOP_PRODUCT_PRICE_TAX ] ) ? $product[ WPSHOP_PRODUCT_PRICE_TAX ] : null; |
|
| 168 | + $tva = !empty($product[WPSHOP_PRODUCT_PRICE_TAX]) ? $product[WPSHOP_PRODUCT_PRICE_TAX] : null; |
|
| 169 | 169 | $item_discount_type = $item_discount_value = $item_discount_amount = 0; |
| 170 | - $d_amount = ! empty( $product ) && ! empty( $product['discount_amount'] ) ? wpshop_tools::formate_number( $product['discount_amount'] ) : null; |
|
| 171 | - $d_rate = ! empty( $product ) && ! empty( $product['discount_rate'] ) ? wpshop_tools::formate_number( $product['discount_rate'] ) : null; |
|
| 172 | - $d_special = ! empty( $product ) && ! empty( $product['special_price'] ) ? wpshop_tools::formate_number( $product['special_price'] ) : null; |
|
| 173 | - if ( ! empty( $d_amount ) ) { |
|
| 170 | + $d_amount = !empty($product) && !empty($product['discount_amount']) ? wpshop_tools::formate_number($product['discount_amount']) : null; |
|
| 171 | + $d_rate = !empty($product) && !empty($product['discount_rate']) ? wpshop_tools::formate_number($product['discount_rate']) : null; |
|
| 172 | + $d_special = !empty($product) && !empty($product['special_price']) ? wpshop_tools::formate_number($product['special_price']) : null; |
|
| 173 | + if (!empty($d_amount)) { |
|
| 174 | 174 | $item_discount_type = 'discount_amount'; |
| 175 | 175 | $item_discount_amount = $product['discount_amount']; |
| 176 | 176 | $item_discount_value = $product['discount_amount']; |
| 177 | - } elseif ( ! empty( $d_rate ) ) { |
|
| 177 | + } elseif (!empty($d_rate)) { |
|
| 178 | 178 | $item_discount_type = 'discount_rate'; |
| 179 | 179 | $item_discount_amount = $product['discount_rate']; |
| 180 | 180 | $item_discount_value = $product['discount_rate']; |
| 181 | - } elseif ( ! empty( $d_special ) ) { |
|
| 181 | + } elseif (!empty($d_special)) { |
|
| 182 | 182 | $item_discount_type = 'special_price'; |
| 183 | 183 | $item_discount_amount = $product['special_price']; |
| 184 | 184 | $item_discount_value = $product['special_price']; |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $item = array( |
| 188 | 188 | 'item_id' => $product['product_id'], |
| 189 | - 'item_ref' => ! empty( $product['product_reference'] ) ? $product['product_reference'] : null, |
|
| 190 | - 'item_name' => ! empty( $product['product_name'] ) ? $product['product_name'] : 'wpshop_product_' . $product['product_id'], |
|
| 189 | + 'item_ref' => !empty($product['product_reference']) ? $product['product_reference'] : null, |
|
| 190 | + 'item_name' => !empty($product['product_name']) ? $product['product_name'] : 'wpshop_product_' . $product['product_id'], |
|
| 191 | 191 | 'item_qty' => $product['product_qty'], |
| 192 | 192 | 'item_pu_ht' => $product['price_ht'], |
| 193 | 193 | 'item_pu_ttc' => $product['product_price'], |
@@ -202,66 +202,66 @@ discard block |
||
| 202 | 202 | 'item_total_ht' => $total_ht, |
| 203 | 203 | 'item_tva_total_amount' => $tva_total_amount, |
| 204 | 204 | 'item_total_ttc' => $total_ttc, |
| 205 | - 'item_meta' => ! empty( $product['item_meta'] ) ? $product['item_meta'] : array(), |
|
| 205 | + 'item_meta' => !empty($product['item_meta']) ? $product['item_meta'] : array(), |
|
| 206 | 206 | ); |
| 207 | - if ( isset( $product['is_downloadable_'] ) ) { |
|
| 207 | + if (isset($product['is_downloadable_'])) { |
|
| 208 | 208 | $item['item_is_downloadable_'] = $product['is_downloadable_']; |
| 209 | 209 | } |
| 210 | - $array_not_to_do = array( WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT, 'product_qty', WPSHOP_PRODUCT_PRICE_TAX, 'product_id', 'product_reference', 'product_name', 'variations' ); |
|
| 211 | - if ( ! empty( $product['item_meta'] ) ) { |
|
| 212 | - foreach ( $product['item_meta'] as $key => $value ) { |
|
| 213 | - if ( ! isset( $item[ 'item_' . $key ] ) && ! in_array( $key, $array_not_to_do ) && ! empty( $product[ $key ] ) ) { |
|
| 214 | - $item[ 'item_' . $key ] = $product[ $key ]; |
|
| 210 | + $array_not_to_do = array(WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT, 'product_qty', WPSHOP_PRODUCT_PRICE_TAX, 'product_id', 'product_reference', 'product_name', 'variations'); |
|
| 211 | + if (!empty($product['item_meta'])) { |
|
| 212 | + foreach ($product['item_meta'] as $key => $value) { |
|
| 213 | + if (!isset($item['item_' . $key]) && !in_array($key, $array_not_to_do) && !empty($product[$key])) { |
|
| 214 | + $item['item_' . $key] = $product[$key]; |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** Check if it's a variation product */ |
| 220 | - if ( ! empty( $product ) && ! empty( $product['item_meta'] ) && ! empty( $product['item_meta']['variations'] ) ) { |
|
| 221 | - foreach ( $product['item_meta']['variations'] as $k => $variation ) { |
|
| 222 | - $product_variation_def = get_post_meta( $k, '_wpshop_variations_attribute_def', true ); |
|
| 223 | - if ( ! empty( $product_variation_def ) ) { |
|
| 224 | - foreach ( $product_variation_def as $attribute_code => $variation_id ) { |
|
| 225 | - $variation_attribute_def = wpshop_attributes::getElement( $attribute_code, '"valid"', 'code' ); |
|
| 226 | - if ( ! empty( $variation_attribute_def ) ) { |
|
| 227 | - $item['item_meta']['variation_definition'][ $attribute_code ]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 228 | - if ( $variation_attribute_def->data_type_to_use == 'custom' ) { |
|
| 229 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id ); |
|
| 230 | - $variation_name = $wpdb->get_var( $query ); |
|
| 220 | + if (!empty($product) && !empty($product['item_meta']) && !empty($product['item_meta']['variations'])) { |
|
| 221 | + foreach ($product['item_meta']['variations'] as $k => $variation) { |
|
| 222 | + $product_variation_def = get_post_meta($k, '_wpshop_variations_attribute_def', true); |
|
| 223 | + if (!empty($product_variation_def)) { |
|
| 224 | + foreach ($product_variation_def as $attribute_code => $variation_id) { |
|
| 225 | + $variation_attribute_def = wpshop_attributes::getElement($attribute_code, '"valid"', 'code'); |
|
| 226 | + if (!empty($variation_attribute_def)) { |
|
| 227 | + $item['item_meta']['variation_definition'][$attribute_code]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 228 | + if ($variation_attribute_def->data_type_to_use == 'custom') { |
|
| 229 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id); |
|
| 230 | + $variation_name = $wpdb->get_var($query); |
|
| 231 | 231 | } else { |
| 232 | - $variation_post = get_post( $variation_id ); |
|
| 232 | + $variation_post = get_post($variation_id); |
|
| 233 | 233 | $variation_name = $variation_post->post_title; |
| 234 | 234 | } |
| 235 | - $item['item_meta']['variation_definition'][ $attribute_code ]['UNSTYLED_VALUE'] = $variation_name; |
|
| 236 | - $item['item_meta']['variation_definition'][ $attribute_code ]['VALUE'] = $variation_name; |
|
| 235 | + $item['item_meta']['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = $variation_name; |
|
| 236 | + $item['item_meta']['variation_definition'][$attribute_code]['VALUE'] = $variation_name; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | } else { |
| 242 | 242 | /** Check if it's product with one variation */ |
| 243 | - $product_variation_def = get_post_meta( $product['product_id'], '_wpshop_variations_attribute_def', true ); |
|
| 244 | - if ( ! empty( $product_variation_def ) ) { |
|
| 245 | - foreach ( $product_variation_def as $attribute_code => $variation_id ) { |
|
| 246 | - $variation_attribute_def = wpshop_attributes::getElement( $attribute_code, '"valid"', 'code' ); |
|
| 247 | - if ( ! empty( $variation_attribute_def ) ) { |
|
| 248 | - $item['item_meta']['variation_definition'][ $attribute_code ]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 249 | - if ( $variation_attribute_def->data_type_to_use == 'custom' ) { |
|
| 250 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id ); |
|
| 251 | - $variation_name = $wpdb->get_var( $query ); |
|
| 243 | + $product_variation_def = get_post_meta($product['product_id'], '_wpshop_variations_attribute_def', true); |
|
| 244 | + if (!empty($product_variation_def)) { |
|
| 245 | + foreach ($product_variation_def as $attribute_code => $variation_id) { |
|
| 246 | + $variation_attribute_def = wpshop_attributes::getElement($attribute_code, '"valid"', 'code'); |
|
| 247 | + if (!empty($variation_attribute_def)) { |
|
| 248 | + $item['item_meta']['variation_definition'][$attribute_code]['NAME'] = $variation_attribute_def->frontend_label; |
|
| 249 | + if ($variation_attribute_def->data_type_to_use == 'custom') { |
|
| 250 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id=%d', $variation_id); |
|
| 251 | + $variation_name = $wpdb->get_var($query); |
|
| 252 | 252 | } else { |
| 253 | - $variation_post = get_post( $variation_id ); |
|
| 253 | + $variation_post = get_post($variation_id); |
|
| 254 | 254 | $variation_name = $variation_post->post_title; |
| 255 | 255 | } |
| 256 | - $item['item_meta']['variation_definition'][ $attribute_code ]['UNSTYLED_VALUE'] = $variation_name; |
|
| 257 | - $item['item_meta']['variation_definition'][ $attribute_code ]['VALUE'] = $variation_name; |
|
| 256 | + $item['item_meta']['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = $variation_name; |
|
| 257 | + $item['item_meta']['variation_definition'][$attribute_code]['VALUE'] = $variation_name; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** On ajoute la possibilité d'étendre les données produits ajoutées dans le panier / Add possibility to extends product data saved into cart */ |
| 264 | - $item = apply_filters( 'wpshop-add-product-to-order', $item, $product ); |
|
| 264 | + $item = apply_filters('wpshop-add-product-to-order', $item, $product); |
|
| 265 | 265 | return $item; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -270,44 +270,44 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | function wps_invoice_output() { |
| 272 | 272 | |
| 273 | - $order_id = ( ! empty( $_GET['order_id'] )) ? (int) $_GET['order_id'] : null; |
|
| 274 | - $invoice_ref = ( ! empty( $_GET['invoice_ref'] )) ? sanitize_text_field( $_GET['invoice_ref'] ) : null; |
|
| 275 | - $mode = ( ! empty( $_GET['mode'] )) ? sanitize_text_field( $_GET['mode'] ) : 'html'; |
|
| 276 | - $is_credit_slip = ( ! empty( $_GET['credit_slip'] )) ? sanitize_text_field( $_GET['credit_slip'] ) : null; |
|
| 273 | + $order_id = (!empty($_GET['order_id'])) ? (int)$_GET['order_id'] : null; |
|
| 274 | + $invoice_ref = (!empty($_GET['invoice_ref'])) ? sanitize_text_field($_GET['invoice_ref']) : null; |
|
| 275 | + $mode = (!empty($_GET['mode'])) ? sanitize_text_field($_GET['mode']) : 'html'; |
|
| 276 | + $is_credit_slip = (!empty($_GET['credit_slip'])) ? sanitize_text_field($_GET['credit_slip']) : null; |
|
| 277 | 277 | $user_id = get_current_user_id(); |
| 278 | - if ( ! empty( $order_id ) && $user_id != 0 ) { |
|
| 278 | + if (!empty($order_id) && $user_id != 0) { |
|
| 279 | 279 | /** Order reading */ |
| 280 | - $order_postmeta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 280 | + $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 281 | 281 | /** Start invoice display */ |
| 282 | - if ( ! empty( $is_credit_slip ) ) { |
|
| 283 | - $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref, 'credit_slip' ); |
|
| 282 | + if (!empty($is_credit_slip)) { |
|
| 283 | + $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref, 'credit_slip'); |
|
| 284 | 284 | } else { |
| 285 | - $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref ); |
|
| 285 | + $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Génération de la facture au format PDF |
| 290 | 290 | */ |
| 291 | - if ( 'pdf' === $mode ) { |
|
| 292 | - require_once( WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php' ); |
|
| 291 | + if ('pdf' === $mode) { |
|
| 292 | + require_once(WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php'); |
|
| 293 | 293 | try { |
| 294 | 294 | // $html_content = wpshop_display::display_template_element('invoice_print_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
| 295 | - $html_content = wpshop_display::display_template_element( 'invoice_page_content_css', array(), array(), 'common' ) . '<page>' . $html_content . '</page>'; |
|
| 296 | - $html2pdf = new HTML2PDF( 'P', 'A4', 'fr' ); |
|
| 297 | - $html2pdf->setDefaultFont( 'Arial' ); |
|
| 298 | - $html2pdf->writeHTML( $html_content ); |
|
| 295 | + $html_content = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
|
| 296 | + $html2pdf = new HTML2PDF('P', 'A4', 'fr'); |
|
| 297 | + $html2pdf->setDefaultFont('Arial'); |
|
| 298 | + $html2pdf->writeHTML($html_content); |
|
| 299 | 299 | ob_clean(); |
| 300 | - $html2pdf->Output( apply_filters( 'wps_filter_invoice_filename', 'order_' . $order_id . '.pdf', $order_id ), 'D' ); |
|
| 300 | + $html2pdf->Output(apply_filters('wps_filter_invoice_filename', 'order_' . $order_id . '.pdf', $order_id), 'D'); |
|
| 301 | 301 | } catch (HTML2PDF_exception $e) { |
| 302 | 302 | echo $e; |
| 303 | 303 | exit; |
| 304 | 304 | } |
| 305 | 305 | } else { |
| 306 | - $order_invoice_ref = ( ! empty( $order_postmeta['order_invoice_ref'] ) ) ? $order_postmeta['order_invoice_ref'] : ''; |
|
| 307 | - $tpl_component['INVOICE_CSS'] = wpshop_display::display_template_element( 'invoice_page_content_css', array(), array(), 'common' ); |
|
| 306 | + $order_invoice_ref = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ''; |
|
| 307 | + $tpl_component['INVOICE_CSS'] = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common'); |
|
| 308 | 308 | $tpl_component['INVOICE_MAIN_PAGE'] = $html_content; |
| 309 | - $tpl_component['INVOICE_TITLE_PAGE'] = sprintf( __( 'Invoice %1$s for order %3$s (#%2$s)', 'wpshop' ), $order_invoice_ref, $order_id, $order_postmeta['order_key'] ); |
|
| 310 | - echo wpshop_display::display_template_element( 'invoice_page', $tpl_component, array(), 'common' ); |
|
| 309 | + $tpl_component['INVOICE_TITLE_PAGE'] = sprintf(__('Invoice %1$s for order %3$s (#%2$s)', 'wpshop'), $order_invoice_ref, $order_id, $order_postmeta['order_key']); |
|
| 310 | + echo wpshop_display::display_template_element('invoice_page', $tpl_component, array(), 'common'); |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | die(); |
@@ -319,21 +319,21 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | function wps_orders_load_details() { |
| 321 | 321 | |
| 322 | - check_ajax_referer( 'wps_orders_load_details' ); |
|
| 323 | - $order_id = ( ! empty( $_POST['order_id'] ) ) ? wpshop_tools::varSanitizer( $_POST['order_id'] ) : ''; |
|
| 322 | + check_ajax_referer('wps_orders_load_details'); |
|
| 323 | + $order_id = (!empty($_POST['order_id'])) ? wpshop_tools::varSanitizer($_POST['order_id']) : ''; |
|
| 324 | 324 | $user_id = get_current_user_id(); |
| 325 | 325 | $status = false; |
| 326 | 326 | $result = ''; |
| 327 | - if ( ! empty( $order_id ) ) { |
|
| 328 | - $order = get_post( $order_id ); |
|
| 329 | - $order_infos = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 330 | - $order_key = ( ! empty( $order_infos['order_key'] ) ) ? $order_infos['order_key'] : '-'; |
|
| 331 | - if ( ! empty( $order ) && ! empty( $user_id ) && $order->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER && $order->post_author == $user_id ) { |
|
| 332 | - $result = do_shortcode( '[wps_cart cart_type="summary" oid="' . $order_id . '"]' ); |
|
| 327 | + if (!empty($order_id)) { |
|
| 328 | + $order = get_post($order_id); |
|
| 329 | + $order_infos = get_post_meta($order_id, '_order_postmeta', true); |
|
| 330 | + $order_key = (!empty($order_infos['order_key'])) ? $order_infos['order_key'] : '-'; |
|
| 331 | + if (!empty($order) && !empty($user_id) && $order->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER && $order->post_author == $user_id) { |
|
| 332 | + $result = do_shortcode('[wps_cart cart_type="summary" oid="' . $order_id . '"]'); |
|
| 333 | 333 | $status = true; |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | - echo json_encode( array( 'status' => $status, 'title' => sprintf( __( 'Order n° %s details', 'wpshop' ), $order_key ), 'content' => $result ) ); |
|
| 336 | + echo json_encode(array('status' => $status, 'title' => sprintf(__('Order n° %s details', 'wpshop'), $order_key), 'content' => $result)); |
|
| 337 | 337 | wp_die(); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -342,60 +342,60 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | function wps_order_choose_customer() { |
| 344 | 344 | |
| 345 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 346 | - if ( ! wp_verify_nonce( $_wpnonce, 'wps_order_choose_customer' ) ) { |
|
| 345 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 346 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_choose_customer')) { |
|
| 347 | 347 | wp_die(); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | $status = false; |
| 351 | 351 | $billing_data = $shipping_data = ''; |
| 352 | - $customer_id = ( ! empty( $_POST['customer_id'] ) ) ? intval( $_POST['customer_id'] ): null; |
|
| 353 | - if ( ! empty( $customer_id ) ) { |
|
| 352 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
| 353 | + if (!empty($customer_id)) { |
|
| 354 | 354 | $wps_address = new wps_address(); |
| 355 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 356 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 355 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 356 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 357 | 357 | $billing_option = $billing_option['choice']; |
| 358 | - $customer_addresses_list = wps_address::get_addresses_list( $customer_id ); |
|
| 358 | + $customer_addresses_list = wps_address::get_addresses_list($customer_id); |
|
| 359 | 359 | $status = true; |
| 360 | - $billing_data = '<div class="wps-alert-info">' . sprintf( __( 'No Billing address created, <a href="%s" title="' . __( 'Create a new billing address', 'wpshop' ) . '" class="thickbox">create one</a>', 'wpshop' ),admin_url( 'admin-ajax.php' ) . '?action=wps-add-an-address-in-admin&address_type=' . $billing_option . '&customer_id=' . $customer_id . '&height=600' ) . '</div>'; |
|
| 361 | - if ( ! empty( $shipping_option ) && ! empty( $shipping_option['activate'] ) ) { |
|
| 360 | + $billing_data = '<div class="wps-alert-info">' . sprintf(__('No Billing address created, <a href="%s" title="' . __('Create a new billing address', 'wpshop') . '" class="thickbox">create one</a>', 'wpshop'), admin_url('admin-ajax.php') . '?action=wps-add-an-address-in-admin&address_type=' . $billing_option . '&customer_id=' . $customer_id . '&height=600') . '</div>'; |
|
| 361 | + if (!empty($shipping_option) && !empty($shipping_option['activate'])) { |
|
| 362 | 362 | $shipping_option = $shipping_option['choice']; |
| 363 | - $shipping_data = '<div class="wps-alert-info">' . sprintf( __( 'No shipping address created, <a href="%s" title="' . __( 'Create a new shipping address', 'wpshop' ) . '" class="thickbox">create one</a>', 'wpshop' ),admin_url( 'admin-ajax.php' ) . '?action=wps-add-an-address-in-admin&address_type=' . $shipping_option . '&customer_id=' . $customer_id . '&height=600' ) . '</div>'; |
|
| 363 | + $shipping_data = '<div class="wps-alert-info">' . sprintf(__('No shipping address created, <a href="%s" title="' . __('Create a new shipping address', 'wpshop') . '" class="thickbox">create one</a>', 'wpshop'), admin_url('admin-ajax.php') . '?action=wps-add-an-address-in-admin&address_type=' . $shipping_option . '&customer_id=' . $customer_id . '&height=600') . '</div>'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if ( ! empty( $customer_addresses_list ) ) { |
|
| 367 | - foreach ( $customer_addresses_list as $address_type => $customer_addresses ) { |
|
| 368 | - if ( $billing_option == $address_type ) { |
|
| 369 | - $billing_data = $wps_address->display_address_in_administration( $customer_addresses, $address_type ); |
|
| 366 | + if (!empty($customer_addresses_list)) { |
|
| 367 | + foreach ($customer_addresses_list as $address_type => $customer_addresses) { |
|
| 368 | + if ($billing_option == $address_type) { |
|
| 369 | + $billing_data = $wps_address->display_address_in_administration($customer_addresses, $address_type); |
|
| 370 | 370 | } else { |
| 371 | - $shipping_data = $wps_address->display_address_in_administration( $customer_addresses, $address_type ); |
|
| 371 | + $shipping_data = $wps_address->display_address_in_administration($customer_addresses, $address_type); |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | - echo json_encode( array( 'status' => $status, 'billing_data' => $billing_data, 'shipping_data' => $shipping_data ) ); |
|
| 376 | + echo json_encode(array('status' => $status, 'billing_data' => $billing_data, 'shipping_data' => $shipping_data)); |
|
| 377 | 377 | wp_die(); |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - static function pay_quotation( $order_id ) { |
|
| 380 | + static function pay_quotation($order_id) { |
|
| 381 | 381 | |
| 382 | 382 | $status = true; |
| 383 | - $order_id = (int) $order_id; |
|
| 384 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 385 | - $order_info = get_post_meta( $order_id, '_order_info', true ); |
|
| 386 | - $_SESSION['shipping_method'] = isset( $order_meta['order_payment']['shipping_method'] ) ? $order_meta['order_payment']['shipping_method'] : 'No Shipping method required'; |
|
| 387 | - if ( isset( $order_info['billing']['address_id'] ) ) { |
|
| 383 | + $order_id = (int)$order_id; |
|
| 384 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 385 | + $order_info = get_post_meta($order_id, '_order_info', true); |
|
| 386 | + $_SESSION['shipping_method'] = isset($order_meta['order_payment']['shipping_method']) ? $order_meta['order_payment']['shipping_method'] : 'No Shipping method required'; |
|
| 387 | + if (isset($order_info['billing']['address_id'])) { |
|
| 388 | 388 | $_SESSION['billing_address'] = $order_info['billing']['address_id']; |
| 389 | 389 | $_SESSION['cart'] = $order_meta; |
| 390 | 390 | $_SESSION['cart']['order_id'] = $order_id; |
| 391 | 391 | $_SESSION['cart']['cart_type'] = 'cart'; |
| 392 | 392 | $_SESSION['cart']['order_shipping_cost_fixe'] = 'on'; |
| 393 | - $permalink = get_permalink( get_option( 'wpshop_cart_page_id' ) ) . '?order_step=5'; |
|
| 393 | + $permalink = get_permalink(get_option('wpshop_cart_page_id')) . '?order_step=5'; |
|
| 394 | 394 | } else { |
| 395 | - $status = self::add_order_to_session( $order_id ); |
|
| 396 | - $permalink = get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ) ); |
|
| 395 | + $status = self::add_order_to_session($order_id); |
|
| 396 | + $permalink = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))); |
|
| 397 | 397 | } |
| 398 | - return array( 'status' => $status, 'permalink' => $permalink ); |
|
| 398 | + return array('status' => $status, 'permalink' => $permalink); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
@@ -404,54 +404,54 @@ discard block |
||
| 404 | 404 | * @method add_order_to_session |
| 405 | 405 | * @param int $order_id Id of order. |
| 406 | 406 | */ |
| 407 | - public static function add_order_to_session( $order_id ) { |
|
| 407 | + public static function add_order_to_session($order_id) { |
|
| 408 | 408 | |
| 409 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 410 | - if ( $order_meta != false ) { |
|
| 409 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 410 | + if ($order_meta != false) { |
|
| 411 | 411 | $_SESSION['cart'] = array(); |
| 412 | 412 | $_SESSION['cart']['order_amount_to_pay_now'] = $order_meta['order_amount_to_pay_now']; |
| 413 | 413 | $_SESSION['cart']['order_items'] = array(); |
| 414 | - if ( ! empty( $order_meta ) && ! empty( $order_meta['order_items'] ) ) { |
|
| 414 | + if (!empty($order_meta) && !empty($order_meta['order_items'])) { |
|
| 415 | 415 | $wpshop_cart_type = 'cart'; |
| 416 | - foreach ( $order_meta['order_items'] as $item ) { |
|
| 417 | - $_SESSION['cart']['order_items'][ $item['item_id'] ] = $item; |
|
| 416 | + foreach ($order_meta['order_items'] as $item) { |
|
| 417 | + $_SESSION['cart']['order_items'][$item['item_id']] = $item; |
|
| 418 | 418 | } |
| 419 | 419 | $wps_cart_ctr = new wps_cart(); |
| 420 | - $order = $wps_cart_ctr->calcul_cart_information( array() ); |
|
| 421 | - $wps_cart_ctr->store_cart_in_session( $order ); |
|
| 420 | + $order = $wps_cart_ctr->calcul_cart_information(array()); |
|
| 421 | + $wps_cart_ctr->store_cart_in_session($order); |
|
| 422 | 422 | } |
| 423 | 423 | $_SESSION['order_id'] = $order_id; |
| 424 | 424 | } |
| 425 | - return (bool) ($order_meta != false); |
|
| 425 | + return (bool)($order_meta != false); |
|
| 426 | 426 | } |
| 427 | 427 | /** |
| 428 | 428 | * AJAX - Delete order by order_id |
| 429 | 429 | */ |
| 430 | 430 | public function wps_delete_order() { |
| 431 | 431 | |
| 432 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 433 | - if ( ! wp_verify_nonce( $_wpnonce, 'wps_delete_order' ) ) { |
|
| 432 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 433 | + if (!wp_verify_nonce($_wpnonce, 'wps_delete_order')) { |
|
| 434 | 434 | wp_die(); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $status = false; |
| 438 | 438 | $output = ''; |
| 439 | - $order_id = ! empty( $_POST['order_id'] ) ? (int) $_POST['order_id'] : 0; |
|
| 440 | - if ( $order_id ) { |
|
| 441 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 439 | + $order_id = !empty($_POST['order_id']) ? (int)$_POST['order_id'] : 0; |
|
| 440 | + if ($order_id) { |
|
| 441 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 442 | 442 | $wps_credit = new wps_credit(); |
| 443 | - $wps_credit->create_an_credit( $order_id ); |
|
| 443 | + $wps_credit->create_an_credit($order_id); |
|
| 444 | 444 | $order_meta['order_status'] = 'canceled'; |
| 445 | - $order_meta['order_payment']['refunded_action']['refunded_date'] = current_time( 'mysql', 0 ); |
|
| 445 | + $order_meta['order_payment']['refunded_action']['refunded_date'] = current_time('mysql', 0); |
|
| 446 | 446 | $order_meta['order_payment']['refunded_action']['author'] = get_current_user_id(); |
| 447 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 447 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 448 | 448 | ob_start(); |
| 449 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'order_row_in_account' ) ); |
|
| 449 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, 'frontend', 'order_row_in_account')); |
|
| 450 | 450 | $output = ob_get_contents(); |
| 451 | 451 | ob_end_clean(); |
| 452 | 452 | $status = true; |
| 453 | 453 | } |
| 454 | - echo json_encode( array( 'status' => $status, 'row' => $output ) ); |
|
| 454 | + echo json_encode(array('status' => $status, 'row' => $output)); |
|
| 455 | 455 | wp_die(); |
| 456 | 456 | } |
| 457 | 457 | |
@@ -462,13 +462,13 @@ discard block |
||
| 462 | 462 | * @param int $order_id OrderID. |
| 463 | 463 | * @return mixed sha1 or false. |
| 464 | 464 | */ |
| 465 | - public static function wps_token_order_customer( $order_id, $date = null ) { |
|
| 466 | - $date = isset( $date ) ? $date : date( 'Ym' ); |
|
| 467 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 468 | - if ( ! isset( $order_metadata['customer_id'] ) ) { |
|
| 465 | + public static function wps_token_order_customer($order_id, $date = null) { |
|
| 466 | + $date = isset($date) ? $date : date('Ym'); |
|
| 467 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 468 | + if (!isset($order_metadata['customer_id'])) { |
|
| 469 | 469 | return false; |
| 470 | 470 | } |
| 471 | - return sha1( site_url() . '_' . $order_id . '_' . $order_metadata['customer_id'] . '_' . $date ); |
|
| 471 | + return sha1(site_url() . '_' . $order_id . '_' . $order_metadata['customer_id'] . '_' . $date); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -479,9 +479,9 @@ discard block |
||
| 479 | 479 | * @param int $order_id OrderID. |
| 480 | 480 | * @return boolean |
| 481 | 481 | */ |
| 482 | - public static function wps_verify_token_order( $token, $order_id ) { |
|
| 483 | - $current_month = self::wps_token_order_customer( $order_id ); |
|
| 484 | - $last_month = self::wps_token_order_customer( $order_id, date_format( date_create( date( 'Y-m' ) . ' - 1month' ), 'Ym' ) ); |
|
| 485 | - return (bool) ( (bool) $current_month && (bool) $last_month && ( $token === $current_month || $token === $last_month ) ); |
|
| 482 | + public static function wps_verify_token_order($token, $order_id) { |
|
| 483 | + $current_month = self::wps_token_order_customer($order_id); |
|
| 484 | + $last_month = self::wps_token_order_customer($order_id, date_format(date_create(date('Y-m') . ' - 1month'), 'Ym')); |
|
| 485 | + return (bool)((bool)$current_month && (bool)$last_month && ($token === $current_month || $token === $last_month)); |
|
| 486 | 486 | } |
| 487 | 487 | } |