@@ -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']) ? sanitize_text_field($_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; |
@@ -640,31 +640,31 @@ discard block |
||
| 640 | 640 | global $attribute_displayed_field, $attribute_options_group; |
| 641 | 641 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 642 | 642 | $editedItem = ''; |
| 643 | - if($itemToEdit != '') |
|
| 643 | + if ($itemToEdit != '') |
|
| 644 | 644 | $editedItem = self::getElement($itemToEdit); |
| 645 | 645 | |
| 646 | 646 | $the_form_content_hidden = $the_form_general_content = ''; |
| 647 | 647 | $the_form_option_content_list = array(); |
| 648 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 648 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 649 | 649 | |
| 650 | - if(!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)){ |
|
| 650 | + if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) { |
|
| 651 | 651 | $input_def['label'] = $input_def['name']; |
| 652 | - $input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_def['label']; |
|
| 652 | + $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label']; |
|
| 653 | 653 | |
| 654 | 654 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 655 | 655 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : ''; |
| 656 | 656 | $currentFieldValue = $input_def['value']; |
| 657 | - if(is_object($editedItem)) |
|
| 657 | + if (is_object($editedItem)) |
|
| 658 | 658 | $currentFieldValue = $editedItem->{$input_def['label']}; |
| 659 | - elseif(($pageAction != '') && ($requestFormValue != '')) |
|
| 659 | + elseif (($pageAction != '') && ($requestFormValue != '')) |
|
| 660 | 660 | $currentFieldValue = $requestFormValue; |
| 661 | 661 | |
| 662 | - if($input_def['label'] == 'status'){ |
|
| 663 | - if(in_array('notused', $input_def['possible_value'])){ |
|
| 662 | + if ($input_def['label'] == 'status') { |
|
| 663 | + if (in_array('notused', $input_def['possible_value'])) { |
|
| 664 | 664 | $key = array_keys($input_def['possible_value'], 'notused'); |
| 665 | 665 | unset($input_def['possible_value'][$key[0]]); |
| 666 | 666 | } |
| 667 | - if(in_array('dbl', $input_def['possible_value'])){ |
|
| 667 | + if (in_array('dbl', $input_def['possible_value'])) { |
|
| 668 | 668 | $key = array_keys($input_def['possible_value'], 'dbl'); |
| 669 | 669 | unset($input_def['possible_value'][$key[0]]); |
| 670 | 670 | } |
@@ -672,94 +672,94 @@ discard block |
||
| 672 | 672 | $input_def['type'] = 'checkbox'; |
| 673 | 673 | $input_def['label'] = __('Use this attribute', 'wpshop'); |
| 674 | 674 | $input_def['possible_value'] = array('valid'); |
| 675 | - $input_def_id.='_valid'; |
|
| 676 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 675 | + $input_def_id .= '_valid'; |
|
| 676 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || ( $input_def['label'] == '_display_informations_about_value') ) { |
|
| 679 | + if ((substr($input_def['label'], 0, 3) == 'is_') || ($input_def['label'] == '_display_informations_about_value')) { |
|
| 680 | 680 | $input_def['type'] = 'checkbox'; |
| 681 | 681 | $input_def['possible_value'] = 'yes'; |
| 682 | 682 | } |
| 683 | - switch($input_def['label']){ |
|
| 683 | + switch ($input_def['label']) { |
|
| 684 | 684 | case 'is_requiring_unit': |
| 685 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using unit with this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 685 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 686 | 686 | break; |
| 687 | 687 | case 'is_visible_in_front': |
| 688 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 688 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 689 | 689 | break; |
| 690 | 690 | case 'is_visible_in_front_listing': |
| 691 | - $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>'; |
|
| 691 | + $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>'; |
|
| 692 | 692 | break; |
| 693 | 693 | case 'is_used_for_sort_by': |
| 694 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute into sortbar', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 694 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 695 | 695 | break; |
| 696 | 696 | case 'is_searchable': |
| 697 | - $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>'; |
|
| 697 | + $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>'; |
|
| 698 | 698 | break; |
| 699 | 699 | case 'is_visible_in_advanced_search': |
| 700 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using in advanced search form', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 700 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 701 | 701 | break; |
| 702 | 702 | case 'frontend_css_class': |
| 703 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 703 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 704 | 704 | break; |
| 705 | 705 | case 'backend_css_class': |
| 706 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 706 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 707 | 707 | break; |
| 708 | 708 | case 'is_historisable': |
| 709 | - $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>'; |
|
| 709 | + $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>'; |
|
| 710 | 710 | break; |
| 711 | 711 | case 'is_filterable': |
| 712 | - $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>'; |
|
| 712 | + $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>'; |
|
| 713 | 713 | break; |
| 714 | 714 | case 'is_intrinsic': |
| 715 | - $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>'; |
|
| 715 | + $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>'; |
|
| 716 | 716 | break; |
| 717 | 717 | case 'is_used_for_variation': |
| 718 | - $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>'; |
|
| 718 | + $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>'; |
|
| 719 | 719 | break; |
| 720 | 720 | case 'is_used_in_variation': |
| 721 | - $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>'; |
|
| 722 | - if ( !empty($editedItem) && ($editedItem->is_used_for_variation == 'yes') ) { |
|
| 721 | + $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>'; |
|
| 722 | + if (!empty($editedItem) && ($editedItem->is_used_for_variation == 'yes')) { |
|
| 723 | 723 | $input_def['option'] = 'disabled="disabled"'; |
| 724 | 724 | } |
| 725 | 725 | break; |
| 726 | 726 | case 'is_user_defined': |
| 727 | - $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>'; |
|
| 727 | + $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>'; |
|
| 728 | 728 | break; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | $input_def['value'] = $currentFieldValue; |
| 732 | - if($input_def['label'] == 'code') |
|
| 732 | + if ($input_def['label'] == 'code') |
|
| 733 | 733 | $input_def['type'] = 'hidden'; |
| 734 | - elseif($input_def['label'] == 'entity_id'){ |
|
| 734 | + elseif ($input_def['label'] == 'entity_id') { |
|
| 735 | 735 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 736 | 736 | $input_def['valueToPut'] = 'index'; |
| 737 | 737 | $input_def['type'] = 'select'; |
| 738 | 738 | |
| 739 | - $i=0; |
|
| 740 | - foreach($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 741 | - if($i <= 0){ |
|
| 739 | + $i = 0; |
|
| 740 | + foreach ($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 741 | + if ($i <= 0) { |
|
| 742 | 742 | $current_entity_id = $entity_id; |
| 743 | 743 | } |
| 744 | 744 | $i++; |
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | - elseif($input_def['label'] == '_unit_group_id'){ |
|
| 747 | + elseif ($input_def['label'] == '_unit_group_id') { |
|
| 748 | 748 | $input_def['possible_value'] = wpshop_attributes_unit::get_unit_group(); |
| 749 | 749 | $input_def['type'] = 'select'; |
| 750 | 750 | } |
| 751 | - elseif($input_def['label'] == '_default_unit'){ |
|
| 751 | + elseif ($input_def['label'] == '_default_unit') { |
|
| 752 | 752 | $unit_group_list = wpshop_attributes_unit::get_unit_group(); |
| 753 | - $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:'')); |
|
| 753 | + $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 : '')); |
|
| 754 | 754 | $input_def['type'] = 'select'; |
| 755 | 755 | } |
| 756 | 756 | elseif ($input_def['label'] == 'backend_input') { |
| 757 | - if ( !is_object($editedItem) ) { |
|
| 757 | + if (!is_object($editedItem)) { |
|
| 758 | 758 | $input_def['type'] = 'hidden'; |
| 759 | 759 | } |
| 760 | 760 | else { |
| 761 | 761 | $new_possible_value = array(); |
| 762 | - switch ( $editedItem->data_type) { |
|
| 762 | + switch ($editedItem->data_type) { |
|
| 763 | 763 | case 'integer': |
| 764 | 764 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 765 | 765 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 768 | 768 | break; |
| 769 | 769 | case 'varchar': |
| 770 | - switch ( $input_def['value'] ) { |
|
| 770 | + switch ($input_def['value']) { |
|
| 771 | 771 | case 'hidden': |
| 772 | 772 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 773 | 773 | break; |
@@ -795,8 +795,8 @@ discard block |
||
| 795 | 795 | elseif ($input_def['label'] == 'frontend_input') { |
| 796 | 796 | $new_possible_value = array(); |
| 797 | 797 | |
| 798 | - if ( is_object($editedItem) ) { |
|
| 799 | - switch ( $editedItem->data_type) { |
|
| 798 | + if (is_object($editedItem)) { |
|
| 799 | + switch ($editedItem->data_type) { |
|
| 800 | 800 | case 'integer': |
| 801 | 801 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 802 | 802 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 805 | 805 | break; |
| 806 | 806 | case 'varchar': |
| 807 | - switch ( $input_def['value'] ) { |
|
| 807 | + switch ($input_def['value']) { |
|
| 808 | 808 | case 'hidden': |
| 809 | 809 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 810 | 810 | break; |
@@ -842,10 +842,10 @@ discard block |
||
| 842 | 842 | |
| 843 | 843 | $input_def['possible_value'] = $new_possible_value; |
| 844 | 844 | |
| 845 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 846 | - switch ( $editedItem->frontend_input ) { |
|
| 845 | + if (!empty($editedItem->frontend_input)) { |
|
| 846 | + switch ($editedItem->frontend_input) { |
|
| 847 | 847 | case 'text': |
| 848 | - switch ( $editedItem->data_type ) { |
|
| 848 | + switch ($editedItem->data_type) { |
|
| 849 | 849 | case 'varchar': |
| 850 | 850 | $input_def['value'] = 'short_text'; |
| 851 | 851 | break; |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - if(is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))){ |
|
| 873 | + if (is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))) { |
|
| 874 | 874 | // $input_def['type'] = 'hidden'; |
| 875 | 875 | $input_def['option'] = ' disabled="disabled" '; |
| 876 | 876 | $the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />'; |
@@ -881,16 +881,16 @@ discard block |
||
| 881 | 881 | $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 882 | 882 | |
| 883 | 883 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 884 | - if ( $input_def['label'] == 'default_value' ) { |
|
| 885 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 886 | - switch ( $editedItem->frontend_input ) { |
|
| 884 | + if ($input_def['label'] == 'default_value') { |
|
| 885 | + if (!empty($editedItem->frontend_input)) { |
|
| 886 | + switch ($editedItem->frontend_input) { |
|
| 887 | 887 | case 'text': |
| 888 | 888 | $input_def['type'] = 'text'; |
| 889 | - switch ( $editedItem->data_type ) { |
|
| 889 | + switch ($editedItem->data_type) { |
|
| 890 | 890 | case 'datetime': |
| 891 | - $the_input = wpshop_attributes::attribute_type_date_config( unserialize($input_def['value']) ); |
|
| 891 | + $the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value'])); |
|
| 892 | 892 | |
| 893 | - $input_def['label'] = __('Date field configuration','wpshop'); |
|
| 893 | + $input_def['label'] = __('Date field configuration', 'wpshop'); |
|
| 894 | 894 | break; |
| 895 | 895 | default: |
| 896 | 896 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | case 'multiple-select': |
| 908 | 908 | case 'radio': |
| 909 | 909 | case 'checkbox': |
| 910 | - $input_def['label'] = __('Options list for attribute','wpshop') . ' |
|
| 910 | + $input_def['label'] = __('Options list for attribute', 'wpshop') . ' |
|
| 911 | 911 | <div class="alignright wpshop_change_select_data_type" > |
| 912 | 912 | +' . __('Change data type for this attribute', 'wpshop') . ' |
| 913 | 913 | </div>'; |
@@ -921,50 +921,50 @@ discard block |
||
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | else { |
| 924 | - $input_def['type']='text'; |
|
| 924 | + $input_def['type'] = 'text'; |
|
| 925 | 925 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | - if( $input_def['label'] == '_unit_group_id') { |
|
| 928 | + if ($input_def['label'] == '_unit_group_id') { |
|
| 929 | 929 | $the_input .= '<div id="wpshop_loader_input_group_unit"></div>'; |
| 930 | - $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>'; |
|
| 930 | + $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>'; |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | - if( $input_def['label'] == '_default_unit') { |
|
| 933 | + if ($input_def['label'] == '_default_unit') { |
|
| 934 | 934 | $the_input .= '<div id="wpshop_loader_input_unit"></div>'; |
| 935 | - $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>'; |
|
| 935 | + $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>'; |
|
| 936 | 936 | $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") . '" />'; |
| 937 | 937 | $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>'; |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | |
| 941 | - if($input_def['type'] != 'hidden'){ |
|
| 942 | - if ( ($input_def['label'] == 'entity_id') && is_object($editedItem) ) { |
|
| 941 | + if ($input_def['type'] != 'hidden') { |
|
| 942 | + if (($input_def['label'] == 'entity_id') && is_object($editedItem)) { |
|
| 943 | 943 | $the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to . another entity', 'wpshop') . '</span>'; |
| 944 | 944 | } |
| 945 | 945 | $input = ' |
| 946 | - <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_def['name'].'" > |
|
| 947 | - <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> |
|
| 948 | - <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> |
|
| 946 | + <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" > |
|
| 947 | + <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> |
|
| 948 | + <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> |
|
| 949 | 949 | </tr>'; |
| 950 | - 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 )) ) |
|
| 950 | + 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))) |
|
| 951 | 951 | $the_form_option_content_list[$input_def['label']] = $input; |
| 952 | 952 | else { |
| 953 | 953 | $the_form_general_content .= $input; |
| 954 | - if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) { |
|
| 954 | + if (($input_def['label'] == 'frontend_input') && !is_object($editedItem)) { |
|
| 955 | 955 | |
| 956 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 956 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 957 | 957 | |
| 958 | 958 | $input = ' |
| 959 | 959 | <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" > |
| 960 | - <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> |
|
| 960 | + <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> |
|
| 961 | 961 | <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> |
| 962 | 962 | </tr>'; |
| 963 | 963 | $the_form_general_content .= $input; |
| 964 | 964 | } |
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | - else{ |
|
| 967 | + else { |
|
| 968 | 968 | $the_form_content_hidden .= ' |
| 969 | 969 | ' . $the_input; |
| 970 | 970 | } |
@@ -980,17 +980,17 @@ discard block |
||
| 980 | 980 | $section_content = $the_form_general_content; |
| 981 | 981 | |
| 982 | 982 | ob_start(); |
| 983 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 983 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 984 | 984 | $the_form_general_content = ob_get_contents(); |
| 985 | 985 | ob_end_clean(); |
| 986 | 986 | |
| 987 | 987 | /** It is attribute TVA, add a button to calcilate price in mass **/ |
| 988 | - if ( !empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva' ) { |
|
| 989 | - $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/>'; |
|
| 990 | - $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop' ); |
|
| 988 | + if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') { |
|
| 989 | + $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/>'; |
|
| 990 | + $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop'); |
|
| 991 | 991 | } |
| 992 | 992 | if (!empty($the_form_option_content_list)) { |
| 993 | - $the_form_option_content_section=''; |
|
| 993 | + $the_form_option_content_section = ''; |
|
| 994 | 994 | foreach ($attribute_options_group as $group_name => $group_content) { |
| 995 | 995 | $section_content = ''; |
| 996 | 996 | foreach ($group_content as $group_code) { |
@@ -999,23 +999,23 @@ discard block |
||
| 999 | 999 | unset($the_form_option_content_list[$group_code]); |
| 1000 | 1000 | } |
| 1001 | 1001 | } |
| 1002 | - $section_legend = __($group_name,'wpshop'); |
|
| 1002 | + $section_legend = __($group_name, 'wpshop'); |
|
| 1003 | 1003 | $section_page_code = self::currentPageCode; |
| 1004 | 1004 | |
| 1005 | 1005 | ob_start(); |
| 1006 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1006 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1007 | 1007 | $the_form_option_content_section .= ob_get_contents(); |
| 1008 | 1008 | ob_end_clean(); |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | /* Check there are other attributes to display not in defined group */ |
| 1012 | 1012 | if (!empty($the_form_option_content_list)) { |
| 1013 | - $section_legend = __('General options','wpshop'); |
|
| 1013 | + $section_legend = __('General options', 'wpshop'); |
|
| 1014 | 1014 | $section_content = implode('', $the_form_option_content_list); |
| 1015 | 1015 | $section_page_code = self::currentPageCode; |
| 1016 | 1016 | |
| 1017 | 1017 | ob_start(); |
| 1018 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1018 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1019 | 1019 | $the_form_option_content = ob_get_contents(); |
| 1020 | 1020 | ob_end_clean(); |
| 1021 | 1021 | |
@@ -1025,17 +1025,17 @@ discard block |
||
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | /* Default content for the current page */ |
| 1028 | - $bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop'); |
|
| 1028 | + $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); |
|
| 1029 | 1029 | $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; |
| 1030 | 1030 | |
| 1031 | - $bloc_list[self::currentPageCode]['options']['title']=__('Options', 'wpshop'); |
|
| 1032 | - $bloc_list[self::currentPageCode]['options']['content']=$the_form_option_content; |
|
| 1031 | + $bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop'); |
|
| 1032 | + $bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content; |
|
| 1033 | 1033 | |
| 1034 | - $action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action' ] ) : ''; |
|
| 1034 | + $action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 1035 | 1035 | $the_form = ' |
| 1036 | 1036 | <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > |
| 1037 | - ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save') , 'hidden') . ' |
|
| 1038 | - ' . 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 | + ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save'), 'hidden') . ' |
|
| 1038 | + ' . 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) . ' |
|
| 1039 | 1039 | </form> |
| 1040 | 1040 | <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>'; |
| 1041 | 1041 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
@@ -1053,7 +1053,7 @@ discard block |
||
| 1053 | 1053 | $the_form .= ' |
| 1054 | 1054 | <script type="text/javascript" > |
| 1055 | 1055 | wpshop(document).ready(function(){ |
| 1056 | - 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') . '"); |
|
| 1056 | + 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') . '"); |
|
| 1057 | 1057 | |
| 1058 | 1058 | jQuery("#wpshop_dialog_duplicate_attribute").dialog({ |
| 1059 | 1059 | autoOpen: false, |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | dialogClass: "wpshop_uidialog_box", |
| 1064 | 1064 | resizable: false, |
| 1065 | 1065 | buttons:{ |
| 1066 | - "'.__('Duplicate', 'wpshop').'": function(){ |
|
| 1066 | + "'.__('Duplicate', 'wpshop') . '": function(){ |
|
| 1067 | 1067 | var data = { |
| 1068 | 1068 | action: "wpshop_duplicate_attribute", |
| 1069 | 1069 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '", |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | } |
| 1080 | 1080 | }, "json"); |
| 1081 | 1081 | }, |
| 1082 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1082 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1083 | 1083 | jQuery(this).dialog("close"); |
| 1084 | 1084 | jQuery(".wpshop_duplicate_attribute_result").remove(); |
| 1085 | 1085 | } |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | dialogClass: "wpshop_uidialog_box", |
| 1098 | 1098 | resizable: false, |
| 1099 | 1099 | buttons:{ |
| 1100 | - "'.__('Change type', 'wpshop').'": function(){ |
|
| 1100 | + "'.__('Change type', 'wpshop') . '": function(){ |
|
| 1101 | 1101 | var delete_entity = false; |
| 1102 | 1102 | if(jQuery("#delete_entity").is(":checked")){ |
| 1103 | 1103 | var delete_entity = true; |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | jQuery("#wpshop_dialog_change_select_data_type").dialog("close"); |
| 1121 | 1121 | }, "json"); |
| 1122 | 1122 | }, |
| 1123 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1123 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1124 | 1124 | jQuery(this).dialog("close"); |
| 1125 | 1125 | } |
| 1126 | 1126 | } |
@@ -1160,7 +1160,7 @@ discard block |
||
| 1160 | 1160 | change_unit_list(); |
| 1161 | 1161 | });'; |
| 1162 | 1162 | |
| 1163 | - if ( !is_object($editedItem) ) { |
|
| 1163 | + if (!is_object($editedItem)) { |
|
| 1164 | 1164 | $the_form .= ' |
| 1165 | 1165 | jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){ |
| 1166 | 1166 | jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html()); |
@@ -1243,23 +1243,23 @@ discard block |
||
| 1243 | 1243 | * |
| 1244 | 1244 | * @return string $currentPageButton The html output code with the different button to add to the interface |
| 1245 | 1245 | */ |
| 1246 | - function getPageFormButton($element_id = 0){ |
|
| 1246 | + function getPageFormButton($element_id = 0) { |
|
| 1247 | 1247 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 1248 | 1248 | $currentPageButton = ''; |
| 1249 | 1249 | |
| 1250 | 1250 | //$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>'; |
| 1251 | 1251 | |
| 1252 | - if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1252 | + if (($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1253 | 1253 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 1254 | 1254 | |
| 1255 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 1255 | + elseif (current_user_can('wpshop_edit_attributes')) |
|
| 1256 | 1256 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
| 1257 | 1257 | |
| 1258 | 1258 | $attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE); |
| 1259 | 1259 | $attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id'); |
| 1260 | - $attribute_code = !empty($attribute->code)?$attribute->code:''; |
|
| 1261 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1262 | - $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1260 | + $attribute_code = !empty($attribute->code) ? $attribute->code : ''; |
|
| 1261 | + if (current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1262 | + $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1263 | 1263 | |
| 1264 | 1264 | return $currentPageButton; |
| 1265 | 1265 | } |
@@ -1273,22 +1273,22 @@ discard block |
||
| 1273 | 1273 | * |
| 1274 | 1274 | * @return object $element_list A wordpress database object containing the attribute list |
| 1275 | 1275 | */ |
| 1276 | - public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false){ |
|
| 1276 | + public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false) { |
|
| 1277 | 1277 | |
| 1278 | 1278 | global $wpdb; |
| 1279 | 1279 | $element_list = array(); |
| 1280 | 1280 | $moreQuery = ""; |
| 1281 | - $moreArgs = array( 1, ); |
|
| 1281 | + $moreArgs = array(1,); |
|
| 1282 | 1282 | |
| 1283 | - $orderby = !empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
|
| 1284 | - $order = !empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
|
| 1283 | + $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : ''; |
|
| 1284 | + $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : ''; |
|
| 1285 | 1285 | |
| 1286 | - if($element_id != ''){ |
|
| 1286 | + if ($element_id != '') { |
|
| 1287 | 1287 | $moreQuery .= " |
| 1288 | 1288 | AND CURRENT_ELEMENT." . $field_to_search . " = %s "; |
| 1289 | 1289 | $moreArgs[] = $element_id; |
| 1290 | 1290 | } |
| 1291 | - if(!empty($orderby) && !empty($order)){ |
|
| 1291 | + if (!empty($orderby) && !empty($order)) { |
|
| 1292 | 1292 | $moreQuery .= " |
| 1293 | 1293 | ORDER BY " . $orderby . " " . $order; |
| 1294 | 1294 | } |
@@ -1297,15 +1297,15 @@ discard block |
||
| 1297 | 1297 | "SELECT CURRENT_ELEMENT.*, ENTITIES.post_name as entity |
| 1298 | 1298 | FROM " . self::getDbTable() . " AS CURRENT_ELEMENT |
| 1299 | 1299 | INNER JOIN {$wpdb->posts} AS ENTITIES ON (ENTITIES.ID = CURRENT_ELEMENT.entity_id) |
| 1300 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, |
|
| 1300 | + WHERE %d AND CURRENT_ELEMENT.status IN (" . $element_status . ") " . $moreQuery, |
|
| 1301 | 1301 | $moreArgs |
| 1302 | 1302 | ); |
| 1303 | 1303 | |
| 1304 | 1304 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 1305 | - if(($element_id == '') || $list){ |
|
| 1305 | + if (($element_id == '') || $list) { |
|
| 1306 | 1306 | $element_list = $wpdb->get_results($query); |
| 1307 | 1307 | } |
| 1308 | - else{ |
|
| 1308 | + else { |
|
| 1309 | 1309 | $element_list = $wpdb->get_row($query); |
| 1310 | 1310 | } |
| 1311 | 1311 | |
@@ -1327,43 +1327,43 @@ discard block |
||
| 1327 | 1327 | $user_id = function_exists('is_user_logged_in') && is_user_logged_in() ? get_current_user_id() : '0'; |
| 1328 | 1328 | $sent_attribute_list = array(); |
| 1329 | 1329 | |
| 1330 | - if ( !empty($attributeToSet) ) { |
|
| 1330 | + if (!empty($attributeToSet)) { |
|
| 1331 | 1331 | foreach ($attributeToSet as $attributeType => $attributeTypeDetails) { |
| 1332 | 1332 | /** Preparation des parametres permettant de supprimer les bonnes valeurs des attributs suivant la configuration de la boutique et de la methode de mise a jour */ |
| 1333 | 1333 | $delete_current_attribute_values_params = array( |
| 1334 | 1334 | 'entity_id' => $entityId, |
| 1335 | 1335 | 'entity_type_id' => $entityTypeId |
| 1336 | 1336 | ); |
| 1337 | - if ( WPSHOP_ATTRIBUTE_VALUE_PER_USER ) { |
|
| 1337 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER) { |
|
| 1338 | 1338 | $delete_current_attribute_values_params['user_id'] = $user_id; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | - if(!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1342 | - foreach($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1341 | + if (!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1342 | + foreach ($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1343 | 1343 | |
| 1344 | - if ( $attributeType == 'decimal' ) { |
|
| 1344 | + if ($attributeType == 'decimal') { |
|
| 1345 | 1345 | $attributeValue = str_replace(',', '.', $attributeValue); |
| 1346 | 1346 | } |
| 1347 | - if ( ($attributeType == 'integer') && !is_array($attributeValue) ) { |
|
| 1347 | + if (($attributeType == 'integer') && !is_array($attributeValue)) { |
|
| 1348 | 1348 | $attributeValue = (int)$attributeValue; |
| 1349 | 1349 | } |
| 1350 | 1350 | $more_query_params_values = array(); |
| 1351 | - if($attribute_code != 'unit') { |
|
| 1351 | + if ($attribute_code != 'unit') { |
|
| 1352 | 1352 | |
| 1353 | 1353 | $unit_id = 0; |
| 1354 | - if(isset($attributeTypeDetails['unit'][$attribute_code])){ |
|
| 1354 | + if (isset($attributeTypeDetails['unit'][$attribute_code])) { |
|
| 1355 | 1355 | $unit_id = $attributeTypeDetails['unit'][$attribute_code]; |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | $currentAttribute = self::getElement($attribute_code, "'valid'", 'code'); |
| 1359 | - if( !empty($currentAttribute) ){ |
|
| 1359 | + if (!empty($currentAttribute)) { |
|
| 1360 | 1360 | $sent_attribute_list[] = $currentAttribute->id; |
| 1361 | 1361 | |
| 1362 | 1362 | /* Enregistrement de la valeur actuelle de l'attribut dans la table d'historique si l'option historique est activee sur l'attribut courant */ |
| 1363 | - if ( $currentAttribute->is_historisable == 'yes') { |
|
| 1363 | + if ($currentAttribute->is_historisable == 'yes') { |
|
| 1364 | 1364 | $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); |
| 1365 | 1365 | $attribute_histo = $wpdb->get_results($query); |
| 1366 | - if(!empty($attribute_histo)){ |
|
| 1366 | + if (!empty($attribute_histo)) { |
|
| 1367 | 1367 | $attribute_histo_content['status'] = 'valid'; |
| 1368 | 1368 | $attribute_histo_content['creation_date'] = current_time('mysql', 0); |
| 1369 | 1369 | $attribute_histo_content['creation_date_value'] = $attribute_histo[0]->creation_date_value; |
@@ -1381,8 +1381,8 @@ discard block |
||
| 1381 | 1381 | } |
| 1382 | 1382 | $attributeValue = str_replace("\\", "", $attributeValue); |
| 1383 | 1383 | |
| 1384 | - if ( empty($from) || (!empty($attributeValue)) ) { |
|
| 1385 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1384 | + if (empty($from) || (!empty($attributeValue))) { |
|
| 1385 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1386 | 1386 | |
| 1387 | 1387 | /** Insertion de la nouvelle valeur de l'attribut dans la base */ |
| 1388 | 1388 | $query_params = array( |
@@ -1396,32 +1396,32 @@ discard block |
||
| 1396 | 1396 | 'creation_date_value' => current_time('mysql', 0) |
| 1397 | 1397 | ); |
| 1398 | 1398 | /** Si l'attribut courant est contenu dans un tableau (exemple: select multiple) on lit tout le tableau et on enregistre chaque valeur separement */ |
| 1399 | - if(is_array($attributeValue)){ |
|
| 1400 | - foreach($attributeValue as $a){ |
|
| 1401 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1399 | + if (is_array($attributeValue)) { |
|
| 1400 | + foreach ($attributeValue as $a) { |
|
| 1401 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | } |
| 1404 | - else{ |
|
| 1405 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1406 | - wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
|
| 1404 | + else { |
|
| 1405 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1406 | + wpeologs_ctr::log_datas_in_files('wpshop_attributes', array( |
|
| 1407 | 1407 | 'object_id' => $entityId, |
| 1408 | - 'message' => __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ) ), 0 |
|
| 1408 | + 'message' => __('Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue, 'wpshop') ), 0 |
|
| 1409 | 1409 | ); |
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | /** 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 */ |
| 1413 | - if ( ( ($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ( $currentAttribute->is_filterable == 'yes') && !empty($attributeValue) ) : |
|
| 1414 | - update_post_meta($entityId, '_'.$attribute_code, $attributeValue); |
|
| 1413 | + if ((($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ($currentAttribute->is_filterable == 'yes') && !empty($attributeValue)) : |
|
| 1414 | + update_post_meta($entityId, '_' . $attribute_code, $attributeValue); |
|
| 1415 | 1415 | endif; |
| 1416 | 1416 | |
| 1417 | 1417 | /** Enregistrement de toutes les valeurs des attributs dans une meta du produit */ |
| 1418 | - $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array) $_POST['attribute_option'][$attribute_code] : null; |
|
| 1418 | + $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array)$_POST['attribute_option'][$attribute_code] : null; |
|
| 1419 | 1419 | if (isset($attribute_option)) { |
| 1420 | 1420 | $value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value'); |
| 1421 | 1421 | if (strtolower($value) == 'yes') : |
| 1422 | - update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option); |
|
| 1422 | + update_post_meta($entityId, 'attribute_option_' . $attribute_code, $attribute_option); |
|
| 1423 | 1423 | else : |
| 1424 | - delete_post_meta($entityId, 'attribute_option_'.$attribute_code); |
|
| 1424 | + delete_post_meta($entityId, 'attribute_option_' . $attribute_code); |
|
| 1425 | 1425 | endif; |
| 1426 | 1426 | } |
| 1427 | 1427 | } |
@@ -1429,15 +1429,15 @@ discard block |
||
| 1429 | 1429 | } |
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | - if ( empty($from) ) { |
|
| 1433 | - $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); |
|
| 1432 | + if (empty($from)) { |
|
| 1433 | + $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); |
|
| 1434 | 1434 | $attr_to_delete = $wpdb->get_results($query); |
| 1435 | - if(!empty($attr_to_delete)){ |
|
| 1435 | + if (!empty($attr_to_delete)) { |
|
| 1436 | 1436 | foreach ($attr_to_delete as $value) { |
| 1437 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1438 | - wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
|
| 1437 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1438 | + wpeologs_ctr::log_datas_in_files('wpshop_attributes', array( |
|
| 1439 | 1439 | 'object_id' => $entityId, |
| 1440 | - 'message' => __( 'Remove the attribute : ' . $value->value_id, 'wpshop' ) ), 0 |
|
| 1440 | + 'message' => __('Remove the attribute : ' . $value->value_id, 'wpshop') ), 0 |
|
| 1441 | 1441 | ); |
| 1442 | 1442 | } |
| 1443 | 1443 | } |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | |
| 1464 | 1464 | $query_params = ""; |
| 1465 | 1465 | $query_params_values = array($attributeId, $entityTypeId, $entityId); |
| 1466 | - if(WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))){ |
|
| 1466 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))) { |
|
| 1467 | 1467 | $query_params = " |
| 1468 | 1468 | AND ATTR_VAL.user_id = %d"; |
| 1469 | 1469 | $query_params_values[] = get_current_user_id(); |
@@ -1479,20 +1479,20 @@ discard block |
||
| 1479 | 1479 | ); |
| 1480 | 1480 | $attributeValue = $wpdb->get_results($query); |
| 1481 | 1481 | |
| 1482 | - if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) { |
|
| 1482 | + if (((count($attributeValue) <= 1) && !empty($attributeValue[0])) && (empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select'))) { |
|
| 1483 | 1483 | $attributeValue = $attributeValue[0]; |
| 1484 | 1484 | } |
| 1485 | - else{ |
|
| 1485 | + else { |
|
| 1486 | 1486 | $entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true); |
| 1487 | - if ( !empty($entity_meta) ) { |
|
| 1487 | + if (!empty($entity_meta)) { |
|
| 1488 | 1488 | $query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId); |
| 1489 | 1489 | $attribute_code = $wpdb->get_var($query); |
| 1490 | 1490 | $attributeValue = !empty($entity_meta[$attribute_code]) ? $entity_meta[$attribute_code] : null; |
| 1491 | 1491 | } |
| 1492 | - if ( is_array($attributeValue) ) { |
|
| 1492 | + if (is_array($attributeValue)) { |
|
| 1493 | 1493 | $tmp_array = array(); |
| 1494 | - if ( !empty($attributeValue) ) { |
|
| 1495 | - foreach ( $attributeValue as $att ) { |
|
| 1494 | + if (!empty($attributeValue)) { |
|
| 1495 | + foreach ($attributeValue as $att) { |
|
| 1496 | 1496 | $obj = new stdClass(); |
| 1497 | 1497 | $obj->value = $att; |
| 1498 | 1498 | $obj->unit_id = 0; |
@@ -1523,9 +1523,9 @@ discard block |
||
| 1523 | 1523 | $elements = array(); |
| 1524 | 1524 | $elementsWithAttributeAndValues = self::get_attribute_list_for_item($entityId, $elementId, $language); |
| 1525 | 1525 | |
| 1526 | - foreach ( $elementsWithAttributeAndValues as $elementDefinition ) { |
|
| 1526 | + foreach ($elementsWithAttributeAndValues as $elementDefinition) { |
|
| 1527 | 1527 | $arrayKey = $elementDefinition->attribute_id; |
| 1528 | - if ( $keyForArray == 'code' ) { |
|
| 1528 | + if ($keyForArray == 'code') { |
|
| 1529 | 1529 | $arrayKey = $elementDefinition->attribute_code; |
| 1530 | 1530 | } |
| 1531 | 1531 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['code'] = $elementDefinition->attribute_set_section_code; |
@@ -1535,7 +1535,7 @@ discard block |
||
| 1535 | 1535 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_table'] = $elementDefinition->backend_table; |
| 1536 | 1536 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_input'] = $elementDefinition->backend_input; |
| 1537 | 1537 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_input'] = $elementDefinition->frontend_input; |
| 1538 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __( $elementDefinition->frontend_label, 'wpshop' ); |
|
| 1538 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __($elementDefinition->frontend_label, 'wpshop'); |
|
| 1539 | 1539 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['attribute_code'] = $elementDefinition->attribute_code; |
| 1540 | 1540 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['data_type_to_use'] = $elementDefinition->data_type_to_use; |
| 1541 | 1541 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['is_visible_in_front'] = $elementDefinition->is_visible_in_front; |
@@ -1545,29 +1545,29 @@ discard block |
||
| 1545 | 1545 | $attributeValueField = 'attribute_value_' . $elementDefinition->data_type; |
| 1546 | 1546 | |
| 1547 | 1547 | // Manage the value differently if it is an array or not |
| 1548 | - if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) { |
|
| 1548 | + if (!empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
|
| 1549 | 1549 | if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
| 1550 | 1550 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField; |
| 1551 | 1551 | } |
| 1552 | 1552 | else { |
| 1553 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField); |
|
| 1553 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'], $elementDefinition->$attributeValueField); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | 1556 | else { |
| 1557 | 1557 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField; |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | - if ( $elementDefinition->backend_input == 'multiple-select' ) { |
|
| 1560 | + if ($elementDefinition->backend_input == 'multiple-select') { |
|
| 1561 | 1561 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['select_value'] = self::get_attribute_type_select_option_info($attributeValueField, 'value'); |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | $attributeUnitField = 'attribute_unit_' . $elementDefinition->data_type; |
| 1565 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $elementDefinition->$attributeUnitField, 'wpshop' ); |
|
| 1566 | - if( !empty($elementDefinition->is_requiring_unit ) && ( $elementDefinition->is_requiring_unit == 'yes' ) && empty( $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] ) ) { |
|
| 1565 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($elementDefinition->$attributeUnitField, 'wpshop'); |
|
| 1566 | + if (!empty($elementDefinition->is_requiring_unit) && ($elementDefinition->is_requiring_unit == 'yes') && empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'])) { |
|
| 1567 | 1567 | $unit = ''; |
| 1568 | - $query = $wpdb->prepare( 'SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1569 | - $unit = $wpdb->get_var( $query ); |
|
| 1570 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $unit, 'wpshop' ); |
|
| 1568 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1569 | + $unit = $wpdb->get_var($query); |
|
| 1570 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($unit, 'wpshop'); |
|
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | 1573 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | $elementsWithAttributeAndValues = array(); |
| 1580 | 1580 | $moreQuery = ""; |
| 1581 | 1581 | |
| 1582 | - $entity_type = empty($defined_entity_type) ? get_post_type( $elementId ) : $defined_entity_type; |
|
| 1582 | + $entity_type = empty($defined_entity_type) ? get_post_type($elementId) : $defined_entity_type; |
|
| 1583 | 1583 | |
| 1584 | 1584 | $query = $wpdb->prepare( |
| 1585 | 1585 | "SELECT POST_META.*, |
@@ -1628,23 +1628,23 @@ discard block |
||
| 1628 | 1628 | * |
| 1629 | 1629 | * @return boolean The result to know if the element has to be displayed on frontend |
| 1630 | 1630 | */ |
| 1631 | - public static function check_attribute_display( $attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1632 | - if ( $attribute_main_config === 'yes' ) { |
|
| 1631 | + public static function check_attribute_display($attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1632 | + if ($attribute_main_config === 'yes') { |
|
| 1633 | 1633 | $attribute_output = true; |
| 1634 | - 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' ) |
|
| 1635 | - || empty($attribute_custom_config) ) { |
|
| 1634 | + 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') |
|
| 1635 | + || empty($attribute_custom_config)) { |
|
| 1636 | 1636 | $attribute_output = true; |
| 1637 | 1637 | } |
| 1638 | - 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')) ) { |
|
| 1638 | + 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'))) { |
|
| 1639 | 1639 | $attribute_output = false; |
| 1640 | 1640 | } |
| 1641 | 1641 | } |
| 1642 | - elseif ( $attribute_main_config === 'no' ) { |
|
| 1642 | + elseif ($attribute_main_config === 'no') { |
|
| 1643 | 1643 | $attribute_output = false; |
| 1644 | - if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) { |
|
| 1644 | + if (empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code])) { |
|
| 1645 | 1645 | $attribute_output = false; |
| 1646 | 1646 | } |
| 1647 | - 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') ) { |
|
| 1647 | + 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')) { |
|
| 1648 | 1648 | $attribute_output = true; |
| 1649 | 1649 | } |
| 1650 | 1650 | } |
@@ -1661,22 +1661,22 @@ discard block |
||
| 1661 | 1661 | global $wpdb; |
| 1662 | 1662 | global $wp_query; |
| 1663 | 1663 | |
| 1664 | - $attribute = self::getElement( $atts['attid'] ); |
|
| 1665 | - if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1666 | - $attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1667 | - $output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output'; |
|
| 1664 | + $attribute = self::getElement($atts['attid']); |
|
| 1665 | + if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1666 | + $attribute_main_config = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1667 | + $output_type = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? 'complete_sheet' : 'mini_output'; |
|
| 1668 | 1668 | $product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true); |
| 1669 | - $display_attribute_value = wpshop_attributes::check_attribute_display( $attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1669 | + $display_attribute_value = wpshop_attributes::check_attribute_display($attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1670 | 1670 | |
| 1671 | - if ( !empty( $attribute->data_type ) ) { |
|
| 1671 | + if (!empty($attribute->data_type)) { |
|
| 1672 | 1672 | $attributeDefinition['unit'] = ''; |
| 1673 | 1673 | |
| 1674 | 1674 | $has_value = false; |
| 1675 | - $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'] ); |
|
| 1676 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) ) { |
|
| 1675 | + $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']); |
|
| 1676 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox'))) { |
|
| 1677 | 1677 | $list_of_value = $wpdb->get_results($query); |
| 1678 | - if ( !empty($list_of_value) ) { |
|
| 1679 | - foreach ( $list_of_value as $value ) { |
|
| 1678 | + if (!empty($list_of_value)) { |
|
| 1679 | + foreach ($list_of_value as $value) { |
|
| 1680 | 1680 | $data[] = $value->value; |
| 1681 | 1681 | } |
| 1682 | 1682 | $has_value = true; |
@@ -1684,10 +1684,10 @@ discard block |
||
| 1684 | 1684 | } |
| 1685 | 1685 | else { |
| 1686 | 1686 | $data = $wpdb->get_var($query); |
| 1687 | - if ( !empty($data) ) { |
|
| 1687 | + if (!empty($data)) { |
|
| 1688 | 1688 | $has_value = true; |
| 1689 | 1689 | } |
| 1690 | - elseif( !empty($attribute->default_value) ) { |
|
| 1690 | + elseif (!empty($attribute->default_value)) { |
|
| 1691 | 1691 | $has_value = true; |
| 1692 | 1692 | $data = $attribute->default_value; |
| 1693 | 1693 | } |
@@ -1699,7 +1699,7 @@ discard block |
||
| 1699 | 1699 | $attributeDefinition['is_requiring_unit'] = $attribute->is_requiring_unit; |
| 1700 | 1700 | $attributeDefinition['backend_input'] = $attribute->backend_input; |
| 1701 | 1701 | $attributeDefinition['data_type_to_use'] = $attribute->data_type_to_use; |
| 1702 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 1702 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 1703 | 1703 | $attribute_value = $attribute_display[0]; |
| 1704 | 1704 | $attributeDefinition['value'] = $attribute_display[1]; |
| 1705 | 1705 | $attribute_unit_list = $attribute_display[2]; |
@@ -1719,13 +1719,13 @@ discard block |
||
| 1719 | 1719 | * @param array $specific_argument Optionnal The different parameters used for filter output |
| 1720 | 1720 | * @return array The definition for the field used to display an attribute |
| 1721 | 1721 | */ |
| 1722 | - public static function get_attribute_field_definition( $attribute, $attribute_value = '', $specific_argument = array() ) { |
|
| 1722 | + public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array()) { |
|
| 1723 | 1723 | global $wpdb; |
| 1724 | 1724 | $wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 1725 | 1725 | $wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT); |
| 1726 | 1726 | $input_def = array(); |
| 1727 | 1727 | $input_def['option'] = $input_def['field_container_class'] = ''; |
| 1728 | - $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 . ']'); |
|
| 1728 | + $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 . ']'); |
|
| 1729 | 1729 | $input_def['input_domain'] = $attributeInputDomain; |
| 1730 | 1730 | $input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id; |
| 1731 | 1731 | $input_def['intrinsec'] = $attribute->is_intrinsic; |
@@ -1745,26 +1745,26 @@ discard block |
||
| 1745 | 1745 | $input_def['frontend_type'] = $attribute->frontend_input; |
| 1746 | 1746 | $input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form; |
| 1747 | 1747 | |
| 1748 | - if ( !empty($attribute_value) && !is_object($attribute_value) ) { |
|
| 1748 | + if (!empty($attribute_value) && !is_object($attribute_value)) { |
|
| 1749 | 1749 | $input_def['value'] = $attribute_value; |
| 1750 | 1750 | } |
| 1751 | - else if ( !empty($attribute_value->value) ) { |
|
| 1751 | + else if (!empty($attribute_value->value)) { |
|
| 1752 | 1752 | $input_def['value'] = stripslashes($attribute_value->value); |
| 1753 | 1753 | } |
| 1754 | - else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) { |
|
| 1754 | + else if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft')) { |
|
| 1755 | 1755 | $input_def['value'] = ''; |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | 1758 | $input_def['options'] = ''; |
| 1759 | 1759 | $input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : ''; |
| 1760 | 1760 | if ($attribute->data_type == 'datetime') { |
| 1761 | - $date_config = unserialize( $attribute->default_value ); |
|
| 1761 | + $date_config = unserialize($attribute->default_value); |
|
| 1762 | 1762 | if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) { |
| 1763 | 1763 | $input_def['value'] = date('Y-m-d'); |
| 1764 | 1764 | } |
| 1765 | 1765 | else { |
| 1766 | 1766 | /** Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/ */ |
| 1767 | - $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 ) : '' ); |
|
| 1767 | + $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) : ''); |
|
| 1768 | 1768 | } |
| 1769 | 1769 | $input_more_class .= ' wpshop_input_datetime '; |
| 1770 | 1770 | $field_script = '<script type="text/javascript" > |
@@ -1777,31 +1777,31 @@ discard block |
||
| 1777 | 1777 | wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true); |
| 1778 | 1778 | wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");'; |
| 1779 | 1779 | |
| 1780 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']) ) { |
|
| 1781 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ) { |
|
| 1780 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) { |
|
| 1781 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) { |
|
| 1782 | 1782 | $field_script .= ' |
| 1783 | 1783 | wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");'; |
| 1784 | 1784 | } |
| 1785 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ) { |
|
| 1785 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) { |
|
| 1786 | 1786 | $field_script .= ' |
| 1787 | 1787 | wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");'; |
| 1788 | 1788 | } |
| 1789 | 1789 | } |
| 1790 | 1790 | |
| 1791 | 1791 | $script_options = $script_options_params = array(); |
| 1792 | - if ( !empty($date_config['field_options']['attribute_type_date_options_day_to_show']) ) { |
|
| 1792 | + if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) { |
|
| 1793 | 1793 | $day_to_show_list = ' '; |
| 1794 | - foreach ( $date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show ) { |
|
| 1794 | + foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) { |
|
| 1795 | 1795 | $day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || '; |
| 1796 | 1796 | } |
| 1797 | 1797 | $script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )'; |
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0]) ) { |
|
| 1801 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 1800 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) { |
|
| 1801 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) { |
|
| 1802 | 1802 | $available_date = ' '; |
| 1803 | - foreach ( $date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list ) { |
|
| 1804 | - if ( !empty($avalaible_date_list) ) { |
|
| 1803 | + foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) { |
|
| 1804 | + if (!empty($avalaible_date_list)) { |
|
| 1805 | 1805 | $available_date .= '"' . $avalaible_date_list . '",'; |
| 1806 | 1806 | } |
| 1807 | 1807 | } |
@@ -1810,7 +1810,7 @@ discard block |
||
| 1810 | 1810 | } |
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | - if ( !empty( $script_options ) ) { |
|
| 1813 | + if (!empty($script_options)) { |
|
| 1814 | 1814 | $field_script .= ' |
| 1815 | 1815 | wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){ |
| 1816 | 1816 | ' . implode(' ', $script_options_params) . '; |
@@ -1838,37 +1838,37 @@ discard block |
||
| 1838 | 1838 | </script>'; |
| 1839 | 1839 | $input_def['options'] .= $field_script; |
| 1840 | 1840 | } |
| 1841 | - if ( in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1842 | - $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ' ); |
|
| 1841 | + if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1842 | + $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select '); |
|
| 1843 | 1843 | $input_def['type'] = ((!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend')) || (!is_admin() && empty($specific_argument['from'])) ? $attribute->frontend_input : $attribute->backend_input); |
| 1844 | 1844 | $input_def['valueToPut'] = 'index'; |
| 1845 | 1845 | |
| 1846 | 1846 | $select_display = self::get_select_output($attribute, $specific_argument); |
| 1847 | - if ( empty( $input_def[ 'options_label' ] ) && !empty( $specific_argument ) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend') ) ) { |
|
| 1848 | - $input_def[ 'options_label' ][ 'original' ] = true; |
|
| 1847 | + if (empty($input_def['options_label']) && !empty($specific_argument) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend'))) { |
|
| 1848 | + $input_def['options_label']['original'] = true; |
|
| 1849 | 1849 | } |
| 1850 | 1850 | $input_def['options'] .= $select_display['more_input']; |
| 1851 | 1851 | $input_def['possible_value'] = (!empty($select_display) && !empty($select_display['possible_value'])) ? $select_display['possible_value'] : ''; |
| 1852 | - if ( !is_admin() ) { |
|
| 1852 | + if (!is_admin()) { |
|
| 1853 | 1853 | $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" />'; |
| 1854 | 1854 | } |
| 1855 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1856 | - $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'); |
|
| 1855 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1856 | + $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'); |
|
| 1857 | 1857 | } |
| 1858 | 1858 | } |
| 1859 | 1859 | $input_def['label_pointer'] = 'for="' . $input_def['id'] . '"'; |
| 1860 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 1860 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 1861 | 1861 | $input_def['label_pointer'] = ''; |
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | 1864 | /* |
| 1865 | 1865 | * Specifc treatment for price attributes |
| 1866 | 1866 | */ |
| 1867 | - if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){ |
|
| 1867 | + if ((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC)) { |
|
| 1868 | 1868 | $input_def['option'] .= ' readonly="readonly" '; |
| 1869 | 1869 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1870 | 1870 | } |
| 1871 | - elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){ |
|
| 1871 | + elseif ((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT)) { |
|
| 1872 | 1872 | $input_def['option'] .= ' readonly="readonly" '; |
| 1873 | 1873 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1874 | 1874 | } |
@@ -1879,7 +1879,7 @@ discard block |
||
| 1879 | 1879 | |
| 1880 | 1880 | $input_def['label'] = str_replace("\\", "", $input_def['label']); |
| 1881 | 1881 | // $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 1882 | - $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 : '' ) . '" '; |
|
| 1882 | + $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 : '') . '" '; |
|
| 1883 | 1883 | $input_def['title'] = !empty($attribute->frontend_help_message) ? ' title="' . $attribute->frontend_help_message . '" ' : ''; |
| 1884 | 1884 | |
| 1885 | 1885 | if (($attribute->is_intrinsic == 'yes') && ((!empty($input_def['value'])) || ($input_def['value'] > 0))) { |
@@ -1890,13 +1890,13 @@ discard block |
||
| 1890 | 1890 | * Add the unit to the attribute if attribute configuration is set to yes |
| 1891 | 1891 | */ |
| 1892 | 1892 | if ($attribute->is_requiring_unit == 'yes') { |
| 1893 | - if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) { |
|
| 1893 | + if (in_array($attribute->code, $wpshop_price_attributes) || (WPSHOP_COST_OF_POSTAGE == $attribute->code)) { |
|
| 1894 | 1894 | $input_def['options'] .= ' <span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>'; |
| 1895 | 1895 | } |
| 1896 | - elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) { |
|
| 1896 | + elseif (in_array($attribute->code, $wpshop_weight_attributes)) { |
|
| 1897 | 1897 | $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
| 1898 | - $query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1899 | - $unity = $wpdb->get_var( $query ); |
|
| 1898 | + $query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1899 | + $unity = $wpdb->get_var($query); |
|
| 1900 | 1900 | $input_def['options'] .= ' <span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>'; |
| 1901 | 1901 | } |
| 1902 | 1902 | else { |
@@ -1904,11 +1904,11 @@ discard block |
||
| 1904 | 1904 | $unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id); |
| 1905 | 1905 | $unit_input_def['type'] = 'select'; |
| 1906 | 1906 | $unit_input_def['option'] = ' class="wpshop_attribute_unit_input chosen_select" '; |
| 1907 | - $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; |
|
| 1907 | + $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; |
|
| 1908 | 1908 | $unit_input_def['name'] = $attribute->code; |
| 1909 | 1909 | $unit_input_def['value'] = (!empty($attribute_value->unit_id) ? $attribute_value->unit_id : ''); |
| 1910 | - if($unit_input_def['value'] == ''){ |
|
| 1911 | - if ( $attribute->_default_unit > 0 ) { |
|
| 1910 | + if ($unit_input_def['value'] == '') { |
|
| 1911 | + if ($attribute->_default_unit > 0) { |
|
| 1912 | 1912 | $unit_input_def['value'] = $attribute->_default_unit; |
| 1913 | 1913 | } |
| 1914 | 1914 | else { |
@@ -1922,18 +1922,18 @@ discard block |
||
| 1922 | 1922 | /* |
| 1923 | 1923 | * Add indication on postage cost tax |
| 1924 | 1924 | */ |
| 1925 | - if ( $attribute->code == WPSHOP_COST_OF_POSTAGE ) { |
|
| 1925 | + if ($attribute->code == WPSHOP_COST_OF_POSTAGE) { |
|
| 1926 | 1926 | $input_def['options'] .= ' <span class="attribute_currency" >' . __('ATI', 'wpshop') . '</span>'; |
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | 1929 | /* |
| 1930 | 1930 | * Create the field output |
| 1931 | 1931 | */ |
| 1932 | - if ( is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1933 | - $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')); |
|
| 1932 | + if (is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1933 | + $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')); |
|
| 1934 | 1934 | $input_def['options'] = ''; |
| 1935 | 1935 | $input_def['label_pointer'] = ''; |
| 1936 | - $input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1936 | + $input_def['option'] = substr($input_def['option'], 0, -2) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1937 | 1937 | $input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container'; |
| 1938 | 1938 | } |
| 1939 | 1939 | else { |
@@ -1948,7 +1948,7 @@ discard block |
||
| 1948 | 1948 | * @param string $output_from |
| 1949 | 1949 | * @return string The output for |
| 1950 | 1950 | */ |
| 1951 | - public static function display_attribute( $attribute_code, $output_from = 'admin', $output_specs = array() ) { |
|
| 1951 | + public static function display_attribute($attribute_code, $output_from = 'admin', $output_specs = array()) { |
|
| 1952 | 1952 | $output = ''; |
| 1953 | 1953 | /* Get the page code */ |
| 1954 | 1954 | $currentPageCode = !empty($output_specs['page_code']) ? $output_specs['page_code'] : ''; |
@@ -1959,17 +1959,17 @@ discard block |
||
| 1959 | 1959 | |
| 1960 | 1960 | /* Get attribute input definition */ |
| 1961 | 1961 | $current_value = (!empty($output_specs['current_value']) ? $output_specs['current_value'] : ''); |
| 1962 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)) ); |
|
| 1962 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from))); |
|
| 1963 | 1963 | |
| 1964 | 1964 | /* Create default output */ |
| 1965 | 1965 | $input_to_display = $input['output'] . $input['options']; |
| 1966 | 1966 | |
| 1967 | 1967 | /* Check if current field is linked to an addon, and if the addon is activated */ |
| 1968 | 1968 | $addons_list = unserialize(WPSHOP_ADDONS_LIST); |
| 1969 | - foreach ( $addons_list as $addon_code => $addon_def ) { |
|
| 1970 | - if ( in_array($attribute_code, $addon_def) ) { |
|
| 1971 | - if ( constant($addon_code) === false ) { |
|
| 1972 | - $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>'; |
|
| 1969 | + foreach ($addons_list as $addon_code => $addon_def) { |
|
| 1970 | + if (in_array($attribute_code, $addon_def)) { |
|
| 1971 | + if (constant($addon_code) === false) { |
|
| 1972 | + $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>'; |
|
| 1973 | 1973 | } |
| 1974 | 1974 | } |
| 1975 | 1975 | } |
@@ -1994,11 +1994,11 @@ discard block |
||
| 1994 | 1994 | /* |
| 1995 | 1995 | * Display attribute option if applicable |
| 1996 | 1996 | */ |
| 1997 | - if ( $output_from == 'admin') { |
|
| 1998 | - $attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop') ) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 1997 | + if ($output_from == 'admin') { |
|
| 1998 | + $attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 1999 | 1999 | |
| 2000 | 2000 | $output['field'] .= ' |
| 2001 | - <div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($element_identifier, $attribute_def->code).'</div>'; |
|
| 2001 | + <div class="attribute_option_'.$attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($element_identifier, $attribute_def->code) . '</div>'; |
|
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | 2004 | $output['field'] .= '</div>'; |
@@ -2016,36 +2016,36 @@ discard block |
||
| 2016 | 2016 | * |
| 2017 | 2017 | * @return string The html code to output directly tabs |
| 2018 | 2018 | */ |
| 2019 | - public static function attribute_of_entity_to_tab( $element_code, $element_id, $element_definition ) { |
|
| 2019 | + public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) { |
|
| 2020 | 2020 | $attributeContentOutput = ''; |
| 2021 | 2021 | |
| 2022 | 2022 | /** Get the different attribute affected to the entity */ |
| 2023 | 2023 | $element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend'); |
| 2024 | 2024 | |
| 2025 | 2025 | |
| 2026 | - if ( is_array($element_atribute_list) && (count($element_atribute_list) > 0) ) { |
|
| 2027 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2026 | + if (is_array($element_atribute_list) && (count($element_atribute_list) > 0)) { |
|
| 2027 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2028 | 2028 | $attributeToShowNumber = 0; |
| 2029 | 2029 | $attributeOutput = ''; |
| 2030 | 2030 | |
| 2031 | - foreach ( $attributeSetContent['attributes'] as $attributeId => $attributeDefinition ) { |
|
| 2031 | + foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) { |
|
| 2032 | 2032 | |
| 2033 | 2033 | /** Check the value type to check if empty or not */ |
| 2034 | - if ( $attributeDefinition['data_type'] == 'int' ) { |
|
| 2034 | + if ($attributeDefinition['data_type'] == 'int') { |
|
| 2035 | 2035 | $attributeDefinition['value'] = (int)$attributeDefinition['value']; |
| 2036 | 2036 | } |
| 2037 | - else if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2037 | + else if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2038 | 2038 | $attributeDefinition['value'] = (float)$attributeDefinition['value']; |
| 2039 | 2039 | } |
| 2040 | 2040 | |
| 2041 | 2041 | /** Check if the attribute is set to be displayed in frontend */ |
| 2042 | - $attribute_display_state = wpshop_attributes::check_attribute_display( $attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2042 | + $attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2043 | 2043 | |
| 2044 | 2044 | /** Output the field if the value is not null */ |
| 2045 | 2045 | |
| 2046 | - if ( (is_array($attributeDefinition['value']) || ( !empty($attributeDefinition['value']) ) ) && $attribute_display_state) { |
|
| 2046 | + if ((is_array($attributeDefinition['value']) || (!empty($attributeDefinition['value']))) && $attribute_display_state) { |
|
| 2047 | 2047 | |
| 2048 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 2048 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 2049 | 2049 | $attribute_value = $attribute_display[0]; |
| 2050 | 2050 | $attributeDefinition['value'] = $attribute_display[1]; |
| 2051 | 2051 | $attribute_unit_list = $attribute_display[2]; |
@@ -2056,8 +2056,8 @@ discard block |
||
| 2056 | 2056 | $tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode; |
| 2057 | 2057 | $tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code']; |
| 2058 | 2058 | $tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop'); |
| 2059 | - $tpl_component['ATTRIBUTE_VALUE'] = ( !is_array($attribute_value) ) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2060 | - $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2059 | + $tpl_component['ATTRIBUTE_VALUE'] = (!is_array($attribute_value)) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2060 | + $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2061 | 2061 | |
| 2062 | 2062 | /** Build template */ |
| 2063 | 2063 | $attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component); |
@@ -2068,9 +2068,9 @@ discard block |
||
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | 2070 | /** Check if the attribute set section is set to be displayed in frontend */ |
| 2071 | - $attribute_set_display_state = wpshop_attributes::check_attribute_display( $attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2071 | + $attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2072 | 2072 | |
| 2073 | - if ( !$attribute_set_display_state ) { |
|
| 2073 | + if (!$attribute_set_display_state) { |
|
| 2074 | 2074 | $attributeToShowNumber = 0; |
| 2075 | 2075 | $attributeOutput = ''; |
| 2076 | 2076 | } |
@@ -2080,8 +2080,8 @@ discard block |
||
| 2080 | 2080 | |
| 2081 | 2081 | /** Gestion de l'affichage */ |
| 2082 | 2082 | $tab_list = $content_list = ''; |
| 2083 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2084 | - if ( !empty($attributeSetContent['count']) > 0 ) { |
|
| 2083 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2084 | + if (!empty($attributeSetContent['count']) > 0) { |
|
| 2085 | 2085 | /** Template parameters */ |
| 2086 | 2086 | $template_part = 'product_attribute_tabs'; |
| 2087 | 2087 | $tpl_component = array(); |
@@ -2090,7 +2090,7 @@ discard block |
||
| 2090 | 2090 | |
| 2091 | 2091 | /** Build template */ |
| 2092 | 2092 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2093 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2093 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2094 | 2094 | /* Include the old way template part */ |
| 2095 | 2095 | ob_start(); |
| 2096 | 2096 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2110,7 +2110,7 @@ discard block |
||
| 2110 | 2110 | |
| 2111 | 2111 | /** Build template */ |
| 2112 | 2112 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2113 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2113 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2114 | 2114 | /* Include the old way template part */ |
| 2115 | 2115 | ob_start(); |
| 2116 | 2116 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2124,16 +2124,16 @@ discard block |
||
| 2124 | 2124 | } |
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | - if ( $tab_list != '' ) { |
|
| 2127 | + if ($tab_list != '') { |
|
| 2128 | 2128 | /** Template parameters */ |
| 2129 | 2129 | $template_part = 'product_attribute_container'; |
| 2130 | 2130 | $tpl_component = array(); |
| 2131 | - $tpl_component['PDT_TABS'] = apply_filters( 'wpshop_extra_tabs_menu_before', '' ).$tab_list.apply_filters( 'wpshop_extra_tabs_menu_after', '' ); |
|
| 2132 | - $tpl_component['PDT_TAB_DETAIL'] = apply_filters( 'wpshop_extra_tabs_content_before', '' ).$content_list.apply_filters( 'wpshop_extra_tabs_content_after', '' ); |
|
| 2131 | + $tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', ''); |
|
| 2132 | + $tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', ''); |
|
| 2133 | 2133 | |
| 2134 | 2134 | /** Build template */ |
| 2135 | 2135 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2136 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2136 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2137 | 2137 | /* Include the old way template part */ |
| 2138 | 2138 | ob_start(); |
| 2139 | 2139 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2156,9 +2156,9 @@ discard block |
||
| 2156 | 2156 | * @param unknown_type $attributeDefinition |
| 2157 | 2157 | * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <> |
| 2158 | 2158 | */ |
| 2159 | - public static function wps_attribute_values_display( $attributeDefinition ) { |
|
| 2159 | + public static function wps_attribute_values_display($attributeDefinition) { |
|
| 2160 | 2160 | $attribute_unit_list = ''; |
| 2161 | - if ( !empty($attributeDefinition['unit']) ) { |
|
| 2161 | + if (!empty($attributeDefinition['unit'])) { |
|
| 2162 | 2162 | /** Template parameters */ |
| 2163 | 2163 | $template_part = 'product_attribute_unit'; |
| 2164 | 2164 | $tpl_component = array(); |
@@ -2170,31 +2170,31 @@ discard block |
||
| 2170 | 2170 | } |
| 2171 | 2171 | |
| 2172 | 2172 | $attribute_value = $attributeDefinition['value']; |
| 2173 | - if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2174 | - $attribute_value =(is_numeric($attribute_value) ) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2175 | - if ( in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) { |
|
| 2176 | - if ( $attributeDefinition['is_requiring_unit'] == 'yes' ) { |
|
| 2173 | + if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2174 | + $attribute_value = (is_numeric($attribute_value)) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2175 | + if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) { |
|
| 2176 | + if ($attributeDefinition['is_requiring_unit'] == 'yes') { |
|
| 2177 | 2177 | $attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency(); |
| 2178 | 2178 | } |
| 2179 | 2179 | $attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']); |
| 2180 | 2180 | } |
| 2181 | 2181 | } |
| 2182 | - if ( $attributeDefinition['data_type'] == 'datetime' ) { |
|
| 2182 | + if ($attributeDefinition['data_type'] == 'datetime') { |
|
| 2183 | 2183 | $attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true); |
| 2184 | 2184 | } |
| 2185 | - if ( $attributeDefinition['backend_input'] == 'select' ) { |
|
| 2185 | + if ($attributeDefinition['backend_input'] == 'select') { |
|
| 2186 | 2186 | $attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
| 2187 | 2187 | } |
| 2188 | 2188 | /** Manage differently if its an array of values or not */ |
| 2189 | - if ( $attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2189 | + if ($attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2190 | 2190 | $attribute_value = ''; |
| 2191 | - if ( is_array($attributeDefinition['value']) ) { |
|
| 2191 | + if (is_array($attributeDefinition['value'])) { |
|
| 2192 | 2192 | foreach ($attributeDefinition['value'] as $v) { |
| 2193 | - $attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2193 | + $attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2194 | 2194 | } |
| 2195 | 2195 | } |
| 2196 | - else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2197 | - $attribute_value = substr($attribute_value,3); |
|
| 2196 | + else $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2197 | + $attribute_value = substr($attribute_value, 3); |
|
| 2198 | 2198 | } |
| 2199 | 2199 | |
| 2200 | 2200 | return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list); |
@@ -2204,13 +2204,13 @@ discard block |
||
| 2204 | 2204 | * Manage display for the output when user uses a shortcode for attributes display |
| 2205 | 2205 | * @param array $shorcode_args The list of argument passed through the shortcode |
| 2206 | 2206 | */ |
| 2207 | - function wpshop_attributes_shortcode( $shorcode_args ) { |
|
| 2207 | + function wpshop_attributes_shortcode($shorcode_args) { |
|
| 2208 | 2208 | $output = ''; |
| 2209 | 2209 | /* |
| 2210 | 2210 | * Read the attribute list |
| 2211 | 2211 | */ |
| 2212 | - foreach ( explode(', ', $shorcode_args['attributes']) as $attribute_code ) { |
|
| 2213 | - $attribute_output_def = wpshop_attributes::display_attribute( $attribute_code, $shorcode_args['from'] ); |
|
| 2212 | + foreach (explode(', ', $shorcode_args['attributes']) as $attribute_code) { |
|
| 2213 | + $attribute_output_def = wpshop_attributes::display_attribute($attribute_code, $shorcode_args['from']); |
|
| 2214 | 2214 | $output .= $attribute_output_def['field']; |
| 2215 | 2215 | } |
| 2216 | 2216 | |
@@ -2232,7 +2232,7 @@ discard block |
||
| 2232 | 2232 | $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid','deleted'"); |
| 2233 | 2233 | $attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_'); |
| 2234 | 2234 | |
| 2235 | - if ( count($productAttributeSetDetails) > 0 ) { |
|
| 2235 | + if (count($productAttributeSetDetails) > 0) { |
|
| 2236 | 2236 | /* Read the attribute list in order to output */ |
| 2237 | 2237 | $shortcodes_attr = ''; |
| 2238 | 2238 | $shortcodes_to_display = false; |
@@ -2242,80 +2242,80 @@ discard block |
||
| 2242 | 2242 | |
| 2243 | 2243 | $shortcodes = $currentTabContent = ''; |
| 2244 | 2244 | $output_nb = 0; |
| 2245 | - if(count($productAttributeSetDetail['attribut']) >= 1){ |
|
| 2246 | - foreach($productAttributeSetDetail['attribut'] as $attribute){ |
|
| 2245 | + if (count($productAttributeSetDetail['attribut']) >= 1) { |
|
| 2246 | + foreach ($productAttributeSetDetail['attribut'] as $attribute) { |
|
| 2247 | 2247 | |
| 2248 | - if ( !empty($attribute->id) ) { |
|
| 2249 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2248 | + if (!empty($attribute->id)) { |
|
| 2249 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2250 | 2250 | $attribute_set_id_is_present = true; |
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | /** Generic part for attribute field output */ |
| 2254 | 2254 | $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)); |
| 2255 | - $product_meta = get_post_meta( $itemToEdit, '_wpshop_product_metadata', true); |
|
| 2255 | + $product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true); |
|
| 2256 | 2256 | |
| 2257 | 2257 | /** Check if value is empty and get value in meta if not empty */ |
| 2258 | 2258 | $value = (empty($value) && !empty($product_meta[$attribute->code])) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null); |
| 2259 | 2259 | |
| 2260 | 2260 | /* Manage specific field as the attribute_set_id in product form */ |
| 2261 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2261 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2262 | 2262 | |
| 2263 | 2263 | $value = empty($value) ? $attributeSetId : $value; |
| 2264 | 2264 | } |
| 2265 | 2265 | $attribute_specification['current_value'] = $value; |
| 2266 | - $attribute_output_def = apply_filters( 'wpshop_attribute_output_def', wpshop_attributes::display_attribute( $attribute->code, 'admin', $attribute_specification), $itemToEdit ); |
|
| 2267 | - if ( ($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id') ) { |
|
| 2266 | + $attribute_output_def = apply_filters('wpshop_attribute_output_def', wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification), $itemToEdit); |
|
| 2267 | + if (($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id')) { |
|
| 2268 | 2268 | $currentTabContent .= $attribute_output_def['field']; |
| 2269 | - $shortcode_code_def=array(); |
|
| 2270 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2271 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2272 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2273 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2269 | + $shortcode_code_def = array(); |
|
| 2270 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2271 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2272 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2273 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2274 | 2274 | ob_start(); |
| 2275 | - 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'); |
|
| 2276 | - $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>'; |
|
| 2275 | + 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'); |
|
| 2276 | + $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>'; |
|
| 2277 | 2277 | ob_end_clean(); |
| 2278 | 2278 | } |
| 2279 | 2279 | else { |
| 2280 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2280 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2281 | 2281 | $attribute_output_def['field_definition']['type'] = 'hidden'; |
| 2282 | 2282 | } |
| 2283 | - $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2283 | + $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2284 | 2284 | } |
| 2285 | 2285 | $output_nb++; |
| 2286 | 2286 | } |
| 2287 | 2287 | } |
| 2288 | 2288 | |
| 2289 | - $currentTabContent = apply_filters( 'wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail ); |
|
| 2289 | + $currentTabContent = apply_filters('wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail); |
|
| 2290 | 2290 | |
| 2291 | 2291 | $shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group'; |
| 2292 | 2292 | $shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit; |
| 2293 | 2293 | $shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id']; |
| 2294 | 2294 | ob_start(); |
| 2295 | - 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'); |
|
| 2296 | - $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>'; |
|
| 2295 | + 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'); |
|
| 2296 | + $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>'; |
|
| 2297 | 2297 | ob_end_clean(); |
| 2298 | 2298 | |
| 2299 | - if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) |
|
| 2300 | - $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>'; |
|
| 2299 | + if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box') |
|
| 2300 | + $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>'; |
|
| 2301 | 2301 | else |
| 2302 | 2302 | $shortcodes_attr .= $attribute_group_display; |
| 2303 | 2303 | |
| 2304 | - if ( $output_nb <= 0 ) { |
|
| 2304 | + if ($output_nb <= 0) { |
|
| 2305 | 2305 | $currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop'); |
| 2306 | 2306 | } |
| 2307 | 2307 | } |
| 2308 | 2308 | |
| 2309 | 2309 | if ($output_nb > 0) { |
| 2310 | 2310 | $shortcodes_to_display = true; |
| 2311 | - if ( $outputType == 'box' ) { |
|
| 2311 | + if ($outputType == 'box') { |
|
| 2312 | 2312 | $box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name']; |
| 2313 | - $box['box'][$productAttributeSetDetail['code'].'_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2313 | + $box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2314 | 2314 | $box['boxContent'][$productAttributeSetDetail['code']] = ' |
| 2315 | 2315 | <div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . ' |
| 2316 | 2316 | </div><div class="wpshop_cls" ></div>'; |
| 2317 | 2317 | } |
| 2318 | - else if ( $outputType == 'column' ) { |
|
| 2318 | + else if ($outputType == 'column') { |
|
| 2319 | 2319 | $currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent); |
| 2320 | 2320 | $currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent); |
| 2321 | 2321 | |
@@ -2325,11 +2325,11 @@ discard block |
||
| 2325 | 2325 | } |
| 2326 | 2326 | } |
| 2327 | 2327 | |
| 2328 | - if( !$attribute_set_id_is_present ) { |
|
| 2328 | + if (!$attribute_set_id_is_present) { |
|
| 2329 | 2329 | /* Get attribute definition */ |
| 2330 | 2330 | $attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code'); |
| 2331 | 2331 | /* Get attribute input definition */ |
| 2332 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')) ); |
|
| 2332 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin'))); |
|
| 2333 | 2333 | $input['type'] = 'hidden'; |
| 2334 | 2334 | |
| 2335 | 2335 | $box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']); |
@@ -2340,13 +2340,13 @@ discard block |
||
| 2340 | 2340 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2341 | 2341 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2342 | 2342 | ob_start(); |
| 2343 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2343 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2344 | 2344 | $box['boxMore'] .= ob_get_contents(); |
| 2345 | 2345 | ob_end_clean(); |
| 2346 | 2346 | $box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; |
| 2347 | 2347 | |
| 2348 | - if ( $shortcodes_to_display ) { |
|
| 2349 | - switch ( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE ) { |
|
| 2348 | + if ($shortcodes_to_display) { |
|
| 2349 | + switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) { |
|
| 2350 | 2350 | case 'fixed-tab': |
| 2351 | 2351 | case 'movable-tab': |
| 2352 | 2352 | if ($outputType == 'box') { |
@@ -2354,7 +2354,7 @@ discard block |
||
| 2354 | 2354 | $box['boxContent']['shortcode'] = $shortcodes_attr; |
| 2355 | 2355 | $box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE; |
| 2356 | 2356 | } |
| 2357 | - else{ |
|
| 2357 | + else { |
|
| 2358 | 2358 | $box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop'); |
| 2359 | 2359 | $box['columnContent']['shortcode'] = $shortcodes_attr; |
| 2360 | 2360 | } |
@@ -2378,12 +2378,12 @@ discard block |
||
| 2378 | 2378 | $ouput['more_input'] = ''; |
| 2379 | 2379 | |
| 2380 | 2380 | $attribute_default_value = $attribute->default_value; |
| 2381 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2381 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2382 | 2382 | $tmp_default_value = unserialize($attribute->default_value); |
| 2383 | 2383 | $attribute_default_value = !empty($tmp_default_value["default_value"]) ? $tmp_default_value["default_value"] : null; |
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | - if ( $attribute->data_type_to_use == 'custom') { |
|
| 2386 | + if ($attribute->data_type_to_use == 'custom') { |
|
| 2387 | 2387 | $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); |
| 2388 | 2388 | $attribute_select_options = $wpdb->get_results($query); |
| 2389 | 2389 | |
@@ -2395,11 +2395,11 @@ discard block |
||
| 2395 | 2395 | // } |
| 2396 | 2396 | endforeach; |
| 2397 | 2397 | } |
| 2398 | - elseif ( $attribute->data_type_to_use == 'internal') { |
|
| 2398 | + elseif ($attribute->data_type_to_use == 'internal') { |
|
| 2399 | 2399 | switch ($attribute_default_value) { |
| 2400 | 2400 | case 'users': |
| 2401 | 2401 | $users = get_users('orderby=nicename'); |
| 2402 | - foreach($users as $user){ |
|
| 2402 | + foreach ($users as $user) { |
|
| 2403 | 2403 | $attribute_select_options_list[$user->ID] = $user->display_name; |
| 2404 | 2404 | } |
| 2405 | 2405 | break; |
@@ -2408,11 +2408,11 @@ discard block |
||
| 2408 | 2408 | $wpshop_attr_custom_post_query = new WP_Query(array( |
| 2409 | 2409 | 'post_type' => $attribute_default_value, |
| 2410 | 2410 | 'posts_per_page' => -1, |
| 2411 | - 'post_status' => array( 'publish', 'draft', 'future' ) , |
|
| 2411 | + 'post_status' => array('publish', 'draft', 'future'), |
|
| 2412 | 2412 | )); |
| 2413 | 2413 | |
| 2414 | - if($wpshop_attr_custom_post_query->have_posts()): |
|
| 2415 | - foreach($wpshop_attr_custom_post_query->posts as $post){ |
|
| 2414 | + if ($wpshop_attr_custom_post_query->have_posts()): |
|
| 2415 | + foreach ($wpshop_attr_custom_post_query->posts as $post) { |
|
| 2416 | 2416 | $attribute_select_options_list[$post->ID] = $post->post_title; |
| 2417 | 2417 | } |
| 2418 | 2418 | endif; |
@@ -2423,27 +2423,27 @@ discard block |
||
| 2423 | 2423 | |
| 2424 | 2424 | /* There is no value existing for this value */ |
| 2425 | 2425 | if (empty($attribute_select_options_list)) : |
| 2426 | - $ouput['more_input'].=__('Nothing found for this field', 'wpshop'); |
|
| 2426 | + $ouput['more_input'] .= __('Nothing found for this field', 'wpshop'); |
|
| 2427 | 2427 | else: |
| 2428 | 2428 | /* Add a default value to the combobox list */ |
| 2429 | 2429 | $default_value_is_serial = false; |
| 2430 | 2430 | $attribute_list_first_element = $attribute->default_value; |
| 2431 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2431 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2432 | 2432 | $default_value_is_serial = true; |
| 2433 | 2433 | $tmp_default_value = unserialize($attribute->default_value); |
| 2434 | 2434 | $attribute_list_first_element = $tmp_default_value["field_options"]["label_for_first_item"]; |
| 2435 | 2435 | } |
| 2436 | 2436 | //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'); |
| 2437 | - foreach ( $attribute_select_options_list as $option_key => $option_value ) { |
|
| 2437 | + foreach ($attribute_select_options_list as $option_key => $option_value) { |
|
| 2438 | 2438 | $ouput['possible_value'][$option_key] = stripslashes($option_value); |
| 2439 | 2439 | } |
| 2440 | 2440 | endif; |
| 2441 | 2441 | |
| 2442 | 2442 | /* Add a extra element to create a new element into list */ |
| 2443 | - if ( is_admin() && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) { |
|
| 2443 | + if (is_admin() && (empty($provenance['from']) || ($provenance['from'] != 'frontend'))) { |
|
| 2444 | 2444 | /** $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.'" />'; */ |
| 2445 | 2445 | } |
| 2446 | - else if ( 'yes' == $attribute->is_used_in_quick_add_form ) { |
|
| 2446 | + else if ('yes' == $attribute->is_used_in_quick_add_form) { |
|
| 2447 | 2447 | $tpl_component = array(); |
| 2448 | 2448 | $tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']'; |
| 2449 | 2449 | $ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component); |
@@ -2452,11 +2452,11 @@ discard block |
||
| 2452 | 2452 | return $ouput; |
| 2453 | 2453 | } |
| 2454 | 2454 | |
| 2455 | - public static function get_affected_value_for_list( $attribute_code, $element_id, $attribute_data_type ) { |
|
| 2455 | + public static function get_affected_value_for_list($attribute_code, $element_id, $attribute_data_type) { |
|
| 2456 | 2456 | global $wpdb; |
| 2457 | 2457 | $affected_value = array(); |
| 2458 | 2458 | |
| 2459 | - if ( $attribute_data_type == 'custom' ) { |
|
| 2459 | + if ($attribute_data_type == 'custom') { |
|
| 2460 | 2460 | $query = $wpdb->prepare(" |
| 2461 | 2461 | SELECT ATT_SELECT_OPTIONS_VALUE.id AS chosen_val, ATT_SELECT_OPTIONS_VALUE.value |
| 2462 | 2462 | FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT |
@@ -2478,20 +2478,20 @@ discard block |
||
| 2478 | 2478 | } |
| 2479 | 2479 | |
| 2480 | 2480 | $attribute_values_for_variations = $wpdb->get_results($query); |
| 2481 | - foreach ( $attribute_values_for_variations as $attribute_def ) { |
|
| 2482 | - $affected_value[] = (int) $attribute_def->chosen_val; |
|
| 2481 | + foreach ($attribute_values_for_variations as $attribute_def) { |
|
| 2482 | + $affected_value[] = (int)$attribute_def->chosen_val; |
|
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | 2485 | return $affected_value; |
| 2486 | 2486 | } |
| 2487 | 2487 | |
| 2488 | 2488 | public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') { |
| 2489 | - switch($attr_code){ |
|
| 2489 | + switch ($attr_code) { |
|
| 2490 | 2490 | case 'is_downloadable_': |
| 2491 | - $option = get_post_meta($item['item_id'], 'attribute_option_'.$attr_code, true); |
|
| 2492 | - switch($attr_option){ |
|
| 2491 | + $option = get_post_meta($item['item_id'], 'attribute_option_' . $attr_code, true); |
|
| 2492 | + switch ($attr_option) { |
|
| 2493 | 2493 | case 'file_url': |
| 2494 | - if(in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_'.$attr_code]) && (strtolower(__($item['item_'.$attr_code], 'wpshop')) == __('yes','wpshop'))) ){ |
|
| 2494 | + if (in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_' . $attr_code]) && (strtolower(__($item['item_' . $attr_code], 'wpshop')) == __('yes', 'wpshop')))) { |
|
| 2495 | 2495 | $file_url = isset($option[$attr_option]) ? $option[$attr_option] : false; |
| 2496 | 2496 | return $file_url; |
| 2497 | 2497 | } |
@@ -2504,17 +2504,17 @@ discard block |
||
| 2504 | 2504 | |
| 2505 | 2505 | public static function get_attribute_option_fields($postid, $code) { |
| 2506 | 2506 | |
| 2507 | - switch($code){ |
|
| 2507 | + switch ($code) { |
|
| 2508 | 2508 | case 'is_downloadable_': |
| 2509 | - $data = get_post_meta($postid, 'attribute_option_'.$code, true); |
|
| 2510 | - $data['file_url'] = !empty($data['file_url'])?$data['file_url']:__('No file selected', 'wpshop'); |
|
| 2511 | - $fields = wp_nonce_field( 'ajax_wpshop_show_downloadable_interface_in_admin'.$postid, '_show_downloadable_interface_in_admin_wpnonce', true, false ); |
|
| 2509 | + $data = get_post_meta($postid, 'attribute_option_' . $code, true); |
|
| 2510 | + $data['file_url'] = !empty($data['file_url']) ? $data['file_url'] : __('No file selected', 'wpshop'); |
|
| 2511 | + $fields = wp_nonce_field('ajax_wpshop_show_downloadable_interface_in_admin' . $postid, '_show_downloadable_interface_in_admin_wpnonce', true, false); |
|
| 2512 | 2512 | $fields .= '<div class="wpshop_form_label alignleft"> </div> |
| 2513 | 2513 | <div class="wpshop_form_input_element alignleft"> |
| 2514 | - <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid.'" title="' .__('Send the downloadable file', 'wpshop'). '"></div> |
|
| 2515 | - <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> |
|
| 2516 | - <input type="hidden" class="product_identifer_field" value="' .( !empty($postid) ? esc_attr( $postid ) : '') . '" /><br/><u>'.__('File url','wpshop').' :</u> |
|
| 2517 | - <div class="is_downloadable_statut_'.$postid.'"><a href="' .$data['file_url']. '" target="_blank" download>'.basename($data['file_url']).'</a></div> |
|
| 2514 | + <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid . '" title="' . __('Send the downloadable file', 'wpshop') . '"></div> |
|
| 2515 | + <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> |
|
| 2516 | + <input type="hidden" class="product_identifer_field" value="' .(!empty($postid) ? esc_attr($postid) : '') . '" /><br/><u>' . __('File url', 'wpshop') . ' :</u> |
|
| 2517 | + <div class="is_downloadable_statut_'.$postid . '"><a href="' . $data['file_url'] . '" target="_blank" download>' . basename($data['file_url']) . '</a></div> |
|
| 2518 | 2518 | </div>'; |
| 2519 | 2519 | return $fields; |
| 2520 | 2520 | break; |
@@ -2539,8 +2539,8 @@ discard block |
||
| 2539 | 2539 | $attribute_value_content = ''; |
| 2540 | 2540 | |
| 2541 | 2541 | $atributes = self::getElement($attribute_code, "'valid'", 'code'); |
| 2542 | - if ( !empty($atributes) ) { |
|
| 2543 | - $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2542 | + if (!empty($atributes)) { |
|
| 2543 | + $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | 2546 | return $attribute_value_content; |
@@ -2552,14 +2552,14 @@ discard block |
||
| 2552 | 2552 | * @param mixed $value |
| 2553 | 2553 | * @return string The complete interface allowing to manage datetime attribute field |
| 2554 | 2554 | */ |
| 2555 | - function attribute_type_date_config( $value ) { |
|
| 2555 | + function attribute_type_date_config($value) { |
|
| 2556 | 2556 | $date_config_output = ''; |
| 2557 | 2557 | |
| 2558 | 2558 | $input_def['name'] = 'default_value'; |
| 2559 | 2559 | $input_def['type'] = 'checkbox'; |
| 2560 | 2560 | $input_def['possible_value'] = 'date_of_current_day'; |
| 2561 | 2561 | $input_def['value'] = !empty($value['default_value']) ? $value['default_value'] : ''; |
| 2562 | - $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>'; |
|
| 2562 | + $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>'; |
|
| 2563 | 2563 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2564 | 2564 | |
| 2565 | 2565 | $input_def = array(); |
@@ -2568,35 +2568,35 @@ discard block |
||
| 2568 | 2568 | $input_def['type'] = 'checkbox'; |
| 2569 | 2569 | $input_def['valueToPut'] = 'index'; |
| 2570 | 2570 | $input_def['value'] = !empty($value['field_options']['attribute_type_date_options_day_to_show']) ? $value['field_options']['attribute_type_date_options_day_to_show'] : ''; |
| 2571 | - $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')); |
|
| 2571 | + $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')); |
|
| 2572 | 2572 | $input_def['options_label']['original'] = true; |
| 2573 | - $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>'; |
|
| 2573 | + $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>'; |
|
| 2574 | 2574 | |
| 2575 | 2575 | /** Past and futur date restriction */ |
| 2576 | 2576 | $input_def = array(); |
| 2577 | 2577 | $input_def['name'] = ''; |
| 2578 | 2578 | $input_def['type'] = 'text'; |
| 2579 | - $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/>'; |
|
| 2579 | + $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/>'; |
|
| 2580 | 2580 | $available_type_input_def = array(); |
| 2581 | 2581 | $available_type_input_def['name'] = ''; |
| 2582 | 2582 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_minimum'; |
| 2583 | 2583 | $available_type_input_def['type'] = 'text'; |
| 2584 | 2584 | $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] : ''; |
| 2585 | - $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/>'; |
|
| 2585 | + $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/>'; |
|
| 2586 | 2586 | $available_type_input_def = array(); |
| 2587 | 2587 | $available_type_input_def['name'] = ''; |
| 2588 | 2588 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_maximum'; |
| 2589 | 2589 | $available_type_input_def['type'] = 'text'; |
| 2590 | 2590 | $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] : ''; |
| 2591 | - $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/>'; |
|
| 2591 | + $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/>'; |
|
| 2592 | 2592 | $date_config_output .= '</div>'; |
| 2593 | 2593 | |
| 2594 | 2594 | $input_def = array(); |
| 2595 | 2595 | $input_def['name'] = ''; |
| 2596 | 2596 | $input_def['type'] = 'text'; |
| 2597 | 2597 | $date_config_output .= ' |
| 2598 | -<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> |
|
| 2599 | -<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/>'; |
|
| 2598 | +<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> |
|
| 2599 | +<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/>'; |
|
| 2600 | 2600 | |
| 2601 | 2601 | $available_type_input_def = array(); |
| 2602 | 2602 | $available_type_input_def['name'] = ''; |
@@ -2609,9 +2609,9 @@ discard block |
||
| 2609 | 2609 | $date_config_output .= wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_type]') . '<br/>'; |
| 2610 | 2610 | |
| 2611 | 2611 | $existing = 0; |
| 2612 | - if ( !empty($value['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 2613 | - foreach ( $value['field_options']['attribute_type_date_options_available_date'] as $index => $value ) { |
|
| 2614 | - if ( !empty($value) ) { |
|
| 2612 | + if (!empty($value['field_options']['attribute_type_date_options_available_date'])) { |
|
| 2613 | + foreach ($value['field_options']['attribute_type_date_options_available_date'] as $index => $value) { |
|
| 2614 | + if (!empty($value)) { |
|
| 2615 | 2615 | $input_def['value'] = $value; |
| 2616 | 2616 | $input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_' . $index; |
| 2617 | 2617 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '<br/>'; |
@@ -2635,20 +2635,20 @@ discard block |
||
| 2635 | 2635 | * @param array $values Valeurs d'attributs |
| 2636 | 2636 | * @return array |
| 2637 | 2637 | */ |
| 2638 | - public static function setAttributesValuesForItem($entityId, $values=array(), $defaultValueForOthers=false, $from = 'webservice') { |
|
| 2639 | - $message=''; |
|
| 2638 | + public static function setAttributesValuesForItem($entityId, $values = array(), $defaultValueForOthers = false, $from = 'webservice') { |
|
| 2639 | + $message = ''; |
|
| 2640 | 2640 | $attribute_available = array(); |
| 2641 | 2641 | $attribute_final = array(); |
| 2642 | 2642 | $entity_type = get_post_type($entityId); |
| 2643 | - $data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2644 | - foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2643 | + $data = self::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2644 | + foreach ($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2645 | 2645 | |
| 2646 | 2646 | // Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity |
| 2647 | - foreach ( $values as $key => $value ) { |
|
| 2648 | - if ( in_array( $key, array_keys( $attribute_available ) ) ) { |
|
| 2647 | + foreach ($values as $key => $value) { |
|
| 2648 | + if (in_array($key, array_keys($attribute_available))) { |
|
| 2649 | 2649 | $attribute_final[$attribute_available[$key]['data_type']][$key] = $value; |
| 2650 | 2650 | } |
| 2651 | - else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n"; |
|
| 2651 | + else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key) . "\n"; |
|
| 2652 | 2652 | } |
| 2653 | 2653 | |
| 2654 | 2654 | // Pour les autres attributs non donné on leur affecte leur valeur par défaut |
@@ -2669,7 +2669,7 @@ discard block |
||
| 2669 | 2669 | } |
| 2670 | 2670 | } |
| 2671 | 2671 | |
| 2672 | - switch ( $entity_type ) { |
|
| 2672 | + switch ($entity_type) { |
|
| 2673 | 2673 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 2674 | 2674 | $meta_key = WPSHOP_PRODUCT_ATTRIBUTE_META_KEY; |
| 2675 | 2675 | break; |
@@ -2699,22 +2699,22 @@ discard block |
||
| 2699 | 2699 | */ |
| 2700 | 2700 | public static function get_attribute_type_select_option_info($option_id, $field = 'label', $attribute_data_type = 'custom', $only_value = false) { |
| 2701 | 2701 | global $wpdb; |
| 2702 | - if( ! is_numeric( $option_id ) ) { |
|
| 2702 | + if (!is_numeric($option_id)) { |
|
| 2703 | 2703 | return ''; |
| 2704 | 2704 | } |
| 2705 | - $option_id = (int) $option_id; |
|
| 2706 | - switch ( $attribute_data_type ) { |
|
| 2705 | + $option_id = (int)$option_id; |
|
| 2706 | + switch ($attribute_data_type) { |
|
| 2707 | 2707 | case 'internal': |
| 2708 | 2708 | $entity_infos = get_post($option_id); |
| 2709 | - if ( !empty($entity_infos) ) { |
|
| 2710 | - if ( !$only_value ) { |
|
| 2709 | + if (!empty($entity_infos)) { |
|
| 2710 | + if (!$only_value) { |
|
| 2711 | 2711 | /** Template parameters */ |
| 2712 | 2712 | $template_part = 'product_attribute_value_internal'; |
| 2713 | 2713 | $tpl_component = array(); |
| 2714 | 2714 | $tpl_component['ATTRIBUTE_VALUE_POST_LINK'] = get_permalink($option_id); |
| 2715 | 2715 | $tpl_component['ATTRIBUTE_VALUE_POST_TITLE'] = $entity_infos->post_title; |
| 2716 | 2716 | |
| 2717 | - foreach ( $entity_infos as $post_definition_key => $post_definition_value ) { |
|
| 2717 | + foreach ($entity_infos as $post_definition_key => $post_definition_value) { |
|
| 2718 | 2718 | $tpl_component['ATTRIBUTE_VALUE_' . strtoupper($post_definition_key)] = $entity_infos->$post_definition_key; |
| 2719 | 2719 | } |
| 2720 | 2720 | |
@@ -2729,8 +2729,8 @@ discard block |
||
| 2729 | 2729 | break; |
| 2730 | 2730 | |
| 2731 | 2731 | default: |
| 2732 | - if ( ! array_key_exists( $option_id, self::$select_option_info_cache ) ) { |
|
| 2733 | - $query = $wpdb->prepare("SELECT " . $field . " FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." WHERE id=%d LIMIT 1", $option_id); |
|
| 2732 | + if (!array_key_exists($option_id, self::$select_option_info_cache)) { |
|
| 2733 | + $query = $wpdb->prepare("SELECT " . $field . " FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE id=%d LIMIT 1", $option_id); |
|
| 2734 | 2734 | self::$select_option_info_cache[$option_id] = $wpdb->get_var($query); |
| 2735 | 2735 | } |
| 2736 | 2736 | $info = self::$select_option_info_cache[$option_id]; |
@@ -2770,39 +2770,39 @@ discard block |
||
| 2770 | 2770 | * @param string $data_type optionnal Le type de donnees choisi pour cet attribut (custom | internal) |
| 2771 | 2771 | * @return string Le resultat sous forme de code html pour la liste des options |
| 2772 | 2772 | */ |
| 2773 | - function get_select_options_list($attribute_id, $data_type='custom') { |
|
| 2773 | + function get_select_options_list($attribute_id, $data_type = 'custom') { |
|
| 2774 | 2774 | global $wpdb; |
| 2775 | 2775 | $output = ''; |
| 2776 | 2776 | |
| 2777 | 2777 | $attribute_select_options = self::get_select_option_list_($attribute_id); |
| 2778 | 2778 | |
| 2779 | 2779 | /* Add possibily to choose datat type to use with list */ |
| 2780 | - if(empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))){ |
|
| 2781 | - unset($input_def);$input_def=array(); |
|
| 2780 | + if (empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))) { |
|
| 2781 | + unset($input_def); $input_def = array(); |
|
| 2782 | 2782 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2783 | 2783 | $input_def['type'] = 'radio'; |
| 2784 | 2784 | $input_def['name'] = 'data_type_to_use'; |
| 2785 | 2785 | $input_def['valueToPut'] = 'index'; |
| 2786 | 2786 | $input_def['possible_value'] = unserialize(WPSHOP_ATTR_SELECT_TYPE); |
| 2787 | 2787 | $input_def['option'] = 'class="wpshop_cls wpshop_attr_combo_data_type"'; |
| 2788 | - $input_def['value'] = $data_type.'_data'; |
|
| 2788 | + $input_def['value'] = $data_type . '_data'; |
|
| 2789 | 2789 | $input_def['options_label']['original'] = true; |
| 2790 | 2790 | $output = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2791 | 2791 | } |
| 2792 | 2792 | |
| 2793 | - if(!empty($attribute_id) || !empty($data_type)){ |
|
| 2794 | - $defaut_value = ( !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value) ) ? $attribute_select_options[0]->default_value : null; |
|
| 2793 | + if (!empty($attribute_id) || !empty($data_type)) { |
|
| 2794 | + $defaut_value = (!empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value)) ? $attribute_select_options[0]->default_value : null; |
|
| 2795 | 2795 | $default_is_serial = false; |
| 2796 | - 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 ) ) ) { |
|
| 2796 | + 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))) { |
|
| 2797 | 2797 | $defaut_value = unserialize($attribute_select_options[0]->default_value); |
| 2798 | 2798 | $default_is_serial = true; |
| 2799 | 2799 | } |
| 2800 | 2800 | /** Add a custom text first item of list */ |
| 2801 | - $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>'; |
|
| 2801 | + $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>'; |
|
| 2802 | 2802 | |
| 2803 | - 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'))){ |
|
| 2803 | + 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'))) { |
|
| 2804 | 2804 | $sub_output = ''; |
| 2805 | - if ( !empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id) ) { |
|
| 2805 | + if (!empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id)) { |
|
| 2806 | 2806 | $sub_output .= ' |
| 2807 | 2807 | <li class="wpshop_attribute_combo_options_container ui-state-disabled" > |
| 2808 | 2808 | <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> |
@@ -2815,7 +2815,7 @@ discard block |
||
| 2815 | 2815 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", $options->value); |
| 2816 | 2816 | $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"' : ''); |
| 2817 | 2817 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = ''; |
| 2818 | - if( current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0) ): |
|
| 2818 | + if (current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0)): |
|
| 2819 | 2819 | $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'); |
| 2820 | 2820 | endif; |
| 2821 | 2821 | $sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin'); |
@@ -2823,13 +2823,13 @@ discard block |
||
| 2823 | 2823 | } |
| 2824 | 2824 | } |
| 2825 | 2825 | $add_button = $add_dialog_box = $user_more_script = ''; |
| 2826 | - if( current_user_can('wpshop_add_attributes_select_values') ) { |
|
| 2826 | + if (current_user_can('wpshop_add_attributes_select_values')) { |
|
| 2827 | 2827 | |
| 2828 | 2828 | $dialog_title = __('New value for attribute', 'wpshop'); |
| 2829 | 2829 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2830 | 2830 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2831 | 2831 | ob_start(); |
| 2832 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2832 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2833 | 2833 | $add_dialog_box = ob_get_contents(); |
| 2834 | 2834 | ob_end_clean(); |
| 2835 | 2835 | |
@@ -2837,23 +2837,23 @@ discard block |
||
| 2837 | 2837 | $add_button_parent_class = 'wpshop_attribute_option_value_add'; |
| 2838 | 2838 | $add_button_name = 'wpshop_add_option_to_select'; |
| 2839 | 2839 | ob_start(); |
| 2840 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2840 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2841 | 2841 | $add_button = ob_get_contents(); |
| 2842 | 2842 | ob_end_clean(); |
| 2843 | 2843 | |
| 2844 | 2844 | $user_more_script = ' |
| 2845 | - jQuery("#'.$dialog_identifier.'").dialog({ |
|
| 2845 | + jQuery("#'.$dialog_identifier . '").dialog({ |
|
| 2846 | 2846 | modal: true, |
| 2847 | 2847 | dialogClass: "wpshop_uidialog_box", |
| 2848 | 2848 | autoOpen:false, |
| 2849 | 2849 | show: "blind", |
| 2850 | 2850 | resizable: false, |
| 2851 | 2851 | buttons:{ |
| 2852 | - "'.__('Add', 'wpshop').'": function(){ |
|
| 2852 | + "'.__('Add', 'wpshop') . '": function(){ |
|
| 2853 | 2853 | var data = { |
| 2854 | 2854 | action: "new_option_for_select", |
| 2855 | 2855 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '", |
| 2856 | - attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(), |
|
| 2856 | + attribute_new_label: jQuery("#'.$dialog_input_identifier . '").val(), |
|
| 2857 | 2857 | attribute_identifier: "' . $attribute_id . '" |
| 2858 | 2858 | }; |
| 2859 | 2859 | jQuery.post(ajaxurl, data, function(response) { |
@@ -2869,21 +2869,21 @@ discard block |
||
| 2869 | 2869 | |
| 2870 | 2870 | jQuery(this).children("img").show(); |
| 2871 | 2871 | }, |
| 2872 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 2872 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 2873 | 2873 | jQuery(this).dialog("close"); |
| 2874 | 2874 | } |
| 2875 | 2875 | }, |
| 2876 | 2876 | close:function(){ |
| 2877 | - jQuery("#'.$dialog_input_identifier.'").val(""); |
|
| 2877 | + jQuery("#'.$dialog_input_identifier . '").val(""); |
|
| 2878 | 2878 | } |
| 2879 | 2879 | }); |
| 2880 | - jQuery(".'.$add_button_parent_class.' input").click(function(){ |
|
| 2881 | - jQuery("#'.$dialog_identifier.'").dialog("open"); |
|
| 2880 | + jQuery(".'.$add_button_parent_class . ' input").click(function(){ |
|
| 2881 | + jQuery("#'.$dialog_identifier . '").dialog("open"); |
|
| 2882 | 2882 | });'; |
| 2883 | 2883 | |
| 2884 | 2884 | } |
| 2885 | 2885 | $output .= $add_dialog_box . ' |
| 2886 | - <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.' |
|
| 2886 | + <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options) > 5 ? $add_button : '') . $sub_output . $add_button . ' |
|
| 2887 | 2887 | </ul> |
| 2888 | 2888 | <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" /> |
| 2889 | 2889 | <script type="text/javascript" > |
@@ -2899,7 +2899,7 @@ discard block |
||
| 2899 | 2899 | var data = { |
| 2900 | 2900 | action: "attribute_output_type", |
| 2901 | 2901 | current_type: jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").val(), |
| 2902 | - elementIdentifier: "'.$attribute_id.'", |
|
| 2902 | + elementIdentifier: "'.$attribute_id . '", |
|
| 2903 | 2903 | data_type_to_use: jQuery(this).val(), |
| 2904 | 2904 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '" |
| 2905 | 2905 | }; |
@@ -2914,10 +2914,10 @@ discard block |
||
| 2914 | 2914 | }); |
| 2915 | 2915 | </script>'; |
| 2916 | 2916 | } |
| 2917 | - 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'))){ |
|
| 2918 | - $sub_output=''; |
|
| 2917 | + 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'))) { |
|
| 2918 | + $sub_output = ''; |
|
| 2919 | 2919 | $wp_types = unserialize(WPSHOP_INTERNAL_TYPES); |
| 2920 | - unset($input_def);$input_def=array(); |
|
| 2920 | + unset($input_def); $input_def = array(); |
|
| 2921 | 2921 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2922 | 2922 | $input_def['type'] = 'select'; |
| 2923 | 2923 | $input_def['name'] = 'default_value][default_value'; |
@@ -2926,20 +2926,20 @@ discard block |
||
| 2926 | 2926 | $input_def['possible_value'] = $wp_types; |
| 2927 | 2927 | $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)); |
| 2928 | 2928 | $combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2929 | - $output .= '<div class="wpshop_cls">'.$combo_wp_type.'</div>'; |
|
| 2930 | - if ( !empty($attribute_id) ) { |
|
| 2929 | + $output .= '<div class="wpshop_cls">' . $combo_wp_type . '</div>'; |
|
| 2930 | + if (!empty($attribute_id)) { |
|
| 2931 | 2931 | $option_list = '<div>' . __('You can reorder element for display them in the order you want into frontend part', 'wpshop') . '</div>'; |
| 2932 | - $options_for_current_attribute = query_posts( array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ) ); |
|
| 2933 | - if ( !empty($options_for_current_attribute) ) { |
|
| 2932 | + $options_for_current_attribute = query_posts(array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); |
|
| 2933 | + if (!empty($options_for_current_attribute)) { |
|
| 2934 | 2934 | $option_list .= '<ul class="wpshop_attribute_combo_values_list_container" >'; |
| 2935 | 2935 | $current_order = ' '; |
| 2936 | - foreach ( $options_for_current_attribute as $options_def ) { |
|
| 2936 | + foreach ($options_for_current_attribute as $options_def) { |
|
| 2937 | 2937 | $current_order .= 'post_' . $options_def->ID . ','; |
| 2938 | 2938 | $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>'; |
| 2939 | 2939 | } |
| 2940 | 2940 | $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" />'; |
| 2941 | 2941 | } |
| 2942 | - $output .= '<div class="wpshop_cls">'.$option_list.'</div>'; |
|
| 2942 | + $output .= '<div class="wpshop_cls">' . $option_list . '</div>'; |
|
| 2943 | 2943 | } |
| 2944 | 2944 | } |
| 2945 | 2945 | } |
@@ -2967,8 +2967,8 @@ discard block |
||
| 2967 | 2967 | $attribute_list_for_entity = self::getElement($entity_id, "'valid'", 'entity_id', true); |
| 2968 | 2968 | |
| 2969 | 2969 | /* Read the list */ |
| 2970 | - if ( !empty ($attribute_list_for_entity ) ) { |
|
| 2971 | - foreach ( $attribute_list_for_entity as $attribute) { |
|
| 2970 | + if (!empty ($attribute_list_for_entity)) { |
|
| 2971 | + foreach ($attribute_list_for_entity as $attribute) { |
|
| 2972 | 2972 | switch ($list_for) { |
| 2973 | 2973 | case 'attribute_value': |
| 2974 | 2974 | $checkbox_state = ' '; |
@@ -2977,8 +2977,8 @@ discard block |
||
| 2977 | 2977 | <select id="wpshop_shortcode_element_attribute_value_product_list_' . $attribute->id . '" class="wpshop_shortcode_element_attribute_value_product_list" >'; |
| 2978 | 2978 | |
| 2979 | 2979 | global $post; |
| 2980 | - $posts = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1) ); |
|
| 2981 | - foreach( $posts as $post ) : |
|
| 2980 | + $posts = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1)); |
|
| 2981 | + foreach ($posts as $post) : |
|
| 2982 | 2982 | setup_postdata($post); |
| 2983 | 2983 | $attribute_possible_values .= '<option value="' . get_the_ID() . '" >' . get_the_ID() . ' - ' . get_the_title() . '</option>'; |
| 2984 | 2984 | endforeach; |
@@ -2994,23 +2994,23 @@ discard block |
||
| 2994 | 2994 | |
| 2995 | 2995 | $checkbox_state = 'disabled '; |
| 2996 | 2996 | $attribute_possible_values = ''; |
| 2997 | - if ( !empty($attribute_values) ) { |
|
| 2997 | + if (!empty($attribute_values)) { |
|
| 2998 | 2998 | $checkbox_state = ''; |
| 2999 | 2999 | $attribute_possible_values = ' |
| 3000 | 3000 | <div class="wpshop_shortcode_element_product_listing_per_attribute_value wpshop_shortcode_element_prodcut_listing_per_attribute_value_' . $attribute->code . '_container" > |
| 3001 | 3001 | <select id="wpshop_attribute_value_for_shortcode_generation_' . $attribute->id . '" class="wpshop_shortcode_element_prodcut_listing_per_attribute_value hidden" >'; |
| 3002 | 3002 | |
| 3003 | - if ( ($attribute->data_type == 'integer') && ( ($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select') ) ) { |
|
| 3003 | + if (($attribute->data_type == 'integer') && (($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select'))) { |
|
| 3004 | 3004 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id=%d ORDER BY position", $attribute->id); |
| 3005 | 3005 | $possible_values = $wpdb->get_results($query); |
| 3006 | 3006 | $already_selected_values = array(); |
| 3007 | 3007 | foreach ($attribute_values as $attribute_value) { |
| 3008 | - if ( !empty($attribute_value->value) ) { |
|
| 3008 | + if (!empty($attribute_value->value)) { |
|
| 3009 | 3009 | $already_selected_values[] = $attribute_value->value; |
| 3010 | 3010 | } |
| 3011 | 3011 | } |
| 3012 | 3012 | foreach ($possible_values as $value) { |
| 3013 | - if ( in_array( $value->id, $already_selected_values ) ) { |
|
| 3013 | + if (in_array($value->id, $already_selected_values)) { |
|
| 3014 | 3014 | $attribute_possible_values .= ' |
| 3015 | 3015 | <option value="' . $value->value . '" >' . $value->label . '</option>'; |
| 3016 | 3016 | } |
@@ -3018,7 +3018,7 @@ discard block |
||
| 3018 | 3018 | } |
| 3019 | 3019 | else { |
| 3020 | 3020 | foreach ($attribute_values as $attribute_value) { |
| 3021 | - if ( !empty($attribute_value->value) ) { |
|
| 3021 | + if (!empty($attribute_value->value)) { |
|
| 3022 | 3022 | $attribute_possible_values .= ' |
| 3023 | 3023 | <option value="' . $attribute_value->value . '" >' . $attribute_value->value . '</option>'; |
| 3024 | 3024 | } |
@@ -3047,23 +3047,23 @@ discard block |
||
| 3047 | 3047 | * |
| 3048 | 3048 | * @return object The attribute list as a wordpress database object |
| 3049 | 3049 | */ |
| 3050 | - function get_attribute_list_in_same_set_section( $attribute_code ) { |
|
| 3050 | + function get_attribute_list_in_same_set_section($attribute_code) { |
|
| 3051 | 3051 | global $wpdb; |
| 3052 | 3052 | |
| 3053 | 3053 | $attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); |
| 3054 | 3054 | |
| 3055 | 3055 | /** Get the entire list of attribute in price set section for display */ |
| 3056 | - $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); |
|
| 3056 | + $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); |
|
| 3057 | 3057 | $attribute_attribution_def = $wpdb->get_row($query); |
| 3058 | 3058 | |
| 3059 | - $query = $wpdb->prepare( " |
|
| 3059 | + $query = $wpdb->prepare(" |
|
| 3060 | 3060 | SELECT ATTR.code, is_visible_in_front_listing, is_visible_in_front |
| 3061 | 3061 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS SET_SECTION_DETAIL |
| 3062 | 3062 | INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = SET_SECTION_DETAIL.attribute_id) |
| 3063 | 3063 | WHERE entity_type_id = %d |
| 3064 | 3064 | AND attribute_set_id = %d |
| 3065 | 3065 | AND attribute_group_id = %d", |
| 3066 | - $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id ); |
|
| 3066 | + $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id); |
|
| 3067 | 3067 | $atribute_list = $wpdb->get_results($query); |
| 3068 | 3068 | |
| 3069 | 3069 | return $atribute_list; |
@@ -3074,7 +3074,7 @@ discard block |
||
| 3074 | 3074 | * @param unknown_type $current_entity_id |
| 3075 | 3075 | * @return Ambigous <multitype:, multitype:NULL > |
| 3076 | 3076 | */ |
| 3077 | - public static function get_variation_available_attribute( $current_entity_id ) { |
|
| 3077 | + public static function get_variation_available_attribute($current_entity_id) { |
|
| 3078 | 3078 | global $wpdb; |
| 3079 | 3079 | $final_list = array(); |
| 3080 | 3080 | |
@@ -3082,7 +3082,7 @@ discard block |
||
| 3082 | 3082 | $query = $wpdb->prepare( |
| 3083 | 3083 | "SELECT ATT.*, ENTITY_META.meta_value |
| 3084 | 3084 | FROM " . self::getDbTable() . " AS ATT |
| 3085 | - 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')) |
|
| 3085 | + 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')) |
|
| 3086 | 3086 | INNER JOIN " . $wpdb->postmeta . " AS ENTITY_META ON ((ENTITY_META.meta_key = %s) AND (ENTITY_META.meta_value = ATT_DETAILS.attribute_set_id)) |
| 3087 | 3087 | WHERE ATT.status IN ('valid') |
| 3088 | 3088 | AND ATT.is_used_for_variation = %s |
@@ -3092,10 +3092,10 @@ discard block |
||
| 3092 | 3092 | ); |
| 3093 | 3093 | $attribute_list = $wpdb->get_results($query); |
| 3094 | 3094 | foreach ($attribute_list as $attribute) { |
| 3095 | - if ( !in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select')) ) { |
|
| 3096 | - $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list( $attribute->code, $current_entity_id, $attribute->data_type_to_use ); |
|
| 3095 | + if (!in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select'))) { |
|
| 3096 | + $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list($attribute->code, $current_entity_id, $attribute->data_type_to_use); |
|
| 3097 | 3097 | |
| 3098 | - if ( empty($attribute_values_for_variations) ) { |
|
| 3098 | + if (empty($attribute_values_for_variations)) { |
|
| 3099 | 3099 | $final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label; |
| 3100 | 3100 | $final_list['unavailable'][$attribute->code]['values'] = array(); |
| 3101 | 3101 | $final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute; |
@@ -3115,16 +3115,16 @@ discard block |
||
| 3115 | 3115 | * @param integer $current_entity_id The current element edited |
| 3116 | 3116 | * @return Ambigous <string, string, mixed> |
| 3117 | 3117 | */ |
| 3118 | - public static function get_variation_available_attribute_display( $current_entity_id, $variation_type = 'multiple' ) { |
|
| 3118 | + public static function get_variation_available_attribute_display($current_entity_id, $variation_type = 'multiple') { |
|
| 3119 | 3119 | $attribute_list = wpshop_attributes::get_variation_available_attribute($current_entity_id); |
| 3120 | 3120 | |
| 3121 | 3121 | $attribute_defined_as_available_for_variation = ''; |
| 3122 | - if ( !empty($attribute_list) ) { |
|
| 3122 | + if (!empty($attribute_list)) { |
|
| 3123 | 3123 | foreach ($attribute_list as $list_type => $attribute_list_by_type) { |
| 3124 | 3124 | $sub_attribute_list = ''; |
| 3125 | 3125 | foreach ($attribute_list_by_type as $attribute_code => $attribute_def) { |
| 3126 | 3126 | $tpl_component = array(); |
| 3127 | - if ( $list_type == 'available' ) { |
|
| 3127 | + if ($list_type == 'available') { |
|
| 3128 | 3128 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; |
| 3129 | 3129 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ''; |
| 3130 | 3130 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
@@ -3138,13 +3138,13 @@ discard block |
||
| 3138 | 3138 | $tpl_component['ADMIN_ATTRIBUTE_CODE_FOR_VARIATION'] = $attribute_code; |
| 3139 | 3139 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code; |
| 3140 | 3140 | $tpl_component['ADMIN_VARIATION_ATTRIBUTE_CONTAINER_CLASS'] = ' wpshop_attribute_for_variation_' . $attribute_code; |
| 3141 | - $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __( $attribute_def['label'], 'wpshop' ); |
|
| 3141 | + $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __($attribute_def['label'], 'wpshop'); |
|
| 3142 | 3142 | $tpl_component['ADMIN_VARIATION_NEW_SINGLE_INPUT'] = ''; |
| 3143 | - if ( $variation_type == 'single' ) { |
|
| 3144 | - $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') ); |
|
| 3145 | - if ( !empty($attribute_output_def['possible_value']) ) { |
|
| 3146 | - foreach( $attribute_output_def['possible_value'] as $value_id => $value ){ |
|
| 3147 | - if ( !in_array($value_id, $attribute_def['values']) ) { |
|
| 3143 | + if ($variation_type == 'single') { |
|
| 3144 | + $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')); |
|
| 3145 | + if (!empty($attribute_output_def['possible_value'])) { |
|
| 3146 | + foreach ($attribute_output_def['possible_value'] as $value_id => $value) { |
|
| 3147 | + if (!in_array($value_id, $attribute_def['values'])) { |
|
| 3148 | 3148 | unset($attribute_output_def['possible_value'][$value_id]); |
| 3149 | 3149 | } |
| 3150 | 3150 | } |
@@ -3159,7 +3159,7 @@ discard block |
||
| 3159 | 3159 | } |
| 3160 | 3160 | } |
| 3161 | 3161 | |
| 3162 | - return array($attribute_defined_as_available_for_variation, ( (!empty($attribute_list['available']) ) ? $attribute_list['available'] : ''), ( ( !empty($attribute_list['unavailable']) ) ? $attribute_list['unavailable'] : '')); |
|
| 3162 | + return array($attribute_defined_as_available_for_variation, ((!empty($attribute_list['available'])) ? $attribute_list['available'] : ''), ((!empty($attribute_list['unavailable'])) ? $attribute_list['unavailable'] : '')); |
|
| 3163 | 3163 | } |
| 3164 | 3164 | |
| 3165 | 3165 | /** |
@@ -3168,18 +3168,18 @@ discard block |
||
| 3168 | 3168 | * @param array $variations_attribute_parameters Allows to give some parameters for customize list |
| 3169 | 3169 | * @return string The output for all specific attribute in each product with option |
| 3170 | 3170 | */ |
| 3171 | - public static function get_variation_attribute( $variations_attribute_parameters ) { |
|
| 3171 | + public static function get_variation_attribute($variations_attribute_parameters) { |
|
| 3172 | 3172 | $output = ''; |
| 3173 | 3173 | |
| 3174 | 3174 | $attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_in_variation", true); |
| 3175 | - if ( !empty( $attribute_list ) ) { |
|
| 3175 | + if (!empty($attribute_list)) { |
|
| 3176 | 3176 | $tpl_component = array(); |
| 3177 | 3177 | $tpl_component['ADMIN_VARIATION_DETAIL'] = ''; |
| 3178 | 3178 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
| 3179 | - foreach ( $attribute_list as $attribute_def ) { |
|
| 3179 | + foreach ($attribute_list as $attribute_def) { |
|
| 3180 | 3180 | |
| 3181 | 3181 | $variations_attribute_parameters['field_custom_name_prefix'] = $variations_attribute_parameters['field_name'] . '[attribute][' . $attribute_def->data_type . ']'; |
| 3182 | - $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 ); |
|
| 3182 | + $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); |
|
| 3183 | 3183 | |
| 3184 | 3184 | $field_output = $attribute_output_def['output']; |
| 3185 | 3185 | |
@@ -3191,9 +3191,9 @@ discard block |
||
| 3191 | 3191 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_ID'] = $attribute_output_def['id']; |
| 3192 | 3192 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_LABEL'] = $attribute_output_def['label']; |
| 3193 | 3193 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] = $field_output; |
| 3194 | - if( isset( $variations_attribute_parameters['post_id'] ) ) { |
|
| 3195 | - $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'; |
|
| 3196 | - $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>'; |
|
| 3194 | + if (isset($variations_attribute_parameters['post_id'])) { |
|
| 3195 | + $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'; |
|
| 3196 | + $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>'; |
|
| 3197 | 3197 | } |
| 3198 | 3198 | $tpl_component['ADMIN_VARIATION_DETAIL'] .= wpshop_display::display_template_element('wpshop_admin_variation_item_details_line', $sub_tpl_component, array(), 'admin'); |
| 3199 | 3199 | unset($sub_tpl_component); |
@@ -3204,7 +3204,7 @@ discard block |
||
| 3204 | 3204 | return $output; |
| 3205 | 3205 | } |
| 3206 | 3206 | |
| 3207 | - public static function get_attribute_user_defined( $use_defined_parameters, $status = "'publish'" ) { |
|
| 3207 | + public static function get_attribute_user_defined($use_defined_parameters, $status = "'publish'") { |
|
| 3208 | 3208 | global $wpdb; |
| 3209 | 3209 | $attribute_user_defined_list = array(); |
| 3210 | 3210 | |
@@ -3231,12 +3231,12 @@ discard block |
||
| 3231 | 3231 | * @param string $post_type The current |
| 3232 | 3232 | * |
| 3233 | 3233 | */ |
| 3234 | - function quick_edit( $column_name, $entity ) { |
|
| 3235 | - switch ( $entity ) { |
|
| 3234 | + function quick_edit($column_name, $entity) { |
|
| 3235 | + switch ($entity) { |
|
| 3236 | 3236 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3237 | 3237 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3238 | - if ( !empty($attribute_def) ) { |
|
| 3239 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3238 | + if (!empty($attribute_def)) { |
|
| 3239 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3240 | 3240 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3241 | 3241 | ?> |
| 3242 | 3242 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -3256,12 +3256,12 @@ discard block |
||
| 3256 | 3256 | * @param string $post_type The current |
| 3257 | 3257 | * |
| 3258 | 3258 | */ |
| 3259 | - public static function bulk_edit( $column_name, $entity ) { |
|
| 3260 | - switch ( $entity ) { |
|
| 3259 | + public static function bulk_edit($column_name, $entity) { |
|
| 3260 | + switch ($entity) { |
|
| 3261 | 3261 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3262 | 3262 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3263 | - if ( !empty($attribute_def) ) { |
|
| 3264 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3263 | + if (!empty($attribute_def)) { |
|
| 3264 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3265 | 3265 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3266 | 3266 | ?> |
| 3267 | 3267 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -38,6 +38,10 @@ discard block |
||
| 38 | 38 | return $url; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $param |
|
| 43 | + * @param string $value |
|
| 44 | + */ |
|
| 41 | 45 | public static function construct_url_parameters($url, $param, $value) { |
| 42 | 46 | $interoguation_marker_pos = strpos($url, '?'); |
| 43 | 47 | if($interoguation_marker_pos===false) |
@@ -86,7 +90,7 @@ discard block |
||
| 86 | 90 | * Display the list of payment methods available |
| 87 | 91 | * |
| 88 | 92 | * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later |
| 89 | - * @return string The different payment method |
|
| 93 | + * @return string[] The different payment method |
|
| 90 | 94 | */ |
| 91 | 95 | function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
| 92 | 96 | $output = ''; |
@@ -250,6 +254,9 @@ discard block |
||
| 250 | 254 | } |
| 251 | 255 | |
| 252 | 256 | |
| 257 | + /** |
|
| 258 | + * @param string|null $payment_status |
|
| 259 | + */ |
|
| 253 | 260 | function setOrderPaymentStatus( $order_id, $payment_status ) { |
| 254 | 261 | /** Get order main information */ |
| 255 | 262 | $order = get_post_meta($order_id, '_order_postmeta', true); |
@@ -377,7 +384,7 @@ discard block |
||
| 377 | 384 | * Allows to inform customer that he would pay a partial amount on this order |
| 378 | 385 | * |
| 379 | 386 | * @param float $current_order_total The current order total to pay before partial amount calcul |
| 380 | - * @return array The amount to pay / A html output with amount to pay and different information |
|
| 387 | + * @return string The amount to pay / A html output with amount to pay and different information |
|
| 381 | 388 | */ |
| 382 | 389 | function partial_payment_calcul( $current_order_total, $for = 'for_all' ) { |
| 383 | 390 | $output = ''; |
@@ -482,6 +489,7 @@ discard block |
||
| 482 | 489 | * @param array $order_meta The complete order meta informations |
| 483 | 490 | * @param integer $payment_index The payment to add/update data for |
| 484 | 491 | * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount') |
| 492 | + * @param integer $order_id |
|
| 485 | 493 | * @return array The order new meta informations |
| 486 | 494 | */ |
| 487 | 495 | public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) { |
@@ -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,29 +20,29 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $wpshop_paypal = new wpshop_paypal(); |
| 22 | 22 | // If the CIC payment method is active |
| 23 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 24 | - if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) { |
|
| 23 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 24 | + if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) { |
|
| 25 | 25 | $wpshop_cic = new wpshop_CIC(); |
| 26 | 26 | } |
| 27 | - wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse'); |
|
| 27 | + wpshop_tools::create_custom_hook('wpshop_bankserver_reponse'); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public static function get_success_payment_url() { |
| 32 | - $url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) ); |
|
| 32 | + $url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id'))); |
|
| 33 | 33 | return self::construct_url_parameters($url, 'paymentResult', 'success'); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public static function get_cancel_payment_url() { |
| 37 | - $url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) ); |
|
| 37 | + $url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id'))); |
|
| 38 | 38 | return $url; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public static function construct_url_parameters($url, $param, $value) { |
| 42 | 42 | $interoguation_marker_pos = strpos($url, '?'); |
| 43 | - if($interoguation_marker_pos===false) |
|
| 44 | - return $url.'?'.$param.'='.$value; |
|
| 45 | - else return $url.'&'.$param.'='.$value; |
|
| 43 | + if ($interoguation_marker_pos === false) |
|
| 44 | + return $url . '?' . $param . '=' . $value; |
|
| 45 | + else return $url . '&' . $param . '=' . $value; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -51,23 +51,23 @@ discard block |
||
| 51 | 51 | public static function wpshop_payment_result() { |
| 52 | 52 | global $wpdb; |
| 53 | 53 | $user_ID = get_current_user_id(); |
| 54 | - $query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID); |
|
| 55 | - $order_post_id = $wpdb->get_var( $query ); |
|
| 56 | - if ( !empty($order_post_id) ) { |
|
| 57 | - $order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true); |
|
| 58 | - if ( !empty($order_postmeta) ) { |
|
| 59 | - switch ( $order_postmeta ) { |
|
| 54 | + $query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID); |
|
| 55 | + $order_post_id = $wpdb->get_var($query); |
|
| 56 | + if (!empty($order_post_id)) { |
|
| 57 | + $order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true); |
|
| 58 | + if (!empty($order_postmeta)) { |
|
| 59 | + switch ($order_postmeta) { |
|
| 60 | 60 | case 'awaiting_payment': |
| 61 | - echo __('We wait your payment.','wpshop'); |
|
| 61 | + echo __('We wait your payment.', 'wpshop'); |
|
| 62 | 62 | break; |
| 63 | 63 | case 'completed': |
| 64 | - echo __('Thank you ! Your payment has been recorded.','wpshop'); |
|
| 64 | + echo __('Thank you ! Your payment has been recorded.', 'wpshop'); |
|
| 65 | 65 | break; |
| 66 | 66 | case 'partially_paid': |
| 67 | - echo __('Thank you ! Your first payment has been recorded.','wpshop'); |
|
| 67 | + echo __('Thank you ! Your first payment has been recorded.', 'wpshop'); |
|
| 68 | 68 | break; |
| 69 | 69 | default: |
| 70 | - echo __('Your payment and your order has been cancelled.','wpshop'); |
|
| 70 | + echo __('Your payment and your order has been cancelled.', 'wpshop'); |
|
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -88,56 +88,56 @@ discard block |
||
| 88 | 88 | * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later |
| 89 | 89 | * @return string The different payment method |
| 90 | 90 | */ |
| 91 | - function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
|
| 91 | + function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') { |
|
| 92 | 92 | $output = ''; |
| 93 | 93 | /** Get available payment method */ |
| 94 | 94 | $paymentMethod = get_option('wpshop_paymentMethod', array()); |
| 95 | 95 | |
| 96 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 97 | - $output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />'; |
|
| 96 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 97 | + $output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ($cart_type == 'cart') { |
| 101 | 101 | $payment_methods = array(); |
| 102 | - if(!empty($paymentMethod['paypal'])) { |
|
| 102 | + if (!empty($paymentMethod['paypal'])) { |
|
| 103 | 103 | $payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'), |
| 104 | 104 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png', |
| 105 | - 'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop') |
|
| 105 | + 'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop') |
|
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | - if(!empty($paymentMethod['checks'])) { |
|
| 108 | + if (!empty($paymentMethod['checks'])) { |
|
| 109 | 109 | $payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'), |
| 110 | 110 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png', |
| 111 | - 'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop') |
|
| 111 | + 'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop') |
|
| 112 | 112 | ); |
| 113 | 113 | } |
| 114 | - if(!empty($paymentMethod['banktransfer'])) { |
|
| 114 | + if (!empty($paymentMethod['banktransfer'])) { |
|
| 115 | 115 | $payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'), |
| 116 | 116 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png', |
| 117 | - 'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop') |
|
| 117 | + 'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop') |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | - if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) { |
|
| 120 | + if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) { |
|
| 121 | 121 | $payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'), |
| 122 | 122 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg', |
| 123 | - 'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop') |
|
| 123 | + 'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop') |
|
| 124 | 124 | ); |
| 125 | 125 | } |
| 126 | 126 | $payment_methods = apply_filters('wpshop_payment_method', $payment_methods); |
| 127 | 127 | |
| 128 | 128 | $payment_method_table = array(); |
| 129 | 129 | |
| 130 | - if ( !empty( $paymentMethod['display_position'] ) ) { |
|
| 130 | + if (!empty($paymentMethod['display_position'])) { |
|
| 131 | 131 | $position_determinated = false; |
| 132 | - foreach ( $paymentMethod['display_position'] as $key => $position) { |
|
| 133 | - if ( $position != null) { |
|
| 132 | + foreach ($paymentMethod['display_position'] as $key => $position) { |
|
| 133 | + if ($position != null) { |
|
| 134 | 134 | $position_determinated = true; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - if ( $position_determinated ) { |
|
| 138 | - for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) { |
|
| 139 | - foreach ( $paymentMethod['display_position'] as $key => $position ) { |
|
| 140 | - if ( $position == $i && !empty($paymentMethod[$key])) { |
|
| 137 | + if ($position_determinated) { |
|
| 138 | + for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) { |
|
| 139 | + foreach ($paymentMethod['display_position'] as $key => $position) { |
|
| 140 | + if ($position == $i && !empty($paymentMethod[$key])) { |
|
| 141 | 141 | if ($key == 'checks') { |
| 142 | 142 | $key = 'check'; |
| 143 | 143 | } |
@@ -148,16 +148,16 @@ discard block |
||
| 148 | 148 | $payment_methods = $payment_method_table; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | - if (!empty($payment_methods) ) { |
|
| 151 | + if (!empty($payment_methods)) { |
|
| 152 | 152 | |
| 153 | - foreach( $payment_methods as $payment_method_identifier => $payment_method_def ) { |
|
| 153 | + foreach ($payment_methods as $payment_method_identifier => $payment_method_def) { |
|
| 154 | 154 | $tpl_component = array(); |
| 155 | 155 | $checked = $active = ''; |
| 156 | 156 | $payment_identifier_for_test = $payment_method_identifier; |
| 157 | 157 | if ($payment_method_identifier == 'check') { |
| 158 | 158 | $payment_identifier_for_test = 'checks'; |
| 159 | 159 | } |
| 160 | - if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) { |
|
| 160 | + if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) { |
|
| 161 | 161 | $checked = ' checked="checked"'; |
| 162 | 162 | $active = ' active'; |
| 163 | 163 | |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active; |
| 166 | 166 | $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked; |
| 167 | 167 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier; |
| 168 | - if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) { |
|
| 169 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : ''; |
|
| 168 | + if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) { |
|
| 169 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : ''; |
|
| 170 | 170 | } |
| 171 | 171 | else { |
| 172 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : ''; |
|
| 172 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : ''; |
|
| 173 | 173 | } |
| 174 | 174 | //$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon']; |
| 175 | 175 | $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name']; |
@@ -180,32 +180,32 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - return array( $output, $paymentMethod['mode'] ); |
|
| 183 | + return array($output, $paymentMethod['mode']); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
| 187 | - public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
|
| 188 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
| 187 | + public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') { |
|
| 188 | + $payment_option = get_option('wps_payment_mode'); |
|
| 189 | 189 | $output = ''; |
| 190 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 191 | - $output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />'; |
|
| 190 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 191 | + $output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />'; |
|
| 192 | 192 | } |
| 193 | - if( $cart_type == 'cart' ) { |
|
| 194 | - if ( !empty($payment_option) && !empty($payment_option['mode']) ) { |
|
| 195 | - foreach( $payment_option['mode'] as $payment_id => $payment_config ) { |
|
| 196 | - if( !empty($payment_config['active']) ) { |
|
| 197 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : ''); |
|
| 198 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : ''); |
|
| 193 | + if ($cart_type == 'cart') { |
|
| 194 | + if (!empty($payment_option) && !empty($payment_option['mode'])) { |
|
| 195 | + foreach ($payment_option['mode'] as $payment_id => $payment_config) { |
|
| 196 | + if (!empty($payment_config['active'])) { |
|
| 197 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : ''); |
|
| 198 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : ''); |
|
| 199 | 199 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id; |
| 200 | 200 | |
| 201 | - if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) { |
|
| 202 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : ''; |
|
| 201 | + if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) { |
|
| 202 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : ''; |
|
| 203 | 203 | } |
| 204 | 204 | else { |
| 205 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : ''; |
|
| 205 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : ''; |
|
| 206 | 206 | } |
| 207 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : ''; |
|
| 208 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : ''; |
|
| 207 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : ''; |
|
| 208 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : ''; |
|
| 209 | 209 | $output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id)); |
| 210 | 210 | unset($tpl_component); |
| 211 | 211 | } |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $wps_message = new wps_message_ctr(); |
| 229 | 229 | |
| 230 | - if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) { |
|
| 231 | - $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' ); |
|
| 232 | - $first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' ); |
|
| 233 | - $last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' ); |
|
| 230 | + if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) { |
|
| 231 | + $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : ''); |
|
| 232 | + $first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
|
| 233 | + $last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 234 | 234 | |
| 235 | 235 | // Envoie du message de confirmation de paiement au client |
| 236 | - switch($order['payment_method']) { |
|
| 236 | + switch ($order['payment_method']) { |
|
| 237 | 237 | case 'check': |
| 238 | 238 | $wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date'])); |
| 239 | 239 | break; |
@@ -250,24 +250,24 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| 253 | - function setOrderPaymentStatus( $order_id, $payment_status ) { |
|
| 253 | + function setOrderPaymentStatus($order_id, $payment_status) { |
|
| 254 | 254 | /** Get order main information */ |
| 255 | 255 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 256 | 256 | $send_email = false; |
| 257 | 257 | |
| 258 | - if ( !empty($order) ) { |
|
| 258 | + if (!empty($order)) { |
|
| 259 | 259 | /** Change order status to given status */ |
| 260 | 260 | $order['order_status'] = strtolower($payment_status); |
| 261 | 261 | /** Put order status into a single meta, allowing to use it easily later */ |
| 262 | 262 | update_post_meta($order_id, '_wpshop_order_status', $order['order_status']); |
| 263 | 263 | |
| 264 | 264 | /** In case the set status is completed, make specific treatment: add the completed date */ |
| 265 | - if ( $payment_status == 'completed' ) { |
|
| 265 | + if ($payment_status == 'completed') { |
|
| 266 | 266 | /** Read order items list, if not empty and check if each item is set to manage stock or not */ |
| 267 | 267 | if (!empty($order['order_items'])) { |
| 268 | 268 | foreach ($order['order_items'] as $o) { |
| 269 | - $product = wpshop_products::get_product_data( $o['item_id'] ); |
|
| 270 | - if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) { |
|
| 269 | + $product = wpshop_products::get_product_data($o['item_id']); |
|
| 270 | + if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) { |
|
| 271 | 271 | wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** Send email to customer when specific case need it */ |
| 284 | - if ( $send_email ) { |
|
| 284 | + if ($send_email) { |
|
| 285 | 285 | /** Get information about customer that make the order */ |
| 286 | 286 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 287 | 287 | $mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']); |
@@ -295,25 +295,25 @@ discard block |
||
| 295 | 295 | /** |
| 296 | 296 | * Get payment method |
| 297 | 297 | */ |
| 298 | - function get_payment_method($post_id){ |
|
| 299 | - $pm = __('Nc','wpshop'); |
|
| 298 | + function get_payment_method($post_id) { |
|
| 299 | + $pm = __('Nc', 'wpshop'); |
|
| 300 | 300 | $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
| 301 | - if ( !empty($order_postmeta['payment_method']) ) { |
|
| 302 | - switch($order_postmeta['payment_method']){ |
|
| 301 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 302 | + switch ($order_postmeta['payment_method']) { |
|
| 303 | 303 | case 'check': |
| 304 | - $pm = __('Check','wpshop'); |
|
| 304 | + $pm = __('Check', 'wpshop'); |
|
| 305 | 305 | break; |
| 306 | 306 | case 'paypal': |
| 307 | - $pm = __('Paypal','wpshop'); |
|
| 307 | + $pm = __('Paypal', 'wpshop'); |
|
| 308 | 308 | break; |
| 309 | 309 | case 'banktransfer': |
| 310 | - $pm = __('Bank transfer','wpshop'); |
|
| 310 | + $pm = __('Bank transfer', 'wpshop'); |
|
| 311 | 311 | break; |
| 312 | 312 | case 'cic': |
| 313 | - $pm = __('Credit card','wpshop'); |
|
| 313 | + $pm = __('Credit card', 'wpshop'); |
|
| 314 | 314 | break; |
| 315 | 315 | default: |
| 316 | - $pm = __('Nc','wpshop'); |
|
| 316 | + $pm = __('Nc', 'wpshop'); |
|
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -333,38 +333,38 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $paymentMethod = $paymentMethod['mode']; |
| 335 | 335 | $payment_validation .= ' |
| 336 | -<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" > |
|
| 337 | - <input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/> |
|
| 338 | - <input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>'; |
|
| 336 | +<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" > |
|
| 337 | + <input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/> |
|
| 338 | + <input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>'; |
|
| 339 | 339 | |
| 340 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 340 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 341 | 341 | $payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>'; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) { |
|
| 344 | + if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) { |
|
| 345 | 345 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>'; |
| 346 | 346 | $display_button = true; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) { |
|
| 349 | + if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) { |
|
| 350 | 350 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>'; |
| 351 | 351 | $display_button = true; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 355 | - if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) { |
|
| 354 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 355 | + if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) { |
|
| 356 | 356 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>'; |
| 357 | 357 | $display_button = true; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if(empty($payment_transaction)){ |
|
| 361 | - $payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . ' : <input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />'; |
|
| 360 | + if (empty($payment_transaction)) { |
|
| 361 | + $payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . ' : <input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />'; |
|
| 362 | 362 | $display_button = true; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if($display_button){ |
|
| 365 | + if ($display_button) { |
|
| 366 | 366 | $payment_validation .= ' |
| 367 | - <br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>'; |
|
| 367 | + <br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>'; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $payment_validation .= ' |
@@ -379,21 +379,21 @@ discard block |
||
| 379 | 379 | * @param float $current_order_total The current order total to pay before partial amount calcul |
| 380 | 380 | * @return array The amount to pay / A html output with amount to pay and different information |
| 381 | 381 | */ |
| 382 | - function partial_payment_calcul( $current_order_total, $for = 'for_all' ) { |
|
| 382 | + function partial_payment_calcul($current_order_total, $for = 'for_all') { |
|
| 383 | 383 | $output = ''; |
| 384 | 384 | $tpl_component = array(); |
| 385 | 385 | |
| 386 | 386 | /** Get current configuration */ |
| 387 | 387 | $partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array())); |
| 388 | - if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) { |
|
| 388 | + if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) { |
|
| 389 | 389 | $amount_of_partial_payment = 0; |
| 390 | - if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) { |
|
| 390 | + if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) { |
|
| 391 | 391 | $amount_of_partial_payment = $partial_payment_configuration[$for]['value']; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | $partial_amount_to_pay = 0; |
| 395 | 395 | $type_of_partial_payment = null; |
| 396 | - if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) { |
|
| 396 | + if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) { |
|
| 397 | 397 | switch ($partial_payment_configuration[$for]['type']) { |
| 398 | 398 | case 'percentage': |
| 399 | 399 | $type_of_partial_payment = '%'; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | function set_payment_transaction_number($order_id, $transaction_number) { |
| 454 | 454 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 455 | 455 | |
| 456 | - if ( !empty($order_postmeta['order_payment']['received']) ) { |
|
| 456 | + if (!empty($order_postmeta['order_payment']['received'])) { |
|
| 457 | 457 | if (count($order_postmeta['order_payment']['received']) == 1) { |
| 458 | 458 | $order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number; |
| 459 | 459 | } |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | * |
| 468 | 468 | * @param integer $order_id |
| 469 | 469 | */ |
| 470 | - function save_payment_return_data( $order_id ) { |
|
| 470 | + function save_payment_return_data($order_id) { |
|
| 471 | 471 | $data = wpshop_tools::getMethode(); |
| 472 | 472 | |
| 473 | - $current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true); |
|
| 473 | + $current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true); |
|
| 474 | 474 | $current_payment_return[] = $data; |
| 475 | 475 | |
| 476 | 476 | update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return); |
@@ -484,23 +484,23 @@ discard block |
||
| 484 | 484 | * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount') |
| 485 | 485 | * @return array The order new meta informations |
| 486 | 486 | */ |
| 487 | - public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) { |
|
| 488 | - |
|
| 489 | - $order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null; |
|
| 490 | - $order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null; |
|
| 491 | - $order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null; |
|
| 492 | - $order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id(); |
|
| 493 | - $order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null; |
|
| 494 | - $order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null; |
|
| 495 | - $order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null; |
|
| 487 | + public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) { |
|
| 488 | + |
|
| 489 | + $order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null; |
|
| 490 | + $order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null; |
|
| 491 | + $order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null; |
|
| 492 | + $order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id(); |
|
| 493 | + $order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null; |
|
| 494 | + $order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null; |
|
| 495 | + $order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null; |
|
| 496 | 496 | $order_meta['order_payment']['received'][$payment_index]['comment'] = ''; |
| 497 | 497 | |
| 498 | 498 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 499 | - if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) { |
|
| 499 | + if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) { |
|
| 500 | 500 | |
| 501 | 501 | /** Generate an invoice number for the current payment. Check if the payment is complete or not */ |
| 502 | - if ( empty($order_meta['order_invoice_ref']) ) { |
|
| 503 | - $order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 502 | + if (empty($order_meta['order_invoice_ref'])) { |
|
| 503 | + $order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | * @param string $payment_method |
| 514 | 514 | * @return integer $key : array id of [order_payment][received] in the order postmeta |
| 515 | 515 | */ |
| 516 | - public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) { |
|
| 516 | + public static function get_order_waiting_payment_array_id($oid, $payment_method) { |
|
| 517 | 517 | $key = 0; |
| 518 | - $order_meta = get_post_meta( $oid, '_order_postmeta', true); |
|
| 519 | - if ( !empty($order_meta) ) { |
|
| 520 | - $key = count( $order_meta['order_payment']['received'] ); |
|
| 521 | - foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) { |
|
| 522 | - if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) { |
|
| 518 | + $order_meta = get_post_meta($oid, '_order_postmeta', true); |
|
| 519 | + if (!empty($order_meta)) { |
|
| 520 | + $key = count($order_meta['order_payment']['received']); |
|
| 521 | + foreach ($order_meta['order_payment']['received'] as $k => $payment_test) { |
|
| 522 | + if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) { |
|
| 523 | 523 | $key = $k; |
| 524 | 524 | } |
| 525 | 525 | } |
@@ -534,52 +534,52 @@ discard block |
||
| 534 | 534 | * @param array $params_array |
| 535 | 535 | * @return string |
| 536 | 536 | */ |
| 537 | - public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) { |
|
| 537 | + public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) { |
|
| 538 | 538 | global $wpshop_payment; global $wpdb; |
| 539 | - $order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true); |
|
| 539 | + $order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true); |
|
| 540 | 540 | |
| 541 | 541 | $wps_message = new wps_message_ctr(); |
| 542 | - if ( !empty($order_meta) ) { |
|
| 542 | + if (!empty($order_meta)) { |
|
| 543 | 543 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 544 | - $user_data = get_userdata( $order_meta['customer_id'] ); |
|
| 545 | - $email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : ''; |
|
| 544 | + $user_data = get_userdata($order_meta['customer_id']); |
|
| 545 | + $email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : ''; |
|
| 546 | 546 | // $email = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ; |
| 547 | - $first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' ); |
|
| 548 | - $last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' ); |
|
| 547 | + $first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
|
| 548 | + $last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 549 | 549 | |
| 550 | - $key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']); |
|
| 550 | + $key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']); |
|
| 551 | 551 | $order_grand_total = $order_meta['order_grand_total']; |
| 552 | - $total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 ); |
|
| 553 | - foreach ( $order_meta['order_payment']['received'] as $received ) { |
|
| 554 | - $total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 ); |
|
| 552 | + $total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0); |
|
| 553 | + foreach ($order_meta['order_payment']['received'] as $received) { |
|
| 554 | + $total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0); |
|
| 555 | 555 | } |
| 556 | 556 | $order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received; |
| 557 | - $order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response ); |
|
| 557 | + $order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response); |
|
| 558 | 558 | |
| 559 | 559 | if ($bank_response == 'completed') { |
| 560 | 560 | |
| 561 | - if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) { |
|
| 561 | + if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) { |
|
| 562 | 562 | $payment_status = 'completed'; |
| 563 | 563 | |
| 564 | - $order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : ( empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref'] ) ; |
|
| 564 | + $order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : (empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref']); |
|
| 565 | 565 | $order_meta['order_invoice_date'] = current_time('mysql', 0); |
| 566 | 566 | |
| 567 | 567 | if (!empty($order_meta['order_items'])) { |
| 568 | 568 | foreach ($order_meta['order_items'] as $item_id => $o) { |
| 569 | 569 | $pid = $o['item_id']; |
| 570 | - if (strpos($item_id,'__') !== false) { |
|
| 571 | - $product_data_id = explode( '__', $item_id ); |
|
| 572 | - $pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid; |
|
| 570 | + if (strpos($item_id, '__') !== false) { |
|
| 571 | + $product_data_id = explode('__', $item_id); |
|
| 572 | + $pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid; |
|
| 573 | 573 | } |
| 574 | - $product = wpshop_products::get_product_data( $pid ); |
|
| 575 | - if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 576 | - $parent_def = wpshop_products::get_parent_variation ( $pid ); |
|
| 574 | + $product = wpshop_products::get_product_data($pid); |
|
| 575 | + if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 576 | + $parent_def = wpshop_products::get_parent_variation($pid); |
|
| 577 | 577 | $parent_post = $parent_def['parent_post']; |
| 578 | - $product = wpshop_products::get_product_data( $parent_post->ID ); |
|
| 578 | + $product = wpshop_products::get_product_data($parent_post->ID); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) { |
|
| 582 | - wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid ); |
|
| 581 | + if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) { |
|
| 582 | + wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -588,40 +588,40 @@ discard block |
||
| 588 | 588 | update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0)); |
| 589 | 589 | |
| 590 | 590 | /** Check if the order content a downloadable product **/ |
| 591 | - if ( ! empty( $order_meta['order_items'] ) ) { |
|
| 592 | - foreach ( $order_meta['order_items'] as $key_value => $item ) { |
|
| 593 | - $link = wps_download_file_ctr::get_product_download_link( $order_id, $item ); |
|
| 594 | - if ( empty( $link ) ) { |
|
| 591 | + if (!empty($order_meta['order_items'])) { |
|
| 592 | + foreach ($order_meta['order_items'] as $key_value => $item) { |
|
| 593 | + $link = wps_download_file_ctr::get_product_download_link($order_id, $item); |
|
| 594 | + if (empty($link)) { |
|
| 595 | 595 | wpeologs_ctr::log_datas_in_files( |
| 596 | 596 | get_class(), |
| 597 | 597 | array( |
| 598 | 598 | 'object_id' => $order_id, |
| 599 | 599 | 'message' => sprintf( |
| 600 | - __( 'Failure returned at order link generation. UserID : <b>%d</b>, ProductID : <b>%d</d>, UserMeta : <pre>%s</pre>', 'wpshop' ), |
|
| 601 | - (int) get_current_user_id(), |
|
| 602 | - (int) $item['item_id'], |
|
| 603 | - print_r( get_user_meta( get_current_user_id(), '_order_download_codes_' . $order_id, true ) ) |
|
| 600 | + __('Failure returned at order link generation. UserID : <b>%d</b>, ProductID : <b>%d</d>, UserMeta : <pre>%s</pre>', 'wpshop'), |
|
| 601 | + (int)get_current_user_id(), |
|
| 602 | + (int)$item['item_id'], |
|
| 603 | + print_r(get_user_meta(get_current_user_id(), '_order_download_codes_' . $order_id, true)) |
|
| 604 | 604 | ), |
| 605 | 605 | ), |
| 606 | 606 | 0 |
| 607 | 607 | ); |
| 608 | 608 | } else { |
| 609 | - $link = '<a href="' . esc_url( $link ) . '" target="_blank">' . __( 'Download the product', 'wpshop' ) . '</a>'; |
|
| 610 | - $wps_message->wpshop_prepared_email( $email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array( 'order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link ), array() ); |
|
| 609 | + $link = '<a href="' . esc_url($link) . '" target="_blank">' . __('Download the product', 'wpshop') . '</a>'; |
|
| 610 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array()); |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Send confirmation e-mail to administrator |
| 616 | - if ( empty($_SESSION['wps-pos-addon']) ) { |
|
| 616 | + if (empty($_SESSION['wps-pos-addon'])) { |
|
| 617 | 617 | $email_option = get_option('wpshop_emails'); |
| 618 | - if( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){ |
|
| 619 | - wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data ); |
|
| 618 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) { |
|
| 619 | + wpshop_checkout::send_order_email_to_administrator($order_id, $user_data); |
|
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | // POS Status |
| 624 | - if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) { |
|
| 624 | + if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') { |
|
| 625 | 625 | $payment_status = 'pos'; |
| 626 | 626 | } |
| 627 | 627 | } |
@@ -630,27 +630,27 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | $order_meta['order_status'] = $payment_status; |
| 633 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 633 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 634 | 634 | $save_metadata = false; |
| 635 | 635 | |
| 636 | - $allow_send_invoice = get_option( 'wpshop_send_invoice' ); |
|
| 637 | - $invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, empty( $order_meta['order_payment']['received'][$key]['invoice_ref'] ) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : ''; |
|
| 636 | + $allow_send_invoice = get_option('wpshop_send_invoice'); |
|
| 637 | + $invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref']) : ''; |
|
| 638 | 638 | |
| 639 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 639 | + $email_option = get_option('wpshop_emails'); |
|
| 640 | 640 | |
| 641 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 642 | - $shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' ); |
|
| 641 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 642 | + $shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : ''); |
|
| 643 | 643 | |
| 644 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 645 | - $order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]) ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 644 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 645 | + $order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 646 | 646 | |
| 647 | - if ( !empty( $email_option ) && !empty( $email_option['send_confirmation_order_message'] ) && $payment_status == 'completed' |
|
| 648 | - && ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) ) { |
|
| 649 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method ) ); |
|
| 647 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed' |
|
| 648 | + && (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email']))) { |
|
| 649 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method)); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) { |
|
| 653 | - $wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
|
| 652 | + if (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email'])) { |
|
| 653 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | else { |
@@ -658,13 +658,13 @@ discard block |
||
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | $order_meta['order_status'] = $payment_status; |
| 661 | - if( !$save_metadata ) { |
|
| 661 | + if (!$save_metadata) { |
|
| 662 | 662 | return $order_meta; |
| 663 | 663 | } |
| 664 | 664 | else { |
| 665 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 665 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 666 | 666 | } |
| 667 | - update_post_meta( $order_id, '_wpshop_order_status', $payment_status); |
|
| 667 | + update_post_meta($order_id, '_wpshop_order_status', $payment_status); |
|
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | * @param integer $order_id The order identifier we want to get the old transaction reference for |
| 677 | 677 | * @return integer |
| 678 | 678 | */ |
| 679 | - public static function get_payment_transaction_number_old_way($order_id){ |
|
| 679 | + public static function get_payment_transaction_number_old_way($order_id) { |
|
| 680 | 680 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 681 | 681 | $transaction_indentifier = 0; |
| 682 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 683 | - switch($order_postmeta['payment_method']){ |
|
| 682 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 683 | + switch ($order_postmeta['payment_method']) { |
|
| 684 | 684 | case 'check': |
| 685 | 685 | $transaction_indentifier = get_post_meta($order_id, '_order_check_number', true); |
| 686 | 686 | break; |
@@ -699,26 +699,26 @@ discard block |
||
| 699 | 699 | return $transaction_indentifier; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - public static function reverify_payment_invoice_ref( $order_id, $index_payment ) { |
|
| 702 | + public static function reverify_payment_invoice_ref($order_id, $index_payment) { |
|
| 703 | 703 | $status = false; |
| 704 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 705 | - if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) { |
|
| 704 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 705 | + if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) { |
|
| 706 | 706 | $order_invoice = $invoice_ref = false; |
| 707 | 707 | |
| 708 | - end( $order_meta['order_payment']['received'] ); |
|
| 709 | - $last_payment = key( $order_meta['order_payment']['received'] ); |
|
| 710 | - if( $last_payment == $index_payment ) { |
|
| 708 | + end($order_meta['order_payment']['received']); |
|
| 709 | + $last_payment = key($order_meta['order_payment']['received']); |
|
| 710 | + if ($last_payment == $index_payment) { |
|
| 711 | 711 | $payments = 0; |
| 712 | - foreach( $order_meta['order_payment']['received'] as $payment ) { |
|
| 713 | - $payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0; |
|
| 712 | + foreach ($order_meta['order_payment']['received'] as $payment) { |
|
| 713 | + $payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0; |
|
| 714 | 714 | } |
| 715 | - if( $order_meta['order_grand_total'] <= $payments ) { |
|
| 716 | - if( $order_meta['order_status'] == 'partially_paid' ) { |
|
| 717 | - $order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true ); |
|
| 715 | + if ($order_meta['order_grand_total'] <= $payments) { |
|
| 716 | + if ($order_meta['order_status'] == 'partially_paid') { |
|
| 717 | + $order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true); |
|
| 718 | 718 | $order_meta['order_status'] = 'completed'; |
| 719 | - $status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' ); |
|
| 719 | + $status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed'); |
|
| 720 | 720 | } |
| 721 | - if( !empty( $order_meta['order_invoice_ref'] ) ) { |
|
| 721 | + if (!empty($order_meta['order_invoice_ref'])) { |
|
| 722 | 722 | $invoice_ref = $order_meta['order_invoice_ref']; |
| 723 | 723 | $status = true; |
| 724 | 724 | } else { |
@@ -729,16 +729,16 @@ discard block |
||
| 729 | 729 | $status = true; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if( $status ) { |
|
| 733 | - if( empty( $invoice_ref ) ) { |
|
| 734 | - $invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 735 | - if( $order_invoice ) { |
|
| 732 | + if ($status) { |
|
| 733 | + if (empty($invoice_ref)) { |
|
| 734 | + $invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 735 | + if ($order_invoice) { |
|
| 736 | 736 | $order_meta['order_invoice_ref'] = $invoice_ref; |
| 737 | 737 | } |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref; |
| 741 | - $status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 741 | + $status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | return $status; |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 3 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
| 2 | +if (!class_exists('WP_List_Table')) { |
|
| 3 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
| 4 | 4 | } |
| 5 | -if ( ! class_exists( 'WP_Posts_List_Table' ) ) { |
|
| 6 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' ); |
|
| 5 | +if (!class_exists('WP_Posts_List_Table')) { |
|
| 6 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php'); |
|
| 7 | 7 | } |
| 8 | 8 | new mass_interface3(); |
| 9 | 9 | class mass_interface3 { |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | 'price_behaviour', |
| 26 | 26 | ); |
| 27 | 27 | public function __construct() { |
| 28 | - add_action( 'init', array( $this, 'mass_init' ) ); |
|
| 29 | - add_action( 'wp_ajax_wps_mass_3_new', array( $this, 'ajax_new' ) ); |
|
| 28 | + add_action('init', array($this, 'mass_init')); |
|
| 29 | + add_action('wp_ajax_wps_mass_3_new', array($this, 'ajax_new')); |
|
| 30 | 30 | } |
| 31 | 31 | public function mass_init() { |
| 32 | - $hook = add_submenu_page( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, __( 'Mass product edit 3', 'wpshop' ), __( 'Mass product edit 3', 'wpshop' ), 'manage_options', 'mass_edit_interface3', array( $this, 'mass_interface' ) ); |
|
| 33 | - add_action( "load-{$hook}", array( $this, 'mass_interface_screen_option' ) ); |
|
| 34 | - add_action( "admin_print_scripts-{$hook}", array( $this, 'ajax_scripts' ) ); |
|
| 32 | + $hook = add_submenu_page('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, __('Mass product edit 3', 'wpshop'), __('Mass product edit 3', 'wpshop'), 'manage_options', 'mass_edit_interface3', array($this, 'mass_interface')); |
|
| 33 | + add_action("load-{$hook}", array($this, 'mass_interface_screen_option')); |
|
| 34 | + add_action("admin_print_scripts-{$hook}", array($this, 'ajax_scripts')); |
|
| 35 | 35 | } |
| 36 | 36 | public function mass_interface() { |
| 37 | - $this->wp_list_table->prepare_items( $this->exclude_attribute_codes ); |
|
| 38 | - add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 ); |
|
| 37 | + $this->wp_list_table->prepare_items($this->exclude_attribute_codes); |
|
| 38 | + add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2); |
|
| 39 | 39 | $this->wp_list_table->screen->render_screen_meta(); |
| 40 | 40 | ?> |
| 41 | 41 | <div class="wrap"> |
| 42 | 42 | <h1 class="wp-heading-inline"><?php |
| 43 | - echo esc_html( $this->post_type_object->labels->name ); |
|
| 43 | + echo esc_html($this->post_type_object->labels->name); |
|
| 44 | 44 | ?></h1> |
| 45 | 45 | |
| 46 | 46 | <?php |
| 47 | - if ( current_user_can( $this->post_type_object->cap->create_posts ) ) { |
|
| 48 | - echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action" onclick="addPost(event, this)">' . esc_html( $this->post_type_object->labels->add_new ) . '</a>'; |
|
| 47 | + if (current_user_can($this->post_type_object->cap->create_posts)) { |
|
| 48 | + echo ' <a href="' . esc_url(admin_url($post_new_file)) . '" class="page-title-action" onclick="addPost(event, this)">' . esc_html($this->post_type_object->labels->add_new) . '</a>'; |
|
| 49 | 49 | } |
| 50 | 50 | ?> |
| 51 | 51 | <form id="posts-filter" method="get"> |
@@ -55,17 +55,17 @@ discard block |
||
| 55 | 55 | <tr id="inline-edit" class="inline-edit-row inline-edit-row-<?php echo "post inline-edit-{$this->post_type_object->name} quick-edit-row quick-edit-row-post inline-edit-{$this->post_type_object->name}"; ?>" style="display: none"> |
| 56 | 56 | <td colspan="<?php echo $this->wp_list_table->get_column_count(); ?>" class="colspanchange"> |
| 57 | 57 | <fieldset class="inline-edit-col"> |
| 58 | - <legend class="inline-edit-legend"><?php echo esc_html( $this->post_type_object->labels->add_new ) ?></legend> |
|
| 58 | + <legend class="inline-edit-legend"><?php echo esc_html($this->post_type_object->labels->add_new) ?></legend> |
|
| 59 | 59 | <div class="inline-edit-col"> |
| 60 | 60 | <label> |
| 61 | - <span class="title"><?php _e( 'Title' ); ?></span> |
|
| 61 | + <span class="title"><?php _e('Title'); ?></span> |
|
| 62 | 62 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 63 | 63 | </label> |
| 64 | 64 | </div> |
| 65 | 65 | </fieldset> |
| 66 | 66 | <p class="submit inline-edit-save"> |
| 67 | - <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button> |
|
| 68 | - <button type="button" class="button button-primary save alignright"><?php echo esc_html( $this->post_type_object->labels->add_new ); ?></button> |
|
| 67 | + <button type="button" class="button cancel alignleft"><?php _e('Cancel'); ?></button> |
|
| 68 | + <button type="button" class="button button-primary save alignright"><?php echo esc_html($this->post_type_object->labels->add_new); ?></button> |
|
| 69 | 69 | <span class="spinner"></span> |
| 70 | 70 | <span class="error" style="display:none"></span> |
| 71 | 71 | <br class="clear" /> |
@@ -79,53 +79,53 @@ discard block |
||
| 79 | 79 | <?php |
| 80 | 80 | } |
| 81 | 81 | public function mass_interface_screen_option() { |
| 82 | - $this->post_type_object = get_post_type_object( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 83 | - $this->wp_list_table = new WPS_Mass_List_Table( array( |
|
| 82 | + $this->post_type_object = get_post_type_object(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 83 | + $this->wp_list_table = new WPS_Mass_List_Table(array( |
|
| 84 | 84 | 'screen' => $this->post_type_object->name, |
| 85 | - ) ); |
|
| 85 | + )); |
|
| 86 | 86 | $this->wp_list_table->show_columns = $this->show_columns; |
| 87 | - $this->wp_list_table->screen->set_screen_reader_content( array( |
|
| 87 | + $this->wp_list_table->screen->set_screen_reader_content(array( |
|
| 88 | 88 | 'heading_views' => $this->post_type_object->labels->filter_items_list, |
| 89 | 89 | 'heading_pagination' => $this->post_type_object->labels->items_list_navigation, |
| 90 | 90 | 'heading_list' => $this->post_type_object->labels->items_list, |
| 91 | - ) ); |
|
| 92 | - $this->wp_list_table->screen->add_option( 'per_page', array( 'default' => 20, 'option' => "edit_{$this->post_type_object->name}_per_page" ) ); |
|
| 91 | + )); |
|
| 92 | + $this->wp_list_table->screen->add_option('per_page', array('default' => 20, 'option' => "edit_{$this->post_type_object->name}_per_page")); |
|
| 93 | 93 | } |
| 94 | - public function hidden_columns( $hidden, $screen ) { |
|
| 95 | - if( $screen == $this->wp_list_table->screen ) { |
|
| 96 | - $hidden = array_diff( array_flip( $this->wp_list_table->get_columns() ), $this->show_columns ); |
|
| 94 | + public function hidden_columns($hidden, $screen) { |
|
| 95 | + if ($screen == $this->wp_list_table->screen) { |
|
| 96 | + $hidden = array_diff(array_flip($this->wp_list_table->get_columns()), $this->show_columns); |
|
| 97 | 97 | } |
| 98 | 98 | return $hidden; |
| 99 | 99 | } |
| 100 | 100 | public function ajax_scripts() { |
| 101 | 101 | wp_enqueue_script( |
| 102 | - 'mass_interface3-ajax', plugin_dir_url( __FILE__ ).'interface3.js', |
|
| 103 | - array( 'jquery' ), |
|
| 102 | + 'mass_interface3-ajax', plugin_dir_url(__FILE__) . 'interface3.js', |
|
| 103 | + array('jquery'), |
|
| 104 | 104 | true |
| 105 | 105 | ); |
| 106 | 106 | } |
| 107 | 107 | public function ajax_new() { |
| 108 | - $new_product_id = wp_insert_post( array( |
|
| 108 | + $new_product_id = wp_insert_post(array( |
|
| 109 | 109 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
| 110 | 110 | 'post_status' => 'publish', |
| 111 | 111 | 'post_title' => $_POST['title'], |
| 112 | - ) ); |
|
| 113 | - if ( !empty( $new_product_id ) ) { |
|
| 114 | - $product_attribute_set_id = ( !empty( $_POST['attributes_set'] ) ) ? intval( $_POST['attributes_set'] ) : 1; |
|
| 115 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $product_attribute_set_id ); |
|
| 112 | + )); |
|
| 113 | + if (!empty($new_product_id)) { |
|
| 114 | + $product_attribute_set_id = (!empty($_POST['attributes_set'])) ? intval($_POST['attributes_set']) : 1; |
|
| 115 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $product_attribute_set_id); |
|
| 116 | 116 | } else { |
| 117 | - wp_die( 1 ); |
|
| 117 | + wp_die(1); |
|
| 118 | 118 | } |
| 119 | - $this->post_type_object = get_post_type_object( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 120 | - $this->wp_list_table = new WPS_Mass_List_Table( array( |
|
| 119 | + $this->post_type_object = get_post_type_object(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 120 | + $this->wp_list_table = new WPS_Mass_List_Table(array( |
|
| 121 | 121 | 'screen' => $this->post_type_object->name, |
| 122 | - ) ); |
|
| 122 | + )); |
|
| 123 | 123 | $this->wp_list_table->show_columns = $this->show_columns; |
| 124 | - $data = $this->wp_list_table->request( $this->exclude_attribute_codes, $new_product_id ); |
|
| 125 | - add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 ); |
|
| 124 | + $data = $this->wp_list_table->request($this->exclude_attribute_codes, $new_product_id); |
|
| 125 | + add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2); |
|
| 126 | 126 | ob_start(); |
| 127 | - $this->wp_list_table->single_row( $data[0] ); |
|
| 128 | - wp_send_json_success( array( 'row' => ob_get_clean() ) ); |
|
| 127 | + $this->wp_list_table->single_row($data[0]); |
|
| 128 | + wp_send_json_success(array('row' => ob_get_clean())); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | class WPS_Mass_List_Table extends WP_List_Table { |
@@ -133,64 +133,64 @@ discard block |
||
| 133 | 133 | public $columns_items = array(); |
| 134 | 134 | public $show_columns = array(); |
| 135 | 135 | public $screen; |
| 136 | - public function __construct( $args ) { |
|
| 137 | - parent::__construct( array( |
|
| 136 | + public function __construct($args) { |
|
| 137 | + parent::__construct(array( |
|
| 138 | 138 | 'plural' => 'posts', |
| 139 | 139 | 'ajax' => true, |
| 140 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
| 141 | - ) ); |
|
| 140 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
| 141 | + )); |
|
| 142 | 142 | } |
| 143 | 143 | public function get_columns() { |
| 144 | 144 | $columns = array( |
| 145 | 145 | 'cb' => '<input type="checkbox" />', |
| 146 | - 'title' => __( 'Title' ), |
|
| 146 | + 'title' => __('Title'), |
|
| 147 | 147 | ); |
| 148 | - foreach ( $this->columns_items as $column => $data_column ) { |
|
| 149 | - $columns[ $column ] = $data_column['name']; |
|
| 148 | + foreach ($this->columns_items as $column => $data_column) { |
|
| 149 | + $columns[$column] = $data_column['name']; |
|
| 150 | 150 | } |
| 151 | 151 | return $columns; |
| 152 | 152 | } |
| 153 | 153 | protected function get_sortable_columns() { |
| 154 | 154 | $sortable_columns = array( |
| 155 | - 'title' => array( 'title', false ), |
|
| 155 | + 'title' => array('title', false), |
|
| 156 | 156 | ); |
| 157 | - foreach ( $this->columns_items as $column => $data_column ) { |
|
| 158 | - $sortable_columns[ $column ] = array( $data_column['code'], false ); |
|
| 157 | + foreach ($this->columns_items as $column => $data_column) { |
|
| 158 | + $sortable_columns[$column] = array($data_column['code'], false); |
|
| 159 | 159 | } |
| 160 | 160 | return $sortable_columns; |
| 161 | 161 | } |
| 162 | - public function column_default( $item, $column_name ) { |
|
| 163 | - if ( isset( $this->columns_items[ $column_name ] ) && is_callable( array( $this, "column_data_{$this->columns_items[ $column_name ]['type']}" ) ) ) { |
|
| 164 | - return call_user_func( array( $this, "column_data_{$this->columns_items[ $column_name ]['type']}" ), |
|
| 165 | - $this->columns_items[ $column_name ]['id'], |
|
| 166 | - $this->columns_items[ $column_name ]['code'], |
|
| 162 | + public function column_default($item, $column_name) { |
|
| 163 | + if (isset($this->columns_items[$column_name]) && is_callable(array($this, "column_data_{$this->columns_items[$column_name]['type']}"))) { |
|
| 164 | + return call_user_func(array($this, "column_data_{$this->columns_items[$column_name]['type']}"), |
|
| 165 | + $this->columns_items[$column_name]['id'], |
|
| 166 | + $this->columns_items[$column_name]['code'], |
|
| 167 | 167 | $item |
| 168 | 168 | ); |
| 169 | 169 | } |
| 170 | - return print_r( $item[ $column_name ], true ); |
|
| 170 | + return print_r($item[$column_name], true); |
|
| 171 | 171 | } |
| 172 | - public function column_cb( $item ) { |
|
| 172 | + public function column_cb($item) { |
|
| 173 | 173 | return sprintf( |
| 174 | 174 | '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
| 175 | 175 | $this->_args['singular'], |
| 176 | 176 | $item['ID'] |
| 177 | 177 | ); |
| 178 | 178 | } |
| 179 | - public function column_title( $item ) { |
|
| 179 | + public function column_title($item) { |
|
| 180 | 180 | return sprintf( |
| 181 | 181 | '<a class="row-title" href="%s" aria-label="%s">%s</a>', |
| 182 | - get_edit_post_link( $item['ID'] ), |
|
| 183 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $item['title'] ) ), |
|
| 182 | + get_edit_post_link($item['ID']), |
|
| 183 | + esc_attr(sprintf(__('“%s” (Edit)'), $item['title'])), |
|
| 184 | 184 | $item['title'] |
| 185 | 185 | ); |
| 186 | 186 | } |
| 187 | - public function column_data_text( $attribute_id, $attribute_code, $item ) { |
|
| 187 | + public function column_data_text($attribute_id, $attribute_code, $item) { |
|
| 188 | 188 | $unit = ''; |
| 189 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
| 190 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 191 | - $value = $item[ $attribute_code ]['value']; |
|
| 189 | + if (is_array($item[$attribute_code])) { |
|
| 190 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 191 | + $value = $item[$attribute_code]['value']; |
|
| 192 | 192 | } else { |
| 193 | - $value = $item[ $attribute_code ]; |
|
| 193 | + $value = $item[$attribute_code]; |
|
| 194 | 194 | } |
| 195 | 195 | return sprintf( |
| 196 | 196 | '<input type="text" name="%1$s[%2$s]" value="%3$s">%4$s', |
@@ -200,35 +200,35 @@ discard block |
||
| 200 | 200 | $unit |
| 201 | 201 | ); |
| 202 | 202 | } |
| 203 | - public function column_data_select( $attribute_id, $attribute_code, $item ) { |
|
| 203 | + public function column_data_select($attribute_id, $attribute_code, $item) { |
|
| 204 | 204 | $unit = ''; |
| 205 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
| 206 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 207 | - $value = $item[ $attribute_code ]['value']; |
|
| 205 | + if (is_array($item[$attribute_code])) { |
|
| 206 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 207 | + $value = $item[$attribute_code]['value']; |
|
| 208 | 208 | } else { |
| 209 | - $value = $item[ $attribute_code ]; |
|
| 209 | + $value = $item[$attribute_code]; |
|
| 210 | 210 | } |
| 211 | 211 | $select_items = array(); |
| 212 | - foreach ( $this->get_select_items_option( $attribute_id ) as $item ) { |
|
| 213 | - $select_items[] = "<option value=\"{$item['id']}\"" . selected( $value, $item['id'], false ) . ">{$item['label']}</option>"; |
|
| 212 | + foreach ($this->get_select_items_option($attribute_id) as $item) { |
|
| 213 | + $select_items[] = "<option value=\"{$item['id']}\"" . selected($value, $item['id'], false) . ">{$item['label']}</option>"; |
|
| 214 | 214 | } |
| 215 | - $select_items = implode( '', $select_items ); |
|
| 215 | + $select_items = implode('', $select_items); |
|
| 216 | 216 | return "<select name='{$attribute_code}[{$item['ID']}]'>{$select_items}</select>{$unit}"; |
| 217 | 217 | } |
| 218 | - public function request( $exclude_attribute_codes, $id_post = null ) { |
|
| 218 | + public function request($exclude_attribute_codes, $id_post = null) { |
|
| 219 | 219 | global $wpdb; |
| 220 | - $per_page = $this->get_items_per_page( 'edit_' . $this->screen->post_type . '_per_page' ); |
|
| 221 | - $exclude_states = get_post_stati( array( |
|
| 220 | + $per_page = $this->get_items_per_page('edit_' . $this->screen->post_type . '_per_page'); |
|
| 221 | + $exclude_states = get_post_stati(array( |
|
| 222 | 222 | 'show_in_admin_all_list' => false, |
| 223 | - ) ); |
|
| 224 | - $exclude_states = implode( "','", $exclude_states ); |
|
| 225 | - $orderby = isset( $_REQUEST['orderby'] ) ? esc_sql( $_REQUEST['orderby'] ) : 'p.post_date'; |
|
| 226 | - $order = isset( $_REQUEST['order'] ) ? esc_sql( $_REQUEST['order'] ) : 'DESC'; |
|
| 227 | - $exclude_attribute_codes = implode( "','", $exclude_attribute_codes ); |
|
| 228 | - $entity_id = wpshop_entities::get_entity_identifier_from_code( $this->screen->post_type ); |
|
| 223 | + )); |
|
| 224 | + $exclude_states = implode("','", $exclude_states); |
|
| 225 | + $orderby = isset($_REQUEST['orderby']) ? esc_sql($_REQUEST['orderby']) : 'p.post_date'; |
|
| 226 | + $order = isset($_REQUEST['order']) ? esc_sql($_REQUEST['order']) : 'DESC'; |
|
| 227 | + $exclude_attribute_codes = implode("','", $exclude_attribute_codes); |
|
| 228 | + $entity_id = wpshop_entities::get_entity_identifier_from_code($this->screen->post_type); |
|
| 229 | 229 | $extra = ''; |
| 230 | - if( !is_null( $id_post ) ) { |
|
| 231 | - $id_post = intval( $id_post ); |
|
| 230 | + if (!is_null($id_post)) { |
|
| 231 | + $id_post = intval($id_post); |
|
| 232 | 232 | $extra = "AND p.ID = {$id_post}"; |
| 233 | 233 | } |
| 234 | 234 | $wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE; |
@@ -282,60 +282,60 @@ discard block |
||
| 282 | 282 | LIMIT %d, %d", |
| 283 | 283 | $entity_id, |
| 284 | 284 | $this->screen->post_type, |
| 285 | - ( $this->get_pagenum() -1 ) * $per_page, |
|
| 285 | + ($this->get_pagenum() - 1) * $per_page, |
|
| 286 | 286 | $per_page |
| 287 | 287 | ), |
| 288 | 288 | ARRAY_A |
| 289 | 289 | ); |
| 290 | - return array_map( array( $this, 'data_reorganize' ), $datas ); |
|
| 290 | + return array_map(array($this, 'data_reorganize'), $datas); |
|
| 291 | 291 | } |
| 292 | - public function prepare_items( $exclude_attribute_codes, $id_post = null ) { |
|
| 292 | + public function prepare_items($exclude_attribute_codes, $id_post = null) { |
|
| 293 | 293 | global $wpdb; |
| 294 | - $per_page = $this->get_items_per_page( 'edit_' . $this->screen->post_type . '_per_page' ); |
|
| 295 | - $this->items = $this->request( $exclude_attribute_codes ); |
|
| 296 | - $total_items = (int) $wpdb->get_var( 'SELECT FOUND_ROWS()' ); |
|
| 294 | + $per_page = $this->get_items_per_page('edit_' . $this->screen->post_type . '_per_page'); |
|
| 295 | + $this->items = $this->request($exclude_attribute_codes); |
|
| 296 | + $total_items = (int)$wpdb->get_var('SELECT FOUND_ROWS()'); |
|
| 297 | 297 | $columns = $this->get_columns(); |
| 298 | 298 | $sortable = $this->get_sortable_columns(); |
| 299 | - $this->_column_headers = array( $columns, array_diff( array_flip( $this->get_columns() ), $this->show_columns ), $sortable ); |
|
| 300 | - $this->set_pagination_args( array( |
|
| 299 | + $this->_column_headers = array($columns, array_diff(array_flip($this->get_columns()), $this->show_columns), $sortable); |
|
| 300 | + $this->set_pagination_args(array( |
|
| 301 | 301 | 'total_items' => $total_items, |
| 302 | 302 | 'per_page' => $per_page, |
| 303 | - 'total_pages' => ceil( $total_items / $per_page ), |
|
| 303 | + 'total_pages' => ceil($total_items / $per_page), |
|
| 304 | 304 | 'orderby' => $orderby, |
| 305 | 305 | 'order' => $order, |
| 306 | - ) ); |
|
| 306 | + )); |
|
| 307 | 307 | } |
| 308 | - public function data_reorganize( $item ) { |
|
| 309 | - $values = explode( ';', $item['data'] ); |
|
| 310 | - foreach ( $values as $value ) { |
|
| 311 | - $value = explode( ':', $value ); |
|
| 312 | - if ( ! isset( $this->columns_items[ $value[1] ] ) ) { |
|
| 313 | - $this->columns_items[ $value[1] ] = array( |
|
| 308 | + public function data_reorganize($item) { |
|
| 309 | + $values = explode(';', $item['data']); |
|
| 310 | + foreach ($values as $value) { |
|
| 311 | + $value = explode(':', $value); |
|
| 312 | + if (!isset($this->columns_items[$value[1]])) { |
|
| 313 | + $this->columns_items[$value[1]] = array( |
|
| 314 | 314 | 'id' => $value[0], |
| 315 | 315 | 'code' => $value[1], |
| 316 | 316 | 'name' => $value[2], |
| 317 | 317 | 'type' => $value[6], |
| 318 | 318 | ); |
| 319 | 319 | } |
| 320 | - if ( 'yes' === $value[4] ) { |
|
| 321 | - $item[ $value[1] ] = array( |
|
| 320 | + if ('yes' === $value[4]) { |
|
| 321 | + $item[$value[1]] = array( |
|
| 322 | 322 | 'value' => $value[3], |
| 323 | 323 | 'unit' => $value[5], |
| 324 | 324 | ); |
| 325 | 325 | } else { |
| 326 | - $item[ $value[1] ] = $value[3]; |
|
| 326 | + $item[$value[1]] = $value[3]; |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | - unset( $item['data'] ); |
|
| 329 | + unset($item['data']); |
|
| 330 | 330 | return $item; |
| 331 | 331 | } |
| 332 | - public function get_select_items_option( $attribute_id ) { |
|
| 333 | - if ( ! isset( self::$wpsdb_values_options[ $attribute_id ] ) ) { |
|
| 332 | + public function get_select_items_option($attribute_id) { |
|
| 333 | + if (!isset(self::$wpsdb_values_options[$attribute_id])) { |
|
| 334 | 334 | global $wpdb; |
| 335 | 335 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 336 | - self::$wpsdb_values_options[ $attribute_id ] = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpsdb_values_options} WHERE attribute_id = %d ORDER BY position", $attribute_id ), ARRAY_A ); |
|
| 336 | + self::$wpsdb_values_options[$attribute_id] = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpsdb_values_options} WHERE attribute_id = %d ORDER BY position", $attribute_id), ARRAY_A); |
|
| 337 | 337 | } |
| 338 | - return self::$wpsdb_values_options[ $attribute_id ]; |
|
| 338 | + return self::$wpsdb_values_options[$attribute_id]; |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | ?> |