Completed
Pull Request — master (#2)
by Jimmy
1247:15 queued 1211:43
created
includes/librairies/HTML2PDF/_class/tcpdfConfig.php 3 patches
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -34,212 +34,212 @@
 block discarded – undo
34 34
 
35 35
 if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
36 36
 
37
-    define('K_TCPDF_EXTERNAL_CONFIG', true);
38
-
39
-    // DOCUMENT_ROOT fix for IIS Webserver
40
-    if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
41
-        if (isset($_SERVER['SCRIPT_FILENAME'])) {
42
-            $_SERVER['DOCUMENT_ROOT'] = str_replace(
43
-                '\\',
44
-                '/',
45
-                substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))
46
-            );
47
-        } elseif (isset($_SERVER['PATH_TRANSLATED'])) {
48
-            $_SERVER['DOCUMENT_ROOT'] = str_replace(
49
-                '\\',
50
-                '/',
51
-                substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))
52
-            );
53
-        } else {
54
-            // define here your DOCUMENT_ROOT path if the previous fails
55
-            $_SERVER['DOCUMENT_ROOT'] = '/var/www';
56
-        }
57
-    }
58
-
59
-    // Automatic calculation for the following K_PATH_MAIN constant
60
-    $kPathMain = str_replace('\\', '/', dirname(__FILE__));
61
-    $kPathMain = dirname($kPathMain).'/'; // remove the current directory
62
-    $kPathMain.= '_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/';
63
-    define('K_PATH_MAIN', $kPathMain);
64
-
65
-    // Automatic calculation for the following K_PATH_URL constant
66
-    if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
67
-        if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') {
68
-            $kPathUrl = 'https://';
69
-        } else {
70
-            $kPathUrl = 'http://';
71
-        }
72
-        $kPathUrl .= $_SERVER['HTTP_HOST'];
73
-        $kPathUrl .= str_replace('\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
74
-    }
75
-
76
-    /**
77
-     * URL path to tcpdf installation folder (http://localhost/tcpdf/).
78
-     * By default it is automatically calculated but you can also set it as a fixed string to improve performances.
79
-     */
80
-    define('K_PATH_URL', $kPathUrl);
81
-
82
-    /**
83
-     * path for PDF fonts
84
-     * use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
85
-     */
86
-    define('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
87
-
88
-    /**
89
-     * cache directory for temporary files (full path)
90
-     */
91
-    define('K_PATH_CACHE', K_PATH_MAIN.'cache/');
92
-
93
-    /**
94
-     * cache directory for temporary files (url path)
95
-     */
96
-    define('K_PATH_URL_CACHE', K_PATH_URL.'cache/');
97
-
98
-    /**
99
-     *images directory
100
-     */
101
-    define('K_PATH_IMAGES', K_PATH_MAIN.'images/');
102
-
103
-    /**
104
-     * blank image
105
-     */
106
-    define('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');
107
-
108
-    /**
109
-     * page format
110
-     */
111
-    define('PDF_PAGE_FORMAT', 'A4');
112
-
113
-    /**
114
-     * page orientation (P=portrait, L=landscape)
115
-     */
116
-    define('PDF_PAGE_ORIENTATION', 'P');
117
-
118
-    /**
119
-     * document creator
120
-     */
121
-    define('PDF_CREATOR', 'HTML2PDF - TCPDF');
122
-
123
-    /**
124
-     * document author
125
-     */
126
-    define('PDF_AUTHOR', 'HTML2PDF - TCPDF');
127
-
128
-    /**
129
-     * header title
130
-     */
131
-    define('PDF_HEADER_TITLE', null);
132
-
133
-    /**
134
-     * header description string
135
-     */
136
-    define('PDF_HEADER_STRING', null);
137
-
138
-    /**
139
-     * image logo
140
-     */
141
-    define('PDF_HEADER_LOGO', null);
142
-
143
-    /**
144
-     * header logo image width [mm]
145
-     */
146
-    define('PDF_HEADER_LOGO_WIDTH', null);
147
-
148
-    /**
149
-     *  document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
150
-     */
151
-    define('PDF_UNIT', 'mm');
152
-
153
-    /**
154
-     * header margin
155
-     */
156
-    define('PDF_MARGIN_HEADER', 0);
157
-
158
-    /**
159
-     * footer margin
160
-     */
161
-    define('PDF_MARGIN_FOOTER', 0);
162
-
163
-    /**
164
-     * top margin
165
-     */
166
-    define('PDF_MARGIN_TOP', 0);
167
-
168
-    /**
169
-     * bottom margin
170
-     */
171
-    define('PDF_MARGIN_BOTTOM', 0);
172
-
173
-    /**
174
-     * left margin
175
-     */
176
-    define('PDF_MARGIN_LEFT', 0);
177
-
178
-    /**
179
-     * right margin
180
-     */
181
-    define('PDF_MARGIN_RIGHT', 0);
182
-
183
-    /**
184
-     * default main font name
185
-     */
186
-    define('PDF_FONT_NAME_MAIN', 'helvetica');
187
-
188
-    /**
189
-     * default main font size
190
-     */
191
-    define('PDF_FONT_SIZE_MAIN', 10);
192
-
193
-    /**
194
-     * default data font name
195
-     */
196
-    define('PDF_FONT_NAME_DATA', 'helvetica');
197
-
198
-    /**
199
-     * default data font size
200
-     */
201
-    define('PDF_FONT_SIZE_DATA', 8);
202
-
203
-    /**
204
-     * default monospaced font name
205
-     */
206
-    define('PDF_FONT_MONOSPACED', 'courier');
207
-
208
-    /**
209
-     * ratio used to adjust the conversion of pixels to user units
210
-     */
211
-    define('PDF_IMAGE_SCALE_RATIO', 1);
212
-
213
-    /**
214
-     * magnification factor for titles
215
-     */
216
-    define('HEAD_MAGNIFICATION', 1);
217
-
218
-    /**
219
-     * height of cell repect font height
220
-     */
221
-    define('K_CELL_HEIGHT_RATIO', 1);
222
-
223
-    /**
224
-     * title magnification respect main font size
225
-     */
226
-    define('K_TITLE_MAGNIFICATION', 1);
227
-
228
-    /**
229
-     * reduction factor for small font
230
-     */
231
-    define('K_SMALL_RATIO', 2/3);
232
-
233
-    /**
234
-     * set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
235
-     */
236
-    define('K_THAI_TOPCHARS', true);
237
-
238
-    /**
239
-     * if true allows to call TCPDF methods using HTML syntax
240
-     * IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
241
-     */
242
-    define('K_TCPDF_CALLS_IN_HTML', false);
37
+	define('K_TCPDF_EXTERNAL_CONFIG', true);
38
+
39
+	// DOCUMENT_ROOT fix for IIS Webserver
40
+	if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
41
+		if (isset($_SERVER['SCRIPT_FILENAME'])) {
42
+			$_SERVER['DOCUMENT_ROOT'] = str_replace(
43
+				'\\',
44
+				'/',
45
+				substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))
46
+			);
47
+		} elseif (isset($_SERVER['PATH_TRANSLATED'])) {
48
+			$_SERVER['DOCUMENT_ROOT'] = str_replace(
49
+				'\\',
50
+				'/',
51
+				substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))
52
+			);
53
+		} else {
54
+			// define here your DOCUMENT_ROOT path if the previous fails
55
+			$_SERVER['DOCUMENT_ROOT'] = '/var/www';
56
+		}
57
+	}
58
+
59
+	// Automatic calculation for the following K_PATH_MAIN constant
60
+	$kPathMain = str_replace('\\', '/', dirname(__FILE__));
61
+	$kPathMain = dirname($kPathMain).'/'; // remove the current directory
62
+	$kPathMain.= '_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/';
63
+	define('K_PATH_MAIN', $kPathMain);
64
+
65
+	// Automatic calculation for the following K_PATH_URL constant
66
+	if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
67
+		if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') {
68
+			$kPathUrl = 'https://';
69
+		} else {
70
+			$kPathUrl = 'http://';
71
+		}
72
+		$kPathUrl .= $_SERVER['HTTP_HOST'];
73
+		$kPathUrl .= str_replace('\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
74
+	}
75
+
76
+	/**
77
+	 * URL path to tcpdf installation folder (http://localhost/tcpdf/).
78
+	 * By default it is automatically calculated but you can also set it as a fixed string to improve performances.
79
+	 */
80
+	define('K_PATH_URL', $kPathUrl);
81
+
82
+	/**
83
+	 * path for PDF fonts
84
+	 * use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
85
+	 */
86
+	define('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
87
+
88
+	/**
89
+	 * cache directory for temporary files (full path)
90
+	 */
91
+	define('K_PATH_CACHE', K_PATH_MAIN.'cache/');
92
+
93
+	/**
94
+	 * cache directory for temporary files (url path)
95
+	 */
96
+	define('K_PATH_URL_CACHE', K_PATH_URL.'cache/');
97
+
98
+	/**
99
+	 *images directory
100
+	 */
101
+	define('K_PATH_IMAGES', K_PATH_MAIN.'images/');
102
+
103
+	/**
104
+	 * blank image
105
+	 */
106
+	define('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');
107
+
108
+	/**
109
+	 * page format
110
+	 */
111
+	define('PDF_PAGE_FORMAT', 'A4');
112
+
113
+	/**
114
+	 * page orientation (P=portrait, L=landscape)
115
+	 */
116
+	define('PDF_PAGE_ORIENTATION', 'P');
117
+
118
+	/**
119
+	 * document creator
120
+	 */
121
+	define('PDF_CREATOR', 'HTML2PDF - TCPDF');
122
+
123
+	/**
124
+	 * document author
125
+	 */
126
+	define('PDF_AUTHOR', 'HTML2PDF - TCPDF');
127
+
128
+	/**
129
+	 * header title
130
+	 */
131
+	define('PDF_HEADER_TITLE', null);
132
+
133
+	/**
134
+	 * header description string
135
+	 */
136
+	define('PDF_HEADER_STRING', null);
137
+
138
+	/**
139
+	 * image logo
140
+	 */
141
+	define('PDF_HEADER_LOGO', null);
142
+
143
+	/**
144
+	 * header logo image width [mm]
145
+	 */
146
+	define('PDF_HEADER_LOGO_WIDTH', null);
147
+
148
+	/**
149
+	 *  document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
150
+	 */
151
+	define('PDF_UNIT', 'mm');
152
+
153
+	/**
154
+	 * header margin
155
+	 */
156
+	define('PDF_MARGIN_HEADER', 0);
157
+
158
+	/**
159
+	 * footer margin
160
+	 */
161
+	define('PDF_MARGIN_FOOTER', 0);
162
+
163
+	/**
164
+	 * top margin
165
+	 */
166
+	define('PDF_MARGIN_TOP', 0);
167
+
168
+	/**
169
+	 * bottom margin
170
+	 */
171
+	define('PDF_MARGIN_BOTTOM', 0);
172
+
173
+	/**
174
+	 * left margin
175
+	 */
176
+	define('PDF_MARGIN_LEFT', 0);
177
+
178
+	/**
179
+	 * right margin
180
+	 */
181
+	define('PDF_MARGIN_RIGHT', 0);
182
+
183
+	/**
184
+	 * default main font name
185
+	 */
186
+	define('PDF_FONT_NAME_MAIN', 'helvetica');
187
+
188
+	/**
189
+	 * default main font size
190
+	 */
191
+	define('PDF_FONT_SIZE_MAIN', 10);
192
+
193
+	/**
194
+	 * default data font name
195
+	 */
196
+	define('PDF_FONT_NAME_DATA', 'helvetica');
197
+
198
+	/**
199
+	 * default data font size
200
+	 */
201
+	define('PDF_FONT_SIZE_DATA', 8);
202
+
203
+	/**
204
+	 * default monospaced font name
205
+	 */
206
+	define('PDF_FONT_MONOSPACED', 'courier');
207
+
208
+	/**
209
+	 * ratio used to adjust the conversion of pixels to user units
210
+	 */
211
+	define('PDF_IMAGE_SCALE_RATIO', 1);
212
+
213
+	/**
214
+	 * magnification factor for titles
215
+	 */
216
+	define('HEAD_MAGNIFICATION', 1);
217
+
218
+	/**
219
+	 * height of cell repect font height
220
+	 */
221
+	define('K_CELL_HEIGHT_RATIO', 1);
222
+
223
+	/**
224
+	 * title magnification respect main font size
225
+	 */
226
+	define('K_TITLE_MAGNIFICATION', 1);
227
+
228
+	/**
229
+	 * reduction factor for small font
230
+	 */
231
+	define('K_SMALL_RATIO', 2/3);
232
+
233
+	/**
234
+	 * set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
235
+	 */
236
+	define('K_THAI_TOPCHARS', true);
237
+
238
+	/**
239
+	 * if true allows to call TCPDF methods using HTML syntax
240
+	 * IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
241
+	 */
242
+	define('K_TCPDF_CALLS_IN_HTML', false);
243 243
 }
244 244
 
245 245
 //============================================================+
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 //============================================================+
3 3
 // File name   : tcpdf_config.php
4 4
 // Begin       : 2004-06-11
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
             $_SERVER['DOCUMENT_ROOT'] = str_replace(
43 43
                 '\\',
44 44
                 '/',
45
-                substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))
45
+                substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF']))
46 46
             );
47 47
         } elseif (isset($_SERVER['PATH_TRANSLATED'])) {
48 48
             $_SERVER['DOCUMENT_ROOT'] = str_replace(
49 49
                 '\\',
50 50
                 '/',
51
-                substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF']))
51
+                substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 - strlen($_SERVER['PHP_SELF']))
52 52
             );
53 53
         } else {
54 54
             // define here your DOCUMENT_ROOT path if the previous fails
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 
59 59
     // Automatic calculation for the following K_PATH_MAIN constant
60 60
     $kPathMain = str_replace('\\', '/', dirname(__FILE__));
61
-    $kPathMain = dirname($kPathMain).'/'; // remove the current directory
62
-    $kPathMain.= '_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/';
61
+    $kPathMain = dirname($kPathMain) . '/'; // remove the current directory
62
+    $kPathMain .= '_tcpdf_' . HTML2PDF_USED_TCPDF_VERSION . '/';
63 63
     define('K_PATH_MAIN', $kPathMain);
64 64
 
65 65
     // Automatic calculation for the following K_PATH_URL constant
66 66
     if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
67
-        if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') {
67
+        if (isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS']) != 'off') {
68 68
             $kPathUrl = 'https://';
69 69
         } else {
70 70
             $kPathUrl = 'http://';
@@ -83,27 +83,27 @@  discard block
 block discarded – undo
83 83
      * path for PDF fonts
84 84
      * use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
85 85
      */
86
-    define('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
86
+    define('K_PATH_FONTS', K_PATH_MAIN . 'fonts/');
87 87
 
88 88
     /**
89 89
      * cache directory for temporary files (full path)
90 90
      */
91
-    define('K_PATH_CACHE', K_PATH_MAIN.'cache/');
91
+    define('K_PATH_CACHE', K_PATH_MAIN . 'cache/');
92 92
 
93 93
     /**
94 94
      * cache directory for temporary files (url path)
95 95
      */
96
-    define('K_PATH_URL_CACHE', K_PATH_URL.'cache/');
96
+    define('K_PATH_URL_CACHE', K_PATH_URL . 'cache/');
97 97
 
98 98
     /**
99 99
      *images directory
100 100
      */
101
-    define('K_PATH_IMAGES', K_PATH_MAIN.'images/');
101
+    define('K_PATH_IMAGES', K_PATH_MAIN . 'images/');
102 102
 
103 103
     /**
104 104
      * blank image
105 105
      */
106
-    define('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');
106
+    define('K_BLANK_IMAGE', K_PATH_IMAGES . '_blank.png');
107 107
 
108 108
     /**
109 109
      * page format
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     /**
229 229
      * reduction factor for small font
230 230
      */
231
-    define('K_SMALL_RATIO', 2/3);
231
+    define('K_SMALL_RATIO', 2 / 3);
232 232
 
233 233
     /**
234 234
      * set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_class/exception.class.php 3 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -11,158 +11,158 @@
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_exception extends exception
13 13
 {
14
-    protected $_tag = null;
15
-    protected $_html = null;
16
-    protected $_other = null;
17
-    protected $_image = null;
18
-    protected $_messageHtml = '';
19
-
20
-    /**
21
-     * generate a HTML2PDF exception
22
-     *
23
-     * @param    int     $err error number
24
-     * @param    mixed   $other additionnal informations
25
-     * @return   string  $html optionnal code HTML associated to the error
26
-     */
27
-    final public function __construct($err = 0, $other = null, $html = '')
28
-    {
29
-        // read the error
30
-        switch($err)
31
-        {
32
-            case 1: // Unsupported tag
33
-                $msg = (HTML2PDF_locale::get('err01'));
34
-                $msg = str_replace('[[OTHER]]', $other, $msg);
35
-                $this->_tag = $other;
36
-                break;
37
-
38
-            case 2: // too long sentence
39
-                $msg = (HTML2PDF_locale::get('err02'));
40
-                $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
41
-                $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
42
-                $msg = str_replace('[[OTHER_2]]', $other[2], $msg);
43
-                break;
44
-
45
-            case 3: // closing tag in excess
46
-                $msg = (HTML2PDF_locale::get('err03'));
47
-                $msg = str_replace('[[OTHER]]', $other, $msg);
48
-                $this->_tag = $other;
49
-                break;
50
-
51
-            case 4: // tags closed in the wrong order
52
-                $msg = (HTML2PDF_locale::get('err04'));
53
-                $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
54
-                break;
55
-
56
-            case 5: // unclosed tag
57
-                $msg = (HTML2PDF_locale::get('err05'));
58
-                $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
59
-                break;
60
-
61
-            case 6: // image can not be loaded
62
-                $msg = (HTML2PDF_locale::get('err06'));
63
-                $msg = str_replace('[[OTHER]]', $other, $msg);
64
-                $this->_image = $other;
65
-                break;
66
-
67
-            case 7: // too big TD content
68
-                $msg = (HTML2PDF_locale::get('err07'));
69
-                break;
70
-
71
-            case 8: // SVG tag not in DRAW tag
72
-                $msg = (HTML2PDF_locale::get('err08'));
73
-                $msg = str_replace('[[OTHER]]', $other, $msg);
74
-                $this->_tag = $other;
75
-                break;
76
-
77
-            case 9: // deprecated
78
-                $msg = (HTML2PDF_locale::get('err09'));
79
-                $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
80
-                $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
81
-                $this->_tag = $other[0];
82
-                break;
83
-
84
-            case 0: // specific error
85
-            default:
86
-                $msg = $other;
87
-                break;
88
-        }
89
-
90
-        // create the HTML message
91
-        $this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">'.HTML2PDF_locale::get('txt01', 'error: ').$err.'</span><br>';
92
-        $this->_messageHtml.= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>';
93
-        $this->_messageHtml.= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>';
94
-        $this->_messageHtml.= '<br>';
95
-        $this->_messageHtml.= $msg;
96
-
97
-        // create the text message
98
-        $msg = HTML2PDF_locale::get('txt01', 'error: ').$err.' : '.strip_tags($msg);
99
-
100
-        // add the optionnal html content
101
-        if ($html) {
102
-            $this->_messageHtml.= "<br><br>HTML : ...".trim(htmlentities($html)).'...';
103
-            $this->_html = $html;
104
-            $msg.= ' HTML : ...'.trim($html).'...';
105
-        }
106
-
107
-        // save the other informations
108
-        $this->_other = $other;
109
-
110
-        // construct the exception
111
-        parent::__construct($msg, $err);
112
-    }
113
-
114
-    /**
115
-     * get the message as string
116
-     *
117
-     * @access public
118
-     * @return string $messageHtml
119
-     */
120
-    public function __toString()
121
-    {
122
-        return $this->_messageHtml;
123
-    }
124
-
125
-    /**
126
-     * get the html tag name
127
-     *
128
-     * @access public
129
-     * @return string $tagName
130
-     */
131
-    public function getTAG()
132
-    {
133
-        return $this->_tag;
134
-    }
135
-
136
-    /**
137
-     * get the optional html code
138
-     *
139
-     * @access public
140
-     * @return string $html
141
-     */
142
-    public function getHTML()
143
-    {
144
-        return $this->_html;
145
-    }
146
-
147
-    /**
148
-     * get the optional other informations
149
-     *
150
-     * @access public
151
-     * @return mixed $other
152
-     */
153
-    public function getOTHER()
154
-    {
155
-        return $this->_other;
156
-    }
157
-
158
-    /**
159
-     * get the image source
160
-     *
161
-     * @access public
162
-     * @return string $imageSrc
163
-     */
164
-    public function getIMAGE()
165
-    {
166
-        return $this->_image;
167
-    }
14
+	protected $_tag = null;
15
+	protected $_html = null;
16
+	protected $_other = null;
17
+	protected $_image = null;
18
+	protected $_messageHtml = '';
19
+
20
+	/**
21
+	 * generate a HTML2PDF exception
22
+	 *
23
+	 * @param    int     $err error number
24
+	 * @param    mixed   $other additionnal informations
25
+	 * @return   string  $html optionnal code HTML associated to the error
26
+	 */
27
+	final public function __construct($err = 0, $other = null, $html = '')
28
+	{
29
+		// read the error
30
+		switch($err)
31
+		{
32
+			case 1: // Unsupported tag
33
+				$msg = (HTML2PDF_locale::get('err01'));
34
+				$msg = str_replace('[[OTHER]]', $other, $msg);
35
+				$this->_tag = $other;
36
+				break;
37
+
38
+			case 2: // too long sentence
39
+				$msg = (HTML2PDF_locale::get('err02'));
40
+				$msg = str_replace('[[OTHER_0]]', $other[0], $msg);
41
+				$msg = str_replace('[[OTHER_1]]', $other[1], $msg);
42
+				$msg = str_replace('[[OTHER_2]]', $other[2], $msg);
43
+				break;
44
+
45
+			case 3: // closing tag in excess
46
+				$msg = (HTML2PDF_locale::get('err03'));
47
+				$msg = str_replace('[[OTHER]]', $other, $msg);
48
+				$this->_tag = $other;
49
+				break;
50
+
51
+			case 4: // tags closed in the wrong order
52
+				$msg = (HTML2PDF_locale::get('err04'));
53
+				$msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
54
+				break;
55
+
56
+			case 5: // unclosed tag
57
+				$msg = (HTML2PDF_locale::get('err05'));
58
+				$msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
59
+				break;
60
+
61
+			case 6: // image can not be loaded
62
+				$msg = (HTML2PDF_locale::get('err06'));
63
+				$msg = str_replace('[[OTHER]]', $other, $msg);
64
+				$this->_image = $other;
65
+				break;
66
+
67
+			case 7: // too big TD content
68
+				$msg = (HTML2PDF_locale::get('err07'));
69
+				break;
70
+
71
+			case 8: // SVG tag not in DRAW tag
72
+				$msg = (HTML2PDF_locale::get('err08'));
73
+				$msg = str_replace('[[OTHER]]', $other, $msg);
74
+				$this->_tag = $other;
75
+				break;
76
+
77
+			case 9: // deprecated
78
+				$msg = (HTML2PDF_locale::get('err09'));
79
+				$msg = str_replace('[[OTHER_0]]', $other[0], $msg);
80
+				$msg = str_replace('[[OTHER_1]]', $other[1], $msg);
81
+				$this->_tag = $other[0];
82
+				break;
83
+
84
+			case 0: // specific error
85
+			default:
86
+				$msg = $other;
87
+				break;
88
+		}
89
+
90
+		// create the HTML message
91
+		$this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">'.HTML2PDF_locale::get('txt01', 'error: ').$err.'</span><br>';
92
+		$this->_messageHtml.= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>';
93
+		$this->_messageHtml.= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>';
94
+		$this->_messageHtml.= '<br>';
95
+		$this->_messageHtml.= $msg;
96
+
97
+		// create the text message
98
+		$msg = HTML2PDF_locale::get('txt01', 'error: ').$err.' : '.strip_tags($msg);
99
+
100
+		// add the optionnal html content
101
+		if ($html) {
102
+			$this->_messageHtml.= "<br><br>HTML : ...".trim(htmlentities($html)).'...';
103
+			$this->_html = $html;
104
+			$msg.= ' HTML : ...'.trim($html).'...';
105
+		}
106
+
107
+		// save the other informations
108
+		$this->_other = $other;
109
+
110
+		// construct the exception
111
+		parent::__construct($msg, $err);
112
+	}
113
+
114
+	/**
115
+	 * get the message as string
116
+	 *
117
+	 * @access public
118
+	 * @return string $messageHtml
119
+	 */
120
+	public function __toString()
121
+	{
122
+		return $this->_messageHtml;
123
+	}
124
+
125
+	/**
126
+	 * get the html tag name
127
+	 *
128
+	 * @access public
129
+	 * @return string $tagName
130
+	 */
131
+	public function getTAG()
132
+	{
133
+		return $this->_tag;
134
+	}
135
+
136
+	/**
137
+	 * get the optional html code
138
+	 *
139
+	 * @access public
140
+	 * @return string $html
141
+	 */
142
+	public function getHTML()
143
+	{
144
+		return $this->_html;
145
+	}
146
+
147
+	/**
148
+	 * get the optional other informations
149
+	 *
150
+	 * @access public
151
+	 * @return mixed $other
152
+	 */
153
+	public function getOTHER()
154
+	{
155
+		return $this->_other;
156
+	}
157
+
158
+	/**
159
+	 * get the image source
160
+	 *
161
+	 * @access public
162
+	 * @return string $imageSrc
163
+	 */
164
+	public function getIMAGE()
165
+	{
166
+		return $this->_image;
167
+	}
168 168
 }
169 169
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - HTML2PDF Exception
4 4
  *
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     final public function __construct($err = 0, $other = null, $html = '')
28 28
     {
29 29
         // read the error
30
-        switch($err)
30
+        switch ($err)
31 31
         {
32 32
             case 1: // Unsupported tag
33 33
                 $msg = (HTML2PDF_locale::get('err01'));
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
         }
89 89
 
90 90
         // create the HTML message
91
-        $this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">'.HTML2PDF_locale::get('txt01', 'error: ').$err.'</span><br>';
92
-        $this->_messageHtml.= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>';
93
-        $this->_messageHtml.= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>';
94
-        $this->_messageHtml.= '<br>';
95
-        $this->_messageHtml.= $msg;
91
+        $this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">' . HTML2PDF_locale::get('txt01', 'error: ') . $err . '</span><br>';
92
+        $this->_messageHtml .= HTML2PDF_locale::get('txt02', 'file:') . ' ' . $this->file . '<br>';
93
+        $this->_messageHtml .= HTML2PDF_locale::get('txt03', 'line:') . ' ' . $this->line . '<br>';
94
+        $this->_messageHtml .= '<br>';
95
+        $this->_messageHtml .= $msg;
96 96
 
97 97
         // create the text message
98
-        $msg = HTML2PDF_locale::get('txt01', 'error: ').$err.' : '.strip_tags($msg);
98
+        $msg = HTML2PDF_locale::get('txt01', 'error: ') . $err . ' : ' . strip_tags($msg);
99 99
 
100 100
         // add the optionnal html content
101 101
         if ($html) {
102
-            $this->_messageHtml.= "<br><br>HTML : ...".trim(htmlentities($html)).'...';
102
+            $this->_messageHtml .= "<br><br>HTML : ..." . trim(htmlentities($html)) . '...';
103 103
             $this->_html = $html;
104
-            $msg.= ' HTML : ...'.trim($html).'...';
104
+            $msg .= ' HTML : ...' . trim($html) . '...';
105 105
         }
106 106
 
107 107
         // save the other informations
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/HTML2PDF/_class/locale.class.php 3 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -11,86 +11,86 @@
 block discarded – undo
11 11
 
12 12
 class HTML2PDF_locale
13 13
 {
14
-    /**
15
-     * code of the current used locale
16
-     * @var string
17
-     */
18
-    static protected $_code = null;
14
+	/**
15
+	 * code of the current used locale
16
+	 * @var string
17
+	 */
18
+	static protected $_code = null;
19 19
 
20
-    /**
21
-     * texts of the current used locale
22
-     * @var array
23
-     */
24
-    static protected $_list = array();
20
+	/**
21
+	 * texts of the current used locale
22
+	 * @var array
23
+	 */
24
+	static protected $_list = array();
25 25
 
26
-    /**
27
-     * directory where locale files are
28
-     * @var string
29
-     */
30
-    static protected $_directory = null;
26
+	/**
27
+	 * directory where locale files are
28
+	 * @var string
29
+	 */
30
+	static protected $_directory = null;
31 31
 
32
-    /**
33
-     * load the locale
34
-     *
35
-     * @access public
36
-     * @param  string $code
37
-     */
38
-    static public function load($code)
39
-    {
40
-        if (self::$_directory===null) {
41
-            self::$_directory = dirname(dirname(__FILE__)).'/locale/';
42
-        }
32
+	/**
33
+	 * load the locale
34
+	 *
35
+	 * @access public
36
+	 * @param  string $code
37
+	 */
38
+	static public function load($code)
39
+	{
40
+		if (self::$_directory===null) {
41
+			self::$_directory = dirname(dirname(__FILE__)).'/locale/';
42
+		}
43 43
 
44
-        // must be in lower case
45
-        $code = strtolower($code);
44
+		// must be in lower case
45
+		$code = strtolower($code);
46 46
 
47
-        // must be [a-z-0-9]
48
-        if (!preg_match('/^([a-z0-9]+)$/isU', $code)) {
49
-            throw new HTML2PDF_exception(0, 'invalid language code ['.self::$_code.']');
50
-        }
47
+		// must be [a-z-0-9]
48
+		if (!preg_match('/^([a-z0-9]+)$/isU', $code)) {
49
+			throw new HTML2PDF_exception(0, 'invalid language code ['.self::$_code.']');
50
+		}
51 51
 
52
-        // save the code
53
-        self::$_code = $code;
52
+		// save the code
53
+		self::$_code = $code;
54 54
 
55
-        // get the name of the locale file
56
-        $file = self::$_directory.self::$_code.'.csv';
55
+		// get the name of the locale file
56
+		$file = self::$_directory.self::$_code.'.csv';
57 57
 
58
-        // the file must exist
59
-        if (!is_file($file)) {
60
-            throw new HTML2PDF_exception(0, 'language code ['.self::$_code.'] unknown. You can create the translation file ['.$file.'] and send it to the webmaster of html2pdf in order to integrate it into a future release');
61
-        }
58
+		// the file must exist
59
+		if (!is_file($file)) {
60
+			throw new HTML2PDF_exception(0, 'language code ['.self::$_code.'] unknown. You can create the translation file ['.$file.'] and send it to the webmaster of html2pdf in order to integrate it into a future release');
61
+		}
62 62
 
63
-        // load the file
64
-        self::$_list = array();
65
-        $handle = fopen($file, 'r');
66
-        while (!feof($handle)) {
67
-            $line = fgetcsv($handle);
68
-            if (count($line)!=2) continue;
69
-            self::$_list[trim($line[0])] = trim($line[1]);
70
-        }
71
-        fclose($handle);
72
-    }
63
+		// load the file
64
+		self::$_list = array();
65
+		$handle = fopen($file, 'r');
66
+		while (!feof($handle)) {
67
+			$line = fgetcsv($handle);
68
+			if (count($line)!=2) continue;
69
+			self::$_list[trim($line[0])] = trim($line[1]);
70
+		}
71
+		fclose($handle);
72
+	}
73 73
 
74
-    /**
75
-     * clean the locale
76
-     *
77
-     * @access public static
78
-     */
79
-    static public function clean()
80
-    {
81
-        self::$_code = null;
82
-        self::$_list = array();
83
-    }
74
+	/**
75
+	 * clean the locale
76
+	 *
77
+	 * @access public static
78
+	 */
79
+	static public function clean()
80
+	{
81
+		self::$_code = null;
82
+		self::$_list = array();
83
+	}
84 84
 
85
-    /**
86
-     * get a text
87
-     *
88
-     * @access public static
89
-     * @param  string $key
90
-     * @return string
91
-     */
92
-    static public function get($key, $default='######')
93
-    {
94
-        return (isset(self::$_list[$key]) ? self::$_list[$key] : $default);
95
-    }
85
+	/**
86
+	 * get a text
87
+	 *
88
+	 * @access public static
89
+	 * @param  string $key
90
+	 * @return string
91
+	 */
92
+	static public function get($key, $default='######')
93
+	{
94
+		return (isset(self::$_list[$key]) ? self::$_list[$key] : $default);
95
+	}
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
  * HTML2PDF Librairy - HTML2PDF Locale
4 4
  *
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
      */
38 38
     static public function load($code)
39 39
     {
40
-        if (self::$_directory===null) {
41
-            self::$_directory = dirname(dirname(__FILE__)).'/locale/';
40
+        if (self::$_directory === null) {
41
+            self::$_directory = dirname(dirname(__FILE__)) . '/locale/';
42 42
         }
43 43
 
44 44
         // must be in lower case
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
 
47 47
         // must be [a-z-0-9]
48 48
         if (!preg_match('/^([a-z0-9]+)$/isU', $code)) {
49
-            throw new HTML2PDF_exception(0, 'invalid language code ['.self::$_code.']');
49
+            throw new HTML2PDF_exception(0, 'invalid language code [' . self::$_code . ']');
50 50
         }
51 51
 
52 52
         // save the code
53 53
         self::$_code = $code;
54 54
 
55 55
         // get the name of the locale file
56
-        $file = self::$_directory.self::$_code.'.csv';
56
+        $file = self::$_directory . self::$_code . '.csv';
57 57
 
58 58
         // the file must exist
59 59
         if (!is_file($file)) {
60
-            throw new HTML2PDF_exception(0, 'language code ['.self::$_code.'] unknown. You can create the translation file ['.$file.'] and send it to the webmaster of html2pdf in order to integrate it into a future release');
60
+            throw new HTML2PDF_exception(0, 'language code [' . self::$_code . '] unknown. You can create the translation file [' . $file . '] and send it to the webmaster of html2pdf in order to integrate it into a future release');
61 61
         }
62 62
 
63 63
         // load the file
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $handle = fopen($file, 'r');
66 66
         while (!feof($handle)) {
67 67
             $line = fgetcsv($handle);
68
-            if (count($line)!=2) continue;
68
+            if (count($line) != 2) continue;
69 69
             self::$_list[trim($line[0])] = trim($line[1]);
70 70
         }
71 71
         fclose($handle);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * @param  string $key
90 90
      * @return string
91 91
      */
92
-    static public function get($key, $default='######')
92
+    static public function get($key, $default = '######')
93 93
     {
94 94
         return (isset(self::$_list[$key]) ? self::$_list[$key] : $default);
95 95
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * HTML2PDF Librairy - HTML2PDF Locale
4 6
  *
@@ -65,7 +67,9 @@  discard block
 block discarded – undo
65 67
         $handle = fopen($file, 'r');
66 68
         while (!feof($handle)) {
67 69
             $line = fgetcsv($handle);
68
-            if (count($line)!=2) continue;
70
+            if (count($line)!=2) {
71
+            	continue;
72
+            }
69 73
             self::$_list[trim($line[0])] = trim($line[1]);
70 74
         }
71 75
         fclose($handle);
Please login to merge, or discard this patch.
includes/librairies/catalog/products.class.php 4 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class wpshop_products {
25 25
 	/**
26
-	*	Définition du code de la classe courante
27
-	*/
26
+	 *	Définition du code de la classe courante
27
+	 */
28 28
 	const currentPageCode = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
29 29
 	const current_page_variation_code = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION;
30 30
 
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 	/**
64
-	*	Déclaration des produits et variations en tant que "post" de wordpress
65
-	*
66
-	*	@see register_post_type()
67
-	*/
64
+	 *	Déclaration des produits et variations en tant que "post" de wordpress
65
+	 *
66
+	 *	@see register_post_type()
67
+	 */
68 68
 	public static function create_wpshop_products_type() {
69 69
 
70 70
 		$options = get_option('wpshop_catalog_product_option', array());
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	}
177 177
 
178 178
 	/**
179
-	*	Create the different bow for the product management page looking for the attribute set to create the different boxes
180
-	*/
179
+	 *	Create the different bow for the product management page looking for the attribute set to create the different boxes
180
+	 */
181 181
 	public static function add_meta_boxes() {
182 182
 		global $post, $currentTabContent;
183 183
 
@@ -607,21 +607,21 @@  discard block
 block discarded – undo
607 607
 	}
608 608
 
609 609
 	/**
610
-	* Display a list of product from a shortcode
611
-	*
612
-	* @param array $atts {
613
-	*	limit : The number of element to display
614
-	*	order : The information to order list by
615
-	*	sorting : List order (ASC | DESC)
616
-	*	display : Display size (normal | mini)
617
-	*	type : Display tyep (grid | list) only work with display=normal
618
-	*	pagination : The number of element per page
619
-	* display_pagination : Display the pagination or not
620
-	* }
621
-	*
622
-	* @return string
623
-	*
624
-	**/
610
+	 * Display a list of product from a shortcode
611
+	 *
612
+	 * @param array $atts {
613
+	 *	limit : The number of element to display
614
+	 *	order : The information to order list by
615
+	 *	sorting : List order (ASC | DESC)
616
+	 *	display : Display size (normal | mini)
617
+	 *	type : Display tyep (grid | list) only work with display=normal
618
+	 *	pagination : The number of element per page
619
+	 * display_pagination : Display the pagination or not
620
+	 * }
621
+	 *
622
+	 * @return string
623
+	 *
624
+	 **/
625 625
 	public static function wpshop_products_func($atts) {
626 626
 		global $wpdb, $wp_query;
627 627
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 	 * @param $description Description of the product
1135 1135
 	 * @param $attrs List of the attributes and values of the product
1136 1136
 	 * @return boolean
1137
-	*/
1137
+	 */
1138 1138
 	function addProduct($name, $description, $attrs=array()) {
1139 1139
 		$new_product = wpshop_entities::create_new_entity(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $name, $description, $attrs);
1140 1140
 		return $new_product[0];
@@ -1448,13 +1448,13 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
 
1450 1450
 	/**
1451
-	*	Define output for product
1452
-	*
1453
-	*	@param mixed $initialContent The initial product content defined into wordpress basic admin interface
1454
-	*	@param integer $product_id The product identifier we want to get and output attribute for
1455
-	*
1456
-	*	@return mixed $content The content to add or to modify the product output in frontend
1457
-	*/
1451
+	 *	Define output for product
1452
+	 *
1453
+	 *	@param mixed $initialContent The initial product content defined into wordpress basic admin interface
1454
+	 *	@param integer $product_id The product identifier we want to get and output attribute for
1455
+	 *
1456
+	 *	@return mixed $content The content to add or to modify the product output in frontend
1457
+	 */
1458 1458
 	public static function product_complete_sheet_output($initialContent, $product_id) {
1459 1459
 		$content = $attributeContentOutput = '';
1460 1460
 		$wps_product_ctr = new wps_product_ctr();
@@ -1754,12 +1754,12 @@  discard block
 block discarded – undo
1754 1754
 
1755 1755
 
1756 1756
 	/**
1757
-	*	Get the products (post) of a given category
1758
-	*
1759
-	*	@param string $category_slug The category slug we want to get the product list for
1760
-	*
1761
-	*	@return mixed $widget_content The output for the product list
1762
-	*/
1757
+	 *	Get the products (post) of a given category
1758
+	 *
1759
+	 *	@param string $category_slug The category slug we want to get the product list for
1760
+	 *
1761
+	 *	@return mixed $widget_content The output for the product list
1762
+	 */
1763 1763
 	public static function get_product_of_category($category_slug, $category_id){
1764 1764
 		global $top_categories;
1765 1765
 		$widget_content = '';
Please login to merge, or discard this patch.
Braces   +89 added lines, -131 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
 * Products management method file
4 6
 *
@@ -200,8 +202,7 @@  discard block
 block discarded – undo
200 202
 			if(((count($attributeEntitySetList) == 1) || ((count($attributeEntitySetList) > 1) && (($post_attribute_set_id > 0) || (isset($attribute_set_id->value) && ($attribute_set_id->value > 0)))))){
201 203
 				if((count($attributeEntitySetList) == 1) || (($post_attribute_set_id <= 0) && ($attribute_set_id->value <= 0))){
202 204
 					$post_attribute_set_id = $attributeEntitySetList[0]->id;
203
-				}
204
-				elseif(($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)){
205
+				} elseif(($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)){
205 206
 					$post_attribute_set_id = $attribute_set_id->value;
206 207
 				}
207 208
 
@@ -213,8 +214,9 @@  discard block
 block discarded – undo
213 214
 					foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
214 215
 						if(!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type'] == 'movable-tab')){
215 216
 							add_meta_box('wpshop_product_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_products', 'meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default', array('boxIdentifier' => $boxIdentifier));
217
+						} else {
218
+							$fixed_box_exist = true;
216 219
 						}
217
-						else $fixed_box_exist = true;
218 220
 					}
219 221
 				}
220 222
 				if ( $fixed_box_exist ) {
@@ -228,8 +230,7 @@  discard block
 block discarded – undo
228 230
 
229 231
 				/**	Product option	*/
230 232
 				add_meta_box('wpshop_product_options', __('Options', 'wpshop'), array('wpshop_products', 'product_options_meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'side', 'default');
231
-			}
232
-			else if ( count($attributeEntitySetList) > 1 ) {
233
+			} else if ( count($attributeEntitySetList) > 1 ) {
233 234
 				$input_def['id'] = 'product_attribute_set_id';
234 235
 				$input_def['name'] = 'product_attribute_set_id';
235 236
 				$input_def['value'] = '';
@@ -477,8 +478,9 @@  discard block
 block discarded – undo
477 478
 			$tpl_component = array();
478 479
 			$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] = '';
479 480
 			for ( $i=1; $i<=$column_count; $i++ ) {
480
-				if (!empty($sub_content[$i]))
481
-					$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] .= '<div class="alignleft" >' . $sub_content[$i] . '</div>';
481
+				if (!empty($sub_content[$i])) {
482
+									$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] .= '<div class="alignleft" >' . $sub_content[$i] . '</div>';
483
+				}
482 484
 			}
483 485
 			$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT_CLASS'] = empty($product_attribute_frontend_display_config) ? ' class="wpshopHide" ' : '';
484 486
 			$tpl_component['ADMIN_PRODUCT_ATTRIBUTE_FRONTEND_DISPLAY_MAIN_CHOICE_CHECK'] = empty($product_attribute_frontend_display_config) ? ' checked="checked"' : '';
@@ -501,7 +503,9 @@  discard block
 block discarded – undo
501 503
 
502 504
 		$query = $wpdb->prepare("SELECT code, frontend_label FROM ".WPSHOP_DBT_ATTRIBUTE." WHERE is_used_for_sort_by = %s",  'yes');
503 505
 		$results = $wpdb->get_results($query, ARRAY_A);
504
-		if(!empty($results))$data = array_merge($data, $results);
506
+		if(!empty($results)) {
507
+			$data = array_merge($data, $results);
508
+		}
505 509
 
506 510
 		return $data;
507 511
 	}
@@ -516,12 +520,7 @@  discard block
 block discarded – undo
516 520
 		if(!empty($data)) {
517 521
 			if ($data['data_type_to_use'] == 'custom' ) {
518 522
 				// Find which table to take
519
-				if($data['data_type']=='datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; }
520
-				elseif($data['data_type']=='decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; }
521
-				elseif($data['data_type']=='integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; }
522
-				elseif($data['data_type']=='options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; }
523
-				elseif($data['data_type']=='text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; }
524
-				elseif($data['data_type']=='varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
523
+				if($data['data_type']=='datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; } elseif($data['data_type']=='decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; } elseif($data['data_type']=='integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; } elseif($data['data_type']=='options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; } elseif($data['data_type']=='text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; } elseif($data['data_type']=='varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
525 524
 
526 525
 				if(isset($table_name)) {
527 526
 					// If the value is an id of a select, radio or checkbox
@@ -535,8 +534,7 @@  discard block
 block discarded – undo
535 534
 							WHERE ATT.code=%s AND ( ATT_OPT.value=%s OR ATT_OPT.value=%s )", $attr_name, strtolower( __( $attr_value, 'wpshop' ) ), $attr_value
536 535
 						);
537 536
 						$data = $wpdb->get_results($query);
538
-					}
539
-					else {
537
+					} else {
540 538
 
541 539
 						$query = $wpdb->prepare("
542 540
 							SELECT ".$table_name.".entity_id FROM ".$table_name."
@@ -548,10 +546,10 @@  discard block
 block discarded – undo
548 546
 						$data = $wpdb->get_results($query);
549 547
 
550 548
 					}
549
+				} else {
550
+					return __('Incorrect shortcode','wpshop');
551 551
 				}
552
-				else return __('Incorrect shortcode','wpshop');
553
-			}
554
-			elseif( $data['data_type_to_use'] == 'internal' )  {
552
+			} elseif( $data['data_type_to_use'] == 'internal' )  {
555 553
 				/** Check the ID of manufacturer **/
556 554
 				$default_value = unserialize( $data['default_value'] );
557 555
 				if( !empty($default_value) && !empty($default_value['default_value']) ) {
@@ -562,9 +560,13 @@  discard block
 block discarded – undo
562 560
 						$data = $wpdb->get_results( $query );
563 561
 					}
564 562
 				}
565
-			}else return __('Incorrect shortcode','wpshop');
563
+			} else {
564
+				return __('Incorrect shortcode','wpshop');
565
+			}
566 566
 
567
-		} else return __('Incorrect shortcode','wpshop');
567
+		} else {
568
+			return __('Incorrect shortcode','wpshop');
569
+		}
568 570
 
569 571
 		if(!empty($data)) {
570 572
 			foreach($data as $p) {
@@ -591,7 +593,9 @@  discard block
 block discarded – undo
591 593
 		global $wp_query;
592 594
 
593 595
 		$atts['product_type'] = 'related';
594
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
596
+		if(empty($atts['pid'])) {
597
+			$atts['pid'] = $wp_query->posts[0]->ID;
598
+		}
595 599
 
596 600
 		$related_product_output = self::wpshop_products_func($atts);
597 601
 
@@ -651,9 +655,12 @@  discard block
 block discarded – undo
651 655
 			// Foreach on the found products
652 656
 			if ( !empty($products) ) {
653 657
 				$pid = implode(',',$products);
654
-				if(empty($pid))$output_results = false;
658
+				if(empty($pid)) {
659
+					$output_results = false;
660
+				}
661
+			} else {
662
+				$output_results = false;
655 663
 			}
656
-			else $output_results = false;
657 664
 		}
658 665
 
659 666
 		/** Get related products	*/
@@ -712,8 +719,7 @@  discard block
 block discarded – undo
712 719
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
713 720
 				$sorting = ob_get_contents();
714 721
 				ob_end_clean();
715
-			}
716
-			else {
722
+			} else {
717 723
 				/*
718 724
 				 * Display hidden field every times
719 725
 				 */
@@ -745,8 +751,7 @@  discard block
 block discarded – undo
745 751
 					$tpl_component['DISPLAY_TYPE_STATE_GRID'] = $type == 'grid' ?' active' : null;
746 752
 					$tpl_component['DISPLAY_TYPE_STATE_LIST'] = $type == 'list' ?' active' : null;
747 753
 					$sorting = wpshop_display::display_template_element($template_part, $tpl_component);
748
-				}
749
-				else if ( !empty($atts['sorting']) && ($atts['sorting'] == 'no') ) {
754
+				} else if ( !empty($atts['sorting']) && ($atts['sorting'] == 'no') ) {
750 755
 					$sub_template_part = 'product_listing_sorting_criteria_hidden';
751 756
 					$sub_tpl_component = array();
752 757
 					$sub_tpl_component['CRITERIA_DEFAULT'] = !empty($sorting_criteria[0]['code']) ? $sorting_criteria[0]['code'] : 'title';
@@ -761,12 +766,10 @@  discard block
 block discarded – undo
761 766
 
762 767
 			if ( !empty( $atts) && !empty($atts['container']) && $atts['container'] == 'no') {
763 768
 				$string = $sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div>';
764
-			}
765
-			else {
769
+			} else {
766 770
 				$string = '<div class="wpshop_products_block">'.$sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div></div>';
767 771
 			}
768
-		}
769
-		else if ( empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no') ) {
772
+		} else if ( empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no') ) {
770 773
 			$string = __('There is nothing to output here', 'wpshop');
771 774
 		}
772 775
 
@@ -831,24 +834,21 @@  discard block
 block discarded – undo
831 834
 				default:
832 835
 					if(!empty($pid)) {
833 836
 						$post_meta = get_post_meta($pid, '_'.$criteria, true);
834
-					}
835
-					else{
837
+					} else{
836 838
 						$check_meta = $wpdb->prepare("SELECT COUNT(meta_id) as meta_criteria FROM " . $wpdb->postmeta . " WHERE meta_key = %s", '_'.$criteria);
837 839
 						$post_meta = $wpdb->get_var($check_meta);
838 840
 					}
839 841
 					if(!empty($post_meta)){
840 842
 						if ( in_array( $criteria, array( 'wpshop_displayed_price', 'product_price' ) ) ) {
841 843
 							$query['orderby'] = 'meta_value_num';
842
-						}
843
-						else {
844
+						} else {
844 845
 							$query['orderby'] = 'meta_value';
845 846
 						}
846 847
 						$query['meta_key'] = '_'.$criteria;
847 848
 					}
848 849
 					break;
849 850
 			}
850
-		}
851
-		else {
851
+		} else {
852 852
 			$query['orderby'] = 'menu_order ID';
853 853
 		}
854 854
 		$post_per_page = $query['posts_per_page'];
@@ -860,8 +860,7 @@  discard block
 block discarded – undo
860 860
 				for( $i = 0; $i < $query['posts_per_page']; $i++ ) {
861 861
 					$tmp_array[] = $query['post__in'][$i];
862 862
 				}
863
-			}
864
-			else {
863
+			} else {
865 864
 				$begin_number = ( ($page_number - 1) * $query['posts_per_page'] ) ;
866 865
 				for( $i = $begin_number ; $i < $query['posts_per_page'] + $begin_number ; $i++ ) {
867 866
 					if ( !empty($query['post__in'][$i]) ) {
@@ -1091,8 +1090,7 @@  discard block
 block discarded – undo
1091 1090
 						$product_meta['attribute_visible_listing'][$attribute->attribute_code] = $value;
1092 1091
 					}
1093 1092
 				}
1094
-			}
1095
-			else {
1093
+			} else {
1096 1094
 
1097 1095
 			}
1098 1096
 
@@ -1194,8 +1192,7 @@  discard block
 block discarded – undo
1194 1192
 					$query = "SELECT MAX(ID) AS PDCT_ID FROM {$wpdb->posts}";
1195 1193
 					$last_ref = $wpdb->get_var($query);
1196 1194
 					$data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'] = WPSHOP_PRODUCT_REFERENCE_PREFIX . str_repeat(0, WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL) . $last_ref;
1197
-				}
1198
-				else {
1195
+				} else {
1199 1196
 					/* Check if the product reference existing in the database */
1200 1197
 					$ref = $data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'];
1201 1198
 					$query = $wpdb->prepare(
@@ -1250,8 +1247,7 @@  discard block
 block discarded – undo
1250 1247
 
1251 1248
 			if ( !empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']) && empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']['default_config']) ) {
1252 1249
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, $data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']);
1253
-			}
1254
-			else if ( $data_to_save['action'] != 'autosave') {
1250
+			} else if ( $data_to_save['action'] != 'autosave') {
1255 1251
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF);
1256 1252
 			}
1257 1253
 
@@ -1325,23 +1321,20 @@  discard block
 block discarded – undo
1325 1321
 			/*	Update the related products list*/
1326 1322
 			if ( !empty($data_to_save['related_products_list']) ) {
1327 1323
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS, $data_to_save['related_products_list']);
1328
-			}
1329
-			else if ( $data_to_save['action'] != 'autosave') {
1324
+			} else if ( $data_to_save['action'] != 'autosave') {
1330 1325
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS);
1331 1326
 			}
1332 1327
 			/*	Update the provider list*/
1333 1328
 			if ( !empty($data_to_save['provider_list']) ) {
1334 1329
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER, $data_to_save['provider_list']);
1335
-			}
1336
-			else if ( $data_to_save['action'] != 'autosave') {
1330
+			} else if ( $data_to_save['action'] != 'autosave') {
1337 1331
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER);
1338 1332
 			}
1339 1333
 
1340 1334
 			/*	Update product options	*/
1341 1335
 			if ( !empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']) ) {
1342 1336
 				update_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', $data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']);
1343
-			}
1344
-			else if ( $data_to_save['action'] != 'autosave') {
1337
+			} else if ( $data_to_save['action'] != 'autosave') {
1345 1338
 				delete_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
1346 1339
 			}
1347 1340
 
@@ -1372,8 +1365,7 @@  discard block
 block discarded – undo
1372 1365
 				foreach( $variations as $variation_id => $variation_data ) {
1373 1366
 					if( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) == 1 ) {
1374 1367
 						return 'single';
1375
-					}
1376
-					elseif( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1 ) {
1368
+					} elseif( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1 ) {
1377 1369
 						$variation_type = 'combined';
1378 1370
 					}
1379 1371
 				}
@@ -1529,8 +1521,7 @@  discard block
 block discarded – undo
1529 1521
 		$display_price_state_when_price_is_empty = true;
1530 1522
 		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1531 1523
 			$display_price_state_when_price_is_empty = false;
1532
-		}
1533
-		else if ( !empty( $productPrice ) ) {
1524
+		} else if ( !empty( $productPrice ) ) {
1534 1525
 			$display_price_state_when_price_is_empty = true;
1535 1526
 		}
1536 1527
 		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'complete' ) : '';
@@ -1590,8 +1581,7 @@  discard block
 block discarded – undo
1590 1581
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
1591 1582
 			$content = ob_get_contents();
1592 1583
 			ob_end_clean();
1593
-		}
1594
-		else {
1584
+		} else {
1595 1585
 			$content = wpshop_display::display_template_element($template_part, $tpl_component);
1596 1586
 		}
1597 1587
 		unset($tpl_component);
@@ -1625,8 +1615,7 @@  discard block
 block discarded – undo
1625 1615
 				$product_more_informations = $post_content[0];
1626 1616
 			}
1627 1617
 
1628
-		}
1629
-		else {
1618
+		} else {
1630 1619
 			$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1631 1620
 			$product_title = '<i>'.__('This product does not exist', 'wpshop').'</i>';
1632 1621
 			$product_link = '';
@@ -1655,8 +1644,7 @@  discard block
 block discarded – undo
1655 1644
 	 			$tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY'];
1656 1645
 	 			$tpl_component_price['TAX_PILOTING'] = (!empty($price_ploting) && $price_ploting == 'HT' ) ? __('ET', 'wpshop') : ''; $product_price_infos['MESSAGE_SAVE_MONEY'];
1657 1646
 	 			$productPrice = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component_price );
1658
-	 		}
1659
-			else {
1647
+	 		} else {
1660 1648
 				$productPrice = wpshop_prices::get_product_price($product, 'price_display', array('mini_output', $output_type) );
1661 1649
 	 		}
1662 1650
 		}
@@ -1671,8 +1659,7 @@  discard block
 block discarded – undo
1671 1659
 		$display_price_state_when_price_is_empty = false;
1672 1660
 		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1673 1661
 			$display_price_state_when_price_is_empty = false;
1674
-		}
1675
-		else if ( !empty( $productPrice ) ) {
1662
+		} else if ( !empty( $productPrice ) ) {
1676 1663
 			$display_price_state_when_price_is_empty = true;
1677 1664
 		}
1678 1665
 		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'mini' ) : '';
@@ -1739,8 +1726,7 @@  discard block
 block discarded – undo
1739 1726
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
1740 1727
 				$content = ob_get_contents();
1741 1728
 				ob_end_clean();
1742
-			}
1743
-			else {
1729
+			} else {
1744 1730
 				$content = wpshop_display::display_template_element($template_part, $tpl_component);
1745 1731
 			}
1746 1732
 			unset($tpl_component);
@@ -1862,8 +1848,7 @@  discard block
 block discarded – undo
1862 1848
 					$option_value = $wpdb->get_var($query);
1863 1849
 					$parent_post = $parent_product['parent_post'];
1864 1850
 					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $parent_post->post_title. ' <br/>('. $option_name . ' : ' . $option_value. ')');
1865
-				}
1866
-				else {
1851
+				} else {
1867 1852
 					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $post->post_title);
1868 1853
 				}
1869 1854
 
@@ -1958,8 +1943,7 @@  discard block
 block discarded – undo
1958 1943
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
1959 1944
 				$product_special_state['output'] = ob_get_contents();
1960 1945
 				ob_end_clean();
1961
-			}
1962
-			else {
1946
+			} else {
1963 1947
 				$product_special_state['output'] = wpshop_display::display_template_element($template_part, $tpl_component);
1964 1948
 			}
1965 1949
 			unset($tpl_component);
@@ -1995,8 +1979,7 @@  discard block
 block discarded – undo
1995 1979
 		/** Si aucun prix trouvé on stop la méthode / If not found price, stop the method */
1996 1980
 		if( empty( $prices_attribute ) ) {
1997 1981
 			return false;
1998
-		}
1999
-		else {
1982
+		} else {
2000 1983
 			/**
2001 1984
 			 * Récupère le prix de base selon le pilotage de prix de la boutique / Get
2002 1985
 			 * the base amount according on the shop price control
@@ -2024,8 +2007,7 @@  discard block
 block discarded – undo
2024 2007
 			if ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) {
2025 2008
 				$price_with_vat = ($base_price * $divider_price_ttc );
2026 2009
 				$price_no_vat 	= $base_price;
2027
-			}
2028
-			else if ( WPSHOP_PRODUCT_PRICE_PILOT == 'TTC' ) {
2010
+			} else if ( WPSHOP_PRODUCT_PRICE_PILOT == 'TTC' ) {
2029 2011
 				$price_with_vat = $base_price;
2030 2012
 				$price_no_vat	= ($price_with_vat / $divider_price_ttc );
2031 2013
 			}
@@ -2118,8 +2100,7 @@  discard block
 block discarded – undo
2118 2100
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2119 2101
 				$button = ob_get_contents();
2120 2102
 				ob_end_clean();
2121
-			}
2122
-			else {
2103
+			} else {
2123 2104
 				$button = wpshop_display::display_template_element($template_part, $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $product_id, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . 'output_type' => $output_type));
2124 2105
 			}
2125 2106
 			unset($tpl_component);
@@ -2161,8 +2142,7 @@  discard block
 block discarded – undo
2161 2142
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2162 2143
 				$quotation_button = ob_get_contents();
2163 2144
 				ob_end_clean();
2164
-			}
2165
-			else {
2145
+			} else {
2166 2146
 				$quotation_button = wpshop_display::display_template_element($template_part, $tpl_component);
2167 2147
 			}
2168 2148
 			unset($tpl_component);
@@ -2213,8 +2193,7 @@  discard block
 block discarded – undo
2213 2193
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2214 2194
 			$galery_output = ob_get_contents();
2215 2195
 			ob_end_clean();
2216
-		}
2217
-		else {
2196
+		} else {
2218 2197
 			$galery_output = wpshop_display::display_template_element($template_part, $tpl_component);
2219 2198
 		}
2220 2199
 		unset($tpl_component);
@@ -2363,8 +2342,7 @@  discard block
 block discarded – undo
2363 2342
 					if ( !empty($content->$attribute_value) ) {
2364 2343
 						if ( !empty($head_wpshop_variation_definition['attributes']) && in_array($content->code, $head_wpshop_variation_definition['attributes']) ) {
2365 2344
 							$variations_output[$post_def->ID]['variation_def'][$content->code] = $content->$attribute_value;
2366
-						}
2367
-						else {
2345
+						} else {
2368 2346
 							$variations_output[$post_def->ID]['variation_dif'][$content->code] = $content->$attribute_value;
2369 2347
 						}
2370 2348
 					}
@@ -2404,8 +2382,7 @@  discard block
 block discarded – undo
2404 2382
 				$tpl_component['VARIATION_DETAIL_PRICE'] = number_format( $p, 2, '.', '').' '.$productCurrency.' '.( ( !empty($price_piloting) && $price_piloting == 'HT' ) ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ) );
2405 2383
 				if ( !empty($price_piloting) && $price_piloting == 'HT' ) {
2406 2384
 
2407
-				}
2408
-				else {
2385
+				} else {
2409 2386
 
2410 2387
 				}
2411 2388
 				$post_obj = $variation['post'];
@@ -2417,17 +2394,14 @@  discard block
 block discarded – undo
2417 2394
 					if ( !empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') {
2418 2395
 						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2419 2396
 							$product_price = ( ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0 ) + $parent_product_infos['parent_post_meta']['price_ht'];
2420
-						}
2421
-						else {
2397
+						} else {
2422 2398
 							$product_price = ( ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0 ) + $parent_product_infos['parent_post_meta']['product_price'];
2423 2399
 						}
2424 2400
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Variation price combined with the parent product price', 'wpshop');
2425
-					}
2426
-					else {
2401
+					} else {
2427 2402
 						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2428 2403
 							$product_price = ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0;
2429
-						}
2430
-						else {
2404
+						} else {
2431 2405
 							$product_price = ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0;
2432 2406
 						}
2433 2407
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Only variation\'s price is used', 'wpshop');
@@ -2498,8 +2472,7 @@  discard block
 block discarded – undo
2498 2472
 			$output .= wpshop_display::display_template_element('wpshop_admin_existing_variation_list', array('ADMIN_EXISTING_VARIATIONS_CONTAINER_CLASS' => '', 'ADMIN_EXISTING_VARIATIONS_CONTAINER' => $existing_variation_list), array(), 'admin');
2499 2473
 			/*	Reset de la liste des résultats pour éviter les comportements indésirables	*/
2500 2474
 			wp_reset_query();
2501
-		}
2502
-		else {
2475
+		} else {
2503 2476
 			$output = __('No variation found for this product. Please use button above for create one', 'wpshop');
2504 2477
 		}
2505 2478
 
@@ -2525,8 +2498,9 @@  discard block
 block discarded – undo
2525 2498
 			if (!empty($product_attribute_order_detail) ) {
2526 2499
 				foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
2527 2500
 					foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
2528
-						if ( !empty($attribute_def->code) )
2529
-							$output_order[$attribute_def->code] = $position;
2501
+						if ( !empty($attribute_def->code) ) {
2502
+													$output_order[$attribute_def->code] = $position;
2503
+						}
2530 2504
 					}
2531 2505
 				}
2532 2506
 			}
@@ -2564,8 +2538,7 @@  discard block
 block discarded – undo
2564 2538
 							if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'custom')) {
2565 2539
 								$tpl_component['VARIATION_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', 'custom'));
2566 2540
 								$position = wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'position', 'custom');
2567
-							}
2568
-							else if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2541
+							} else if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2569 2542
 								$post_def = get_post($attribute_value);
2570 2543
 								$tpl_component['VARIATION_VALUE'] = stripslashes($post_def->post_title);
2571 2544
 								$position = $post_def->menu_order;
@@ -2899,8 +2872,7 @@  discard block
 block discarded – undo
2899 2872
 				//Get Summary cart
2900 2873
 				$response['product_output'] = $wpshop_products->wps_get_summary_variations_product( $product_id, $the_product, ( !empty( $wpshop_variation_selected ) || !empty( $wpshop_free_variation ) ? true : false )  );
2901 2874
 				$response_status = true;
2902
-			}
2903
-			else {
2875
+			} else {
2904 2876
 				//Product without variations
2905 2877
 				$product_data = wpshop_products::get_product_data($product_id);
2906 2878
 				$response['product_price_output'] = wpshop_prices::get_product_price($product_data, 'price_display', 'complete_sheet');
@@ -2971,8 +2943,7 @@  discard block
 block discarded – undo
2971 2943
 						}
2972 2944
 					}
2973 2945
 				}
2974
-			}
2975
-			else {
2946
+			} else {
2976 2947
 				// Get combined variations
2977 2948
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_key = '_wpshop_variations_attribute_def' AND P_META.meta_value = '" . serialize($query_variation) . "'", $product_id);
2978 2949
 				$combined_variation_id = $wpdb->get_var($query);
@@ -2995,12 +2966,10 @@  discard block
 block discarded – undo
2995 2966
 						}
2996 2967
 					}
2997 2968
 					$product_to_add_to_cart['display_lower_price'] = true;
2998
-				}
2999
-				else {
2969
+				} else {
3000 2970
 					$product_to_add_to_cart[$product_id]['variations'] = array();
3001 2971
 				}
3002
-			}
3003
-			else {
2972
+			} else {
3004 2973
 				$product_to_add_to_cart['text_from'] = '';
3005 2974
 				$product_to_add_to_cart[$product_id]['variations'] = ( !empty($product_variation_type) && $product_variation_type == 'single' ) ? $single_variations : $combined_variations;
3006 2975
 			}
@@ -3051,11 +3020,9 @@  discard block
 block discarded – undo
3051 3020
 
3052 3021
 						if( !empty($discount_config['type']) && $discount_config['type'] == 'discount_amount' ) {
3053 3022
 							$product_into_cart['discount_amount'] = $discount_amount + $product_into_cart['discount_amount'];
3054
-						}
3055
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'discount_rate' ) {
3023
+						} elseif( !empty($discount_config['type']) && $discount_config['type'] == 'discount_rate' ) {
3056 3024
 							$product_into_cart['discount_rate'] = $discount_rate + $discount_config['value'];
3057
-						}
3058
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'special_price' ) {
3025
+						} elseif( !empty($discount_config['type']) && $discount_config['type'] == 'special_price' ) {
3059 3026
 							$product_into_cart['special_price'] = $special_price + $discount_config['value'];
3060 3027
 						}
3061 3028
 					}
@@ -3076,14 +3043,12 @@  discard block
 block discarded – undo
3076 3043
 					$product_into_cart['product_price'] = $variations_discount_total_price['price_ati'];
3077 3044
 					$product_into_cart['price_ht'] = $variations_discount_total_price['price_et'];
3078 3045
 					$product_into_cart['tva'] = $variations_discount_total_price['vat_amount'];
3079
-				}
3080
-				else {
3046
+				} else {
3081 3047
 					$product_into_cart['product_price'] = $variations_total_price['price_ati'];
3082 3048
 					$product_into_cart['price_ht'] = $variations_total_price['price_et'];
3083 3049
 					$product_into_cart['tva'] = $variations_total_price['vat_amount'];
3084 3050
 				}
3085
-			}
3086
-			else {
3051
+			} else {
3087 3052
 				// Add variations price to product price
3088 3053
 				if( !empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati']) ) {
3089 3054
 					$product_into_cart['price_ttc_before_discount'] = ( $product_into_cart['product_price'] + $variations_total_price['price_ati'] );
@@ -3092,8 +3057,7 @@  discard block
 block discarded – undo
3092 3057
 					$product_into_cart['product_price'] += $variations_discount_total_price['price_ati'];
3093 3058
 					$product_into_cart['price_ht'] += $variations_discount_total_price['price_et'];
3094 3059
 					$product_into_cart['tva'] += $variations_discount_total_price['vat_amount'];
3095
-				}
3096
-				else {
3060
+				} else {
3097 3061
 					$product_into_cart['product_price'] += $variations_total_price['price_ati'];
3098 3062
 					$product_into_cart['price_ht'] += $variations_total_price['price_et'];
3099 3063
 					$product_into_cart['tva'] += $variations_total_price['vat_amount'];
@@ -3107,17 +3071,14 @@  discard block
 block discarded – undo
3107 3071
 
3108 3072
 					if( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_amount' ) {
3109 3073
 						$product_into_cart['discount_amount'] = $discount_amount +  $parent_discount_config['value'];
3110
-					}
3111
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate' ) {
3074
+					} elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate' ) {
3112 3075
 						$product_into_cart['discount_rate'] = $discount_rate + $parent_discount_config['value'];
3113
-					}
3114
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price' ) {
3076
+					} elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price' ) {
3115 3077
 						$product_into_cart['special_price'] = $special_price + $parent_discount_config['value'];
3116 3078
 					}
3117 3079
 				}
3118 3080
 			}
3119
-		}
3120
-		else {
3081
+		} else {
3121 3082
 			// If product have just Free variations
3122 3083
 			$discount_config = wpshop_prices::check_discount_for_product( $head_product_id );
3123 3084
 			if( !empty($discount_config) ) {
@@ -3161,8 +3122,7 @@  discard block
 block discarded – undo
3161 3122
 					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3162 3123
 						$variation_attribute_ordered['attribute_list'][$output_order[$variation_attribute_code]] = $display_data;
3163 3124
 					}
3164
-				}
3165
-				else {
3125
+				} else {
3166 3126
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3167 3127
 					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3168 3128
 						$variation_attribute_ordered['attribute_list'][] = $display_data;
@@ -3202,8 +3162,7 @@  discard block
 block discarded – undo
3202 3162
 					$variation_definition = explode('-_variation_val_-', $build_variation);
3203 3163
 					$attribute_code = $variation_definition[0];
3204 3164
 					$attribute_selected_value = $variation_definition[1];
3205
-				}
3206
-				else {
3165
+				} else {
3207 3166
 					$attribute_code = $build_variation_key;
3208 3167
 					$attribute_selected_value = $build_variation;
3209 3168
 				}
@@ -3291,8 +3250,7 @@  discard block
 block discarded – undo
3291 3250
 				$output .= '<li>' .sprintf( __( 'Ordered by %s %s (%s) on %s (Order ref. : %s)', 'wpshop'), $sales_information['customer_name'], $sales_information['customer_firstname'], $sales_information['customer_email'], $sales_information['order_date'], $sales_information['order_key'] ). '</li>';
3292 3251
 			}
3293 3252
 			$output .= '</ul>';
3294
-		}
3295
-		else {
3253
+		} else {
3296 3254
 			$output .= __( 'This product has never been ordered', 'wpshop');
3297 3255
 		}
3298 3256
 
@@ -3310,8 +3268,9 @@  discard block
 block discarded – undo
3310 3268
 		if ( count($product_attribute_order_detail) > 0 ) {
3311 3269
 			foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
3312 3270
 				foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
3313
-					if ( !empty($attribute_def->code) )
3314
-						$output_order[$attribute_def->code] = $position;
3271
+					if ( !empty($attribute_def->code) ) {
3272
+											$output_order[$attribute_def->code] = $position;
3273
+					}
3315 3274
 				}
3316 3275
 			}
3317 3276
 		}
@@ -3331,8 +3290,7 @@  discard block
 block discarded – undo
3331 3290
 				if ( !empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
3332 3291
 					$tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value;
3333 3292
 				}
3334
-			}
3335
-			else {
3293
+			} else {
3336 3294
 				$variation_attribute_ordered = wpshop_products::get_selected_variation_display( $product_definition_value, $output_order, 'selection_summary' );
3337 3295
 			}
3338 3296
 		}
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 	/**
1132 1132
 	 * Add a product into the db. This function is used for the EDI
1133 1133
 	 * @param $name Name of the product
1134
-	 * @param $description Description of the product
1134
+	 * @param string $description Description of the product
1135 1135
 	 * @param $attrs List of the attributes and values of the product
1136 1136
 	 * @return boolean
1137 1137
 	*/
@@ -1450,10 +1450,10 @@  discard block
 block discarded – undo
1450 1450
 	/**
1451 1451
 	*	Define output for product
1452 1452
 	*
1453
-	*	@param mixed $initialContent The initial product content defined into wordpress basic admin interface
1453
+	*	@param string $initialContent The initial product content defined into wordpress basic admin interface
1454 1454
 	*	@param integer $product_id The product identifier we want to get and output attribute for
1455 1455
 	*
1456
-	*	@return mixed $content The content to add or to modify the product output in frontend
1456
+	*	@return string $content The content to add or to modify the product output in frontend
1457 1457
 	*/
1458 1458
 	public static function product_complete_sheet_output($initialContent, $product_id) {
1459 1459
 		$content = $attributeContentOutput = '';
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
 
2509 2509
 	/**
2510 2510
 	 * Retrieve and display the variation for a given product
2511
-	 * @param integer $product_id The product identifier to get variation for
2511
+	 * @param integer $post_id The product identifier to get variation for
2512 2512
 	 */
2513 2513
 	public static function wpshop_variation( $post_id = '', $from_admin = false, $order_id = '', $qty = 1 ) {
2514 2514
 		global $wp_query;
@@ -3300,6 +3300,9 @@  discard block
 block discarded – undo
3300 3300
 	}
3301 3301
 
3302 3302
 
3303
+	/**
3304
+	 * @param boolean $has_variation
3305
+	 */
3303 3306
 	function wps_get_summary_variations_product( $product_id, $the_product, $has_variation ) {
3304 3307
 		global $wpdb, $wpshop_payment;
3305 3308
 		$output = '';
Please login to merge, or discard this patch.
Spacing   +802 added lines, -802 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 /**
3 3
 * Products management method file
4 4
 *
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 */
11 11
 
12 12
 /*	Check if file is include. No direct access possible with file url	*/
13
-if ( !defined( 'WPSHOP_VERSION' ) ) {
14
-	die( __('Access is not allowed by this way', 'wpshop') );
13
+if (!defined('WPSHOP_VERSION')) {
14
+	die(__('Access is not allowed by this way', 'wpshop'));
15 15
 }
16 16
 
17 17
 /**
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 		die();
38 38
 	}
39 39
 
40
-	function products_list_js () {
40
+	function products_list_js() {
41 41
 		global $wpdb;
42 42
 		/** Create a JS Array of products **/
43 43
 // 		$query = $wpdb->prepare('SELECT ID, post_title FROM ' .$wpdb->posts. '  WHERE post_type = %s AND post_status = %s', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish');
44 44
 // 		$products_post = $wpdb->get_results( $query );
45 45
 
46
-		$products_post = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'post_status' => 'publish', 'posts_per_page' => -1 ) );
46
+		$products_post = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'post_status' => 'publish', 'posts_per_page' => -1));
47 47
 
48
-		if ( !empty( $products_post ) ) {
49
-			$products_js_array  = 'var products = [';
50
-			foreach ( $products_post as $product ) {
51
-				$barcode = get_post_meta( $product->ID, '_barcode', true);
52
-				$products_js_array .= '{label:"#' .$product->ID. ' ' .str_replace('"', '', $product->post_title). ' - ' .( (!empty($barcode) ) ? $barcode : '' ). '", ';
53
-				$products_js_array .= 'value:"' .$product->ID. '", ';
54
-				$products_js_array .= ( !empty($barcode) ) ? 'desc:"' .$barcode. '"},' : '},';
48
+		if (!empty($products_post)) {
49
+			$products_js_array = 'var products = [';
50
+			foreach ($products_post as $product) {
51
+				$barcode = get_post_meta($product->ID, '_barcode', true);
52
+				$products_js_array .= '{label:"#' . $product->ID . ' ' . str_replace('"', '', $product->post_title) . ' - ' . ((!empty($barcode)) ? $barcode : '') . '", ';
53
+				$products_js_array .= 'value:"' . $product->ID . '", ';
54
+				$products_js_array .= (!empty($barcode)) ? 'desc:"' . $barcode . '"},' : '},';
55 55
 			}
56 56
 			$products_js_array .= '];';
57 57
 		}
58
-		$output = wpshop_display::display_template_element('wps_orders_products_list_js', array('PRODUCTS_JS_ARRAY' => $products_js_array) , array(), 'admin');
58
+		$output = wpshop_display::display_template_element('wps_orders_products_list_js', array('PRODUCTS_JS_ARRAY' => $products_js_array), array(), 'admin');
59 59
 		return $output;
60 60
 	}
61 61
 
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 				'with_front'		=> false,
78 78
 		);
79 79
 
80
-		if ( empty( $options['wpshop_catalog_product_slug'] ) || $options['wpshop_catalog_product_slug'] == '/' ) {
80
+		if (empty($options['wpshop_catalog_product_slug']) || $options['wpshop_catalog_product_slug'] == '/') {
81 81
 			$slug = false;
82 82
 		} else {
83 83
 			$slug['slug'] = $options['wpshop_catalog_product_slug'];
84
-			if( !empty( $options['wpshop_catalog_product_slug_with_category'] ) ) {
84
+			if (!empty($options['wpshop_catalog_product_slug_with_category'])) {
85 85
 				$slug['slug'] .= '/%' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '%';
86 86
 			}
87 87
 		}
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
 		/*	Définition des produits 	*/
91 91
 		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, array(
92 92
 			'labels' => array(
93
-				'name'					=> __( 'Products', 'wpshop' ),
94
-				'singular_name' 		=> __( 'Catalog', 'wpshop' ),
95
-				'add_new_item' 			=> __( 'Add new product', 'wpshop' ),
96
-				'add_new' 				=> __( 'Add new product', 'wpshop' ),
97
-				'add_new_item' 			=> __( 'Add new product', 'wpshop' ),
98
-				'edit_item' 			=> __( 'Edit product', 'wpshop' ),
99
-				'new_item' 				=> __( 'New product', 'wpshop' ),
100
-				'view_item' 			=> __( 'View product', 'wpshop' ),
101
-				'search_items' 			=> __( 'Search products', 'wpshop' ),
102
-				'not_found' 			=> __( 'No products found', 'wpshop' ),
103
-				'not_found_in_trash' 	=> __( 'No products found in Trash', 'wpshop' ),
93
+				'name'					=> __('Products', 'wpshop'),
94
+				'singular_name' 		=> __('Catalog', 'wpshop'),
95
+				'add_new_item' 			=> __('Add new product', 'wpshop'),
96
+				'add_new' 				=> __('Add new product', 'wpshop'),
97
+				'add_new_item' 			=> __('Add new product', 'wpshop'),
98
+				'edit_item' 			=> __('Edit product', 'wpshop'),
99
+				'new_item' 				=> __('New product', 'wpshop'),
100
+				'view_item' 			=> __('View product', 'wpshop'),
101
+				'search_items' 			=> __('Search products', 'wpshop'),
102
+				'not_found' 			=> __('No products found', 'wpshop'),
103
+				'not_found_in_trash' 	=> __('No products found in Trash', 'wpshop'),
104 104
 				'parent_item_colon' 	=> ''
105 105
 			),
106 106
 			'supports' 				=> unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT),
@@ -108,26 +108,26 @@  discard block
 block discarded – undo
108 108
 			'has_archive'			=> false,
109 109
 			'show_in_nav_menus' 	=> true,
110 110
 			//'rewrite' 				=> false,	//	For information see below
111
-			'taxonomies' 			=> array( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES ),
111
+			'taxonomies' 			=> array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES),
112 112
 			'menu_icon' 			=> 'dashicons-archive',
113 113
 			'rewrite' 				=> $slug,
114 114
 		));
115 115
 
116 116
 		/*	Définition des variations de produit (Déclinaisons)	*/
117
-		register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, array(
117
+		register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, array(
118 118
 			'labels'				=> array(
119
-				'name' 					=> __( 'Variations', 'wpshop' ),
120
-				'singular_name' 		=> __( 'Variation', 'wpshop' ),
121
-				'add_new' 				=> __( 'Add Variation', 'wpshop' ),
122
-				'add_new_item' 			=> __( 'Add New Variation', 'wpshop' ),
123
-				'edit' 					=> __( 'Edit', 'wpshop' ),
124
-				'edit_item' 			=> __( 'Edit Variation', 'wpshop' ),
125
-				'new_item' 				=> __( 'New Variation', 'wpshop' ),
126
-				'view' 					=> __( 'View Variation', 'wpshop' ),
127
-				'view_item' 			=> __( 'View Variation', 'wpshop' ),
128
-				'search_items' 			=> __( 'Search Variations', 'wpshop' ),
129
-				'not_found' 			=> __( 'No Variations found', 'wpshop' ),
130
-				'not_found_in_trash' 	=> __( 'No Variations found in trash', 'wpshop' ),
119
+				'name' 					=> __('Variations', 'wpshop'),
120
+				'singular_name' 		=> __('Variation', 'wpshop'),
121
+				'add_new' 				=> __('Add Variation', 'wpshop'),
122
+				'add_new_item' 			=> __('Add New Variation', 'wpshop'),
123
+				'edit' 					=> __('Edit', 'wpshop'),
124
+				'edit_item' 			=> __('Edit Variation', 'wpshop'),
125
+				'new_item' 				=> __('New Variation', 'wpshop'),
126
+				'view' 					=> __('View Variation', 'wpshop'),
127
+				'view_item' 			=> __('View Variation', 'wpshop'),
128
+				'search_items' 			=> __('Search Variations', 'wpshop'),
129
+				'not_found' 			=> __('No Variations found', 'wpshop'),
130
+				'not_found_in_trash' 	=> __('No Variations found in trash', 'wpshop'),
131 131
 				'parent_item_colon' 	=> ''
132 132
 			),
133 133
 			'supports' 				=> unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT),
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 
164 164
 	public static function hidden_meta_boxes($hidden, $screen, $use_defaults) {
165 165
 		global $wpdb;
166
-		if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT === $screen->post_type ) {
167
-			$user_meta_for_wpshop = array('metaboxhidden_'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
168
-			foreach($user_meta_for_wpshop as $meta_to_check){
169
-				$metas_hidden = get_user_meta( get_current_user_id(), $meta_to_check, true );
170
-				if( empty( $metas_hidden ) && !is_array( $metas_hidden ) ) {
171
-					$hidden = unserialize( WPSHOP_PRODUCT_HIDDEN_METABOX );
166
+		if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT === $screen->post_type) {
167
+			$user_meta_for_wpshop = array('metaboxhidden_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
168
+			foreach ($user_meta_for_wpshop as $meta_to_check) {
169
+				$metas_hidden = get_user_meta(get_current_user_id(), $meta_to_check, true);
170
+				if (empty($metas_hidden) && !is_array($metas_hidden)) {
171
+					$hidden = unserialize(WPSHOP_PRODUCT_HIDDEN_METABOX);
172 172
 				}
173 173
 			}
174 174
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	public static function add_meta_boxes() {
182 182
 		global $post, $currentTabContent;
183 183
 
184
-		if(!empty($post->post_type) && ( ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) ) ) {
184
+		if (!empty($post->post_type) && (($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION))) {
185 185
 			/*	Get the attribute set list for the current entity	*/
186 186
 			$attributeEntitySetList = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode));
187 187
 			/*	Check if the meta information of the current product already exists 	*/
@@ -189,19 +189,19 @@  discard block
 block discarded – undo
189 189
 			/*	Check if the product has been saved without meta information set	*/
190 190
 			$attribute_set_id = wpshop_attributes::get_attribute_value_content('product_attribute_set_id', $post->ID, self::currentPageCode);
191 191
 			/*	Unset 'free_product' from list of attributes set	*/
192
-			foreach( $attributeEntitySetList as $key_attribute_set => $attribute_set ) {
193
-				if( $attribute_set->slug == 'free_product' ) {
192
+			foreach ($attributeEntitySetList as $key_attribute_set => $attribute_set) {
193
+				if ($attribute_set->slug == 'free_product') {
194 194
 					unset($attributeEntitySetList[$key_attribute_set]);
195 195
 					break;
196 196
 				}
197 197
 			}
198 198
 
199 199
 			/*	Check if an attribute has already been choosen for the curernt entity or if the user has to choose a entity set before continuing	*/
200
-			if(((count($attributeEntitySetList) == 1) || ((count($attributeEntitySetList) > 1) && (($post_attribute_set_id > 0) || (isset($attribute_set_id->value) && ($attribute_set_id->value > 0)))))){
201
-				if((count($attributeEntitySetList) == 1) || (($post_attribute_set_id <= 0) && ($attribute_set_id->value <= 0))){
200
+			if (((count($attributeEntitySetList) == 1) || ((count($attributeEntitySetList) > 1) && (($post_attribute_set_id > 0) || (isset($attribute_set_id->value) && ($attribute_set_id->value > 0)))))) {
201
+				if ((count($attributeEntitySetList) == 1) || (($post_attribute_set_id <= 0) && ($attribute_set_id->value <= 0))) {
202 202
 					$post_attribute_set_id = $attributeEntitySetList[0]->id;
203 203
 				}
204
-				elseif(($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)){
204
+				elseif (($post_attribute_set_id <= 0) && ($attribute_set_id->value > 0)) {
205 205
 					$post_attribute_set_id = $attribute_set_id->value;
206 206
 				}
207 207
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
 
210 210
 				$fixed_box_exist = false;
211 211
 				/*	Get all the other attribute set for hte current entity	*/
212
-				if(isset($currentTabContent['box']) && count($currentTabContent['box']) > 0){
213
-					foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
214
-						if(!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type'] == 'movable-tab')){
212
+				if (isset($currentTabContent['box']) && count($currentTabContent['box']) > 0) {
213
+					foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
214
+						if (!empty($currentTabContent['box'][$boxIdentifier . '_backend_display_type']) && ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'movable-tab')) {
215 215
 							add_meta_box('wpshop_product_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_products', 'meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default', array('boxIdentifier' => $boxIdentifier));
216 216
 						}
217 217
 						else $fixed_box_exist = true;
218 218
 					}
219 219
 				}
220
-				if ( $fixed_box_exist ) {
220
+				if ($fixed_box_exist) {
221 221
 					add_meta_box('wpshop_product_fixed_tab', __('Product data', 'wpshop'), array('wpshop_products', 'product_data_meta_box'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'high', array('currentTabContent' => $currentTabContent));
222 222
 					add_meta_box('wpshop_product_fixed_tab', __('Product data', 'wpshop'), array('wpshop_products', 'product_data_meta_box'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'normal', 'high', array('currentTabContent' => $currentTabContent));
223 223
 				}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 				/**	Product option	*/
230 230
 				add_meta_box('wpshop_product_options', __('Options', 'wpshop'), array('wpshop_products', 'product_options_meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'side', 'default');
231 231
 			}
232
-			else if ( count($attributeEntitySetList) > 1 ) {
232
+			else if (count($attributeEntitySetList) > 1) {
233 233
 				$input_def['id'] = 'product_attribute_set_id';
234 234
 				$input_def['name'] = 'product_attribute_set_id';
235 235
 				$input_def['value'] = '';
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 				$input_def['value'] = '';
240 240
 				foreach ($attributeEntitySetList as $set) {
241
-					if( $set->default_set == 'yes' ) {
241
+					if ($set->default_set == 'yes') {
242 242
 						$input_def['value'] = $set->id;
243 243
 					}
244 244
 				}
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				$currentTabContent['boxContent']['attribute_set_selector'] = '
247 247
 	<ul class="attribute_set_selector" >
248 248
 		<li class="attribute_set_selector_title_select" ><label for="title" >' . __('Choose a title for your product', 'wpshop') . '</label></li>
249
-		<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . __('Choose an attribute group for this product', 'wpshop') . '</label>&nbsp;'.wpshop_form::check_input_type($input_def, self::currentPageCode.'_attribute[integer]').'</li>
249
+		<li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . __('Choose an attribute group for this product', 'wpshop') . '</label>&nbsp;' . wpshop_form::check_input_type($input_def, self::currentPageCode . '_attribute[integer]') . '</li>
250 250
 		<li class="attribute_set_selector_save_instruction" >' . __('Save the product with the "Save draft" button on the right side', 'wpshop') . '</li>
251 251
 		<li class="attribute_set_selector_after_save_instruction" >' . __('Once the group chosen, the different attribute will be displayed here', 'wpshop') . '</li>
252 252
 	</ul>';
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @param object $post
264 264
 	 */
265
-	public static function product_options_meta_box_content( $post ) {
265
+	public static function product_options_meta_box_content($post) {
266 266
 		$output = '';
267 267
 
268
-		$product_current_options = get_post_meta( $post->ID, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', true);
268
+		$product_current_options = get_post_meta($post->ID, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', true);
269 269
 
270 270
 		$tpl_component = array();
271 271
 		$tpl_component['ADMIN_PRODUCT_OPTION_FOR_CART_AUTOADD_CHECKBOX_STATE'] = (!empty($product_current_options['cart']) && !empty($product_current_options['cart']['auto_add'])) ? ' checked="checked"' : '';
@@ -284,25 +284,25 @@  discard block
 block discarded – undo
284 284
 
285 285
 		echo '<div id="fixed-tabs" class="wpshop_tabs wpshop_detail_tabs wpshop_product_attribute_tabs" >
286 286
 				<ul>';
287
-		if(!empty($currentTabContent['box'])){
288
-			foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
289
-				if(!empty($currentTabContent['boxContent'][$boxIdentifier])) {
290
-					if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') {
291
-						echo '<li><a href="#tabs-'.sanitize_title($boxIdentifier).'">'.__($boxTitle, 'wpshop').'</a></li>';
287
+		if (!empty($currentTabContent['box'])) {
288
+			foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
289
+				if (!empty($currentTabContent['boxContent'][$boxIdentifier])) {
290
+					if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') {
291
+						echo '<li><a href="#tabs-' . sanitize_title($boxIdentifier) . '">' . __($boxTitle, 'wpshop') . '</a></li>';
292 292
 					}
293 293
 				}
294 294
 			}
295 295
 		}
296
-		echo '<li><a href="#tabs-product-related">'.__('Related products', 'wpshop').'</a></li>';
297
-		echo '<li><a href="#tabs-product-provider">'.__('Providers', 'wpshop').'</a></li>';
298
-		echo '<li class="wpshop_product_data_display_tab" ><a href="#tabs-product-display">'.__('Product display', 'wpshop').'</a></li>';
296
+		echo '<li><a href="#tabs-product-related">' . __('Related products', 'wpshop') . '</a></li>';
297
+		echo '<li><a href="#tabs-product-provider">' . __('Providers', 'wpshop') . '</a></li>';
298
+		echo '<li class="wpshop_product_data_display_tab" ><a href="#tabs-product-display">' . __('Product display', 'wpshop') . '</a></li>';
299 299
 		echo '</ul>';
300 300
 
301
-		if(!empty($currentTabContent['box'])){
302
-			foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){
303
-				if(!empty($currentTabContent['boxContent'][$boxIdentifier])) {
304
-					if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') {
305
-						echo '<div id="tabs-'.sanitize_title($boxIdentifier).'">'.$currentTabContent['boxContent'][$boxIdentifier].'</div>';
301
+		if (!empty($currentTabContent['box'])) {
302
+			foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) {
303
+				if (!empty($currentTabContent['boxContent'][$boxIdentifier])) {
304
+					if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') {
305
+						echo '<div id="tabs-' . sanitize_title($boxIdentifier) . '">' . $currentTabContent['boxContent'][$boxIdentifier] . '</div>';
306 306
 					}
307 307
 				}
308 308
 			}
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 	 * @param object $post The current edited post
325 325
 	 * @return string
326 326
 	 */
327
-	public static function related_products_meta_box_content( $post ) {
327
+	public static function related_products_meta_box_content($post) {
328 328
 		$content = $existing_selection = '';
329 329
 
330
-		if( !empty($post->ID) ) {
330
+		if (!empty($post->ID)) {
331 331
 			$related_products_id = get_post_meta($post->ID, WPSHOP_PRODUCT_RELATED_PRODUCTS, true);
332
-			if( !empty($related_products_id) && !empty($related_products_id[0]) ) {
332
+			if (!empty($related_products_id) && !empty($related_products_id[0])) {
333 333
 				foreach ($related_products_id as $related_product_id) {
334 334
 					$existing_selection .= '<option selected value="' . $related_product_id . '" >' . get_the_title($related_product_id) . '</option>';
335 335
 				}
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 	 * @param object $post The current edited post
350 350
 	 * @return string
351 351
 	 */
352
-	public static function provider_products_meta_box_content( $post ) {
352
+	public static function provider_products_meta_box_content($post) {
353 353
 		$content = $existing_selection = '';
354 354
 
355
-		if( !empty($post->ID) ) {
355
+		if (!empty($post->ID)) {
356 356
 			$providers_id = get_post_meta($post->ID, WPSHOP_PRODUCT_PROVIDER, true);
357
-			if( !empty($providers_id) && !empty($providers_id[0]) ) {
357
+			if (!empty($providers_id) && !empty($providers_id[0])) {
358 358
 				foreach ($providers_id as $provider_id) {
359
-					$existing_selection .= '<option selected value="' . $provider_id . '" >' . get_the_title( $provider_id ) . '</option>';
359
+					$existing_selection .= '<option selected value="' . $provider_id . '" >' . get_the_title($provider_id) . '</option>';
360 360
 				}
361 361
 			}
362 362
 		}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * Define the metabox content for the action box
374 374
 	 * @param obejct $post The current element being edited
375 375
 	 */
376
-	public static function product_actions_meta_box_content( $post ) {
376
+	public static function product_actions_meta_box_content($post) {
377 377
 		$output = '';
378 378
 		/*
379 379
 		 * Template parameters
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		$template_part = 'wpshop_duplicate_product';
382 382
 		$tpl_component = array();
383 383
 		$tpl_component['PRODUCT_ID'] = $post->ID;
384
-		$tpl_component['PRINT_PRODUCT_SHEET_LINK'] = WPSHOP_TEMPLATES_URL.'product_sheet.php?pid='.$post->ID;
384
+		$tpl_component['PRINT_PRODUCT_SHEET_LINK'] = WPSHOP_TEMPLATES_URL . 'product_sheet.php?pid=' . $post->ID;
385 385
 		/*
386 386
 		 * Build template
387 387
 		*/
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	/**
395 395
 	 *	Define the content of the product main information box
396 396
 	 */
397
-	public static function meta_box_content($post, $metaboxArgs){
397
+	public static function meta_box_content($post, $metaboxArgs) {
398 398
 		global $currentTabContent;
399 399
 
400 400
 		/*	Add the extra fields defined by the default attribute group in the general section	*/
@@ -407,19 +407,19 @@  discard block
 block discarded – undo
407 407
 	 * @param object $post The current element being edited
408 408
 	 * @return string The metabox content
409 409
 	 */
410
-	public static function product_frontend_display_config_meta_box( $post ) {
410
+	public static function product_frontend_display_config_meta_box($post) {
411 411
 		$content = '';
412 412
 
413 413
 		$product_attribute_frontend_display_config = null;
414
-		if( !empty($post->ID) ) {
414
+		if (!empty($post->ID)) {
415 415
 			$product_attribute_frontend_display_config = get_post_meta($post->ID, WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
416 416
 
417 417
 			$extra_options = get_option('wpshop_extra_options', array());
418
-			$column_count = (!empty($extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY'])?$extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY']:3);
419
-			$attribute_list = wpshop_attributes::getElementWithAttributeAndValue(wpshop_entities::get_entity_identifier_from_code( self::currentPageCode ), $post->ID, WPSHOP_CURRENT_LOCALE);
418
+			$column_count = (!empty($extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY']) ? $extra_options['WPSHOP_COLUMN_NUMBER_PRODUCT_EDITION_FOR_FRONT_DISPLAY'] : 3);
419
+			$attribute_list = wpshop_attributes::getElementWithAttributeAndValue(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $post->ID, WPSHOP_CURRENT_LOCALE);
420 420
 			$column = 1;
421 421
 
422
-			if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) {
422
+			if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') {
423 423
 				$sub_tpl_component = array();
424 424
 				$sub_tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_NAME'] = __('Action on product', 'wpshop');
425 425
 
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 				$tpl_component['ADMIN_ATTRIBUTE_FD_ID'] = $post->ID . '_product_action_button_add_to_cart';
430 430
 				$button_is_set_to_be_displayed = (WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no';
431 431
 
432
-				$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display( $button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'complete_sheet') ? ' checked="checked"' : '';
433
-				$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display( $button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'mini_output') ? ' checked="checked"' : '';
432
+				$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display($button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'complete_sheet') ? ' checked="checked"' : '';
433
+				$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display($button_is_set_to_be_displayed, $product_attribute_frontend_display_config, 'product_action_button', 'add_to_cart', 'mini_output') ? ' checked="checked"' : '';
434 434
 				$sub_tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_CONTENT'] = wpshop_display::display_template_element('wpshop_admin_attr_config_for_front_display', $tpl_component, array(), 'admin');
435 435
 				unset($tpl_component);
436 436
 
@@ -440,21 +440,21 @@  discard block
 block discarded – undo
440 440
 				$sub_content[1] = wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display', $sub_tpl_component, array(), 'admin');
441 441
 			}
442 442
 
443
-			if ( !empty($attribute_list[$post->ID]) && is_array($attribute_list[$post->ID]) ) {
444
-				foreach ( $attribute_list[$post->ID] as $attribute_set_section_name => $attribute_set_section_content ) {
445
-					if ( !isset($sub_content[$column]) ) {
443
+			if (!empty($attribute_list[$post->ID]) && is_array($attribute_list[$post->ID])) {
444
+				foreach ($attribute_list[$post->ID] as $attribute_set_section_name => $attribute_set_section_content) {
445
+					if (!isset($sub_content[$column])) {
446 446
 						$sub_content[$column] = '';
447 447
 					}
448 448
 
449 449
 					$attribute_sub_output = '';
450
-					foreach ( $attribute_set_section_content['attributes'] as $attribute_id => $attribute_def ) {
451
-						if ( $attribute_def['attribute_code'] != 'product_attribute_set_id' ) {
450
+					foreach ($attribute_set_section_content['attributes'] as $attribute_id => $attribute_def) {
451
+						if ($attribute_def['attribute_code'] != 'product_attribute_set_id') {
452 452
 							$tpl_component = array();
453 453
 							$tpl_component['ADMIN_ATTRIBUTE_LABEL'] = $attribute_def['frontend_label'];
454 454
 							$tpl_component['ADMIN_ATTRIBUTE_FD_NAME'] = self::currentPageCode . '_attr_frontend_display[attribute][' . $attribute_def['attribute_code'] . ']';
455 455
 							$tpl_component['ADMIN_ATTRIBUTE_FD_ID'] = $post->ID . '_' . $attribute_def['attribute_code'];
456
-							$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display( $attribute_def['is_visible_in_front'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'complete_sheet') ? ' checked="checked"' : '';
457
-							$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display( $attribute_def['is_visible_in_front_listing'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'mini_output') ? ' checked="checked"' : '';
456
+							$tpl_component['ADMIN_ATTRIBUTE_COMPLETE_SHEET_CHECK'] = wpshop_attributes::check_attribute_display($attribute_def['is_visible_in_front'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'complete_sheet') ? ' checked="checked"' : '';
457
+							$tpl_component['ADMIN_ATTRIBUTE_MINI_OUTPUT_CHECK'] = wpshop_attributes::check_attribute_display($attribute_def['is_visible_in_front_listing'], $product_attribute_frontend_display_config, 'attribute', $attribute_def['attribute_code'], 'mini_output') ? ' checked="checked"' : '';
458 458
 							$attribute_sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_config_for_front_display', $tpl_component, array(), 'admin');
459 459
 							unset($tpl_component);
460 460
 						}
@@ -465,18 +465,18 @@  discard block
 block discarded – undo
465 465
 					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_CONTENT'] = $attribute_sub_output;
466 466
 					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_FD_NAME'] = self::currentPageCode . '_attr_frontend_display[attribute_set_section][' . $attribute_set_section_content['code'] . ']';
467 467
 					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_FD_ID'] = $attribute_set_section_content['code'];
468
-					$ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK = wpshop_attributes::check_attribute_display( $attribute_set_section_content['display_on_frontend'], $product_attribute_frontend_display_config, 'attribute_set_section', $attribute_set_section_content['code'], 'complete_sheet') ? ' checked="checked"' : '';
469
-					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_INPUT_CHECKBOX'] = '<input type="checkbox" name="' .  self::currentPageCode . '_attr_frontend_display[attribute_set_section][' . $attribute_set_section_content['code'] . '][complete_sheet]" id="' .  $attribute_set_section_content['code'] . '_complete_sheet" value="yes"' . $ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK . ' /><label for="' .  $attribute_set_section_content['code'] . '_complete_sheet" >' . __('Display in product page', 'wpshop') . '</label>';
468
+					$ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK = wpshop_attributes::check_attribute_display($attribute_set_section_content['display_on_frontend'], $product_attribute_frontend_display_config, 'attribute_set_section', $attribute_set_section_content['code'], 'complete_sheet') ? ' checked="checked"' : '';
469
+					$tpl_component['ADMIN_ATTRIBUTE_SET_SECTION_INPUT_CHECKBOX'] = '<input type="checkbox" name="' . self::currentPageCode . '_attr_frontend_display[attribute_set_section][' . $attribute_set_section_content['code'] . '][complete_sheet]" id="' . $attribute_set_section_content['code'] . '_complete_sheet" value="yes"' . $ADMIN_ATTRIBUTE_SET_SECTION_COMPLETE_SHEET_CHECK . ' /><label for="' . $attribute_set_section_content['code'] . '_complete_sheet" >' . __('Display in product page', 'wpshop') . '</label>';
470 470
 					$sub_content[$column] .= wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display', $tpl_component, array(), 'admin');
471 471
 					$column++;
472
-					if ( $column > $column_count ){
472
+					if ($column > $column_count) {
473 473
 						$column = 1;
474 474
 					}
475 475
 				}
476 476
 			}
477 477
 			$tpl_component = array();
478 478
 			$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] = '';
479
-			for ( $i=1; $i<=$column_count; $i++ ) {
479
+			for ($i = 1; $i <= $column_count; $i++) {
480 480
 				if (!empty($sub_content[$i]))
481 481
 					$tpl_component['ADMIN_ATTRIBUTE_FRONTEND_DISPLAY_CONTENT'] .= '<div class="alignleft" >' . $sub_content[$i] . '</div>';
482 482
 			}
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$tpl_component['ADMIN_PRODUCT_ATTRIBUTE_FRONTEND_DISPLAY_MAIN_CHOICE_CHECK'] = empty($product_attribute_frontend_display_config) ? ' checked="checked"' : '';
485 485
 			$tpl_component['ADMIN_ATTRIBUTE_FD_NAME'] = self::currentPageCode . '_attr_frontend_display';
486 486
 
487
-			$content = wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display_default_choice',$tpl_component, array(), 'admin') . '<div class="wpshop_cls"></div>';
487
+			$content = wpshop_display::display_template_element('wpshop_admin_attr_set_section_for_front_display_default_choice', $tpl_component, array(), 'admin') . '<div class="wpshop_cls"></div>';
488 488
 		}
489 489
 
490 490
 		return $content;
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 
500 500
 		$data = array(array('code' => 'title', 'frontend_label' => __('Product name', 'wpshop')), array('code' => 'date', 'frontend_label' => __('Date added', 'wpshop')), array('code' => 'modified', 'frontend_label' => __('Date modified', 'wpshop')));
501 501
 
502
-		$query = $wpdb->prepare("SELECT code, frontend_label FROM ".WPSHOP_DBT_ATTRIBUTE." WHERE is_used_for_sort_by = %s",  'yes');
502
+		$query = $wpdb->prepare("SELECT code, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE is_used_for_sort_by = %s", 'yes');
503 503
 		$results = $wpdb->get_results($query, ARRAY_A);
504
-		if(!empty($results))$data = array_merge($data, $results);
504
+		if (!empty($results))$data = array_merge($data, $results);
505 505
 
506 506
 		return $data;
507 507
 	}
@@ -513,62 +513,62 @@  discard block
 block discarded – undo
513 513
 		$query = "SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code=%s";
514 514
 		$data = (array)$wpdb->get_row($wpdb->prepare($query, $attr_name));
515 515
 
516
-		if(!empty($data)) {
517
-			if ($data['data_type_to_use'] == 'custom' ) {
516
+		if (!empty($data)) {
517
+			if ($data['data_type_to_use'] == 'custom') {
518 518
 				// Find which table to take
519
-				if($data['data_type']=='datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; }
520
-				elseif($data['data_type']=='decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; }
521
-				elseif($data['data_type']=='integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; }
522
-				elseif($data['data_type']=='options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; }
523
-				elseif($data['data_type']=='text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; }
524
-				elseif($data['data_type']=='varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
525
-
526
-				if(isset($table_name)) {
519
+				if ($data['data_type'] == 'datetime') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; }
520
+				elseif ($data['data_type'] == 'decimal') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; }
521
+				elseif ($data['data_type'] == 'integer') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; }
522
+				elseif ($data['data_type'] == 'options') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; }
523
+				elseif ($data['data_type'] == 'text') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; }
524
+				elseif ($data['data_type'] == 'varchar') { $table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; }
525
+
526
+				if (isset($table_name)) {
527 527
 					// If the value is an id of a select, radio or checkbox
528
-					if(in_array($data['backend_input'], array('select','multiple-select', 'radio','checkbox'))) {
528
+					if (in_array($data['backend_input'], array('select', 'multiple-select', 'radio', 'checkbox'))) {
529 529
 
530 530
 						$query = $wpdb->prepare("
531
-							SELECT ".$table_name.".entity_id FROM ".$table_name."
532
-							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = ".$table_name.".entity_id ) AND ( P.post_status = 'publish' ) )
533
-							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE." AS ATT ON ATT.id = ".$table_name.".attribute_id
534
-							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." AS ATT_OPT ON ".$table_name.".value = ATT_OPT.id
535
-							WHERE ATT.code=%s AND ( ATT_OPT.value=%s OR ATT_OPT.value=%s )", $attr_name, strtolower( __( $attr_value, 'wpshop' ) ), $attr_value
531
+							SELECT ".$table_name . ".entity_id FROM " . $table_name . "
532
+							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = " . $table_name . ".entity_id ) AND ( P.post_status = 'publish' ) )
533
+							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE . " AS ATT ON ATT.id = " . $table_name . ".attribute_id
534
+							LEFT JOIN ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS ATT_OPT ON " . $table_name . ".value = ATT_OPT.id
535
+							WHERE ATT.code=%s AND ( ATT_OPT.value=%s OR ATT_OPT.value=%s )", $attr_name, strtolower(__($attr_value, 'wpshop')), $attr_value
536 536
 						);
537 537
 						$data = $wpdb->get_results($query);
538 538
 					}
539 539
 					else {
540 540
 
541 541
 						$query = $wpdb->prepare("
542
-							SELECT ".$table_name.".entity_id FROM ".$table_name."
543
-							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = ".$table_name.".entity_id ) AND ( P.post_status = 'publish' ) )
544
-							INNER JOIN ".WPSHOP_DBT_ATTRIBUTE." AS ATT ON ATT.id = ".$table_name.".attribute_id
545
-								INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = ".$table_name.".entity_id ) AND ( P.post_status = 'publish' ) )
546
-							WHERE ATT.code=%s AND ".$table_name.".value=%s", $attr_name, sprintf('%.5f', $attr_value) // force useless zero like 48.58000
542
+							SELECT ".$table_name . ".entity_id FROM " . $table_name . "
543
+							INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = " . $table_name . ".entity_id ) AND ( P.post_status = 'publish' ) )
544
+							INNER JOIN ".WPSHOP_DBT_ATTRIBUTE . " AS ATT ON ATT.id = " . $table_name . ".attribute_id
545
+								INNER JOIN {$wpdb->posts} AS P ON ( ( P.ID = " . $table_name . ".entity_id ) AND ( P.post_status = 'publish' ) )
546
+							WHERE ATT.code=%s AND ".$table_name . ".value=%s", $attr_name, sprintf('%.5f', $attr_value) // force useless zero like 48.58000
547 547
 						);
548 548
 						$data = $wpdb->get_results($query);
549 549
 
550 550
 					}
551 551
 				}
552
-				else return __('Incorrect shortcode','wpshop');
552
+				else return __('Incorrect shortcode', 'wpshop');
553 553
 			}
554
-			elseif( $data['data_type_to_use'] == 'internal' )  {
554
+			elseif ($data['data_type_to_use'] == 'internal') {
555 555
 				/** Check the ID of manufacturer **/
556
-				$default_value = unserialize( $data['default_value'] );
557
-				if( !empty($default_value) && !empty($default_value['default_value']) ) {
558
-					$query = get_post( $attr_value );
559
-					$pid = ( !empty($query) && !empty($query->ID) ) ? $query->ID : '';
560
-					if ( !empty($pid) ) {
561
-						$query = $wpdb->prepare( 'SELECT post_id AS entity_id FROM '.$wpdb->postmeta.' WHERE post_id = ID AND post_status = %s AND meta_key = %s AND meta_value = %s', 'publish', '_'.$data['code'], $pid);
562
-						$data = $wpdb->get_results( $query );
556
+				$default_value = unserialize($data['default_value']);
557
+				if (!empty($default_value) && !empty($default_value['default_value'])) {
558
+					$query = get_post($attr_value);
559
+					$pid = (!empty($query) && !empty($query->ID)) ? $query->ID : '';
560
+					if (!empty($pid)) {
561
+						$query = $wpdb->prepare('SELECT post_id AS entity_id FROM ' . $wpdb->postmeta . ' WHERE post_id = ID AND post_status = %s AND meta_key = %s AND meta_value = %s', 'publish', '_' . $data['code'], $pid);
562
+						$data = $wpdb->get_results($query);
563 563
 					}
564 564
 				}
565
-			}else return __('Incorrect shortcode','wpshop');
565
+			} else return __('Incorrect shortcode', 'wpshop');
566 566
 
567
-		} else return __('Incorrect shortcode','wpshop');
567
+		} else return __('Incorrect shortcode', 'wpshop');
568 568
 
569
-		if(!empty($data)) {
570
-			foreach($data as $p) {
571
-				if ( !empty($p) && is_object($p) && !empty($p->entity_id) ) {
569
+		if (!empty($data)) {
570
+			foreach ($data as $p) {
571
+				if (!empty($p) && is_object($p) && !empty($p->entity_id)) {
572 572
 					$products[] = $p->entity_id;
573 573
 				}
574 574
 			}
@@ -591,14 +591,14 @@  discard block
 block discarded – undo
591 591
 		global $wp_query;
592 592
 
593 593
 		$atts['product_type'] = 'related';
594
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
594
+		if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
595 595
 
596 596
 		$related_product_output = self::wpshop_products_func($atts);
597 597
 
598 598
 		$output = '';
599
-		if ( !empty( $related_product_output ) ) {
599
+		if (!empty($related_product_output)) {
600 600
 			ob_start();
601
-			require( wpshop_tools::get_template_part( WPS_PRODUCT_DIR, WPS_PRODUCT_TEMPLATES_MAIN_DIR, 'frontend', 'related_product') );
601
+			require(wpshop_tools::get_template_part(WPS_PRODUCT_DIR, WPS_PRODUCT_TEMPLATES_MAIN_DIR, 'frontend', 'related_product'));
602 602
 			$output = ob_get_contents();
603 603
 			ob_end_clean();
604 604
 		}
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 		$string = '';
630 630
 		$have_results = false;
631 631
 		$output_results = true;
632
-		$type = ( empty($atts['type']) OR !in_array($atts['type'], array('grid','list')) ) ? WPSHOP_DISPLAY_LIST_TYPE : $atts['type'];
632
+		$type = (empty($atts['type']) OR !in_array($atts['type'], array('grid', 'list'))) ? WPSHOP_DISPLAY_LIST_TYPE : $atts['type'];
633 633
 		$pagination = isset($atts['pagination']) ? intval($atts['pagination']) : WPSHOP_ELEMENT_NB_PER_PAGE;
634 634
 		$cid = !empty($atts['cid']) ? $atts['cid'] : 0;
635 635
 		$pid = !empty($atts['pid']) ? $atts['pid'] : 0;
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
 
645 645
 		/** Get products which have att_name equal to att_value	*/
646 646
 		if (!empty($atts['att_name']) && !empty($atts['att_value'])) {
647
-			$attr = $atts['att_name'].':'.$atts['att_value'];
647
+			$attr = $atts['att_name'] . ':' . $atts['att_value'];
648 648
 
649 649
 			$products = self::get_products_matching_attribute($atts['att_name'], $atts['att_value']);
650 650
 
651 651
 			// Foreach on the found products
652
-			if ( !empty($products) ) {
653
-				$pid = implode(',',$products);
654
-				if(empty($pid))$output_results = false;
652
+			if (!empty($products)) {
653
+				$pid = implode(',', $products);
654
+				if (empty($pid))$output_results = false;
655 655
 			}
656 656
 			else $output_results = false;
657 657
 		}
@@ -661,14 +661,14 @@  discard block
 block discarded – undo
661 661
 			switch ($atts['product_type']) {
662 662
 				case 'related':
663 663
 					$product_id = !empty($atts['pid']) ? (int)$atts['pid'] : get_the_ID();
664
-					$type = !empty($atts['display_mode']) && in_array($atts['display_mode'],array('list','grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE;
664
+					$type = !empty($atts['display_mode']) && in_array($atts['display_mode'], array('list', 'grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE;
665 665
 					$grid_element_nb_per_line = !empty($atts['grid_element_nb_per_line']) ? $atts['grid_element_nb_per_line'] : WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE;
666 666
 
667 667
 					$pids = get_post_meta((int)$product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true);
668
-					if ( !empty($pids) && !empty($pids[0]) ) {
668
+					if (!empty($pids) && !empty($pids[0])) {
669 669
 						$pid = implode(',', $pids);
670 670
 					}
671
-					if(empty($pid) || $pid == $product_id) {
671
+					if (empty($pid) || $pid == $product_id) {
672 672
 						$output_results = false;
673 673
 					}
674 674
 
@@ -677,21 +677,21 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 
679 679
 		/** Output all the products	*/
680
-		if ( $output_results ) {
680
+		if ($output_results) {
681 681
 			$data = self::wpshop_get_product_by_criteria((!empty($atts['order']) ? $atts['order'] : (!empty($atts['creator']) ? ($atts['creator'] == 'current') : '')), $cid, $pid, $type, $order_by_sorting, 1, $pagination, $limit, $grid_element_nb_per_line, $display_pagination);
682 682
 
683
-			if ( $data[0] ) {
683
+			if ($data[0]) {
684 684
 				$have_results = true;
685 685
 				$string = $data[1];
686 686
 			}
687 687
 		}
688 688
 
689 689
 		/** If there are result to display	*/
690
-		if ( $have_results ) {
690
+		if ($have_results) {
691 691
 			$sorting = '';
692
-			if ( !empty($pid) ) {
692
+			if (!empty($pid)) {
693 693
 				$product_list = explode(',', $pid);
694
-				if ( count($product_list) == 1 ) {
694
+				if (count($product_list) == 1) {
695 695
 					$atts['sorting'] = 'no';
696 696
 				}
697 697
 			}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 			 * Build template
707 707
 			*/
708 708
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
709
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
709
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
710 710
 				/*	Include the old way template part	*/
711 711
 				ob_start();
712 712
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -729,24 +729,24 @@  discard block
 block discarded – undo
729 729
 				$tpl_component['SORTING_HIDDEN_FIELDS'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component, array(), 'admin');
730 730
 				unset($sub_tpl_component);
731 731
 
732
-				if ( (!empty($sorting_criteria) && is_array($sorting_criteria)) ) {
732
+				if ((!empty($sorting_criteria) && is_array($sorting_criteria))) {
733 733
 					$sub_template_part = 'product_listing_sorting_criteria';
734 734
 					$sub_tpl_component = array();
735 735
 					$criteria = '';
736
-					foreach($sorting_criteria as $c):
737
-						$criteria .= '<option value="' . $c['code'] . '">' . __($c['frontend_label'],'wpshop') . '</option>';
736
+					foreach ($sorting_criteria as $c):
737
+						$criteria .= '<option value="' . $c['code'] . '">' . __($c['frontend_label'], 'wpshop') . '</option>';
738 738
 					endforeach;
739 739
 					$sub_tpl_component['SORTING_CRITERIA_LIST'] = $criteria;
740 740
 					$tpl_component['SORTING_CRITERIA'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component);
741 741
 					unset($sub_tpl_component);
742 742
 				}
743 743
 
744
-				if ( empty($atts['sorting']) || ( !empty($atts['sorting']) && ($atts['sorting'] != 'no') ) ) {
745
-					$tpl_component['DISPLAY_TYPE_STATE_GRID'] = $type == 'grid' ?' active' : null;
746
-					$tpl_component['DISPLAY_TYPE_STATE_LIST'] = $type == 'list' ?' active' : null;
744
+				if (empty($atts['sorting']) || (!empty($atts['sorting']) && ($atts['sorting'] != 'no'))) {
745
+					$tpl_component['DISPLAY_TYPE_STATE_GRID'] = $type == 'grid' ? ' active' : null;
746
+					$tpl_component['DISPLAY_TYPE_STATE_LIST'] = $type == 'list' ? ' active' : null;
747 747
 					$sorting = wpshop_display::display_template_element($template_part, $tpl_component);
748 748
 				}
749
-				else if ( !empty($atts['sorting']) && ($atts['sorting'] == 'no') ) {
749
+				else if (!empty($atts['sorting']) && ($atts['sorting'] == 'no')) {
750 750
 					$sub_template_part = 'product_listing_sorting_criteria_hidden';
751 751
 					$sub_tpl_component = array();
752 752
 					$sub_tpl_component['CRITERIA_DEFAULT'] = !empty($sorting_criteria[0]['code']) ? $sorting_criteria[0]['code'] : 'title';
@@ -759,31 +759,31 @@  discard block
 block discarded – undo
759 759
 			}
760 760
 			unset($tpl_component);
761 761
 
762
-			if ( !empty( $atts) && !empty($atts['container']) && $atts['container'] == 'no') {
763
-				$string = $sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div>';
762
+			if (!empty($atts) && !empty($atts['container']) && $atts['container'] == 'no') {
763
+				$string = $sorting . '<div class="wps-catalog-container wps-bloc-loader">' . $string . '</div>';
764 764
 			}
765 765
 			else {
766
-				$string = '<div class="wpshop_products_block">'.$sorting.'<div class="wps-catalog-container wps-bloc-loader">'.$string.'</div></div>';
766
+				$string = '<div class="wpshop_products_block">' . $sorting . '<div class="wps-catalog-container wps-bloc-loader">' . $string . '</div></div>';
767 767
 			}
768 768
 		}
769
-		else if ( empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no') ) {
769
+		else if (empty($atts['no_result_message']) || ($atts['no_result_message'] != 'no')) {
770 770
 			$string = __('There is nothing to output here', 'wpshop');
771 771
 		}
772 772
 
773 773
 		return do_shortcode($string);
774 774
 	}
775 775
 
776
-	public static function wpshop_get_product_by_criteria( $criteria = null, $cid=0, $pid=0, $display_type, $order='ASC', $page_number, $products_per_page=0, $nb_of_product_limit=0, $grid_element_nb_per_line=WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE, $display_pagination = true ) {
776
+	public static function wpshop_get_product_by_criteria($criteria = null, $cid = 0, $pid = 0, $display_type, $order = 'ASC', $page_number, $products_per_page = 0, $nb_of_product_limit = 0, $grid_element_nb_per_line = WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE, $display_pagination = true) {
777 777
 		global $wpdb;
778 778
 
779 779
 		$string = '<span id="wpshop_loading">&nbsp;</span>';
780 780
 		$have_results = false;
781
-		$display_type = (!empty($display_type) && in_array($display_type,array('grid','list'))) ? $display_type : 'grid';
781
+		$display_type = (!empty($display_type) && in_array($display_type, array('grid', 'list'))) ? $display_type : 'grid';
782 782
 
783 783
 		/** Check if Discount are activated */
784
-		$discount_option = get_option( 'wpshop_catalog_product_option' );
784
+		$discount_option = get_option('wpshop_catalog_product_option');
785 785
 
786
-		if ( $criteria == 'product_price' && !empty($discount_option) && !empty($discount_option['discount']) && $discount_option['discount'] == 'on') {
786
+		if ($criteria == 'product_price' && !empty($discount_option) && !empty($discount_option['discount']) && $discount_option['discount'] == 'on') {
787 787
 			$criteria = 'wpshop_displayed_price';
788 788
 		}
789 789
 
@@ -796,18 +796,18 @@  discard block
 block discarded – undo
796 796
 		);
797 797
 
798 798
 		// If the limit is greater than zero, hide pagination and change posts_per_page var
799
-		if ( $nb_of_product_limit > 0 ) {
799
+		if ($nb_of_product_limit > 0) {
800 800
 			$query['posts_per_page'] = $nb_of_product_limit;
801 801
 			unset($query['paged']);
802 802
 		}
803
-		if( !empty($pid) ) {
804
-			if(!is_array($pid)){
803
+		if (!empty($pid)) {
804
+			if (!is_array($pid)) {
805 805
 				$pid = explode(',', $pid);
806 806
 			}
807 807
 
808 808
 			$query['post__in'] = $pid;
809 809
 		}
810
-		if ( !empty($cid) ) {
810
+		if (!empty($cid)) {
811 811
 			$cid = explode(',', $cid);
812 812
 			$query['tax_query'] = array(array(
813 813
 				'taxonomy' => WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES,
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 				'operator' => 'IN'
817 817
 			));
818 818
 		}
819
-		if($criteria != null) {
820
-			switch($criteria){
819
+		if ($criteria != null) {
820
+			switch ($criteria) {
821 821
 				case 'creator':
822 822
 				case 'author':
823 823
 					$query['author'] = get_current_user_id();
@@ -829,21 +829,21 @@  discard block
 block discarded – undo
829 829
 					$query['orderby'] = $criteria;
830 830
 					break;
831 831
 				default:
832
-					if(!empty($pid)) {
833
-						$post_meta = get_post_meta($pid, '_'.$criteria, true);
832
+					if (!empty($pid)) {
833
+						$post_meta = get_post_meta($pid, '_' . $criteria, true);
834 834
 					}
835
-					else{
836
-						$check_meta = $wpdb->prepare("SELECT COUNT(meta_id) as meta_criteria FROM " . $wpdb->postmeta . " WHERE meta_key = %s", '_'.$criteria);
835
+					else {
836
+						$check_meta = $wpdb->prepare("SELECT COUNT(meta_id) as meta_criteria FROM " . $wpdb->postmeta . " WHERE meta_key = %s", '_' . $criteria);
837 837
 						$post_meta = $wpdb->get_var($check_meta);
838 838
 					}
839
-					if(!empty($post_meta)){
840
-						if ( in_array( $criteria, array( 'wpshop_displayed_price', 'product_price' ) ) ) {
839
+					if (!empty($post_meta)) {
840
+						if (in_array($criteria, array('wpshop_displayed_price', 'product_price'))) {
841 841
 							$query['orderby'] = 'meta_value_num';
842 842
 						}
843 843
 						else {
844 844
 							$query['orderby'] = 'meta_value';
845 845
 						}
846
-						$query['meta_key'] = '_'.$criteria;
846
+						$query['meta_key'] = '_' . $criteria;
847 847
 					}
848 848
 					break;
849 849
 			}
@@ -852,33 +852,33 @@  discard block
 block discarded – undo
852 852
 			$query['orderby'] = 'menu_order ID';
853 853
 		}
854 854
 		$post_per_page = $query['posts_per_page'];
855
-		$total_products = ( !empty($query['post__in']) ) ? $query['post__in'] : 0;
856
-		if ( !empty($pid) && !empty($query['post__in']) && count($query['post__in']) > $query['posts_per_page'] ) {
855
+		$total_products = (!empty($query['post__in'])) ? $query['post__in'] : 0;
856
+		if (!empty($pid) && !empty($query['post__in']) && count($query['post__in']) > $query['posts_per_page']) {
857 857
 			$tmp_array = array();
858 858
 
859
-			if ( empty($page_number) || $page_number == 1 ) {
860
-				for( $i = 0; $i < $query['posts_per_page']; $i++ ) {
859
+			if (empty($page_number) || $page_number == 1) {
860
+				for ($i = 0; $i < $query['posts_per_page']; $i++) {
861 861
 					$tmp_array[] = $query['post__in'][$i];
862 862
 				}
863 863
 			}
864 864
 			else {
865
-				$begin_number = ( ($page_number - 1) * $query['posts_per_page'] ) ;
866
-				for( $i = $begin_number ; $i < $query['posts_per_page'] + $begin_number ; $i++ ) {
867
-					if ( !empty($query['post__in'][$i]) ) {
865
+				$begin_number = (($page_number - 1) * $query['posts_per_page']);
866
+				for ($i = $begin_number; $i < $query['posts_per_page'] + $begin_number; $i++) {
867
+					if (!empty($query['post__in'][$i])) {
868 868
 						$tmp_array[] = $query['post__in'][$i];
869 869
 					}
870 870
 				}
871 871
 			}
872
-			unset( $query['post__in'] );
872
+			unset($query['post__in']);
873 873
 			$query['post__in'] = $tmp_array;
874 874
 			$query['posts_per_page'] = -1;
875 875
 		}
876 876
 
877 877
 		$query['post_status'] = 'publish';
878 878
 
879
-		$custom_query = new WP_Query( $query );
879
+		$custom_query = new WP_Query($query);
880 880
 
881
-		if ( $custom_query->have_posts() ) {
881
+		if ($custom_query->have_posts()) {
882 882
 			$have_results = true;
883 883
 
884 884
 			// ---------------- //
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 				$current_position++;
895 895
 			endwhile;
896 896
 			$tpl_component = array();
897
-			$tpl_component['PRODUCT_CONTAINER_TYPE_CLASS'] = ($display_type == 'grid' ? ' ' . $display_type . '_' . $grid_element_nb_per_line : '') . ' '. $display_type .'_mode';
897
+			$tpl_component['PRODUCT_CONTAINER_TYPE_CLASS'] = ($display_type == 'grid' ? ' ' . $display_type . '_' . $grid_element_nb_per_line : '') . ' ' . $display_type . '_mode';
898 898
 			$tpl_component['PRODUCT_LIST_DISPLAY_TYPE'] = $display_type;
899 899
 			$tpl_component['PRODUCT_LIST_PER_LINE'] = $grid_element_nb_per_line;
900 900
 			$tpl_component['PRODUCT_LIST'] = $product_list;
@@ -905,39 +905,39 @@  discard block
 block discarded – undo
905 905
 			// --------------------- //
906 906
 			// Pagination management //
907 907
 			// --------------------- //
908
-			if($display_pagination) {
909
-				if($nb_of_product_limit==0) {
908
+			if ($display_pagination) {
909
+				if ($nb_of_product_limit == 0) {
910 910
 
911 911
 					$paginate = paginate_links(array(
912 912
 						'base' => '%_%',
913 913
 						'format' => '/?page_product=%#%',
914
-						'current' => $page_number ,
914
+						'current' => $page_number,
915 915
 						'total' => $custom_query->max_num_pages,
916 916
 						'type' => 'array',
917 917
 						'prev_next' => false
918 918
 					));
919
-					if(!empty($paginate)) {
919
+					if (!empty($paginate)) {
920 920
 						$string .= '<ul class="pagination wps-pagination">';
921
-						foreach($paginate as $p) {
922
-							$string .= '<li>'.$p.'</li>';
921
+						foreach ($paginate as $p) {
922
+							$string .= '<li>' . $p . '</li>';
923 923
 						}
924 924
 						$string .= '</ul>';
925 925
 					}
926 926
 				}
927 927
 
928
-				if ( !empty($pid) && !empty($query['post__in']) && count($total_products) > $post_per_page ) {
928
+				if (!empty($pid) && !empty($query['post__in']) && count($total_products) > $post_per_page) {
929 929
 					$paginate = paginate_links(array(
930 930
 							'base' => '%_%',
931 931
 							'format' => '/?page_product=%#%',
932 932
 							'current' => $page_number,
933
-							'total' => ceil( count($total_products) / $post_per_page ) ,
933
+							'total' => ceil(count($total_products) / $post_per_page),
934 934
 							'type' => 'array',
935 935
 							'prev_next' => false
936 936
 					));
937
-					if(!empty($paginate)) {
937
+					if (!empty($paginate)) {
938 938
 						$string .= '<ul class="pagination wps-pagination">';
939
-						foreach($paginate as $p) {
940
-							$string .= '<li>'.$p.'</li>';
939
+						foreach ($paginate as $p) {
940
+							$string .= '<li>' . $p . '</li>';
941 941
 						}
942 942
 						$string .= '</ul>';
943 943
 					}
@@ -955,21 +955,21 @@  discard block
 block discarded – undo
955 955
 	 * @param integer $product_id The product we want to update quantity for
956 956
 	 * @param decimal $qty The new quantity
957 957
 	 */
958
-	public static function reduce_product_stock_qty($product_id, $qty, $variation_id = '' ) {
958
+	public static function reduce_product_stock_qty($product_id, $qty, $variation_id = '') {
959 959
 		global $wpdb;
960 960
 
961 961
 		$product = self::get_product_data($product_id);
962 962
 		/** Check if there is variation ***/
963
-		if ( !empty($variation_id) && $variation_id != $product_id ) {
964
-			$variation_post_type = get_post_type( $variation_id );
965
-			if ( $variation_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
963
+		if (!empty($variation_id) && $variation_id != $product_id) {
964
+			$variation_post_type = get_post_type($variation_id);
965
+			if ($variation_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
966 966
 				/** Check if variation def is combined **/
967
-				$variations = get_post_meta( $product_id, '_wpshop_variation_defining', true );
968
-				if ( !empty($variations) && !empty($variations['options']) && !empty($variations['options']['priority']) && in_array( 'combined', $variations['options']['priority']) ) {
967
+				$variations = get_post_meta($product_id, '_wpshop_variation_defining', true);
968
+				if (!empty($variations) && !empty($variations['options']) && !empty($variations['options']['priority']) && in_array('combined', $variations['options']['priority'])) {
969 969
 					/** Get post meta of variation */
970
-					$variation_metadata = get_post_meta( $variation_id, '_wpshop_product_metadata', true );
971
-					if ( !empty($variation_metadata) && isset($variation_metadata['product_stock']) ) {
972
-						$product = self::get_product_data( $variation_id );
970
+					$variation_metadata = get_post_meta($variation_id, '_wpshop_product_metadata', true);
971
+					if (!empty($variation_metadata) && isset($variation_metadata['product_stock'])) {
972
+						$product = self::get_product_data($variation_id);
973 973
 						$product_id = $variation_id;
974 974
 					}
975 975
 				}
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
 		if (!empty($product)) {
980 980
 			$newQty = $product['product_stock'] - $qty;
981 981
 			$value_id = 0;
982
-			if ( $newQty >= 0 ) {
982
+			if ($newQty >= 0) {
983 983
 				$query = '
984 984
 					SELECT wp_wpshop__attribute_value_decimal.value_id
985 985
 					FROM wp_wpshop__attribute_value_decimal
986 986
 					LEFT JOIN wp_wpshop__attribute ON wp_wpshop__attribute_value_decimal.attribute_id = wp_wpshop__attribute.id
987
-					WHERE wp_wpshop__attribute_value_decimal.entity_id='.$product_id.' AND wp_wpshop__attribute.code="product_stock"
987
+					WHERE wp_wpshop__attribute_value_decimal.entity_id='.$product_id . ' AND wp_wpshop__attribute.code="product_stock"
988 988
 					LIMIT 1
989 989
 				';
990 990
 				$value_id = $wpdb->get_var($query);
@@ -994,10 +994,10 @@  discard block
 block discarded – undo
994 994
 			$attribute_histo_content = array();
995 995
 			$attribute_histo_content['status'] = 'valid';
996 996
 			$attribute_histo_content['creation_date'] = current_time('mysql', 0);
997
-			$attribute_histo_content['creation_date_value'] = ( !empty( $attribute_histo[0]->creation_date_value ) ) ? $attribute_histo[0]->creation_date_value : current_time('mysql', 0);
997
+			$attribute_histo_content['creation_date_value'] = (!empty($attribute_histo[0]->creation_date_value)) ? $attribute_histo[0]->creation_date_value : current_time('mysql', 0);
998 998
 			$attribute_histo_content['original_value_id'] = $value_id;
999
-			$attribute_histo_content['entity_type_id'] = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
1000
-			$stock_atribute = wpshop_attributes::getElement( 'product_stock', "'valid'", 'code' );
999
+			$attribute_histo_content['entity_type_id'] = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
1000
+			$stock_atribute = wpshop_attributes::getElement('product_stock', "'valid'", 'code');
1001 1001
 			$attribute_histo_content['attribute_id'] = $stock_atribute->id;
1002 1002
 			$attribute_histo_content['entity_id'] = $product_id;
1003 1003
 			$attribute_histo_content['value'] = $product['product_stock'];
@@ -1017,15 +1017,15 @@  discard block
 block discarded – undo
1017 1017
 	 * @param boolean $for_cart_storage
1018 1018
 	 * @return array Information about the product defined by first parameter
1019 1019
 	 */
1020
-	public static function get_product_data( $product_id, $for_cart_storage = false, $post_status = '"publish"') {
1020
+	public static function get_product_data($product_id, $for_cart_storage = false, $post_status = '"publish"') {
1021 1021
 		global $wpdb;
1022 1022
 			$query = $wpdb->prepare('
1023 1023
 			SELECT P.*, PM.meta_value AS attribute_set_id
1024
-			FROM '.$wpdb->posts.' AS P
1025
-				INNER JOIN '.$wpdb->postmeta.' AS PM ON (PM.post_id=P.ID)
1024
+			FROM '.$wpdb->posts . ' AS P
1025
+				INNER JOIN '.$wpdb->postmeta . ' AS PM ON (PM.post_id=P.ID)
1026 1026
 			WHERE
1027 1027
 				P.ID = %d
1028
-				AND ( (P.post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'") OR (P.post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '") OR (P.post_type = "free_product") )
1028
+				AND ( (P.post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '") OR (P.post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '") OR (P.post_type = "free_product") )
1029 1029
 				AND P.post_status IN (' . $post_status . ')
1030 1030
 				AND	PM.meta_key = "_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id"
1031 1031
 			LIMIT 1
@@ -1037,35 +1037,35 @@  discard block
 block discarded – undo
1037 1037
 		$product_meta = array();
1038 1038
 
1039 1039
 		if (!empty($product)) {
1040
-			$product_data['product_id'] = ( !empty($product->ID) ) ?  $product->ID : '';
1041
-			$product_data['post_name'] = ( !empty($product->post_name) ) ? $product->post_name : '';
1042
-			$product_data['product_name'] = ( !empty($product->post_title) ) ? $product->post_title : '';
1043
-			$product_data['post_title'] = ( !empty($product->post_title) ) ? $product->post_title : '';
1040
+			$product_data['product_id'] = (!empty($product->ID)) ? $product->ID : '';
1041
+			$product_data['post_name'] = (!empty($product->post_name)) ? $product->post_name : '';
1042
+			$product_data['product_name'] = (!empty($product->post_title)) ? $product->post_title : '';
1043
+			$product_data['post_title'] = (!empty($product->post_title)) ? $product->post_title : '';
1044 1044
 
1045
-			$product_data['product_author_id'] = ( !empty($product->post_author) ) ? $product->post_author : '';
1046
-			$product_data['product_date'] = ( !empty($product->post_date) ) ? $product->post_date : '';
1047
-			$product_data['product_content'] = ( !empty($product->post_content) ) ? $product->post_content : '';
1048
-			$product_data['product_excerpt'] = ( !empty($product->post_excerpt) ) ? $product->post_excerpt : wp_trim_words( $product_data['product_content'], apply_filters( 'excerpt_length', 50 ), '...' );
1045
+			$product_data['product_author_id'] = (!empty($product->post_author)) ? $product->post_author : '';
1046
+			$product_data['product_date'] = (!empty($product->post_date)) ? $product->post_date : '';
1047
+			$product_data['product_content'] = (!empty($product->post_content)) ? $product->post_content : '';
1048
+			$product_data['product_excerpt'] = (!empty($product->post_excerpt)) ? $product->post_excerpt : wp_trim_words($product_data['product_content'], apply_filters('excerpt_length', 50), '...');
1049 1049
 
1050
-			$product_data['product_meta_attribute_set_id'] = ( !empty($product->attribute_set_id) ) ? $product->attribute_set_id : '';
1050
+			$product_data['product_meta_attribute_set_id'] = (!empty($product->attribute_set_id)) ? $product->attribute_set_id : '';
1051 1051
 
1052 1052
 			$data = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), $product->ID, WPSHOP_CURRENT_LOCALE, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
1053
-			if ( !empty($data) ) {
1053
+			if (!empty($data)) {
1054 1054
 				foreach ($data as $attribute) {
1055
-					$data_type = 'attribute_value_'.$attribute->data_type;
1055
+					$data_type = 'attribute_value_' . $attribute->data_type;
1056 1056
 					$value = $attribute->$data_type;
1057
-					if (in_array($attribute->backend_input, array('select','multiple-select', 'radio','checkbox'))) {
1057
+					if (in_array($attribute->backend_input, array('select', 'multiple-select', 'radio', 'checkbox'))) {
1058 1058
 						$value = wpshop_attributes::get_attribute_type_select_option_info($value, 'value');
1059 1059
 					}
1060 1060
 
1061 1061
 					/** Special traitment regarding attribute_code	*/
1062
-					switch($attribute->attribute_code) {
1062
+					switch ($attribute->attribute_code) {
1063 1063
 						case 'product_weight':
1064 1064
 							$default_weight_unity = get_option('wpshop_shop_default_weight_unity');
1065
-							if ( !empty($default_weight_unity) ) {
1066
-								$query = $wpdb->prepare('SELECT unit FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id = %d', $default_weight_unity);
1065
+							if (!empty($default_weight_unity)) {
1066
+								$query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d', $default_weight_unity);
1067 1067
 								$unity = $wpdb->get_var($query);
1068
-								if ( $unity == 'kg') {
1068
+								if ($unity == 'kg') {
1069 1069
 									$value *= 1000;
1070 1070
 								}
1071 1071
 
@@ -1077,17 +1077,17 @@  discard block
 block discarded – undo
1077 1077
 					}
1078 1078
 					$product_data[$attribute->attribute_code] = $value;
1079 1079
 
1080
-					if(!$for_cart_storage OR $for_cart_storage && $attribute->is_recordable_in_cart_meta == 'yes') {
1081
-						$meta = get_post_meta($product->ID, 'attribute_option_'.$attribute->attribute_code, true);
1082
-						if(!empty($meta)) {
1080
+					if (!$for_cart_storage OR $for_cart_storage && $attribute->is_recordable_in_cart_meta == 'yes') {
1081
+						$meta = get_post_meta($product->ID, 'attribute_option_' . $attribute->attribute_code, true);
1082
+						if (!empty($meta)) {
1083 1083
 							$product_meta[$attribute->attribute_code] = $meta;
1084 1084
 						}
1085 1085
 					}
1086 1086
 
1087
-					if ( ($attribute->is_visible_in_front == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) ) {
1087
+					if (($attribute->is_visible_in_front == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES)))) {
1088 1088
 						$product_meta['attribute_visible'][$attribute->attribute_code] = $value;
1089 1089
 					}
1090
-					if ( ($attribute->is_visible_in_front_listing == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) ) {
1090
+					if (($attribute->is_visible_in_front_listing == 'yes') && (!in_array($attribute->attribute_code, unserialize(WPSHOP_ATTRIBUTE_PRICES)))) {
1091 1091
 						$product_meta['attribute_visible_listing'][$attribute->attribute_code] = $value;
1092 1092
 					}
1093 1093
 				}
@@ -1097,16 +1097,16 @@  discard block
 block discarded – undo
1097 1097
 			}
1098 1098
 
1099 1099
 			/**	Get datas about product options	*/
1100
-			if ( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
1100
+			if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
1101 1101
 				$variation_details = get_post_meta($product->ID, '_wpshop_variations_attribute_def', true);
1102 1102
 
1103
-				foreach ( $variation_details as $attribute_code => $attribute_value) {
1103
+				foreach ($variation_details as $attribute_code => $attribute_value) {
1104 1104
 					$variation_id = $attribute_value;
1105 1105
 					$attribute_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
1106 1106
 
1107 1107
 					$product_meta['variation_definition'][$attribute_code]['UNSTYLED_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', $attribute_definition->data_type_to_use, true));
1108 1108
 					$product_meta['variation_definition'][$attribute_code]['NAME'] = $attribute_definition->frontend_label;
1109
-					switch( $attribute_definition->backend_input ) {
1109
+					switch ($attribute_definition->backend_input) {
1110 1110
 						case 'select':
1111 1111
 						case 'multiple-select':
1112 1112
 						case 'radio':
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 	 * @param $attrs List of the attributes and values of the product
1136 1136
 	 * @return boolean
1137 1137
 	*/
1138
-	function addProduct($name, $description, $attrs=array()) {
1138
+	function addProduct($name, $description, $attrs = array()) {
1139 1139
 		$new_product = wpshop_entities::create_new_entity(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $name, $description, $attrs);
1140 1140
 		return $new_product[0];
1141 1141
 	}
@@ -1146,13 +1146,13 @@  discard block
 block discarded – undo
1146 1146
 	 * @param string $product_search Optionnal Define a search term for request
1147 1147
 	 * @return object|string If $formated is set to true will display an html output with all product. Else return a wordpress database object with the product list
1148 1148
 	 */
1149
-	function product_list($formated=false, $product_search=null) {
1149
+	function product_list($formated = false, $product_search = null) {
1150 1150
 		global $wpdb;
1151 1151
 
1152 1152
 		$query_extra_params = $query_extra_params_value = '';
1153
-		if( !empty($product_search) ) {
1154
-			$query_extra_params = " AND post_title LIKE '%%".$product_search."%%'";
1155
-			if ( is_array($product_search) ) {
1153
+		if (!empty($product_search)) {
1154
+			$query_extra_params = " AND post_title LIKE '%%" . $product_search . "%%'";
1155
+			if (is_array($product_search)) {
1156 1156
 				$query_extra_params = " AND ID IN (%s)";
1157 1157
 				$query_extra_params_value = implode(",", $product_search);
1158 1158
 			}
@@ -1164,12 +1164,12 @@  discard block
 block discarded – undo
1164 1164
 		/*
1165 1165
 		 * Make some arangement on output if parameter is given
1166 1166
 		 */
1167
-		if ( $formated ) {
1168
-			$product_string='';
1167
+		if ($formated) {
1168
+			$product_string = '';
1169 1169
 			foreach ($data as $d) {
1170 1170
 				$product_string .= '
1171 1171
 					<li class="wpshop_shortcode_element_container wpshop_shortcode_element_container_product" >
1172
-						<input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_product" value="'.$d->ID.'" id="'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'-'.$d->ID.'" name="products[]" /><label for="'.WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'-'.$d->ID.'" > '.$d->post_title.'</label>
1172
+						<input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_product" value="'.$d->ID . '" id="' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '-' . $d->ID . '" name="products[]" /><label for="' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '-' . $d->ID . '" > ' . $d->post_title . '</label>
1173 1173
 					</li>';
1174 1174
 			}
1175 1175
 		}
@@ -1180,17 +1180,17 @@  discard block
 block discarded – undo
1180 1180
 	/**
1181 1181
 	 * Enregistrement des données pour le produit
1182 1182
 	 */
1183
-	function save_product_custom_informations( $post_id , $data_to_save = array() ) {
1183
+	function save_product_custom_informations($post_id, $data_to_save = array()) {
1184 1184
 		global $wpdb;
1185 1185
 
1186
-		$data_to_save = ( !empty($data_to_save) ) ? $data_to_save : (array) $_REQUEST;
1186
+		$data_to_save = (!empty($data_to_save)) ? $data_to_save : (array)$_REQUEST;
1187 1187
 		// Apply a filter to extra actions
1188
-		$data_to_save = apply_filters( 'wps_save_product_extra_filter', $data_to_save );
1188
+		$data_to_save = apply_filters('wps_save_product_extra_filter', $data_to_save);
1189 1189
 
1190
-		if ( !empty($data_to_save['post_ID']) && ( (get_post_type($data_to_save['post_ID']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || (get_post_type($data_to_save['post_ID']) == "free_product") ) ) {
1191
-			if ( !empty($data_to_save[wpshop_products::currentPageCode . '_attribute']) ) {
1190
+		if (!empty($data_to_save['post_ID']) && ((get_post_type($data_to_save['post_ID']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || (get_post_type($data_to_save['post_ID']) == "free_product"))) {
1191
+			if (!empty($data_to_save[wpshop_products::currentPageCode . '_attribute'])) {
1192 1192
 				/*	Fill the product reference automatically if nothing is sent	*/
1193
-				if ( empty($data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference']) ) {
1193
+				if (empty($data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'])) {
1194 1194
 					$query = "SELECT MAX(ID) AS PDCT_ID FROM {$wpdb->posts}";
1195 1195
 					$last_ref = $wpdb->get_var($query);
1196 1196
 					$data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'] = WPSHOP_PRODUCT_REFERENCE_PREFIX . str_repeat(0, WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL) . $last_ref;
@@ -1200,16 +1200,16 @@  discard block
 block discarded – undo
1200 1200
 					$ref = $data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'];
1201 1201
 					$query = $wpdb->prepare(
1202 1202
 						"SELECT value_id
1203
-						FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR."
1203
+						FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . "
1204 1204
 							INNER JOIN {$wpdb->posts} ON ( ID = entity_id )
1205 1205
 						WHERE value = %s
1206 1206
 							AND entity_id != %d
1207 1207
 							AND entity_type_id = %d"
1208 1208
 						, $ref, $data_to_save['post_ID'], wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
1209
-					$existing_reference = $wpdb->get_var( $query );
1209
+					$existing_reference = $wpdb->get_var($query);
1210 1210
 
1211 1211
 					/* If this product reference exist -> Create a new product reference */
1212
-					if ( $wpdb->num_rows > 0 ) {
1212
+					if ($wpdb->num_rows > 0) {
1213 1213
 						$query = "SELECT MAX(ID) AS PDCT_ID FROM " . $wpdb->posts;
1214 1214
 						$last_ref = $wpdb->get_var($query);
1215 1215
 						$data_to_save[wpshop_products::currentPageCode . '_attribute']['varchar']['product_reference'] = WPSHOP_PRODUCT_REFERENCE_PREFIX . str_repeat(0, WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL) . $last_ref;
@@ -1219,27 +1219,27 @@  discard block
 block discarded – undo
1219 1219
 				/*	Save the attributes values into wpshop eav database	*/
1220 1220
 				$update_from = !empty($data_to_save[wpshop_products::currentPageCode . '_provenance']) ? $data_to_save[wpshop_products::currentPageCode . '_provenance'] : '';
1221 1221
 				$lang = WPSHOP_CURRENT_LOCALE;
1222
-				if ( !empty($data_to_save['icl_post_language']) ) {
1222
+				if (!empty($data_to_save['icl_post_language'])) {
1223 1223
 					$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", $data_to_save['icl_post_language']);
1224 1224
 					$lang = $wpdb->get_var($query);
1225 1225
 				}
1226 1226
 				wpshop_attributes::saveAttributeForEntity($data_to_save[wpshop_products::currentPageCode . '_attribute'], wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $data_to_save['post_ID'], $lang, $update_from);
1227 1227
 
1228 1228
 				/*	Update product price looking for shop parameters	*/
1229
-				wpshop_products::calculate_price( $data_to_save['post_ID'] );
1229
+				wpshop_products::calculate_price($data_to_save['post_ID']);
1230 1230
 
1231 1231
 				/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
1232 1232
 				$productMetaDatas = array();
1233
-				foreach ( $data_to_save[wpshop_products::currentPageCode . '_attribute'] as $attributeType => $attributeValues ) {
1234
-					foreach ( $attributeValues as $attributeCode => $attributeValue ) {
1235
-						if ( $attributeCode == 'product_attribute_set_id' ) {
1233
+				foreach ($data_to_save[wpshop_products::currentPageCode . '_attribute'] as $attributeType => $attributeValues) {
1234
+					foreach ($attributeValues as $attributeCode => $attributeValue) {
1235
+						if ($attributeCode == 'product_attribute_set_id') {
1236 1236
 							/*	Update the attribute set id for the current product	*/
1237 1237
 							update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $attributeValue);
1238 1238
 						}
1239
-						if ( $attributeType == 'decimal' ) {
1239
+						if ($attributeType == 'decimal') {
1240 1240
 							$attributeValue = str_replace(',', '.', $attributeValue);
1241 1241
 						}
1242
-						if ( ($attributeType == 'integer') && !is_array($attributeValue) ) {
1242
+						if (($attributeType == 'integer') && !is_array($attributeValue)) {
1243 1243
 							$attributeValue = (int)$attributeValue;
1244 1244
 						}
1245 1245
 						$productMetaDatas[$attributeCode] = $attributeValue;
@@ -1248,51 +1248,51 @@  discard block
 block discarded – undo
1248 1248
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $productMetaDatas);
1249 1249
 			}
1250 1250
 
1251
-			if ( !empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']) && empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']['default_config']) ) {
1251
+			if (!empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']) && empty($data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']['default_config'])) {
1252 1252
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, $data_to_save[wpshop_products::currentPageCode . '_attr_frontend_display']);
1253 1253
 			}
1254
-			else if ( $data_to_save['action'] != 'autosave') {
1254
+			else if ($data_to_save['action'] != 'autosave') {
1255 1255
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF);
1256 1256
 			}
1257 1257
 
1258 1258
 
1259
-			$product = wpshop_products::get_product_data( $data_to_save['post_ID'], false, '"publish"' );
1260
-			if( empty($product['product_id']) ) {
1259
+			$product = wpshop_products::get_product_data($data_to_save['post_ID'], false, '"publish"');
1260
+			if (empty($product['product_id'])) {
1261 1261
 				$product['product_id'] = $data_to_save['post_ID'];
1262 1262
 			}
1263
-			$price = wpshop_prices::get_product_price( $product, 'just_price_infos', array('mini_output', 'grid') );
1264
-			update_post_meta( $data_to_save['post_ID'], '_wps_price_infos', $price );
1263
+			$price = wpshop_prices::get_product_price($product, 'just_price_infos', array('mini_output', 'grid'));
1264
+			update_post_meta($data_to_save['post_ID'], '_wps_price_infos', $price);
1265 1265
 
1266 1266
 
1267 1267
 			/**	Save product variation	*/
1268
-			if ( !empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION]) ) {
1269
-				foreach ( $data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION] as $variation_id => $variation_definition ) {
1268
+			if (!empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION])) {
1269
+				foreach ($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION] as $variation_id => $variation_definition) {
1270 1270
 
1271
-					foreach ( unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
1271
+					foreach (unserialize(WPSHOP_ATTRIBUTE_PRICES) as $price_attribute_code) {
1272 1272
 						$price_attr_def = wpshop_attributes::getElement($price_attribute_code, "'valid'", 'code');
1273
-						if ( !empty($variation_definition) && !empty($variation_definition['attribute']) && is_object($price_attr_def) && !empty($variation_definition['attribute'][$price_attr_def->data_type]) && is_array($variation_definition['attribute'][$price_attr_def->data_type]) && !array_key_exists($price_attribute_code, $variation_definition['attribute'][$price_attr_def->data_type]) ) {
1273
+						if (!empty($variation_definition) && !empty($variation_definition['attribute']) && is_object($price_attr_def) && !empty($variation_definition['attribute'][$price_attr_def->data_type]) && is_array($variation_definition['attribute'][$price_attr_def->data_type]) && !array_key_exists($price_attribute_code, $variation_definition['attribute'][$price_attr_def->data_type])) {
1274 1274
 							$variation_definition['attribute'][$price_attr_def->data_type][$price_attribute_code] = !empty($data_to_save[wpshop_products::currentPageCode . '_attribute'][$price_attr_def->data_type][$price_attribute_code]) ? $data_to_save[wpshop_products::currentPageCode . '_attribute'][$price_attr_def->data_type][$price_attribute_code] : 0;
1275 1275
 						}
1276 1276
 					}
1277 1277
 					$lang = WPSHOP_CURRENT_LOCALE;
1278
-					if ( !empty($data_to_save['icl_post_language']) ) {
1278
+					if (!empty($data_to_save['icl_post_language'])) {
1279 1279
 						$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", $data_to_save['icl_post_language']);
1280 1280
 						$lang = $wpdb->get_var($query);
1281 1281
 					}
1282 1282
 					wpshop_attributes::saveAttributeForEntity($variation_definition['attribute'], wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $variation_id, $lang);
1283 1283
 
1284 1284
 					/**	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
1285
-					$variation_metadata = get_post_meta( $variation_id, '_wpshop_product_metadata', true);
1286
-					if ( !empty($variation_metadata) ) {
1287
-						$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION),  $variation_id);
1288
-						if ( !empty($attributes_list)) {
1285
+					$variation_metadata = get_post_meta($variation_id, '_wpshop_product_metadata', true);
1286
+					if (!empty($variation_metadata)) {
1287
+						$attributes_list = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION), $variation_id);
1288
+						if (!empty($attributes_list)) {
1289 1289
 							foreach ($attributes_list as $attribute) {
1290
-								$value_key = 'attribute_value_'.$attribute->data_type;
1290
+								$value_key = 'attribute_value_' . $attribute->data_type;
1291 1291
 								$attributeValue = $attribute->$value_key;
1292
-								if ( $attribute->data_type == 'decimal' ) {
1292
+								if ($attribute->data_type == 'decimal') {
1293 1293
 									$attributeValue = str_replace(',', '.', $attribute->$value_key);
1294 1294
 								}
1295
-								if ( ($attribute->data_type == 'integer') && !is_array($attributeValue) ) {
1295
+								if (($attribute->data_type == 'integer') && !is_array($attributeValue)) {
1296 1296
 									$attributeValue = (int)$attribute->$value_key;
1297 1297
 								}
1298 1298
 								$variation_metadata[$attribute->code] = $attribute->$value_key;
@@ -1300,12 +1300,12 @@  discard block
 block discarded – undo
1300 1300
 						}
1301 1301
 					}
1302 1302
 
1303
-					foreach ( $variation_definition['attribute'] as $attributeType => $attributeValues ) {
1304
-						foreach ( $attributeValues as $attributeCode => $attributeValue ) {
1305
-							if ( $attributeType == 'decimal' ) {
1303
+					foreach ($variation_definition['attribute'] as $attributeType => $attributeValues) {
1304
+						foreach ($attributeValues as $attributeCode => $attributeValue) {
1305
+							if ($attributeType == 'decimal') {
1306 1306
 								$attributeValue = str_replace(',', '.', $attributeValue);
1307 1307
 							}
1308
-							if ( ($attributeType == 'integer') && !is_array($attributeValue) ) {
1308
+							if (($attributeType == 'integer') && !is_array($attributeValue)) {
1309 1309
 								$attributeValue = (int)$attributeValue;
1310 1310
 							}
1311 1311
 							$variation_metadata[$attributeCode] = $attributeValue;
@@ -1314,46 +1314,46 @@  discard block
 block discarded – undo
1314 1314
 					update_post_meta($variation_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $variation_metadata);
1315 1315
 
1316 1316
 					/** Save attached picture id **/
1317
-					$attached_picture_id = ( !empty($data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id']) ) ? intval( $data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id'] ) : '';
1318
-					$selected_picture = update_post_meta( $variation_id, '_wps_variation_attached_picture', $attached_picture_id );
1317
+					$attached_picture_id = (!empty($data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id'])) ? intval($data_to_save['wps_pdt_variations'][$variation_id]['wps_attached_picture_id']) : '';
1318
+					$selected_picture = update_post_meta($variation_id, '_wps_variation_attached_picture', $attached_picture_id);
1319 1319
 
1320 1320
 					/*	Update product price looking for shop parameters	*/
1321
-					wpshop_products::calculate_price( $variation_id );
1321
+					wpshop_products::calculate_price($variation_id);
1322 1322
 				}
1323 1323
 			}
1324 1324
 
1325 1325
 			/*	Update the related products list*/
1326
-			if ( !empty($data_to_save['related_products_list']) ) {
1326
+			if (!empty($data_to_save['related_products_list'])) {
1327 1327
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS, $data_to_save['related_products_list']);
1328 1328
 			}
1329
-			else if ( $data_to_save['action'] != 'autosave') {
1329
+			else if ($data_to_save['action'] != 'autosave') {
1330 1330
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_RELATED_PRODUCTS);
1331 1331
 			}
1332 1332
 			/*	Update the provider list*/
1333
-			if ( !empty($data_to_save['provider_list']) ) {
1333
+			if (!empty($data_to_save['provider_list'])) {
1334 1334
 				update_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER, $data_to_save['provider_list']);
1335 1335
 			}
1336
-			else if ( $data_to_save['action'] != 'autosave') {
1336
+			else if ($data_to_save['action'] != 'autosave') {
1337 1337
 				delete_post_meta($data_to_save['post_ID'], WPSHOP_PRODUCT_PROVIDER);
1338 1338
 			}
1339 1339
 
1340 1340
 			/*	Update product options	*/
1341
-			if ( !empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']) ) {
1341
+			if (!empty($data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options'])) {
1342 1342
 				update_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options', $data_to_save[WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT]['options']);
1343 1343
 			}
1344
-			else if ( $data_to_save['action'] != 'autosave') {
1344
+			else if ($data_to_save['action'] != 'autosave') {
1345 1345
 				delete_post_meta($data_to_save['post_ID'], '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
1346 1346
 			}
1347 1347
 
1348 1348
 			/** Add flag on variations to check which type of variation **/
1349
-			$check_product_have_variations = self::get_variation( $post_id );
1350
-			if( !empty($check_product_have_variations) ) {
1351
-				$variation_flag = self::check_variation_type( $post_id );
1352
-				$variation_defining = get_post_meta( $post_id, '_wpshop_variation_defining', true );
1349
+			$check_product_have_variations = self::get_variation($post_id);
1350
+			if (!empty($check_product_have_variations)) {
1351
+				$variation_flag = self::check_variation_type($post_id);
1352
+				$variation_defining = get_post_meta($post_id, '_wpshop_variation_defining', true);
1353 1353
 				$variation_defining['variation_type'] = $variation_flag;
1354
-				update_post_meta( $post_id, '_wpshop_variation_defining', $variation_defining );
1354
+				update_post_meta($post_id, '_wpshop_variation_defining', $variation_defining);
1355 1355
 			}
1356
-			add_post_meta( $post_id, '_wpshop_variation_defining', array( 'follow_general_config' => true, 'options' => array( 'priority' => array( 'combined' ), 'price_behaviour' => array( 'replacement' ), 'price_display' => ( !empty($catalog_product_option) && !empty($catalog_product_option['price_display']) ) ? $catalog_product_option['price_display'] : array( 'text_from' => 'on', 'lower_price' => 'on' ) ) ), true );
1356
+			add_post_meta($post_id, '_wpshop_variation_defining', array('follow_general_config' => true, 'options' => array('priority' => array('combined'), 'price_behaviour' => array('replacement'), 'price_display' => (!empty($catalog_product_option) && !empty($catalog_product_option['price_display'])) ? $catalog_product_option['price_display'] : array('text_from' => 'on', 'lower_price' => 'on'))), true);
1357 1357
 		}
1358 1358
 
1359 1359
 		flush_rewrite_rules();
@@ -1364,16 +1364,16 @@  discard block
 block discarded – undo
1364 1364
 	 * @param integer $post_id
1365 1365
 	 * @return string
1366 1366
 	 */
1367
-	public function check_variation_type( $post_id ) {
1367
+	public function check_variation_type($post_id) {
1368 1368
 		$variation_type = 'single';
1369
-		if( !empty($variation_type) ) {
1370
-			$variations = self::get_variation( $post_id );
1371
-			if( !empty($variations) ) {
1372
-				foreach( $variations as $variation_id => $variation_data ) {
1373
-					if( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) == 1 ) {
1369
+		if (!empty($variation_type)) {
1370
+			$variations = self::get_variation($post_id);
1371
+			if (!empty($variations)) {
1372
+				foreach ($variations as $variation_id => $variation_data) {
1373
+					if (!empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) == 1) {
1374 1374
 						return 'single';
1375 1375
 					}
1376
-					elseif( !empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1 ) {
1376
+					elseif (!empty($variation_data) && !empty($variation_data['variation_def']) && count($variation_data['variation_def']) > 1) {
1377 1377
 						$variation_type = 'combined';
1378 1378
 					}
1379 1379
 				}
@@ -1391,21 +1391,21 @@  discard block
 block discarded – undo
1391 1391
 	 *
1392 1392
 	 * @return mixed The new permalink for the current element
1393 1393
 	 */
1394
-	public static function set_product_permalink($permalink, $post, $unknown){
1394
+	public static function set_product_permalink($permalink, $post, $unknown) {
1395 1395
 		$options = get_option('wpshop_catalog_product_option', array());
1396 1396
 
1397
-		if( $post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT /* && 'publish' == $post->post_status */ ) {
1398
-			if( !isset( $options['wpshop_catalog_product_slug_with_category'] ) || $options['wpshop_catalog_product_slug_with_category'] != 'yes' ) {
1397
+		if ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT /* && 'publish' == $post->post_status */) {
1398
+			if (!isset($options['wpshop_catalog_product_slug_with_category']) || $options['wpshop_catalog_product_slug_with_category'] != 'yes') {
1399 1399
 				return $permalink;
1400 1400
 			} else {
1401
-				$options_cats = get_option( 'wpshop_catalog_categories_option', array() );
1402
-				$product_categories = wp_get_object_terms( $post->ID, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES );
1403
-				if( empty( $product_categories ) ) {
1401
+				$options_cats = get_option('wpshop_catalog_categories_option', array());
1402
+				$product_categories = wp_get_object_terms($post->ID, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
1403
+				if (empty($product_categories)) {
1404 1404
 					$product_category_slug = $options_cats['wpshop_catalog_no_category_slug'];
1405 1405
 				} else {
1406 1406
 					$product_category_slug = $product_categories[0]->slug;
1407 1407
 				}
1408
-				$permalink = str_replace( '%' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '%', $product_category_slug, $permalink );
1408
+				$permalink = str_replace('%' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '%', $product_category_slug, $permalink);
1409 1409
 			}
1410 1410
 		}
1411 1411
 
@@ -1439,10 +1439,10 @@  discard block
 block discarded – undo
1439 1439
 		}*/
1440 1440
 	}
1441 1441
 
1442
-	public static function set_product_request_by_name( $query ) {
1442
+	public static function set_product_request_by_name($query) {
1443 1443
 		$options = get_option('wpshop_catalog_product_option', array());
1444 1444
 
1445
-		if ( $query->is_main_query() && ( 2 == count( $query->query ) || isset( $query->query['page'] ) ) && ! empty( $query->query['name'] ) && empty( $options['wpshop_catalog_product_slug'] ) );
1445
+		if ($query->is_main_query() && (2 == count($query->query) || isset($query->query['page'])) && !empty($query->query['name']) && empty($options['wpshop_catalog_product_slug']));
1446 1446
 		//	$query->set( 'post_type', array( 'post', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'page' ) );
1447 1447
 	}
1448 1448
 
@@ -1466,57 +1466,57 @@  discard block
 block discarded – undo
1466 1466
 		/** Get product definition	*/
1467 1467
 
1468 1468
 		$product = self::get_product_data($product_id);
1469
-		wp_cache_set( 'wpshop_product_data_'.$product_id, $product );
1469
+		wp_cache_set('wpshop_product_data_' . $product_id, $product);
1470 1470
 
1471 1471
 		/** Get the product thumbnail	*/
1472 1472
 		$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1473
-		if ( has_post_thumbnail($product_id) ) {
1474
-			$thumbnail_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
1473
+		if (has_post_thumbnail($product_id)) {
1474
+			$thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
1475 1475
 			$tpl_component = array();
1476 1476
 			$tpl_component['PRODUCT_THUMBNAIL_URL'] = $thumbnail_url[0];
1477
-			$tpl_component['PRODUCT_THUMBNAIL'] = get_the_post_thumbnail( $product_id, 'wpshop-product-galery' );
1478
-			$tpl_component['PRODUCT_THUMBNAIL_FULL'] = get_the_post_thumbnail( $product_id, 'full' );
1479
-			$image_attributes = wp_get_attachment_metadata( get_post_thumbnail_id() );
1480
-			if ( !empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes']) ) {
1481
-				foreach ( $image_attributes['sizes'] as $size_name => $size_def) {
1477
+			$tpl_component['PRODUCT_THUMBNAIL'] = get_the_post_thumbnail($product_id, 'wpshop-product-galery');
1478
+			$tpl_component['PRODUCT_THUMBNAIL_FULL'] = get_the_post_thumbnail($product_id, 'full');
1479
+			$image_attributes = wp_get_attachment_metadata(get_post_thumbnail_id());
1480
+			if (!empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes'])) {
1481
+				foreach ($image_attributes['sizes'] as $size_name => $size_def) {
1482 1482
 					$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = wp_get_attachment_image(get_post_thumbnail_id(), $size_name);
1483
-					$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = ( !empty( $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] ) ) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1483
+					$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = (!empty($tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)])) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1484 1484
 				}
1485 1485
 			}
1486
-			$tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] = ( !empty( $tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] ) ) ? $tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1487
-			$productThumbnail = wpshop_display::display_template_element( 'product_thumbnail', $tpl_component );
1486
+			$tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] = (!empty($tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'])) ? $tpl_component['PRODUCT_THUMBNAIL_WPSHOP-PRODUCT-GALERY'] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1487
+			$productThumbnail = wpshop_display::display_template_element('product_thumbnail', $tpl_component);
1488 1488
 			unset($tpl_component);
1489 1489
 		}
1490 1490
 
1491
-		$product_document_galery = wps_media_manager_frontend_ctr::get_product_complete_sheet_attachments( $product_id );
1491
+		$product_document_galery = wps_media_manager_frontend_ctr::get_product_complete_sheet_attachments($product_id);
1492 1492
 
1493 1493
 		/**	Retrieve product attributes for output	*/
1494
-		$attributeContentOutput = wpshop_attributes::attribute_of_entity_to_tab( wpshop_entities::get_entity_identifier_from_code( self::currentPageCode ), $product_id, $product);
1494
+		$attributeContentOutput = wpshop_attributes::attribute_of_entity_to_tab(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $product_id, $product);
1495 1495
 
1496 1496
 		/** Retrieve product price */
1497
-		$price_attribute = wpshop_attributes::getElement( 'product_price', "'valid'", 'code' );
1498
-		$price_display = wpshop_attributes::check_attribute_display( $price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
1499
-		$catalog_options = get_option( 'wpshop_catalog_main_option' , array() );
1497
+		$price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
1498
+		$price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
1499
+		$catalog_options = get_option('wpshop_catalog_main_option', array());
1500 1500
 		$productPrice = '';
1501 1501
 		$wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting');
1502 1502
 		$check_product_price = wpshop_prices::check_product_price($product);
1503
-		$result_price_piloting = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1504
-		if ( $price_display && !( !empty( $catalog_options ) && ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) && $result_price_piloting == 0 ) ) {
1503
+		$result_price_piloting = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1504
+		if ($price_display && !(!empty($catalog_options) && (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes') && $result_price_piloting == 0)) {
1505 1505
 			$productPrice = wpshop_prices::get_product_price($product, 'price_display', 'complete_sheet');
1506 1506
 		}
1507 1507
 
1508 1508
 		/** Check if there is at less 1 product in stock	*/
1509 1509
 		$productStock = $wps_product_ctr->check_stock($product_id, 1);
1510
-		$productStock = ( $productStock === true ) ? 1 : null;
1510
+		$productStock = ($productStock === true) ? 1 : null;
1511 1511
 
1512 1512
 		/** if !product stock check product have variation with stock **/
1513 1513
 // 		if ( empty($productStock) ) {
1514
-			$product_variation_meta = get_post_meta( $product_id, '_wpshop_variation_defining', true );
1515
-			if ( !empty($product_variation_meta) && !empty($product_variation_meta['options']) && !empty($product_variation_meta['options']['priority']) && in_array('combined', $product_variation_meta['options']['priority']) ) {
1516
-				$variations = wpshop_products::get_variation( $product_id );
1517
-				if ( !empty($variations) ) {
1518
-					foreach( $variations as $variation ) {
1519
-						if ( !empty($variation) && !empty($variation['variation_dif']) && array_key_exists('product_stock', $variation['variation_dif']) && round( $variation['variation_dif']['product_stock'] ) > 0 ) {
1514
+			$product_variation_meta = get_post_meta($product_id, '_wpshop_variation_defining', true);
1515
+			if (!empty($product_variation_meta) && !empty($product_variation_meta['options']) && !empty($product_variation_meta['options']['priority']) && in_array('combined', $product_variation_meta['options']['priority'])) {
1516
+				$variations = wpshop_products::get_variation($product_id);
1517
+				if (!empty($variations)) {
1518
+					foreach ($variations as $variation) {
1519
+						if (!empty($variation) && !empty($variation['variation_dif']) && array_key_exists('product_stock', $variation['variation_dif']) && round($variation['variation_dif']['product_stock']) > 0) {
1520 1520
 							$productStock = 1;
1521 1521
 						}
1522 1522
 					}
@@ -1525,16 +1525,16 @@  discard block
 block discarded – undo
1525 1525
 // 		}
1526 1526
 
1527 1527
 		/** Define "Add to cart" button	 */
1528
-		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display( ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'complete_sheet');
1528
+		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display(((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'complete_sheet');
1529 1529
 		$display_price_state_when_price_is_empty = true;
1530
-		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1530
+		if (empty($productPrice) && (!empty($catalog_options) || (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes'))) {
1531 1531
 			$display_price_state_when_price_is_empty = false;
1532 1532
 		}
1533
-		else if ( !empty( $productPrice ) ) {
1533
+		else if (!empty($productPrice)) {
1534 1534
 			$display_price_state_when_price_is_empty = true;
1535 1535
 		}
1536
-		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'complete' ) : '';
1537
-		$product_quantity_chooser_input = ( true === $add_to_cart_button_display_state ) ? wpshop_display::display_template_element( 'product_complete_sheet_quantity_chooser', array( 'PRODUCT_ID' => $product_id, ) ) : '';
1536
+		$add_to_cart_button = (true === $add_to_cart_button_display_state) && (true === $display_price_state_when_price_is_empty) ? self::display_add_to_cart_button($product_id, $productStock, 'complete') : '';
1537
+		$product_quantity_chooser_input = (true === $add_to_cart_button_display_state) ? wpshop_display::display_template_element('product_complete_sheet_quantity_chooser', array('PRODUCT_ID' => $product_id,)) : '';
1538 1538
 
1539 1539
 		/** Define "Ask a quotation" button	*/
1540 1540
 		$quotation_button = self::display_quotation_button($product_id, (!empty($product['quotation_allowed']) ? $product['quotation_allowed'] : null), 'complete');
@@ -1551,14 +1551,14 @@  discard block
 block discarded – undo
1551 1551
 		$tpl_component['PRODUCT_PRICE'] = $productPrice;
1552 1552
 		$modules_option = get_option('wpshop_modules');
1553 1553
 		$tpl_component['LOW_STOCK_ALERT_MESSAGE'] = '';
1554
-		if ( !empty($modules_option) && !empty($modules_option['wpshop_low_stock_alert']) && $modules_option['wpshop_low_stock_alert']['activated'] == 'on' ) {
1554
+		if (!empty($modules_option) && !empty($modules_option['wpshop_low_stock_alert']) && $modules_option['wpshop_low_stock_alert']['activated'] == 'on') {
1555 1555
 			$wps_marketing_tools = new wps_marketing_tools_ctr();
1556
-			$tpl_component['LOW_STOCK_ALERT_MESSAGE'] = $wps_marketing_tools->display_alert_stock_message( array( 'id' => $product_id ) );
1556
+			$tpl_component['LOW_STOCK_ALERT_MESSAGE'] = $wps_marketing_tools->display_alert_stock_message(array('id' => $product_id));
1557 1557
 		}
1558 1558
 
1559 1559
 
1560 1560
 		/** Gallery **/
1561
-		$tpl_component['PRODUCT_COMPLETE_SHEET_GALLERY'] = wps_media_manager_frontend_ctr::get_product_complete_sheet_galery( $product_id );
1561
+		$tpl_component['PRODUCT_COMPLETE_SHEET_GALLERY'] = wps_media_manager_frontend_ctr::get_product_complete_sheet_galery($product_id);
1562 1562
 
1563 1563
 		$product_new_def = self::display_product_special_state('declare_new', 'complete', (!empty($product['declare_new']) ? $product['declare_new'] : 'no'), (!empty($product['set_new_from']) ? $product['set_new_from'] : ''), (!empty($product['set_new_to']) ? $product['set_new_to'] : ''));
1564 1564
 
@@ -1577,14 +1577,14 @@  discard block
 block discarded – undo
1577 1577
 		$tpl_component['PRODUCT_BUTTON_ADD_TO_CART'] = $add_to_cart_button;
1578 1578
 		$tpl_component['PRODUCT_BUTTON_QUOTATION'] = $quotation_button;
1579 1579
 		$tpl_component['PRODUCT_QUANTITY_CHOOSER'] = $product_quantity_chooser_input;
1580
-		$tpl_component['PRODUCT_BUTTONS'] = $tpl_component['PRODUCT_BUTTON_QUOTATION'].$tpl_component['PRODUCT_BUTTON_ADD_TO_CART'];
1580
+		$tpl_component['PRODUCT_BUTTONS'] = $tpl_component['PRODUCT_BUTTON_QUOTATION'] . $tpl_component['PRODUCT_BUTTON_ADD_TO_CART'];
1581 1581
 		$tpl_component['PRODUCT_GALERY_DOCS'] = $product_document_galery;
1582 1582
 		$tpl_component['PRODUCT_FEATURES'] = $attributeContentOutput;
1583
-		$tpl_component = apply_filters( 'wps-filter-product-complete-sheet-output', $tpl_component, $product_id );
1583
+		$tpl_component = apply_filters('wps-filter-product-complete-sheet-output', $tpl_component, $product_id);
1584 1584
 
1585 1585
 		/** Build template	*/
1586 1586
 		$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
1587
-		if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
1587
+		if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
1588 1588
 			/*	Include the old way template part	*/
1589 1589
 			ob_start();
1590 1590
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -1605,14 +1605,14 @@  discard block
 block discarded – undo
1605 1605
 
1606 1606
 		/** Get the product thumbnail	*/
1607 1607
 		$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1608
-		if(has_post_thumbnail($product_id)){
1608
+		if (has_post_thumbnail($product_id)) {
1609 1609
 			$productThumbnail = get_the_post_thumbnail($product_id, 'thumbnail');
1610 1610
 		}
1611 1611
 
1612 1612
 		$product = self::get_product_data($product_id);
1613 1613
 
1614 1614
 		/**	Get the product information for output	*/
1615
-		if ( !empty($product) ) {
1615
+		if (!empty($product)) {
1616 1616
 
1617 1617
 			$product_title = $product['post_title'];
1618 1618
 			$product_name = $product['post_name'];
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 			$product_more_informations = $product['product_content'];
1621 1621
 			$product_excerpt = $product['product_excerpt'];
1622 1622
 
1623
-			if ( strpos($product['product_content'], '<!--more-->') ) {
1623
+			if (strpos($product['product_content'], '<!--more-->')) {
1624 1624
 				$post_content = explode('<!--more-->', $product['product_content']);
1625 1625
 				$product_more_informations = $post_content[0];
1626 1626
 			}
@@ -1628,55 +1628,55 @@  discard block
 block discarded – undo
1628 1628
 		}
1629 1629
 		else {
1630 1630
 			$productThumbnail = wpshop_display::display_template_element('product_thumbnail_default', array());
1631
-			$product_title = '<i>'.__('This product does not exist', 'wpshop').'</i>';
1631
+			$product_title = '<i>' . __('This product does not exist', 'wpshop') . '</i>';
1632 1632
 			$product_link = '';
1633 1633
 			$product_more_informations = '';
1634 1634
 			$product_excerpt = '';
1635 1635
 		}
1636 1636
 
1637 1637
 		/** Retrieve product price	*/
1638
-		$price_attribute = wpshop_attributes::getElement( 'product_price', "'valid'", 'code' );
1639
-		$price_display = wpshop_attributes::check_attribute_display( $price_attribute->is_visible_in_front_listing, $product['custom_display'], 'attribute', 'product_price', 'mini_output');
1640
-		$catalog_options = get_option( 'wpshop_catalog_main_option' , array() );
1638
+		$price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
1639
+		$price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front_listing, $product['custom_display'], 'attribute', 'product_price', 'mini_output');
1640
+		$catalog_options = get_option('wpshop_catalog_main_option', array());
1641 1641
 		$productPrice = '';
1642 1642
 		$wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting');
1643 1643
 		$check_product_price = wpshop_prices::check_product_price($product);
1644
-		$result_price_piloting = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1645
-		if ( $price_display && !( !empty( $catalog_options ) && ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) && $result_price_piloting == 0 ) ) {
1646
-			$product_price_infos = wpshop_prices::get_product_price( $product, 'just_price_infos', 'mini_output' );
1644
+		$result_price_piloting = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $check_product_price['et'] : $check_product_price['ati'];
1645
+		if ($price_display && !(!empty($catalog_options) && (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes') && $result_price_piloting == 0)) {
1646
+			$product_price_infos = wpshop_prices::get_product_price($product, 'just_price_infos', 'mini_output');
1647 1647
 
1648
-	 		if ( !empty($product_price_infos) ) {
1648
+	 		if (!empty($product_price_infos)) {
1649 1649
 	 			$tpl_component_price = array();
1650 1650
 	 			/** Price piloting **/
1651
-	 			$price_ploting = get_option( 'wpshop_shop_price_piloting' );
1652
-	 			$tpl_component_price['CROSSED_OUT_PRICE'] = ( !empty($product_price_infos['CROSSED_OUT_PRICE']) ) ? ( ( !empty($product_price_infos['PRICE_FROM']) ) ? __('Price from', 'wpshop') . ' ' : '' ) . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $product_price_infos['CROSSED_OUT_PRICE'])) : '';
1653
-	 			$variations = wpshop_products::get_variation( $product_id );
1654
-				$tpl_component_price['PRODUCT_PRICE'] = ( empty($product_price_infos['CROSSED_OUT_PRICE']) && ( !empty( $variations ) && !empty($product_price_infos['PRICE_FROM'] ) ) ) ? __('Price from', 'wpshop') . ' ' . $product_price_infos['PRODUCT_PRICE'] : $product_price_infos['PRODUCT_PRICE'];
1651
+	 			$price_ploting = get_option('wpshop_shop_price_piloting');
1652
+	 			$tpl_component_price['CROSSED_OUT_PRICE'] = (!empty($product_price_infos['CROSSED_OUT_PRICE'])) ? ((!empty($product_price_infos['PRICE_FROM'])) ? __('Price from', 'wpshop') . ' ' : '') . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $product_price_infos['CROSSED_OUT_PRICE'])) : '';
1653
+	 			$variations = wpshop_products::get_variation($product_id);
1654
+				$tpl_component_price['PRODUCT_PRICE'] = (empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && !empty($product_price_infos['PRICE_FROM']))) ? __('Price from', 'wpshop') . ' ' . $product_price_infos['PRODUCT_PRICE'] : $product_price_infos['PRODUCT_PRICE'];
1655 1655
 	 			$tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY'];
1656
-	 			$tpl_component_price['TAX_PILOTING'] = (!empty($price_ploting) && $price_ploting == 'HT' ) ? __('ET', 'wpshop') : ''; $product_price_infos['MESSAGE_SAVE_MONEY'];
1657
-	 			$productPrice = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component_price );
1656
+	 			$tpl_component_price['TAX_PILOTING'] = (!empty($price_ploting) && $price_ploting == 'HT') ? __('ET', 'wpshop') : ''; $product_price_infos['MESSAGE_SAVE_MONEY'];
1657
+	 			$productPrice = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component_price);
1658 1658
 	 		}
1659 1659
 			else {
1660
-				$productPrice = wpshop_prices::get_product_price($product, 'price_display', array('mini_output', $output_type) );
1660
+				$productPrice = wpshop_prices::get_product_price($product, 'price_display', array('mini_output', $output_type));
1661 1661
 	 		}
1662 1662
 		}
1663 1663
 
1664 1664
 		/** Check if there is at less 1 product in stock	*/
1665 1665
 		$wps_product_ctr = new wps_product_ctr();
1666 1666
 		$productStock = $wps_product_ctr->check_stock($product_id, 1);
1667
-		$productStock = $productStock===true ? 1 : null;
1667
+		$productStock = $productStock === true ? 1 : null;
1668 1668
 
1669 1669
 		/** Define "Add to cart" button	*/
1670
-		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display( ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'mini_output');
1670
+		$add_to_cart_button_display_state = wpshop_attributes::check_attribute_display(((WPSHOP_DEFINED_SHOP_TYPE == 'sale') ? 'yes' : 'no'), $product['custom_display'], 'product_action_button', 'add_to_cart', 'mini_output');
1671 1671
 		$display_price_state_when_price_is_empty = false;
1672
-		if ( empty( $productPrice ) && ( !empty( $catalog_options ) || ( !empty( $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] ) && $catalog_options[ 'wpshop_catalog_empty_price_behaviour' ] == 'yes' ) ) ) {
1672
+		if (empty($productPrice) && (!empty($catalog_options) || (!empty($catalog_options['wpshop_catalog_empty_price_behaviour']) && $catalog_options['wpshop_catalog_empty_price_behaviour'] == 'yes'))) {
1673 1673
 			$display_price_state_when_price_is_empty = false;
1674 1674
 		}
1675
-		else if ( !empty( $productPrice ) ) {
1675
+		else if (!empty($productPrice)) {
1676 1676
 			$display_price_state_when_price_is_empty = true;
1677 1677
 		}
1678
-		$add_to_cart_button = ( true === $add_to_cart_button_display_state)  && ( true === $display_price_state_when_price_is_empty ) ? self::display_add_to_cart_button( $product_id, $productStock, 'mini' ) : '';
1679
-		$product_quantity_chooser_input = ( true === $add_to_cart_button_display_state ) ? wpshop_display::display_template_element( 'product_complete_sheet_quantity_chooser', array( 'PRODUCT_ID' => $product_id, ) ) : '';
1678
+		$add_to_cart_button = (true === $add_to_cart_button_display_state) && (true === $display_price_state_when_price_is_empty) ? self::display_add_to_cart_button($product_id, $productStock, 'mini') : '';
1679
+		$product_quantity_chooser_input = (true === $add_to_cart_button_display_state) ? wpshop_display::display_template_element('product_complete_sheet_quantity_chooser', array('PRODUCT_ID' => $product_id,)) : '';
1680 1680
 
1681 1681
 		/** Define "Ask a quotation" button	*/
1682 1682
 		$quotation_button = self::display_quotation_button($product_id, (!empty($product['quotation_allowed']) ? $product['quotation_allowed'] : null));
@@ -1690,11 +1690,11 @@  discard block
 block discarded – undo
1690 1690
 		$product_featured = $product_featured_def['output'];
1691 1691
 		$product_class .= $product_featured_def['class'];
1692 1692
 
1693
-		if ( !($current_item_position%$grid_element_nb_per_line) ) {
1693
+		if (!($current_item_position % $grid_element_nb_per_line)) {
1694 1694
 			$product_class .= ' wpshop_last_product_of_line';
1695 1695
 		}
1696 1696
 
1697
-		if ( !empty($product['product_id']) ) {
1697
+		if (!empty($product['product_id'])) {
1698 1698
 			/** Template parameters	*/
1699 1699
 			$template_part = 'product_mini_' . $output_type;
1700 1700
 			$tpl_component = array();
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 			$tpl_component['PRODUCT_BUTTONS'] = $tpl_component['PRODUCT_BUTTON_ADD_TO_CART'] . $tpl_component['PRODUCT_BUTTON_QUOTATION'];
1709 1709
 			$tpl_component['PRODUCT_PRICE'] = $productPrice;
1710 1710
 			$tpl_component['PRODUCT_PERMALINK'] = $product_link;
1711
-			$tpl_component['PRODUCT_TITLE'] = ( !empty($product_title) ) ? $product_title  : '';
1711
+			$tpl_component['PRODUCT_TITLE'] = (!empty($product_title)) ? $product_title : '';
1712 1712
 			$tpl_component['PRODUCT_NAME'] = $product_name;
1713 1713
 			$tpl_component['PRODUCT_DESCRIPTION'] = $product_more_informations;
1714 1714
 			$tpl_component['PRODUCT_IS_NEW'] = $product_new;
@@ -1716,24 +1716,24 @@  discard block
 block discarded – undo
1716 1716
 			$tpl_component['PRODUCT_EXTRA_STATE'] = $tpl_component['PRODUCT_IS_NEW'] . $tpl_component['PRODUCT_IS_FEATURED'];
1717 1717
 			$tpl_component['PRODUCT_THUMBNAIL'] = $productThumbnail;
1718 1718
 
1719
-			if ( has_post_thumbnail($product_id) ) {
1720
-				$image_attributes = wp_get_attachment_metadata( get_post_thumbnail_id($product_id)  );
1721
-				if ( !empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes']) ) {
1719
+			if (has_post_thumbnail($product_id)) {
1720
+				$image_attributes = wp_get_attachment_metadata(get_post_thumbnail_id($product_id));
1721
+				if (!empty($image_attributes) && !empty($image_attributes['sizes']) && is_array($image_attributes['sizes'])) {
1722 1722
 					$existing_image_sizes = get_intermediate_image_sizes();
1723
-					foreach ( $existing_image_sizes as $size_name) {
1723
+					foreach ($existing_image_sizes as $size_name) {
1724 1724
 						$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = wp_get_attachment_image(get_post_thumbnail_id($product_id), $size_name);
1725
-						$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = ( !empty( $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] ) ) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1725
+						$tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] = (!empty($tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)])) ? $tpl_component['PRODUCT_THUMBNAIL_' . strtoupper($size_name)] : WPSHOP_DEFAULT_PRODUCT_PICTURE;
1726 1726
 					}
1727 1727
 				}
1728 1728
 			}
1729 1729
 
1730 1730
 			$tpl_component['PRODUCT_EXCERPT'] = $product_excerpt;
1731 1731
 			$tpl_component['PRODUCT_OUTPUT_TYPE'] = $output_type;
1732
-			$tpl_component = apply_filters( 'wps-filter-product-mini-output', $tpl_component, $product_id );
1732
+			$tpl_component = apply_filters('wps-filter-product-mini-output', $tpl_component, $product_id);
1733 1733
 
1734 1734
 			/** Build template	*/
1735 1735
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
1736
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
1736
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
1737 1737
 				/**	Include the old way template part	*/
1738 1738
 				ob_start();
1739 1739
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -1760,18 +1760,18 @@  discard block
 block discarded – undo
1760 1760
 	*
1761 1761
 	*	@return mixed $widget_content The output for the product list
1762 1762
 	*/
1763
-	public static function get_product_of_category($category_slug, $category_id){
1763
+	public static function get_product_of_category($category_slug, $category_id) {
1764 1764
 		global $top_categories;
1765 1765
 		$widget_content = '';
1766
-		$products = wp_cache_get( 'wpshop_products_category_'.$category_id );
1767
-		if( false == $products ) {
1766
+		$products = wp_cache_get('wpshop_products_category_' . $category_id);
1767
+		if (false == $products) {
1768 1768
 			$args = array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES => $category_slug);
1769 1769
 			$products = get_posts($args);
1770
-			wp_cache_set( 'wpshop_products_category_'.$category_id, $products );
1770
+			wp_cache_set('wpshop_products_category_' . $category_id, $products);
1771 1771
 		}
1772
-		if(is_array($products) && (count($products) > 0)){
1773
-			foreach($products as $product){
1774
-				if ( $product->post_status == "publish" ) {
1772
+		if (is_array($products) && (count($products) > 0)) {
1773
+			foreach ($products as $product) {
1774
+				if ($product->post_status == "publish") {
1775 1775
 					ob_start();
1776 1776
 					require(wpshop_display::get_template_file('categories_products-widget.tpl.php'));
1777 1777
 					$widget_content .= ob_get_contents();
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 	 * @param unknown_type $selected_product
1789 1789
 	 * @return string
1790 1790
 	 */
1791
-	function custom_product_list($selected_product = array()){
1791
+	function custom_product_list($selected_product = array()) {
1792 1792
 		global $wpdb;
1793 1793
 
1794 1794
 		/*	Start the table definition	*/
@@ -1816,9 +1816,9 @@  discard block
 block discarded – undo
1816 1816
 		$posts = query_posts(array(
1817 1817
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'posts_per_page' => -1
1818 1818
 		));
1819
-		if(!empty($posts)){
1819
+		if (!empty($posts)) {
1820 1820
 			$has_result = true;
1821
-			foreach($posts as $post){
1821
+			foreach ($posts as $post) {
1822 1822
 				$tableRowsId[$current_line_index] = 'product_' . $post->ID;
1823 1823
 
1824 1824
 				$post_info = get_post_meta($post->ID, '_wpshop_product_metadata', true);
@@ -1826,12 +1826,12 @@  discard block
 block discarded – undo
1826 1826
 				unset($tableRowValue);
1827 1827
 				$tableRowValue[] = array('class' => 'wpshop_product_selector_cell', 'value' => '<input type="checkbox" name="wp_list_product[]" value="' . $post->ID . '" class="wpshop_product_cb_dialog" id="wpshop_product_cb_dialog_' . $post->ID . '" />');
1828 1828
 				$tableRowValue[] = array('class' => 'wpshop_product_identifier_cell', 'value' => '<label for="wpshop_product_cb_dialog_' . $post->ID . '" >' . WPSHOP_IDENTIFIER_PRODUCT . $post->ID . '</label>');
1829
-				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID  . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1830
-				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => ( !empty($post_info['product_reference']) ) ? $post_info['product_reference'] : '');
1829
+				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1830
+				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => (!empty($post_info['product_reference'])) ? $post_info['product_reference'] : '');
1831 1831
 				$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $post->post_title);
1832 1832
 				$tableRowValue[] = array('class' => 'wpshop_product_link_cell', 'value' => '<a href="' . $post->guid . '" target="wpshop_product_view_product" target="wpshop_view_product" >' . __('View product', 'wpshop') . '</a><br/>
1833
-				<a href="' . admin_url('post.php?post=' . $post->ID  . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1834
-				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty( $post_info[WPSHOP_PRODUCT_PRICE_HT]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty($post_info[WPSHOP_PRODUCT_PRICE_TTC]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1833
+				<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1834
+				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_HT])) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_TTC])) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1835 1835
 				$tableRows[] = $tableRowValue;
1836 1836
 
1837 1837
 				$current_line_index++;
@@ -1841,9 +1841,9 @@  discard block
 block discarded – undo
1841 1841
 		$posts = query_posts(array(
1842 1842
 				'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'posts_per_page' => -1
1843 1843
 		));
1844
-		if(!empty($posts)){
1844
+		if (!empty($posts)) {
1845 1845
 			$has_result = true;
1846
-			foreach($posts as $post){
1846
+			foreach ($posts as $post) {
1847 1847
 				$tableRowsId[$current_line_index] = 'product_' . $post->ID;
1848 1848
 
1849 1849
 				$post_info = get_post_meta($post->ID, '_wpshop_product_metadata', true);
@@ -1851,25 +1851,25 @@  discard block
 block discarded – undo
1851 1851
 				unset($tableRowValue);
1852 1852
 				$tableRowValue[] = array('class' => 'wpshop_product_selector_cell', 'value' => '<input type="checkbox" name="wp_list_product[]" value="' . $post->ID . '" class="wpshop_product_cb_dialog" id="wpshop_product_cb_dialog_' . $post->ID . '" />');
1853 1853
 				$tableRowValue[] = array('class' => 'wpshop_product_identifier_cell', 'value' => '<label for="wpshop_product_cb_dialog_' . $post->ID . '" >' . WPSHOP_IDENTIFIER_PRODUCT . $post->ID . '</label>');
1854
-				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID  . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1855
-				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => ( !empty($post_info['product_reference']) ) ? $post_info['product_reference'] : '');
1854
+				$tableRowValue[] = array('class' => 'wpshop_product_quantity_cell', 'value' => '<a href="#" class="order_product_action_button qty_change">-</a><input type="text" name="wpshop_pdt_qty[' . $post->ID . ']" value="1" class="wpshop_order_product_qty" /><a href="#" class="order_product_action_button qty_change">+</a>');
1855
+				$tableRowValue[] = array('class' => 'wpshop_product_sku_cell', 'value' => (!empty($post_info['product_reference'])) ? $post_info['product_reference'] : '');
1856 1856
 				$parent_product = wpshop_products::get_parent_variation($post->ID);
1857
-				if ( !empty($parent_product) && !empty($parent_product['parent_post']) ) {
1858
-					$product_variations_postmeta = get_post_meta($post->ID,'_wpshop_variations_attribute_def', true);
1859
-					$query = $wpdb->prepare('SELECT frontend_label FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', key($product_variations_postmeta) );
1857
+				if (!empty($parent_product) && !empty($parent_product['parent_post'])) {
1858
+					$product_variations_postmeta = get_post_meta($post->ID, '_wpshop_variations_attribute_def', true);
1859
+					$query = $wpdb->prepare('SELECT frontend_label FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', key($product_variations_postmeta));
1860 1860
 					$option_name = $wpdb->get_var($query);
1861
-					$query = $wpdb->prepare('SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $product_variations_postmeta[key($product_variations_postmeta)]);
1861
+					$query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $product_variations_postmeta[key($product_variations_postmeta)]);
1862 1862
 					$option_value = $wpdb->get_var($query);
1863 1863
 					$parent_post = $parent_product['parent_post'];
1864
-					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $parent_post->post_title. ' <br/>('. $option_name . ' : ' . $option_value. ')');
1864
+					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $parent_post->post_title . ' <br/>(' . $option_name . ' : ' . $option_value . ')');
1865 1865
 				}
1866 1866
 				else {
1867 1867
 					$tableRowValue[] = array('class' => 'wpshop_product_name_cell', 'value' => $post->post_title);
1868 1868
 				}
1869 1869
 
1870 1870
 				$tableRowValue[] = array('class' => 'wpshop_product_link_cell', 'value' => '<a href="' . $post->guid . '" target="wpshop_product_view_product" target="wpshop_view_product" >' . __('View product', 'wpshop') . '</a><br/>
1871
-				<a href="' . admin_url('post.php?post=' . $post->ID  . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1872
-				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty( $post_info[WPSHOP_PRODUCT_PRICE_HT]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ( ( !empty($post_info[WPSHOP_PRODUCT_PRICE_TTC]) ) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC],2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1871
+				<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" target="wpshop_edit_product" >' . __('Edit product', 'wpshop') . '</a>');
1872
+				$tableRowValue[] = array('class' => 'wpshop_product_price_cell', 'value' => __('Price ET', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_HT])) ? round($post_info[WPSHOP_PRODUCT_PRICE_HT], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : '') . '<br/>' . __('Price ATI', 'wpshop') . '&nbsp;:&nbsp;' . ((!empty($post_info[WPSHOP_PRODUCT_PRICE_TTC])) ? round($post_info[WPSHOP_PRODUCT_PRICE_TTC], 2) . '&nbsp;' . wpshop_tools::wpshop_get_currency() : ''));
1873 1873
 				$tableRows[] = $tableRowValue;
1874 1874
 
1875 1875
 				$current_line_index++;
@@ -1927,15 +1927,15 @@  discard block
 block discarded – undo
1927 1927
 
1928 1928
 		/** PRODUCT MARK AS NEW */
1929 1929
 		$show_product_special_state = false;
1930
-		if ( (strtolower(__($special_state_def, 'wpshop')) === strtolower(__('Yes', 'wpshop')) ) &&
1930
+		if ((strtolower(__($special_state_def, 'wpshop')) === strtolower(__('Yes', 'wpshop'))) &&
1931 1931
 				(empty($special_state_start) || ($special_state_start == '0000-00-00') || ($special_state_start >= $current_time)) &&
1932
-				(empty($special_state_end) || ($special_state_end == '0000-00-00') || ($special_state_end <= $current_time)) ) {
1932
+				(empty($special_state_end) || ($special_state_end == '0000-00-00') || ($special_state_end <= $current_time))) {
1933 1933
 			$show_product_special_state = true;
1934 1934
 		}
1935 1935
 
1936
-		if ( $show_product_special_state ) {
1936
+		if ($show_product_special_state) {
1937 1937
 			/** Check the type of special output needed	*/
1938
-			switch ( $special ) {
1938
+			switch ($special) {
1939 1939
 				case 'declare_new':
1940 1940
 					$product_special_state['class'] = ' wpshop_product_is_new_' . $output_type;
1941 1941
 					$template_part = 'product_is_new_sticker';
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 			/** Build template		*/
1954 1954
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
1955
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
1955
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
1956 1956
 				/**	Include the old way template part	*/
1957 1957
 				ob_start();
1958 1958
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
 	 *
1976 1976
 	 * @param integer $element_id Identifier of current product
1977 1977
 	 */
1978
-	public static function calculate_price( $element_id ) {
1978
+	public static function calculate_price($element_id) {
1979 1979
 		global $wpdb;
1980 1980
 
1981 1981
 		/**
@@ -1987,13 +1987,13 @@  discard block
 block discarded – undo
1987 1987
 			"SELECT ATTR.code, ATTR_VAL.value_id AS id, ATTR_VAL.value, ATTR.id AS attribute_id
1988 1988
 			FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR
1989 1989
 				RIGHT JOIN " . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . " AS ATTR_VAL ON ((ATTR_VAL.attribute_id = ATTR.id) AND (ATTR_VAL.entity_id = %d))
1990
-			WHERE ATTR.code IN ('" . implode( "', '",  unserialize( WPSHOP_ATTRIBUTE_PRICES ) ) . "')",
1990
+			WHERE ATTR.code IN ('" . implode("', '", unserialize(WPSHOP_ATTRIBUTE_PRICES)) . "')",
1991 1991
 			$element_id
1992 1992
 		);
1993
-		$prices_attribute = $wpdb->get_results( $query, OBJECT_K );
1993
+		$prices_attribute = $wpdb->get_results($query, OBJECT_K);
1994 1994
 
1995 1995
 		/** Si aucun prix trouvé on stop la méthode / If not found price, stop the method */
1996
-		if( empty( $prices_attribute ) ) {
1996
+		if (empty($prices_attribute)) {
1997 1997
 			return false;
1998 1998
 		}
1999 1999
 		else {
@@ -2001,18 +2001,18 @@  discard block
 block discarded – undo
2001 2001
 			 * Récupère le prix de base selon le pilotage de prix de la boutique / Get
2002 2002
 			 * the base amount according on the shop price control
2003 2003
 			 */
2004
-			$base_price 		= $prices_attribute[constant( 'WPSHOP_PRODUCT_PRICE_' . WPSHOP_PRODUCT_PRICE_PILOT )]->value;
2005
-			$rate_vat			= wpshop_prices::get_rate_vat( $element_id );
2006
-			$divider_price_ttc 	= 1 + ( $rate_vat->value / 100 );
2004
+			$base_price = $prices_attribute[constant('WPSHOP_PRODUCT_PRICE_' . WPSHOP_PRODUCT_PRICE_PILOT)]->value;
2005
+			$rate_vat = wpshop_prices::get_rate_vat($element_id);
2006
+			$divider_price_ttc = 1 + ($rate_vat->value / 100);
2007 2007
 
2008 2008
 			/**
2009 2009
 			 * Informations nécessaire pour crée un attribut / Information needed to
2010 2010
 			 * create an attribute
2011 2011
 			 */
2012
-			$entity_type_id	= wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
2013
-			$language 		= WPSHOP_CURRENT_LOCALE;
2012
+			$entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
2013
+			$language = WPSHOP_CURRENT_LOCALE;
2014 2014
 
2015
-			if ( !empty($_REQUEST['icl_post_language']) ) {
2015
+			if (!empty($_REQUEST['icl_post_language'])) {
2016 2016
 				$query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", sanitize_text_field($_REQUEST['icl_post_language']));
2017 2017
 				$language = $wpdb->get_var($query);
2018 2018
 			}
@@ -2021,13 +2021,13 @@  discard block
 block discarded – undo
2021 2021
 			 * Vérifie la configuration pour savoir comment calculer les prix pour le produit /
2022 2022
 			 * Check configuration to know how to make the calcul for the product
2023 2023
 			 */
2024
-			if ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) {
2025
-				$price_with_vat = ($base_price * $divider_price_ttc );
2026
-				$price_no_vat 	= $base_price;
2024
+			if (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') {
2025
+				$price_with_vat = ($base_price * $divider_price_ttc);
2026
+				$price_no_vat = $base_price;
2027 2027
 			}
2028
-			else if ( WPSHOP_PRODUCT_PRICE_PILOT == 'TTC' ) {
2028
+			else if (WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') {
2029 2029
 				$price_with_vat = $base_price;
2030
-				$price_no_vat	= ($price_with_vat / $divider_price_ttc );
2030
+				$price_no_vat = ($price_with_vat / $divider_price_ttc);
2031 2031
 			}
2032 2032
 
2033 2033
 			/**
@@ -2035,29 +2035,29 @@  discard block
 block discarded – undo
2035 2035
 			 * type que celui-ci / The last parameter allows not to delete the
2036 2036
 			 * attributes of the same type as this one
2037 2037
 			 */
2038
-			wpshop_attributes::saveAttributeForEntity( array( 'decimal' => array( 'product_price' => $price_with_vat )), $entity_type_id, $element_id, $language, 'wpshop_products' );
2039
-			wpshop_attributes::saveAttributeForEntity( array( 'decimal' => array( 'price_ht' => $price_no_vat )), $entity_type_id, $element_id, $language, 'wpshop_product' );
2038
+			wpshop_attributes::saveAttributeForEntity(array('decimal' => array('product_price' => $price_with_vat)), $entity_type_id, $element_id, $language, 'wpshop_products');
2039
+			wpshop_attributes::saveAttributeForEntity(array('decimal' => array('price_ht' => $price_no_vat)), $entity_type_id, $element_id, $language, 'wpshop_product');
2040 2040
 
2041 2041
 			/** Ajout ou met à jour de l'attribut tva / Add or update the attribute vat */
2042 2042
 			$vat_amount = $price_with_vat - $price_no_vat;
2043
-			wpshop_attributes::saveAttributeForEntity( array( 'decimal' => array( 'tva' => $vat_amount )), $entity_type_id, $element_id, $language, 'wpshop_product' );
2043
+			wpshop_attributes::saveAttributeForEntity(array('decimal' => array('tva' => $vat_amount)), $entity_type_id, $element_id, $language, 'wpshop_product');
2044 2044
 
2045 2045
 			/**	Update the product meta information with the calculated prices	*/
2046
-			$product_postmeta 									= get_post_meta( $element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true );
2047
-			$product_postmeta[WPSHOP_PRODUCT_PRICE_TTC] 		= number_format( round( $price_with_vat, 5 ), 5, '.', '' );
2048
-			$product_postmeta[WPSHOP_PRODUCT_PRICE_HT] 			= number_format( round( $price_no_vat, 5 ), 5, '.', '' );
2049
-			$product_postmeta[WPSHOP_PRODUCT_PRICE_TAX_AMOUNT] 	= number_format( round( $vat_amount, 5 ), 5, '.', '' );
2046
+			$product_postmeta = get_post_meta($element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
2047
+			$product_postmeta[WPSHOP_PRODUCT_PRICE_TTC] 		= number_format(round($price_with_vat, 5), 5, '.', '');
2048
+			$product_postmeta[WPSHOP_PRODUCT_PRICE_HT] 			= number_format(round($price_no_vat, 5), 5, '.', '');
2049
+			$product_postmeta[WPSHOP_PRODUCT_PRICE_TAX_AMOUNT] = number_format(round($vat_amount, 5), 5, '.', '');
2050 2050
 			$product_postmeta[WPSHOP_PRODUCT_PRICE_TAX] 		= $rate_vat->id;
2051 2051
 
2052
-			update_post_meta($element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $product_postmeta );
2052
+			update_post_meta($element_id, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, $product_postmeta);
2053 2053
 
2054 2054
 			/** Met à jour la meta _wps_price_infos */
2055
-			$p 		= wpshop_products::get_product_data( $element_id );
2056
-			$price 	= wpshop_prices::get_product_price( $p, 'just_price_infos', array( 'mini_output', 'grid' ) );
2057
-			update_post_meta( $element_id, '_wps_price_infos', $price );
2055
+			$p = wpshop_products::get_product_data($element_id);
2056
+			$price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', 'grid'));
2057
+			update_post_meta($element_id, '_wps_price_infos', $price);
2058 2058
 
2059 2059
 			/** Met à jour la meta _wpshop_displayed_price */
2060
-			wps_filter_search::save_displayed_price_meta( $element_id );
2060
+			wps_filter_search::save_displayed_price_meta($element_id);
2061 2061
 		}
2062 2062
 
2063 2063
 		return true;
@@ -2077,24 +2077,24 @@  discard block
 block discarded – undo
2077 2077
 		$button = '';
2078 2078
 // 		$attributes_frontend_display = get_post_meta( $product_id, '_wpshop_product_attributes_frontend_display', true );
2079 2079
 
2080
-		if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' /*&& ( empty($attributes_frontend_display) || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['mini_output']) && $output_type == 'mini') || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['complete_sheet']) && $output_type == 'complete') ) */) {
2080
+		if (WPSHOP_DEFINED_SHOP_TYPE == 'sale' /*&& ( empty($attributes_frontend_display) || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['mini_output']) && $output_type == 'mini') || ( !empty($attributes_frontend_display) && !empty($attributes_frontend_display['product_action_button']) && !empty($attributes_frontend_display['product_action_button']['complete_sheet']) && $output_type == 'complete') ) */) {
2081 2081
 			/*
2082 2082
 			 * Check if current product has variation for button display
2083 2083
 			 */
2084
-			$variations_exists = get_posts( array( 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $product_id) );
2085
-			$variations_list = ( !empty($variations_exists) && is_array( wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode)) ) ) ? true : false;
2084
+			$variations_exists = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'post_parent' => $product_id));
2085
+			$variations_list = (!empty($variations_exists) && is_array(wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode)))) ? true : false;
2086 2086
 
2087 2087
 			/*
2088 2088
 			 * Template parameters
2089 2089
 			 */
2090 2090
 
2091 2091
 
2092
-			if( get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) {
2092
+			if (get_post_type($product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
2093 2093
 				/** Check variation stock **/
2094
-				$variations = self::get_variation( $product_id );
2095
-				if ( !empty($variations) ) {
2096
-					foreach($variations as $variation ) {
2097
-						if( !empty($variation) && !empty($variation['variation_dif']) && !empty($variation['variation_dif']['product_stock']) ) {
2094
+				$variations = self::get_variation($product_id);
2095
+				if (!empty($variations)) {
2096
+					foreach ($variations as $variation) {
2097
+						if (!empty($variation) && !empty($variation['variation_dif']) && !empty($variation['variation_dif']['product_stock'])) {
2098 2098
 							$productStock += $variation['variation_dif']['product_stock'];
2099 2099
 						}
2100 2100
 					}
@@ -2112,7 +2112,7 @@  discard block
 block discarded – undo
2112 2112
 			 * Build template
2113 2113
 			 */
2114 2114
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2115
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2115
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2116 2116
 				/*	Include the old way template part	*/
2117 2117
 				ob_start();
2118 2118
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2137,11 +2137,11 @@  discard block
 block discarded – undo
2137 2137
 	 *
2138 2138
 	 * @return string $button The html output for the button
2139 2139
 	 */
2140
-	public static function display_quotation_button($product_id, $product_quotation_state,  $output_type = 'mini') {
2140
+	public static function display_quotation_button($product_id, $product_quotation_state, $output_type = 'mini') {
2141 2141
 		$quotation_button = '';
2142 2142
 
2143
-		if ( WPSHOP_ADDONS_QUOTATION && (!empty($product_quotation_state) && strtolower(__($product_quotation_state, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) && (empty($_SESSION['cart']['cart_type']) || ($_SESSION['cart']['cart_type'] == 'quotation')) ) {
2144
-			$variations_list = ( is_array( wpshop_products::get_variation( $product_id ) ) && is_array( wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode)) ) ) ? array_merge( wpshop_products::get_variation( $product_id ), wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode) ) ) : array();
2143
+		if (WPSHOP_ADDONS_QUOTATION && (!empty($product_quotation_state) && strtolower(__($product_quotation_state, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) && (empty($_SESSION['cart']['cart_type']) || ($_SESSION['cart']['cart_type'] == 'quotation'))) {
2144
+			$variations_list = (is_array(wpshop_products::get_variation($product_id)) && is_array(wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode)))) ? array_merge(wpshop_products::get_variation($product_id), wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode))) : array();
2145 2145
 			/**
2146 2146
 			 * Template parameters
2147 2147
 			 */
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 			 * Build template
2156 2156
 			 */
2157 2157
 			$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2158
-			if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2158
+			if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2159 2159
 				/*	Include the old way template part	*/
2160 2160
 				ob_start();
2161 2161
 				require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2181,13 +2181,13 @@  discard block
 block discarded – undo
2181 2181
 	 *
2182 2182
 	 * @return string The attachement gallery output
2183 2183
 	 */
2184
-	public static function display_attachment_gallery( $attachement_type, $content ) {
2184
+	public static function display_attachment_gallery($attachement_type, $content) {
2185 2185
 		$galery_output = '';
2186 2186
 
2187 2187
 		/*
2188 2188
 		 * Get the template part for given galery type
2189 2189
 		 */
2190
-		switch ( $attachement_type ) {
2190
+		switch ($attachement_type) {
2191 2191
 			case 'picture':
2192 2192
 					$template_part = 'product_attachment_picture_galery';
2193 2193
 				break;
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
 		 * Build template
2208 2208
 		 */
2209 2209
 		$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2210
-		if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2210
+		if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2211 2211
 			/*	Include the old way template part	*/
2212 2212
 			ob_start();
2213 2213
 			require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2227,11 +2227,11 @@  discard block
 block discarded – undo
2227 2227
 	 * Define the metabox to display in product edition page in backend
2228 2228
 	 * @param object $post The current element displayed for edition
2229 2229
 	 */
2230
-	public static function meta_box_variations( $post ) {
2230
+	public static function meta_box_variations($post) {
2231 2231
 		$output = '';
2232 2232
 		/*	Variations container	*/
2233 2233
 		$tpl_component = array();
2234
-		$tpl_component['ADMIN_VARIATION_CONTAINER'] = self::display_variation_admin( $post->ID );
2234
+		$tpl_component['ADMIN_VARIATION_CONTAINER'] = self::display_variation_admin($post->ID);
2235 2235
 		$output .= wpshop_display::display_template_element('wpshop_admin_variation_metabox', $tpl_component, array(), 'admin');
2236 2236
 		echo '<span class="wpshop_loading_ wpshopHide" ><img src="' . admin_url('images/loading.gif') . '" alt="loading picture" /></span>' . $output . '<div class="wpshop_cls" ></div>';
2237 2237
 	}
@@ -2246,12 +2246,12 @@  discard block
 block discarded – undo
2246 2246
 	 *
2247 2247
 	 * @return mixed The last created variation identifier
2248 2248
 	 */
2249
-	public static function creation_variation_callback( $possible_variations, $element_id ) {
2249
+	public static function creation_variation_callback($possible_variations, $element_id) {
2250 2250
 		/** Get existing variation	*/
2251
-		$existing_variations_in_db = wpshop_products::get_variation( $element_id );
2251
+		$existing_variations_in_db = wpshop_products::get_variation($element_id);
2252 2252
 		$existing_variations = array();
2253
-		if ( !empty($existing_variations_in_db) ) {
2254
-			foreach ( $existing_variations_in_db as $variations_def) {
2253
+		if (!empty($existing_variations_in_db)) {
2254
+			foreach ($existing_variations_in_db as $variations_def) {
2255 2255
 				$existing_variations[] = $variations_def['variation_def'];
2256 2256
 			}
2257 2257
 		}
@@ -2259,22 +2259,22 @@  discard block
 block discarded – undo
2259 2259
 		$attribute_defining_variation = get_post_meta($element_id, '_wpshop_variation_defining', true);
2260 2260
 
2261 2261
 		/**	Read possible values	*/
2262
-		foreach ( $possible_variations as $variation_definition) {
2263
-			if ( in_array($variation_definition, $existing_variations) ) {
2262
+		foreach ($possible_variations as $variation_definition) {
2263
+			if (in_array($variation_definition, $existing_variations)) {
2264 2264
 				continue;
2265 2265
 			}
2266 2266
 
2267 2267
 			$attribute_to_set = array();
2268
-			foreach ( $variation_definition as $attribute_code => $attribute_selected_value ) {
2268
+			foreach ($variation_definition as $attribute_code => $attribute_selected_value) {
2269 2269
 				$attribute = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
2270 2270
 				$attribute_to_set[$attribute->data_type][$attribute_code] = $attribute_selected_value;
2271
-				if ( empty($attribute_defining_variation['attributes']) || (!in_array($attribute_code, $attribute_defining_variation['attributes'])) ) {
2271
+				if (empty($attribute_defining_variation['attributes']) || (!in_array($attribute_code, $attribute_defining_variation['attributes']))) {
2272 2272
 					$attribute_defining_variation['attributes'][] = $attribute_code;
2273 2273
 				}
2274 2274
 			}
2275 2275
 			$variation_id = wpshop_products::create_variation($element_id, $attribute_to_set);
2276 2276
 		}
2277
-		update_post_meta($element_id, '_wpshop_variation_defining', $attribute_defining_variation );
2277
+		update_post_meta($element_id, '_wpshop_variation_defining', $attribute_defining_variation);
2278 2278
 
2279 2279
 		return !empty($variation_id) ? $variation_id : 0;
2280 2280
 	}
@@ -2288,13 +2288,13 @@  discard block
 block discarded – undo
2288 2288
 	 *
2289 2289
 	 * @return mixed <number, WP_Error> The variation identifier or an error in case the creation was not succesfull
2290 2290
 	 */
2291
-	public static function create_variation( $head_product, $variation_attributes ) {
2291
+	public static function create_variation($head_product, $variation_attributes) {
2292 2292
 		/** Create custom title */
2293 2293
 		$title_variation = "";
2294
-		if(!empty($variation_attributes)) {
2295
-			foreach($variation_attributes as $type => $array) {
2296
-				if(!empty($array)) {
2297
-					foreach($array as $code => $value) {
2294
+		if (!empty($variation_attributes)) {
2295
+			foreach ($variation_attributes as $type => $array) {
2296
+				if (!empty($array)) {
2297
+					foreach ($array as $code => $value) {
2298 2298
 						$title_variation .= " " . $code . " " . $value;
2299 2299
 					}
2300 2300
 				}
@@ -2302,25 +2302,25 @@  discard block
 block discarded – undo
2302 2302
 		}
2303 2303
 
2304 2304
 		$variation = array(
2305
-			'post_title' => sprintf(__('Product %s variation %s', 'wpshop'), $head_product, get_the_title( $head_product )) . $title_variation,
2305
+			'post_title' => sprintf(__('Product %s variation %s', 'wpshop'), $head_product, get_the_title($head_product)) . $title_variation,
2306 2306
 			'post_content' => '',
2307 2307
 			'post_status' => 'publish',
2308 2308
 			'post_author' => get_current_user_id(),
2309 2309
 			'post_parent' => $head_product,
2310 2310
 			'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION
2311 2311
 		);
2312
-		$variation_id = wp_insert_post( $variation );
2312
+		$variation_id = wp_insert_post($variation);
2313 2313
 
2314 2314
 		wpshop_attributes::saveAttributeForEntity($variation_attributes, wpshop_entities::get_entity_identifier_from_code(wpshop_products::currentPageCode), $variation_id, WPSHOP_CURRENT_LOCALE, '');
2315 2315
 
2316 2316
 		/*	Update product price looking for shop parameters	*/
2317
-		wpshop_products::calculate_price( $variation_id );
2317
+		wpshop_products::calculate_price($variation_id);
2318 2318
 
2319 2319
 		/*	Save the attributes values into wordpress post metadata database in order to have a backup and to make frontend search working	*/
2320 2320
 		$productMetaDatas = array();
2321
-		foreach ( $variation_attributes as $attributeType => $attributeValues ) {
2322
-			foreach ( $attributeValues as $attributeCode => $attributeValue ) {
2323
-				if ( !empty($attributeValue) ) {
2321
+		foreach ($variation_attributes as $attributeType => $attributeValues) {
2322
+			foreach ($attributeValues as $attributeCode => $attributeValue) {
2323
+				if (!empty($attributeValue)) {
2324 2324
 					$productMetaDatas[$attributeCode] = $attributeValue;
2325 2325
 				}
2326 2326
 			}
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
 	 * @param integer $head_product The product identifier to get the variation for
2340 2340
 	 * @return object The variation list
2341 2341
 	 */
2342
-	public static function get_variation( $head_product ) {
2342
+	public static function get_variation($head_product) {
2343 2343
 		global $wpdb;
2344 2344
 		$variations_output = null;
2345 2345
 // 		$variations = query_posts(array(
@@ -2350,18 +2350,18 @@  discard block
 block discarded – undo
2350 2350
 // 			'posts_per_page'=> -1
2351 2351
 // 		));
2352 2352
 
2353
-		$query = $wpdb->prepare( 'SELECT * FROM ' .$wpdb->posts.' WHERE post_type = %s AND post_parent = %d AND post_status = %s ORDER BY ID ASC', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, $head_product, 'publish' );
2354
-		$variations = $wpdb->get_results( $query );
2353
+		$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_parent = %d AND post_status = %s ORDER BY ID ASC', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, $head_product, 'publish');
2354
+		$variations = $wpdb->get_results($query);
2355 2355
 
2356
-		if ( !empty( $variations ) ) {
2357
-			$head_wpshop_variation_definition = get_post_meta( $head_product, '_wpshop_variation_defining', true );
2356
+		if (!empty($variations)) {
2357
+			$head_wpshop_variation_definition = get_post_meta($head_product, '_wpshop_variation_defining', true);
2358 2358
 
2359
-			foreach ( $variations as $post_def ) {
2360
-				$data = wpshop_attributes::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $post_def->ID, WPSHOP_CURRENT_LOCALE, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
2361
-				foreach ( $data as $content ) {
2359
+			foreach ($variations as $post_def) {
2360
+				$data = wpshop_attributes::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode), $post_def->ID, WPSHOP_CURRENT_LOCALE, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
2361
+				foreach ($data as $content) {
2362 2362
 					$attribute_value = 'attribute_value_' . $content->data_type;
2363
-					if ( !empty($content->$attribute_value) ) {
2364
-						if ( !empty($head_wpshop_variation_definition['attributes']) && in_array($content->code, $head_wpshop_variation_definition['attributes']) ) {
2363
+					if (!empty($content->$attribute_value)) {
2364
+						if (!empty($head_wpshop_variation_definition['attributes']) && in_array($content->code, $head_wpshop_variation_definition['attributes'])) {
2365 2365
 							$variations_output[$post_def->ID]['variation_def'][$content->code] = $content->$attribute_value;
2366 2366
 						}
2367 2367
 						else {
@@ -2383,26 +2383,26 @@  discard block
 block discarded – undo
2383 2383
 	 * @param integer $head_product L'identifiant du produit dont on veut afficher les variations
2384 2384
 	 * @return string Le code html permettant l'affichage des variations dans l'interface d'édition du produit
2385 2385
 	 */
2386
-	public static function display_variation_admin( $head_product ) {
2386
+	public static function display_variation_admin($head_product) {
2387 2387
 		$output = '';
2388 2388
 		$productCurrency = wpshop_tools::wpshop_get_currency();
2389 2389
 		/*	Récupération de la liste des variations pour le produit en cours d'édition	*/
2390
-		$variations = self::get_variation( $head_product );
2391
-		$price_piloting = get_option( 'wpshop_shop_price_piloting' );
2390
+		$variations = self::get_variation($head_product);
2391
+		$price_piloting = get_option('wpshop_shop_price_piloting');
2392 2392
 
2393 2393
 		/*	Affichage de la liste des variations pour le produit en cours d'édition	*/
2394
-		if ( !empty($variations) && is_array($variations) ) {
2394
+		if (!empty($variations) && is_array($variations)) {
2395 2395
 			$existing_variation_list = wpshop_display::display_template_element('wpshop_admin_existing_variation_controller', array(), array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product), 'admin');
2396 2396
 
2397
-			foreach ( $variations as $variation ) {
2397
+			foreach ($variations as $variation) {
2398 2398
 				$tpl_component = array();
2399 2399
 
2400 2400
 				$tpl_component['ADMIN_EXISTING_VARIATIONS_CLASS'] = ' wpshop_variation_' . self::currentPageCode;
2401 2401
 				$tpl_component['VARIATION_IDENTIFIER'] = $variation['post']->ID;
2402 2402
 				$tpl_component['VARIATION_DETAIL'] = '  ';
2403
-				$p = ( !empty($variation['variation_dif']['product_price']) || !empty($variation['variation_dif']['price_ht']) ) ? ( ( !empty($price_piloting) && $price_piloting == 'HT' && !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0 ) : 0;
2404
-				$tpl_component['VARIATION_DETAIL_PRICE'] = number_format( $p, 2, '.', '').' '.$productCurrency.' '.( ( !empty($price_piloting) && $price_piloting == 'HT' ) ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ) );
2405
-				if ( !empty($price_piloting) && $price_piloting == 'HT' ) {
2403
+				$p = (!empty($variation['variation_dif']['product_price']) || !empty($variation['variation_dif']['price_ht'])) ? ((!empty($price_piloting) && $price_piloting == 'HT' && !empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : (!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0) : 0;
2404
+				$tpl_component['VARIATION_DETAIL_PRICE'] = number_format($p, 2, '.', '') . ' ' . $productCurrency . ' ' . ((!empty($price_piloting) && $price_piloting == 'HT') ? __('ET', 'wpshop') : __('ATI', 'wpshop'));
2405
+				if (!empty($price_piloting) && $price_piloting == 'HT') {
2406 2406
 
2407 2407
 				}
2408 2408
 				else {
@@ -2410,66 +2410,66 @@  discard block
 block discarded – undo
2410 2410
 				}
2411 2411
 				$post_obj = $variation['post'];
2412 2412
 
2413
-				$parent_product_infos = wpshop_products::get_parent_variation( $post_obj->ID );
2414
-				if ( !empty($parent_product_infos) ) {
2413
+				$parent_product_infos = wpshop_products::get_parent_variation($post_obj->ID);
2414
+				if (!empty($parent_product_infos)) {
2415 2415
 					$parent_post = $parent_product_infos['parent_post'];
2416 2416
 					$product_option_postmeta = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true);
2417
-					if ( !empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') {
2418
-						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2419
-							$product_price = ( ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0 ) + $parent_product_infos['parent_post_meta']['price_ht'];
2417
+					if (!empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') {
2418
+						if (!empty($price_piloting) && $price_piloting == 'HT') {
2419
+							$product_price = ((!empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : 0) + $parent_product_infos['parent_post_meta']['price_ht'];
2420 2420
 						}
2421 2421
 						else {
2422
-							$product_price = ( ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0 ) + $parent_product_infos['parent_post_meta']['product_price'];
2422
+							$product_price = ((!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0) + $parent_product_infos['parent_post_meta']['product_price'];
2423 2423
 						}
2424 2424
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Variation price combined with the parent product price', 'wpshop');
2425 2425
 					}
2426 2426
 					else {
2427
-						if( !empty($price_piloting) && $price_piloting == 'HT' ) {
2428
-							$product_price = ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0;
2427
+						if (!empty($price_piloting) && $price_piloting == 'HT') {
2428
+							$product_price = (!empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : 0;
2429 2429
 						}
2430 2430
 						else {
2431
-							$product_price = ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0;
2431
+							$product_price = (!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0;
2432 2432
 						}
2433 2433
 						$tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Only variation\'s price is used', 'wpshop');
2434 2434
 					}
2435
-					$product_price = number_format(str_replace(',', '.',$product_price), 2, '.', '').' '.$productCurrency.' '.( ( !empty($price_piloting) && $price_piloting == 'HT' ) ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ) );
2435
+					$product_price = number_format(str_replace(',', '.', $product_price), 2, '.', '') . ' ' . $productCurrency . ' ' . ((!empty($price_piloting) && $price_piloting == 'HT') ? __('ET', 'wpshop') : __('ATI', 'wpshop'));
2436 2436
 					$tpl_component['VARIATION_DETAIL_SALE_PRICE'] = $product_price;
2437 2437
 				}
2438 2438
 
2439
-				if ( !empty($variation['variation_def']) ) {
2440
-					foreach ( $variation['variation_def'] as $variation_key => $variation_value ) {
2441
-						if ( !empty($variation_value) ) {
2439
+				if (!empty($variation['variation_def'])) {
2440
+					foreach ($variation['variation_def'] as $variation_key => $variation_value) {
2441
+						if (!empty($variation_value)) {
2442 2442
 							$attribute_def_for_variation = wpshop_attributes::getElement($variation_key, "'valid'", 'code');
2443 2443
 							$tpl_component['VARIATION_DETAIL'] .= '<input type="hidden" name="' . self::current_page_variation_code . '[' . $variation['post']->ID . '][attribute][' . $attribute_def_for_variation->data_type . '][' . $variation_key . ']" value="' . $variation_value . '" />' . wpshop_display::display_template_element('wpshop_admin_variation_item_def_header', array('VARIATION_ATTRIBUTE_CODE' => $attribute_def_for_variation->frontend_label, 'VARIATION_ATTRIBUTE_CODE_VALUE' => stripslashes(wpshop_attributes::get_attribute_type_select_option_info($variation_value, 'label', $attribute_def_for_variation->data_type_to_use, true))), array(), 'admin');
2444 2444
 							$tpl_component['VARIATION_IMAGE_CHOICE'] = '';
2445 2445
 
2446 2446
 							/** Define Link image to variation interface **/
2447
-							if( !empty($product_option_postmeta) && !empty($product_option_postmeta['attributes']) && !empty($product_option_postmeta['variation_type']) && ( ( count( $product_option_postmeta['attributes'] ) == 1 && $product_option_postmeta['variation_type'] == 'single' ) || ($product_option_postmeta['variation_type'] == 'combined' ) ) ) {
2448
-								$pictures = get_posts( array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => null, 'post_parent' => $head_product) );
2447
+							if (!empty($product_option_postmeta) && !empty($product_option_postmeta['attributes']) && !empty($product_option_postmeta['variation_type']) && ((count($product_option_postmeta['attributes']) == 1 && $product_option_postmeta['variation_type'] == 'single') || ($product_option_postmeta['variation_type'] == 'combined'))) {
2448
+								$pictures = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => null, 'post_parent' => $head_product));
2449 2449
 
2450
-								$media_id_data = get_post_meta( $head_product, '_wps_product_media', true );
2451
-								if( !empty($media_id_data) ) {
2452
-									$medias_ids = explode( ',', $media_id_data );
2450
+								$media_id_data = get_post_meta($head_product, '_wps_product_media', true);
2451
+								if (!empty($media_id_data)) {
2452
+									$medias_ids = explode(',', $media_id_data);
2453 2453
 
2454
-									if ( !empty( $medias_ids ) ) {
2455
-										foreach ( $medias_ids as $media_id ) {
2456
-											if ( !empty( $media_id ) ) {
2457
-												$pictures[] = get_post( $media_id );
2454
+									if (!empty($medias_ids)) {
2455
+										foreach ($medias_ids as $media_id) {
2456
+											if (!empty($media_id)) {
2457
+												$pictures[] = get_post($media_id);
2458 2458
 											}
2459 2459
 										}
2460 2460
 									}
2461 2461
 								}
2462 2462
 
2463 2463
 								$pictures_data = '';
2464
-								if( !empty($pictures) ) {
2465
-									$selected_picture = get_post_meta($variation['post']->ID, '_wps_variation_attached_picture', true );
2464
+								if (!empty($pictures)) {
2465
+									$selected_picture = get_post_meta($variation['post']->ID, '_wps_variation_attached_picture', true);
2466 2466
 
2467 2467
 									$done_picture = array();
2468
-									foreach( $pictures as $picture ) {
2469
-										if ( !in_array( $picture->ID, $done_picture ) ) {
2470
-											if( wp_attachment_is_image( $picture->ID ) ) {
2471
-												$checked = ( ( !empty($selected_picture) && $selected_picture == $picture->ID ) ? 'checked="checked"' : '' );
2472
-												$pictures_data .= wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_element', array( 'PICTURE_CHOICE_VARIATION_ID' => $picture->ID, 'PRODUCT_VARIATION_ID' =>$variation['post']->ID, 'PICTURE_CHOICE_SELECTED' => $checked, 'PICTURE_CHOICE_VARIATION_IMG' => wp_get_attachment_image( $picture->ID, 'thumbnail' ) ), array(), 'admin');
2468
+									foreach ($pictures as $picture) {
2469
+										if (!in_array($picture->ID, $done_picture)) {
2470
+											if (wp_attachment_is_image($picture->ID)) {
2471
+												$checked = ((!empty($selected_picture) && $selected_picture == $picture->ID) ? 'checked="checked"' : '');
2472
+												$pictures_data .= wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_element', array('PICTURE_CHOICE_VARIATION_ID' => $picture->ID, 'PRODUCT_VARIATION_ID' =>$variation['post']->ID, 'PICTURE_CHOICE_SELECTED' => $checked, 'PICTURE_CHOICE_VARIATION_IMG' => wp_get_attachment_image($picture->ID, 'thumbnail')), array(), 'admin');
2473 2473
 
2474 2474
 												$done_picture[] = $picture->ID;
2475 2475
 											}
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 									}
2478 2478
 								}
2479 2479
 
2480
-								$tpl_component['VARIATION_IMAGE_CHOICE'] = wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_container',  array( 'PICTURE_CHOICE_CONTAINER_CONTENT' => $pictures_data ), array(), 'admin');
2480
+								$tpl_component['VARIATION_IMAGE_CHOICE'] = wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_container', array('PICTURE_CHOICE_CONTAINER_CONTENT' => $pictures_data), array(), 'admin');
2481 2481
 							}
2482 2482
 
2483 2483
 						}
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 				$tpl_component['VARIATION_DETAIL'] = substr($tpl_component['VARIATION_DETAIL'], 0, -2);
2489 2489
 
2490 2490
 				$tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = ' wpshopHide';
2491
-				$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute( array('input_class' => ' ', 'field_name' => wpshop_products::current_page_variation_code . '[' . $variation['post']->ID . ']','page_code' => self::current_page_variation_code, 'field_id' => self::current_page_variation_code . '_' . $variation['post']->ID, 'variation_dif_values' => (!empty($variation['variation_dif']) ? $variation['variation_dif'] : array())) );
2491
+				$tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' ', 'field_name' => wpshop_products::current_page_variation_code . '[' . $variation['post']->ID . ']', 'page_code' => self::current_page_variation_code, 'field_id' => self::current_page_variation_code . '_' . $variation['post']->ID, 'variation_dif_values' => (!empty($variation['variation_dif']) ? $variation['variation_dif'] : array())));
2492 2492
 				$tpl_component['VARIATION_DEFINITION_CONTENT'] = wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $variation['post']->ID), 'admin');
2493 2493
 
2494 2494
 				/*	Add the variation definition to output	*/
@@ -2510,22 +2510,22 @@  discard block
 block discarded – undo
2510 2510
 	 * Retrieve and display the variation for a given product
2511 2511
 	 * @param integer $product_id The product identifier to get variation for
2512 2512
 	 */
2513
-	public static function wpshop_variation( $post_id = '', $from_admin = false, $order_id = '', $qty = 1 ) {
2513
+	public static function wpshop_variation($post_id = '', $from_admin = false, $order_id = '', $qty = 1) {
2514 2514
 		global $wp_query;
2515 2515
 		$output = '';
2516 2516
 
2517
-		$product_id = empty($post_id) ? $wp_query->post->ID : $post_id ;
2518
-		$wpshop_product_attributes_frontend_display = get_post_meta( $product_id, '_wpshop_product_attributes_frontend_display', true );
2519
-		$head_wpshop_variation_definition = get_post_meta( $product_id, '_wpshop_variation_defining', true );
2517
+		$product_id = empty($post_id) ? $wp_query->post->ID : $post_id;
2518
+		$wpshop_product_attributes_frontend_display = get_post_meta($product_id, '_wpshop_product_attributes_frontend_display', true);
2519
+		$head_wpshop_variation_definition = get_post_meta($product_id, '_wpshop_variation_defining', true);
2520 2520
 
2521 2521
 		/**	Get attribute order for current product	*/
2522
-		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)  ) ;
2522
+		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true));
2523 2523
 		$output_order = array();
2524
-		if ( count($product_attribute_order_detail) > 0 ) {
2525
-			if (!empty($product_attribute_order_detail) ) {
2526
-				foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
2527
-					foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
2528
-						if ( !empty($attribute_def->code) )
2524
+		if (count($product_attribute_order_detail) > 0) {
2525
+			if (!empty($product_attribute_order_detail)) {
2526
+				foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
2527
+					foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) {
2528
+						if (!empty($attribute_def->code))
2529 2529
 							$output_order[$attribute_def->code] = $position;
2530 2530
 					}
2531 2531
 				}
@@ -2539,49 +2539,49 @@  discard block
 block discarded – undo
2539 2539
 		$possible_values_for_selection_calculation = array();
2540 2540
 
2541 2541
 		/*	Vérification de l'existence de déclinaison pour le produit	*/
2542
-		$wpshop_variation_list = self::get_variation( $product_id );
2543
-		if ( !empty($wpshop_variation_list) ) {
2542
+		$wpshop_variation_list = self::get_variation($product_id);
2543
+		if (!empty($wpshop_variation_list)) {
2544 2544
 			foreach ($wpshop_variation_list as $variation) {
2545
-				if (!empty($variation['variation_def']) ) {
2546
-					$display_option = get_post_meta( $post_id, '_wpshop_product_attributes_frontend_display', true );
2547
-					foreach ( $variation['variation_def'] as $attribute_code => $attribute_value ) {
2548
-						if ( empty($display_option) || ( !empty($display_option['attribute']) && !empty($display_option['attribute'][$attribute_code]) && !empty($display_option['attribute'][$attribute_code]['complete_sheet']) ) ) {
2545
+				if (!empty($variation['variation_def'])) {
2546
+					$display_option = get_post_meta($post_id, '_wpshop_product_attributes_frontend_display', true);
2547
+					foreach ($variation['variation_def'] as $attribute_code => $attribute_value) {
2548
+						if (empty($display_option) || (!empty($display_option['attribute']) && !empty($display_option['attribute'][$attribute_code]) && !empty($display_option['attribute'][$attribute_code]['complete_sheet']))) {
2549 2549
 							$tpl_component = array();
2550 2550
 
2551 2551
 							$attribute_db_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
2552 2552
 							$default_value_is_serial = false;
2553 2553
 							$attribute_list_first_element = $attribute_db_definition->default_value;
2554
-							if ( !empty($attribute_db_definition->default_value) && ($attribute_db_definition->default_value == serialize(false) || @unserialize($attribute_db_definition->default_value) !== false) ) {
2554
+							if (!empty($attribute_db_definition->default_value) && ($attribute_db_definition->default_value == serialize(false) || @unserialize($attribute_db_definition->default_value) !== false)) {
2555 2555
 								$default_value_is_serial = true;
2556 2556
 								$tmp_default_value = unserialize($attribute_db_definition->default_value);
2557 2557
 								$attribute_list_first_element = !empty($tmp_default_value['field_options']['label_for_first_item']) ? $tmp_default_value['field_options']['label_for_first_item'] : null;
2558 2558
 							}
2559 2559
 
2560
-							if ( $default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none') ) {
2561
-								$possible_values[$attribute_code][0][0] = ($default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none')) ? stripslashes( sprintf( $attribute_list_first_element, strtolower($attribute_db_definition->frontend_label)) ) : __('Choose a value', 'wpshop');
2560
+							if ($default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none')) {
2561
+								$possible_values[$attribute_code][0][0] = ($default_value_is_serial && !empty($attribute_list_first_element) && ($attribute_list_first_element != 'none')) ? stripslashes(sprintf($attribute_list_first_element, strtolower($attribute_db_definition->frontend_label))) : __('Choose a value', 'wpshop');
2562 2562
 							}
2563 2563
 
2564
-							if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'custom')) {
2564
+							if (!empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'custom')) {
2565 2565
 								$tpl_component['VARIATION_VALUE'] = stripslashes(wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'label', 'custom'));
2566 2566
 								$position = wpshop_attributes::get_attribute_type_select_option_info($attribute_value, 'position', 'custom');
2567 2567
 							}
2568
-							else if ( !empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2568
+							else if (!empty($attribute_value) && ($attribute_db_definition->data_type_to_use == 'internal')) {
2569 2569
 								$post_def = get_post($attribute_value);
2570 2570
 								$tpl_component['VARIATION_VALUE'] = stripslashes($post_def->post_title);
2571 2571
 								$position = $post_def->menu_order;
2572 2572
 							}
2573 2573
 
2574
-							if ( !empty($variation['variation_dif']) ) {
2575
-								foreach ( $variation['variation_dif'] as $attribute_dif_code => $attribute_dif_value) {
2574
+							if (!empty($variation['variation_dif'])) {
2575
+								foreach ($variation['variation_dif'] as $attribute_dif_code => $attribute_dif_value) {
2576 2576
 									$wpshop_prices_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES);
2577 2577
 									$the_value = $attribute_dif_value;
2578
-									if ( in_array($attribute_dif_code, $wpshop_prices_attributes) ) {
2578
+									if (in_array($attribute_dif_code, $wpshop_prices_attributes)) {
2579 2579
 										$the_value = wpshop_display::format_field_output('wpshop_product_price', $attribute_dif_value);
2580 2580
 									}
2581 2581
 									$tpl_component['VARIATION_DIF_' . strtoupper($attribute_dif_code)] = stripslashes($the_value);
2582 2582
 								}
2583 2583
 							}
2584
-							if ( !empty($attribute_value) ) {
2584
+							if (!empty($attribute_value)) {
2585 2585
 								$possible_values[$attribute_code][$position][$attribute_value] = wpshop_display::display_template_element('product_variation_item_possible_values', $tpl_component, array('type' => 'attribute_for_variation', 'id' => $attribute_code));
2586 2586
 								$possible_values_for_selection_calculation[$attribute_code][$attribute_value] = $tpl_component['VARIATION_VALUE'];
2587 2587
 							}
@@ -2592,33 +2592,33 @@  discard block
 block discarded – undo
2592 2592
 			}
2593 2593
 
2594 2594
 			$variation_tpl = array();
2595
-			if ( !empty($head_wpshop_variation_definition['attributes']) ) {
2596
-				foreach ( $head_wpshop_variation_definition['attributes'] as $attribute_code ) {
2595
+			if (!empty($head_wpshop_variation_definition['attributes'])) {
2596
+				foreach ($head_wpshop_variation_definition['attributes'] as $attribute_code) {
2597 2597
 					$attribute_db_definition = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
2598
-					if ( !empty( $attribute_db_definition ) ) {
2599
-						$attribute_display_state = wpshop_attributes::check_attribute_display( $attribute_db_definition->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_code, 'complete_sheet');
2598
+					if (!empty($attribute_db_definition)) {
2599
+						$attribute_display_state = wpshop_attributes::check_attribute_display($attribute_db_definition->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_code, 'complete_sheet');
2600 2600
 
2601 2601
 
2602 2602
 
2603
-						$is_required = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_code, $head_wpshop_variation_definition['options']['required_attributes']) )) ) ? true : false;
2604
-						if ( !$is_required && $attribute_db_definition->is_required == 'yes' ) {
2603
+						$is_required = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_code, $head_wpshop_variation_definition['options']['required_attributes'])))) ? true : false;
2604
+						if (!$is_required && $attribute_db_definition->is_required == 'yes') {
2605 2605
 							$is_required = true;
2606 2606
 						}
2607 2607
 
2608 2608
 						$input_def = array();
2609 2609
 						$input_def['type'] = $attribute_db_definition->frontend_input;
2610 2610
 						$value = isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : (!empty($attribute_db_definition->default_value) ? $attribute_db_definition->default_value : null);
2611
-						if ( in_array($attribute_db_definition->frontend_input, array('radio', 'checkbox')) ) {
2611
+						if (in_array($attribute_db_definition->frontend_input, array('radio', 'checkbox'))) {
2612 2612
 							unset($possible_values[$attribute_code][0]);
2613 2613
 							$value = array($value);
2614 2614
 						}
2615 2615
 						$input_def['id'] = 'wpshop_variation_attr_' . $attribute_code;
2616 2616
 						$input_def['name'] = $attribute_code;
2617 2617
 						$real_possible_values = array();
2618
-						if ( !empty($possible_values[$attribute_code]) ) {
2618
+						if (!empty($possible_values[$attribute_code])) {
2619 2619
 							ksort($possible_values[$attribute_code]);
2620
-							foreach ( $possible_values[$attribute_code] as $position => $def ) {
2621
-								foreach ( $def as $attribute_value => $attribute_value_output ) {
2620
+							foreach ($possible_values[$attribute_code] as $position => $def) {
2621
+								foreach ($def as $attribute_value => $attribute_value_output) {
2622 2622
 									$real_possible_values[$attribute_value] = $attribute_value_output;
2623 2623
 								}
2624 2624
 							}
@@ -2628,19 +2628,19 @@  discard block
 block discarded – undo
2628 2628
 						$input_def['value'] = $value;
2629 2629
 
2630 2630
 						$input_def['options']['more_input'] = '';
2631
-						if ( !empty($possible_values_for_selection_calculation[$attribute_code]) ) {
2632
-							foreach ( $possible_values_for_selection_calculation[$attribute_code] as $value_id => $value ) {
2631
+						if (!empty($possible_values_for_selection_calculation[$attribute_code])) {
2632
+							foreach ($possible_values_for_selection_calculation[$attribute_code] as $value_id => $value) {
2633 2633
 								$input_def['options']['more_input'] .= '<input type="hidden" disabled="disabled" value="' . str_replace("\\", "", $value) . '" name="' . $input_def['id'] . '_current_value" id="' . $input_def['id'] . '_current_value_' . $value_id . '" />';
2634 2634
 							}
2635 2635
 						}
2636 2636
 
2637 2637
 						$input_def['options_label']['original'] = true;
2638
-						$input_def['option'] = 'data-nonce="' . wp_create_nonce( 'wpshop_ajax_wpshop_variation_selection' ) . '" class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_code . ' ' : '') . ( $attribute_db_definition->_display_informations_about_value == 'yes' ? ' wpshop_display_information_about_value' : '' ) . ' ' . (( is_admin() ) ? $attribute_db_definition->backend_css_class : $attribute_db_definition->frontend_css_class) . '" ';
2639
-						if ( !empty(  $real_possible_values ) ) {
2638
+						$input_def['option'] = 'data-nonce="' . wp_create_nonce('wpshop_ajax_wpshop_variation_selection') . '" class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_code . ' ' : '') . ($attribute_db_definition->_display_informations_about_value == 'yes' ? ' wpshop_display_information_about_value' : '') . ' ' . ((is_admin()) ? $attribute_db_definition->backend_css_class : $attribute_db_definition->frontend_css_class) . '" ';
2639
+						if (!empty($real_possible_values)) {
2640 2640
 							$tpl_component = array();
2641 2641
 							$attribute_output_def['value'] = isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_code] : $input_def['value'];
2642 2642
 							$tpl_component['VARIATION_INPUT'] = wpshop_form::check_input_type($input_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) . $input_def['options']['more_input'];
2643
-							$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_code . '" >' . stripslashes($attribute_db_definition->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_db_definition->frontend_label) );
2643
+							$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_code . '" >' . stripslashes($attribute_db_definition->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_db_definition->frontend_label));
2644 2644
 							$tpl_component['VARIATION_CODE'] = $attribute_code;
2645 2645
 							$tpl_component['VARIATION_LABEL_HELPER'] = !empty($attribute_db_definition->frontend_help_message) ? ' title="' . $attribute_db_definition->frontend_help_message . '" ' : '';
2646 2646
 						 	$tpl_component['VARIATION_LABEL_CLASS'] = !empty($attribute_db_definition->frontend_help_message) ? ' wpshop_att_variation_helper' : '';
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
 							$tpl_component['VARIATION_PARENT_ID'] = $product_id;
2649 2649
 							$tpl_component['VARIATION_PARENT_TYPE'] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
2650 2650
 							$tpl_component['VARIATION_CONTAINER_CLASS'] = ($is_required ? ' attribute_is_required_container attribute_is_required_container_' . $attribute_code : '') . ' wpshop_variation_' . $attribute_code . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . ' wpshop_variation_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product_id;
2651
-							$tpl_component['VARIATION_REQUIRED_INDICATION'] = ( $is_required ) ? __('Required variation', 'wpshop') : '';
2651
+							$tpl_component['VARIATION_REQUIRED_INDICATION'] = ($is_required) ? __('Required variation', 'wpshop') : '';
2652 2652
 							$variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_code)] = wpshop_display::display_template_element('product_variation_item', $tpl_component);
2653 2653
 							$variation_attribute_ordered[$output_order[$attribute_code]] = $variation_tpl['VARIATION_COMPLETE_OUTPUT_' . strtoupper($attribute_code)];
2654 2654
 						}
@@ -2662,23 +2662,23 @@  discard block
 block discarded – undo
2662 2662
 		$variation_tpl['VARIATION_FORM_ELEMENT_ID'] = $product_id;
2663 2663
 		wp_reset_query();
2664 2664
 
2665
-		$attribute_defined_to_be_user_defined = wpshop_attributes::get_attribute_user_defined( array('entity_type_id' => self::currentPageCode) );
2666
-		if ( !empty($attribute_defined_to_be_user_defined) ) {
2667
-			foreach ( $attribute_defined_to_be_user_defined as $attribute_not_in_variation_but_user_defined ) {
2668
-				$is_required = ( (!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && ( in_array( $attribute_not_in_variation_but_user_defined->code, $head_wpshop_variation_definition['options']['required_attributes']) )) || $attribute_not_in_variation_but_user_defined->is_required == 'yes' ) ? true : false;
2665
+		$attribute_defined_to_be_user_defined = wpshop_attributes::get_attribute_user_defined(array('entity_type_id' => self::currentPageCode));
2666
+		if (!empty($attribute_defined_to_be_user_defined)) {
2667
+			foreach ($attribute_defined_to_be_user_defined as $attribute_not_in_variation_but_user_defined) {
2668
+				$is_required = ((!empty($head_wpshop_variation_definition['options']) && !empty($head_wpshop_variation_definition['options']['required_attributes']) && (in_array($attribute_not_in_variation_but_user_defined->code, $head_wpshop_variation_definition['options']['required_attributes']))) || $attribute_not_in_variation_but_user_defined->is_required == 'yes') ? true : false;
2669 2669
 
2670
-				$attribute_display_state = wpshop_attributes::check_attribute_display( $attribute_not_in_variation_but_user_defined->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_not_in_variation_but_user_defined->code, 'complete_sheet');
2671
-				if ( $attribute_display_state &&  array_key_exists($attribute_not_in_variation_but_user_defined->code, $output_order) && !in_array($attribute_not_in_variation_but_user_defined->code, $variation_attribute) && ($attribute_not_in_variation_but_user_defined->is_used_for_variation == 'no') ) {
2672
-					$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_not_in_variation_but_user_defined, (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code] : 'Salut' ));
2670
+				$attribute_display_state = wpshop_attributes::check_attribute_display($attribute_not_in_variation_but_user_defined->is_visible_in_front, $wpshop_product_attributes_frontend_display, 'attribute', $attribute_not_in_variation_but_user_defined->code, 'complete_sheet');
2671
+				if ($attribute_display_state && array_key_exists($attribute_not_in_variation_but_user_defined->code, $output_order) && !in_array($attribute_not_in_variation_but_user_defined->code, $variation_attribute) && ($attribute_not_in_variation_but_user_defined->is_used_for_variation == 'no')) {
2672
+					$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_not_in_variation_but_user_defined, (is_array($head_wpshop_variation_definition) && isset($head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code]) ? $head_wpshop_variation_definition['options']['attributes_default_value'][$attribute_not_in_variation_but_user_defined->code] : 'Salut'));
2673 2673
 
2674 2674
 					$tpl_component = array();
2675
-					$attribute_output_def['option'] = 'data-nonce="' . wp_create_nonce( 'wpshop_ajax_wpshop_variation_selection' ) . '" class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_not_in_variation_but_user_defined->code : '') . ' ' . ( str_replace('"', '', str_replace('class="', '', $attribute_output_def['option'])) ) . ' ' . (( is_admin() ) ? $attribute_not_in_variation_but_user_defined->backend_css_class : $attribute_not_in_variation_but_user_defined->frontend_css_class) . '" ';
2675
+					$attribute_output_def['option'] = 'data-nonce="' . wp_create_nonce('wpshop_ajax_wpshop_variation_selection') . '" class="wpshop_variation_selector_input' . ($is_required ? ' attribute_is_required_input attribute_is_required_input_' . $attribute_not_in_variation_but_user_defined->code : '') . ' ' . (str_replace('"', '', str_replace('class="', '', $attribute_output_def['option']))) . ' ' . ((is_admin()) ? $attribute_not_in_variation_but_user_defined->backend_css_class : $attribute_not_in_variation_but_user_defined->frontend_css_class) . '" ';
2676 2676
 					$tpl_component['VARIATION_INPUT'] = wpshop_form::check_input_type($attribute_output_def, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION . '[free]') . $attribute_output_def['options'];
2677
-					$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_not_in_variation_but_user_defined->code . '" >' . stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) );
2677
+					$tpl_component['VARIATION_LABEL'] = ($is_required ? '<span class="attribute_is_required attribute_is_required_' . $attribute_not_in_variation_but_user_defined->code . '" >' . stripslashes($attribute_not_in_variation_but_user_defined->frontend_label) . '</span> <span class="required" >*</span>' : stripslashes($attribute_not_in_variation_but_user_defined->frontend_label));
2678 2678
 					$tpl_component['VARIATION_CODE'] = $attribute_not_in_variation_but_user_defined->code;
2679 2679
 					$tpl_component['VARIATION_LABEL_HELPER'] = !empty($attribute_not_in_variation_but_user_defined->frontend_help_message) ? ' title="' . $attribute_not_in_variation_but_user_defined->frontend_help_message . '" ' : '';
2680 2680
 					$tpl_component['VARIATION_LABEL_CLASS'] = !empty($attribute_not_in_variation_but_user_defined->frontend_help_message) ? ' wpshop_att_variation_helper' : '';
2681
-					$tpl_component['VARIATION_REQUIRED_INDICATION'] = ( $is_required ) ? __('Required variation', 'wpshop') : '';
2681
+					$tpl_component['VARIATION_REQUIRED_INDICATION'] = ($is_required) ? __('Required variation', 'wpshop') : '';
2682 2682
 					$tpl_component['VARIATION_IDENTIFIER'] = $attribute_output_def['id'];
2683 2683
 					$tpl_component['VARIATION_PARENT_ID'] = $product_id;
2684 2684
 					$tpl_component['VARIATION_PARENT_TYPE'] = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT;
@@ -2690,17 +2690,17 @@  discard block
 block discarded – undo
2690 2690
 		}
2691 2691
 
2692 2692
 		$variation_tpl['VARIATION_FORM_VARIATION_LIST'] = '';
2693
-		if ( !empty($variation_attribute_ordered) && is_array($variation_attribute_ordered) ) {
2693
+		if (!empty($variation_attribute_ordered) && is_array($variation_attribute_ordered)) {
2694 2694
 			ksort($variation_attribute_ordered);
2695
-			foreach ( $variation_attribute_ordered as $attribute_variation_to_output ) {
2695
+			foreach ($variation_attribute_ordered as $attribute_variation_to_output) {
2696 2696
 				$variation_tpl['VARIATION_FORM_VARIATION_LIST'] .= $attribute_variation_to_output;
2697 2697
 			}
2698 2698
 		}
2699 2699
 		$variation_tpl['FROM_ADMIN_INDICATOR'] = $variation_tpl['ORDER_ID_INDICATOR'] = '';
2700
-		$variation_tpl['PRODUCT_ADDED_TO_CART_QTY'] = ( !empty( $qty ) ) ? $qty : 1;
2701
-		if ( $from_admin && !empty($order_id) ) {
2700
+		$variation_tpl['PRODUCT_ADDED_TO_CART_QTY'] = (!empty($qty)) ? $qty : 1;
2701
+		if ($from_admin && !empty($order_id)) {
2702 2702
 			$variation_tpl['FROM_ADMIN_INDICATOR'] = '<input type="hidden" name="wps_orders_from_admin" value="1" />';
2703
-			$variation_tpl['ORDER_ID_INDICATOR'] = '<input type="hidden" name="wps_orders_order_id" value="' .$order_id. '" />';
2703
+			$variation_tpl['ORDER_ID_INDICATOR'] = '<input type="hidden" name="wps_orders_order_id" value="' . $order_id . '" />';
2704 2704
 
2705 2705
 		}
2706 2706
 		$output = !empty($variation_tpl['VARIATION_FORM_VARIATION_LIST']) ? wpshop_display::display_template_element('product_variation_form', $variation_tpl) : '';
@@ -2708,11 +2708,11 @@  discard block
 block discarded – undo
2708 2708
 		return $output;
2709 2709
 	}
2710 2710
 
2711
-	public static function get_parent_variation ( $variation_id ) {
2711
+	public static function get_parent_variation($variation_id) {
2712 2712
 		$result = array();
2713
-		if ( !empty($variation_id) ) {
2714
-			$variation_post = get_post( $variation_id);
2715
-			if ( !empty($variation_post) && !empty($variation_post->post_parent) ) {
2713
+		if (!empty($variation_id)) {
2714
+			$variation_post = get_post($variation_id);
2715
+			if (!empty($variation_post) && !empty($variation_post->post_parent)) {
2716 2716
 				$result['parent_post'] = get_post($variation_post->post_parent);
2717 2717
 				$result['parent_post_meta'] = get_post_meta($variation_post->post_parent, '_wpshop_product_metadata', true);
2718 2718
 			}
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
 	 * Display the current configuration for a given product
2725 2725
 	 * @param array $shortcode_attribute Some parameters given by the shortcode for display
2726 2726
 	 */
2727
-	function wpshop_product_variations_summary( $shortcode_attribute ) {
2727
+	function wpshop_product_variations_summary($shortcode_attribute) {
2728 2728
 		$output = '';
2729 2729
 
2730 2730
 		$product_variations_selection_args = array(
@@ -2734,36 +2734,36 @@  discard block
 block discarded – undo
2734 2734
 
2735 2735
 		$current_user_id = get_current_user_id();
2736 2736
 
2737
-		if ( !empty( $_SESSION ) && !empty( $_SESSION[ 'cart' ] ) && !empty( $_SESSION[ 'cart' ][ 'order_items' ] ) ) {
2738
-			foreach ( $_SESSION[ 'cart' ][ 'order_items' ] as $item_id => $item ) {
2739
-				if ( !empty( $item ) && !empty( $item[ 'item_id' ] ) ) {
2737
+		if (!empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items'])) {
2738
+			foreach ($_SESSION['cart']['order_items'] as $item_id => $item) {
2739
+				if (!empty($item) && !empty($item['item_id'])) {
2740 2740
 
2741 2741
 					$free_variations = array();
2742
-					if ( !empty( $item['item_meta'] ) && !empty( $item['item_meta']['free_variation'] ) ) {
2743
-						foreach ( $item['item_meta']['free_variation'] as $attribute_code => $attribute_value ) {
2742
+					if (!empty($item['item_meta']) && !empty($item['item_meta']['free_variation'])) {
2743
+						foreach ($item['item_meta']['free_variation'] as $attribute_code => $attribute_value) {
2744 2744
 							$free_variations[] = $attribute_code . '-_variation_val_-' . $attribute_value;
2745 2745
 						}
2746 2746
 					}
2747 2747
 
2748 2748
 					$variations = array();
2749
-					if ( !empty( $item['item_meta'] ) && !empty( $item['item_meta']['variations'] ) ) {
2750
-						foreach ( $item['item_meta']['variations'] as $variation_id => $variation_def ) {
2749
+					if (!empty($item['item_meta']) && !empty($item['item_meta']['variations'])) {
2750
+						foreach ($item['item_meta']['variations'] as $variation_id => $variation_def) {
2751 2751
 
2752
-							if ( !empty( $variation_def[ 'item_meta' ] ) && !empty( $variation_def[ 'item_meta' ][ 'variation_definition' ] ) ) {
2753
-								foreach ( $variation_def[ 'item_meta' ][ 'variation_definition' ] as $attribute_code => $attribute_selected_data ) {
2754
-									$variations[] = $attribute_code . '-_variation_val_-' . $attribute_selected_data[ 'ID' ];
2752
+							if (!empty($variation_def['item_meta']) && !empty($variation_def['item_meta']['variation_definition'])) {
2753
+								foreach ($variation_def['item_meta']['variation_definition'] as $attribute_code => $attribute_selected_data) {
2754
+									$variations[] = $attribute_code . '-_variation_val_-' . $attribute_selected_data['ID'];
2755 2755
 								}
2756 2756
 							}
2757 2757
 						}
2758 2758
 					}
2759
-					$product_variation_summary = self::wpshop_ajax_wpshop_variation_selection( $item[ 'item_id' ], $variations, $free_variations, null, $item[ 'item_qty' ] );
2759
+					$product_variation_summary = self::wpshop_ajax_wpshop_variation_selection($item['item_id'], $variations, $free_variations, null, $item['item_qty']);
2760 2760
 
2761
-					$product_variations_selection_args['PRODUCT_VARIATION_SELECTION_DISPLAY'] .= $product_variation_summary[ 1 ][ 'product_output' ];
2761
+					$product_variations_selection_args['PRODUCT_VARIATION_SELECTION_DISPLAY'] .= $product_variation_summary[1]['product_output'];
2762 2762
 				}
2763 2763
 			}
2764 2764
 		}
2765 2765
 
2766
-		$output .= wpshop_display::display_template_element( 'wpshop_product_configuration_summary', $product_variations_selection_args );
2766
+		$output .= wpshop_display::display_template_element('wpshop_product_configuration_summary', $product_variations_selection_args);
2767 2767
 
2768 2768
 		echo $output;
2769 2769
 	}
@@ -2779,53 +2779,53 @@  discard block
 block discarded – undo
2779 2779
 	 *
2780 2780
 	 * @return array Le résultat du calcul pour l'affichage / Output result
2781 2781
 	 */
2782
-	public static function wpshop_ajax_wpshop_variation_selection( $product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty = 1 ) {
2782
+	public static function wpshop_ajax_wpshop_variation_selection($product_id, $wpshop_variation_selected, $wpshop_free_variation, $wpshop_current_for_display, $product_qty = 1) {
2783 2783
 		global $wpdb;
2784 2784
 
2785 2785
 		$wpshop_cart = new wps_cart();
2786 2786
 		$wpshop_products = new wpshop_products();
2787 2787
 
2788 2788
 		$response = '';
2789
-		$response_status = $has_variation = false ;
2789
+		$response_status = $has_variation = false;
2790 2790
 		$tpl_component = array();
2791 2791
 
2792 2792
 		// Check if variations exists
2793
-		if ( !empty( $wpshop_variation_selected ) || !empty( $wpshop_free_variation ) ) {
2793
+		if (!empty($wpshop_variation_selected) || !empty($wpshop_free_variation)) {
2794 2794
 
2795 2795
 			//Recover all selected variations
2796 2796
 			$variations_selected = array();
2797
-			if ( !empty($wpshop_variation_selected) ) {
2798
-				foreach ( $wpshop_variation_selected as $selected_variation ) {
2797
+			if (!empty($wpshop_variation_selected)) {
2798
+				foreach ($wpshop_variation_selected as $selected_variation) {
2799 2799
 					$variation_definition = explode('-_variation_val_-', $selected_variation);
2800 2800
 					$variations_selected[$variation_definition[0]] = $variation_definition[1];
2801 2801
 				}
2802 2802
 			}
2803 2803
 
2804 2804
 			// Check variations priority
2805
-			$product_with_variation = wpshop_products::get_variation_by_priority( $variations_selected, $product_id );
2805
+			$product_with_variation = wpshop_products::get_variation_by_priority($variations_selected, $product_id);
2806 2806
 
2807 2807
 			// Check if $product_with_variation have variations
2808
-			if ( !empty($product_with_variation[$product_id]['variations']) || !empty( $wpshop_free_variation )  ) {
2808
+			if (!empty($product_with_variation[$product_id]['variations']) || !empty($wpshop_free_variation)) {
2809 2809
 
2810
-				$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart( $product_id, $product_qty, $variations_selected );
2810
+				$formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $variations_selected);
2811 2811
 				$product_to_add_to_cart = $formatted_product[0];
2812
-				foreach ( $formatted_product[0] as $pid => $product_more_content) {
2812
+				foreach ($formatted_product[0] as $pid => $product_more_content) {
2813 2813
 					$order_items[$pid]['product_id'] = $product_more_content['id'];
2814 2814
 
2815 2815
 					/** For product with variation	*/
2816
-					$order_items[$pid]['product_variation_type'] = !empty( $product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
2816
+					$order_items[$pid]['product_variation_type'] = !empty($product_more_content['variation_priority']) ? $product_more_content['variation_priority'] : '';
2817 2817
 					$order_items[$pid]['free_variation'] = !empty($product_more_content['free_variation']) ? $product_more_content['free_variation'] : '';
2818 2818
 					$order_items[$pid]['product_variation'] = '';
2819
-					if ( !empty($product_more_content['variations']) ) {
2820
-						foreach ( $product_more_content['variations'] as $variation_id) {
2819
+					if (!empty($product_more_content['variations'])) {
2820
+						foreach ($product_more_content['variations'] as $variation_id) {
2821 2821
 							$order_items[$pid]['product_variation'][] = $variation_id;
2822 2822
 						}
2823 2823
 					}
2824 2824
 				}
2825 2825
 
2826 2826
 				// If Product list is not empty, add products to order
2827
-				if( !empty($order_items) ) {
2828
-					foreach ( $order_items as $product_id => $d ) {
2827
+				if (!empty($order_items)) {
2828
+					foreach ($order_items as $product_id => $d) {
2829 2829
 						$product_key = $product_id;
2830 2830
 
2831 2831
 						// Formate datas
@@ -2833,71 +2833,71 @@  discard block
 block discarded – undo
2833 2833
 						$product_variation = !empty($d['product_variation']) ? $d['product_variation'] : null;
2834 2834
 
2835 2835
 						// If product is a single variation product
2836
-						if ( !empty($product_variation) && ( count($product_variation) == 1 ) ) {
2836
+						if (!empty($product_variation) && (count($product_variation) == 1)) {
2837 2837
 							$product_id = $product_variation[0];
2838 2838
 						}
2839 2839
 
2840 2840
 						// Construct final product
2841 2841
 						$product = wpshop_products::get_product_data($d['product_id'], true);
2842
-						$the_product = array_merge( array('product_id'	=> $d['product_id'], 'product_qty' 	=> 1 ), $product);
2842
+						$the_product = array_merge(array('product_id'	=> $d['product_id'], 'product_qty' 	=> 1), $product);
2843 2843
 
2844 2844
 						//	Add variation to product into cart for storage
2845
-						if ( !empty($product_variation) ) {
2846
-							$the_product = wpshop_products::get_variation_price_behaviour( $the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']) );
2845
+						if (!empty($product_variation)) {
2846
+							$the_product = wpshop_products::get_variation_price_behaviour($the_product, $product_variation, $head_product_id, array('type' => $d['product_variation_type']));
2847 2847
 						}
2848 2848
 
2849 2849
 						// Free Variations Checking
2850
-						if ( !empty( $d['free_variation'] ) ) {
2850
+						if (!empty($d['free_variation'])) {
2851 2851
 							$the_product['item_meta']['free_variation'] = $d['free_variation'];
2852 2852
 							$head_product_id = $the_product['product_id'];
2853 2853
 						}
2854 2854
 
2855 2855
 						// If product is a variation, we check parent product general
2856
-						if( get_post_type( $the_product['product_id'] )  == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
2857
-							$parent_def = wpshop_products::get_parent_variation ( $the_product['product_id'] );
2858
-							if( !empty($parent_def) && !empty($parent_def['parent_post']) ) {
2859
-								$variation_def = get_post_meta( $parent_def['parent_post']->ID, '_wpshop_variation_defining', true );
2856
+						if (get_post_type($the_product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
2857
+							$parent_def = wpshop_products::get_parent_variation($the_product['product_id']);
2858
+							if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
2859
+								$variation_def = get_post_meta($parent_def['parent_post']->ID, '_wpshop_variation_defining', true);
2860 2860
 								$parent_meta = $parent_def['parent_post_meta'];
2861
-								if( !empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority'] ) && !empty($variation_def['options']['price_behaviour']) && in_array( 'addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1 ) {
2862
-									$the_product['product_price'] += number_format( str_replace( ',', '.', $parent_meta['product_price'] ), 2, '.', '' );
2863
-									$the_product['price_ht'] += number_format( str_replace( ',', '.',$parent_meta['price_ht']) , 2, '.', '' );
2864
-									$the_product['tva'] += number_format( str_replace( ',', '.', $parent_meta['tva']) , 2, '.', '' );
2861
+								if (!empty($variation_def) && !empty($variation_def['options']) && !empty($variation_def['options']['priority']) && in_array('combined', $variation_def['options']['priority']) && !empty($variation_def['options']['price_behaviour']) && in_array('addition', $variation_def['options']['price_behaviour']) && !empty($variation_def['attributes']) && count($variation_def['attributes']) > 1) {
2862
+									$the_product['product_price'] += number_format(str_replace(',', '.', $parent_meta['product_price']), 2, '.', '');
2863
+									$the_product['price_ht'] += number_format(str_replace(',', '.', $parent_meta['price_ht']), 2, '.', '');
2864
+									$the_product['tva'] += number_format(str_replace(',', '.', $parent_meta['tva']), 2, '.', '');
2865 2865
 								}
2866 2866
 							}
2867 2867
 						}
2868 2868
 					}
2869 2869
 				}
2870 2870
 
2871
-				if( !empty($the_product) && empty($the_product['price_ttc_before_discount']) && empty($the_product['price_ht_before_discount']) ) {
2872
-					$price_infos = wpshop_prices::check_product_price( $the_product, true );
2873
-					if ( !empty($price_infos['discount']['discount_exist']) ) {
2871
+				if (!empty($the_product) && empty($the_product['price_ttc_before_discount']) && empty($the_product['price_ht_before_discount'])) {
2872
+					$price_infos = wpshop_prices::check_product_price($the_product, true);
2873
+					if (!empty($price_infos['discount']['discount_exist'])) {
2874 2874
 						$the_product['price_ttc_before_discount'] = $the_product['product_price'];
2875 2875
 						$the_product['price_ht_before_discount'] = $the_product['price_ht'];
2876 2876
 					}
2877
-					$the_product['price_ht'] = ( !empty($price_infos['discount']) &&  !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ?  $price_infos['discount']['discount_et_price'] : $price_infos['et'];
2878
-					$the_product['product_price'] = ( !empty($price_infos['discount']) &&  !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati'];
2879
-					$the_product['tva'] = ( !empty($price_infos['discount']) &&  !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva'];
2877
+					$the_product['price_ht'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_et_price'] : $price_infos['et'];
2878
+					$the_product['product_price'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_ati_price'] : $price_infos['ati'];
2879
+					$the_product['tva'] = (!empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) && $price_infos['discount']['discount_exist']) ? $price_infos['discount']['discount_tva'] : $price_infos['tva'];
2880 2880
 				}
2881 2881
 
2882
-				$product = wpshop_products::get_product_data( $product_id, true );
2882
+				$product = wpshop_products::get_product_data($product_id, true);
2883 2883
 				// Add free variations to product
2884
-				if (  !empty( $wpshop_free_variation )  ) {
2884
+				if (!empty($wpshop_free_variation)) {
2885 2885
 					$the_product['item_meta']['free_variation'] = $wpshop_free_variation;
2886 2886
 				}
2887 2887
 				// Change picture if have a selected variation
2888
-				$the_selected_variation = !empty( $product_with_variation ) && !empty( $product_with_variation[$head_product_id] ) && !empty( $product_with_variation[$head_product_id]['variations'] ) ? $product_with_variation[$head_product_id]['variations'] : null;
2889
-				$response['wps_product_image'] = $wpshop_products->wps_selected_variation_picture( $head_product_id, $the_selected_variation );
2888
+				$the_selected_variation = !empty($product_with_variation) && !empty($product_with_variation[$head_product_id]) && !empty($product_with_variation[$head_product_id]['variations']) ? $product_with_variation[$head_product_id]['variations'] : null;
2889
+				$response['wps_product_image'] = $wpshop_products->wps_selected_variation_picture($head_product_id, $the_selected_variation);
2890 2890
 
2891 2891
 				// Price Display
2892
-				$price_attribute = wpshop_attributes::getElement( 'product_price', "'valid'", 'code' );
2893
-				$price_display = wpshop_attributes::check_attribute_display( $price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
2892
+				$price_attribute = wpshop_attributes::getElement('product_price', "'valid'", 'code');
2893
+				$price_display = wpshop_attributes::check_attribute_display($price_attribute->is_visible_in_front, $product['custom_display'], 'attribute', 'product_price', 'complete_sheet');
2894 2894
 				$productPrice = '';
2895
-				if ( $price_display ) {
2895
+				if ($price_display) {
2896 2896
 					$response['product_price_output'] = wpshop_prices::get_product_price($the_product, 'price_display', 'complete_sheet', false, true);
2897 2897
 				}
2898 2898
 
2899 2899
 				//Get Summary cart
2900
-				$response['product_output'] = $wpshop_products->wps_get_summary_variations_product( $product_id, $the_product, ( !empty( $wpshop_variation_selected ) || !empty( $wpshop_free_variation ) ? true : false )  );
2900
+				$response['product_output'] = $wpshop_products->wps_get_summary_variations_product($product_id, $the_product, (!empty($wpshop_variation_selected) || !empty($wpshop_free_variation) ? true : false));
2901 2901
 				$response_status = true;
2902 2902
 			}
2903 2903
 			else {
@@ -2907,7 +2907,7 @@  discard block
 block discarded – undo
2907 2907
 			}
2908 2908
 		}
2909 2909
 
2910
-		return array( $response_status, $response );
2910
+		return array($response_status, $response);
2911 2911
 	}
2912 2912
 
2913 2913
 	/**
@@ -2915,7 +2915,7 @@  discard block
 block discarded – undo
2915 2915
 	 *
2916 2916
 	 * @param array $shortcode_attribute Some parameters given by the shortcode for display
2917 2917
 	 */
2918
-	function wpshop_product_variation_value_detail( $shortcode_attribute ) {
2918
+	function wpshop_product_variation_value_detail($shortcode_attribute) {
2919 2919
 		echo wpshop_display::display_template_element('wpshop_product_variation_value_detail_container', array());
2920 2920
 	}
2921 2921
 
@@ -2927,47 +2927,47 @@  discard block
 block discarded – undo
2927 2927
 	 *
2928 2928
 	 * @return array The product list for adding to the cart build by variation priority
2929 2929
 	 */
2930
-	public static function get_variation_by_priority( $selected_variation, $product_id, $add_to_cart_action = false ) {
2930
+	public static function get_variation_by_priority($selected_variation, $product_id, $add_to_cart_action = false) {
2931 2931
 		global $wpdb;
2932 2932
 		$all_required_variations_selected = $no_selected_variation = true;
2933 2933
 		$single_variations = $combined_variations = $product_to_add_to_cart = array();
2934 2934
 
2935 2935
 		// Check if all required variations are selected
2936
-		$required_attributes_list = wpshop_prices::check_required_attributes( $product_id );
2937
-		foreach( $selected_variation as $k => $value ) {
2938
-			if( $value == 0 && in_array($k, $required_attributes_list) ) {
2936
+		$required_attributes_list = wpshop_prices::check_required_attributes($product_id);
2937
+		foreach ($selected_variation as $k => $value) {
2938
+			if ($value == 0 && in_array($k, $required_attributes_list)) {
2939 2939
 				$all_required_variations_selected = false;
2940 2940
 			}
2941
-			if( $value != 0 ) {
2941
+			if ($value != 0) {
2942 2942
 				$no_selected_variation = false;
2943 2943
 			}
2944 2944
 		}
2945
-		if( !empty($selected_variation) ) {
2945
+		if (!empty($selected_variation)) {
2946 2946
 			//Check variations configuration
2947 2947
 			$product_variation_configuration = get_post_meta($product_id, '_wpshop_variation_defining', true);
2948 2948
 			// Check variations type
2949
-			$product_variation_type = ( !empty($product_variation_configuration) && !empty($product_variation_configuration['variation_type']) ) ? $product_variation_configuration['variation_type'] : 'single';
2949
+			$product_variation_type = (!empty($product_variation_configuration) && !empty($product_variation_configuration['variation_type'])) ? $product_variation_configuration['variation_type'] : 'single';
2950 2950
 			$product_to_add_to_cart[$product_id]['variation_priority'] = $product_variation_type;
2951 2951
 
2952 2952
 			//Check defined variation priority
2953
-			$priority = (!empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['priority'][0]) ) ?  $product_variation_configuration['options']['priority'][0] : 'combined';
2953
+			$priority = (!empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['priority'][0])) ? $product_variation_configuration['options']['priority'][0] : 'combined';
2954 2954
 			$product_to_add_to_cart[$product_id]['defined_variation_priority'] = $priority;
2955 2955
 
2956 2956
 			// Recover all product variations
2957 2957
 			$query_variation = $selected_variation;
2958 2958
 			// Delete free variations
2959
-			unset( $query_variation['free'] );
2959
+			unset($query_variation['free']);
2960 2960
 
2961
-			if( $product_variation_type == 'single' ) {
2961
+			if ($product_variation_type == 'single') {
2962 2962
 				// Get single variations
2963 2963
 				$single_variations = array();
2964
-				foreach ( $selected_variation as $attribute_code => $attribute_value ) {
2965
-					if ( isset($attribute_value) && $attribute_code != 'free' ) {
2964
+				foreach ($selected_variation as $attribute_code => $attribute_value) {
2965
+					if (isset($attribute_value) && $attribute_code != 'free') {
2966 2966
 						$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "'", $product_id);
2967 2967
 						$single_variation_id = $wpdb->get_var($query);
2968
-						if ( !empty($single_variation_id) ) {
2968
+						if (!empty($single_variation_id)) {
2969 2969
 							$single_variations[] = $single_variation_id;
2970
-							unset( $query_variation[$attribute_code] );
2970
+							unset($query_variation[$attribute_code]);
2971 2971
 						}
2972 2972
 					}
2973 2973
 				}
@@ -2976,21 +2976,21 @@  discard block
 block discarded – undo
2976 2976
 				// Get combined variations
2977 2977
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_key = '_wpshop_variations_attribute_def' AND P_META.meta_value = '" . serialize($query_variation) . "'", $product_id);
2978 2978
 				$combined_variation_id = $wpdb->get_var($query);
2979
-				if ( !empty($combined_variation_id) ) {
2979
+				if (!empty($combined_variation_id)) {
2980 2980
 					$combined_variations[] = $combined_variation_id;
2981 2981
 				}
2982 2982
 
2983 2983
 			}
2984 2984
 
2985 2985
 			//If all required variations are not selected
2986
-			if ( !$all_required_variations_selected || $no_selected_variation ) {
2986
+			if (!$all_required_variations_selected || $no_selected_variation) {
2987 2987
 				$product_to_add_to_cart['text_from'] = 'on';
2988 2988
 				// If we choose to display lower price variation combinaison
2989
-				if( empty($product_variation_configuration) || ( !empty($product_variation_configuration) && empty($product_variation_configuration['options']) ) || ( !empty($product_variation_configuration) && !empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['price_display']) && !empty($product_variation_configuration['options']['price_display']['lower_price']) ) ) {
2989
+				if (empty($product_variation_configuration) || (!empty($product_variation_configuration) && empty($product_variation_configuration['options'])) || (!empty($product_variation_configuration) && !empty($product_variation_configuration['options']) && !empty($product_variation_configuration['options']['price_display']) && !empty($product_variation_configuration['options']['price_display']['lower_price']))) {
2990 2990
 					//Get lower price variation combinaison
2991
-					$lower_price_variations = wpshop_prices::check_product_lower_price( $product_id );
2992
-					if ( !empty($lower_price_variations['variations']) && is_array($lower_price_variations['variations']) ) {
2993
-						foreach( $lower_price_variations['variations'] as $lower_price_variation ) {
2991
+					$lower_price_variations = wpshop_prices::check_product_lower_price($product_id);
2992
+					if (!empty($lower_price_variations['variations']) && is_array($lower_price_variations['variations'])) {
2993
+						foreach ($lower_price_variations['variations'] as $lower_price_variation) {
2994 2994
 							$product_to_add_to_cart[$product_id]['variations'][] = $lower_price_variation;
2995 2995
 						}
2996 2996
 					}
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 			}
3003 3003
 			else {
3004 3004
 				$product_to_add_to_cart['text_from'] = '';
3005
-				$product_to_add_to_cart[$product_id]['variations'] = ( !empty($product_variation_type) && $product_variation_type == 'single' ) ? $single_variations : $combined_variations;
3005
+				$product_to_add_to_cart[$product_id]['variations'] = (!empty($product_variation_type) && $product_variation_type == 'single') ? $single_variations : $combined_variations;
3006 3006
 			}
3007 3007
 		}
3008 3008
 
@@ -3010,30 +3010,30 @@  discard block
 block discarded – undo
3010 3010
 	}
3011 3011
 
3012 3012
 
3013
-	public static function get_variation_price_behaviour( $product_into_cart, $product_variations, $head_product_id, $variations_options ) {
3013
+	public static function get_variation_price_behaviour($product_into_cart, $product_variations, $head_product_id, $variations_options) {
3014 3014
 		global $wpdb;
3015 3015
 
3016
-		if( !empty($product_variations) ) {
3016
+		if (!empty($product_variations)) {
3017 3017
 			// Initialize variations total price datas
3018
-			$variations_total_price = array( 'price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0);
3019
-			$variations_discount_total_price = array( 'price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0 );
3018
+			$variations_total_price = array('price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0);
3019
+			$variations_discount_total_price = array('price_et' => 0, 'vat_amount' => 0, 'price_ati' => 0);
3020 3020
 			$vat_rate = 0;
3021 3021
 			$discount_amount = $discount_rate = $special_price = 0;
3022 3022
 			// Recover Head product metadata
3023
-			$head_product_metadata = get_post_meta( $head_product_id, '_wpshop_product_metadata', true );
3024
-			$tva_rate_id = ( !empty($head_product_metadata['tx_tva']) ) ? $head_product_metadata['tx_tva'] : 0;
3025
-			if( !empty($tva_rate_id) ) {
3023
+			$head_product_metadata = get_post_meta($head_product_id, '_wpshop_product_metadata', true);
3024
+			$tva_rate_id = (!empty($head_product_metadata['tx_tva'])) ? $head_product_metadata['tx_tva'] : 0;
3025
+			if (!empty($tva_rate_id)) {
3026 3026
 				// Recover VAT Rate of product
3027
-				$query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS.' WHERE id = %d', $tva_rate_id );
3028
-				$vat_rate = $wpdb->get_var( $query );
3027
+				$query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $tva_rate_id);
3028
+				$vat_rate = $wpdb->get_var($query);
3029 3029
 			}
3030
-			$price_piloting = get_option( 'wpshop_shop_price_piloting');
3031
-			foreach( $product_variations as $product_variation ) {
3030
+			$price_piloting = get_option('wpshop_shop_price_piloting');
3031
+			foreach ($product_variations as $product_variation) {
3032 3032
 				$variation_metadata['product_price'] = 0;
3033
-				$variation_metadata = get_post_meta( $product_variation, '_wpshop_product_metadata', true );
3034
-				if( !empty($variation_metadata) ) {
3035
-					$p_et = ( ( empty($price_piloting) || $price_piloting == 'TTC' ) ? ( ( !empty( $variation_metadata['product_price'] ) ? $variation_metadata['product_price'] : 0 ) / ( 1 + ( $vat_rate / 100) ) )  : $variation_metadata['price_ht'] );
3036
-					$p_ati = ( ( empty($price_piloting) || $price_piloting == 'TTC' ) ? ( !empty( $variation_metadata['product_price'] ) ? $variation_metadata['product_price'] : 0 ) : ( $variation_metadata['price_ht'] * ( 1 + ( $vat_rate / 100) ) ) );
3033
+				$variation_metadata = get_post_meta($product_variation, '_wpshop_product_metadata', true);
3034
+				if (!empty($variation_metadata)) {
3035
+					$p_et = ((empty($price_piloting) || $price_piloting == 'TTC') ? ((!empty($variation_metadata['product_price']) ? $variation_metadata['product_price'] : 0) / (1 + ($vat_rate / 100))) : $variation_metadata['price_ht']);
3036
+					$p_ati = ((empty($price_piloting) || $price_piloting == 'TTC') ? (!empty($variation_metadata['product_price']) ? $variation_metadata['product_price'] : 0) : ($variation_metadata['price_ht'] * (1 + ($vat_rate / 100))));
3037 3037
 
3038 3038
 					$variations_total_price['price_et'] += $p_et;
3039 3039
 					$variations_total_price['price_ati'] += $p_ati;
@@ -3042,20 +3042,20 @@  discard block
 block discarded – undo
3042 3042
 					$variation_metadata['tx_tva'] = $product_into_cart['tx_tva'] = $vat_rate;
3043 3043
 
3044 3044
 					// Check discount
3045
-					$discount_config = wpshop_prices::check_discount_for_product( $product_variation );
3046
-					if ( !empty($discount_config) && !empty($discount_config['value']) ) {
3047
-						$variation_discount_prices = wpshop_prices::calcul_discounted_price( $variation_metadata, $discount_config );
3045
+					$discount_config = wpshop_prices::check_discount_for_product($product_variation);
3046
+					if (!empty($discount_config) && !empty($discount_config['value'])) {
3047
+						$variation_discount_prices = wpshop_prices::calcul_discounted_price($variation_metadata, $discount_config);
3048 3048
 						$variations_discount_total_price['price_et'] += $variation_discount_prices['price_ht'];
3049 3049
 						$variations_discount_total_price['price_ati'] += $variation_discount_prices['product_price'];
3050 3050
 						$variations_discount_total_price['vat_amount'] += $variation_discount_prices['tva'];
3051 3051
 
3052
-						if( !empty($discount_config['type']) && $discount_config['type'] == 'discount_amount' ) {
3052
+						if (!empty($discount_config['type']) && $discount_config['type'] == 'discount_amount') {
3053 3053
 							$product_into_cart['discount_amount'] = $discount_amount + $product_into_cart['discount_amount'];
3054 3054
 						}
3055
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'discount_rate' ) {
3055
+						elseif (!empty($discount_config['type']) && $discount_config['type'] == 'discount_rate') {
3056 3056
 							$product_into_cart['discount_rate'] = $discount_rate + $discount_config['value'];
3057 3057
 						}
3058
-						elseif( !empty($discount_config['type']) && $discount_config['type'] == 'special_price' ) {
3058
+						elseif (!empty($discount_config['type']) && $discount_config['type'] == 'special_price') {
3059 3059
 							$product_into_cart['special_price'] = $special_price + $discount_config['value'];
3060 3060
 						}
3061 3061
 					}
@@ -3066,10 +3066,10 @@  discard block
 block discarded – undo
3066 3066
 			}
3067 3067
 
3068 3068
 			// Check if add or replace variation price to head product
3069
-			$product_variation_defining = get_post_meta( $head_product_id, '_wpshop_variation_defining', true );
3070
-			if( empty($product_variation_defining) || ( !empty($product_variation_defining) && empty($product_variation_defining['options']) ) || ( ( !empty($product_variation_defining) ) && !empty($product_variation_defining['options']) && !empty($product_variation_defining['options']['price_behaviour']) && !empty($product_variation_defining['options']['price_behaviour'][0]) && $product_variation_defining['options']['price_behaviour'][0] == 'replacement' ) ){
3069
+			$product_variation_defining = get_post_meta($head_product_id, '_wpshop_variation_defining', true);
3070
+			if (empty($product_variation_defining) || (!empty($product_variation_defining) && empty($product_variation_defining['options'])) || ((!empty($product_variation_defining)) && !empty($product_variation_defining['options']) && !empty($product_variation_defining['options']['price_behaviour']) && !empty($product_variation_defining['options']['price_behaviour'][0]) && $product_variation_defining['options']['price_behaviour'][0] == 'replacement')) {
3071 3071
 				//Replace the product price
3072
-				if( !empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati']) ) {
3072
+				if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) {
3073 3073
 					$product_into_cart['price_ttc_before_discount'] = $variations_total_price['price_ati'];
3074 3074
 					$product_into_cart['price_ht_before_discount'] = $variations_total_price['price_et'];
3075 3075
 
@@ -3085,9 +3085,9 @@  discard block
 block discarded – undo
3085 3085
 			}
3086 3086
 			else {
3087 3087
 				// Add variations price to product price
3088
-				if( !empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati']) ) {
3089
-					$product_into_cart['price_ttc_before_discount'] = ( $product_into_cart['product_price'] + $variations_total_price['price_ati'] );
3090
-					$product_into_cart['price_ht_before_discount'] = ( $product_into_cart['price_ht'] + $variations_total_price['price_et'] );
3088
+				if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) {
3089
+					$product_into_cart['price_ttc_before_discount'] = ($product_into_cart['product_price'] + $variations_total_price['price_ati']);
3090
+					$product_into_cart['price_ht_before_discount'] = ($product_into_cart['price_ht'] + $variations_total_price['price_et']);
3091 3091
 
3092 3092
 					$product_into_cart['product_price'] += $variations_discount_total_price['price_ati'];
3093 3093
 					$product_into_cart['price_ht'] += $variations_discount_total_price['price_et'];
@@ -3099,19 +3099,19 @@  discard block
 block discarded – undo
3099 3099
 					$product_into_cart['tva'] += $variations_total_price['vat_amount'];
3100 3100
 				}
3101 3101
 				// Check parent discount
3102
-				$parent_discount_config = wpshop_prices::check_discount_for_product( $head_product_id );
3103
-				if( !empty($parent_discount_config) ) {
3104
-					$product_into_cart['price_ttc_before_discount'] = ( !empty( $product_into_cart['price_ttc_before_discount'] ) ) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3105
-					$product_into_cart['price_ht_before_discount'] = ( !empty($product_into_cart['price_ht_before_discount']) ) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3106
-					$product_into_cart = wpshop_prices::calcul_discounted_price( $product_into_cart, $parent_discount_config );
3107
-
3108
-					if( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_amount' ) {
3109
-						$product_into_cart['discount_amount'] = $discount_amount +  $parent_discount_config['value'];
3102
+				$parent_discount_config = wpshop_prices::check_discount_for_product($head_product_id);
3103
+				if (!empty($parent_discount_config)) {
3104
+					$product_into_cart['price_ttc_before_discount'] = (!empty($product_into_cart['price_ttc_before_discount'])) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3105
+					$product_into_cart['price_ht_before_discount'] = (!empty($product_into_cart['price_ht_before_discount'])) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3106
+					$product_into_cart = wpshop_prices::calcul_discounted_price($product_into_cart, $parent_discount_config);
3107
+
3108
+					if (!empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_amount') {
3109
+						$product_into_cart['discount_amount'] = $discount_amount + $parent_discount_config['value'];
3110 3110
 					}
3111
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate' ) {
3111
+					elseif (!empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'discount_rate') {
3112 3112
 						$product_into_cart['discount_rate'] = $discount_rate + $parent_discount_config['value'];
3113 3113
 					}
3114
-					elseif( !empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price' ) {
3114
+					elseif (!empty($parent_discount_config['type']) && $parent_discount_config['type'] == 'special_price') {
3115 3115
 						$product_into_cart['special_price'] = $special_price + $parent_discount_config['value'];
3116 3116
 					}
3117 3117
 				}
@@ -3119,16 +3119,16 @@  discard block
 block discarded – undo
3119 3119
 		}
3120 3120
 		else {
3121 3121
 			// If product have just Free variations
3122
-			$discount_config = wpshop_prices::check_discount_for_product( $head_product_id );
3123
-			if( !empty($discount_config) ) {
3124
-				$product_into_cart['price_ttc_before_discount'] = ( !empty( $product_into_cart['price_ttc_before_discount'] ) ) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3125
-				$product_into_cart['price_ht_before_discount'] = ( !empty($product_into_cart['price_ht_before_discount']) ) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3126
-				$product_into_cart = wpshop_prices::calcul_discounted_price( $product_into_cart, $discount_config );
3122
+			$discount_config = wpshop_prices::check_discount_for_product($head_product_id);
3123
+			if (!empty($discount_config)) {
3124
+				$product_into_cart['price_ttc_before_discount'] = (!empty($product_into_cart['price_ttc_before_discount'])) ? $product_into_cart['price_ttc_before_discount'] : $product_into_cart['product_price'];
3125
+				$product_into_cart['price_ht_before_discount'] = (!empty($product_into_cart['price_ht_before_discount'])) ? $product_into_cart['price_ht_before_discount'] : $product_into_cart['price_ht'];
3126
+				$product_into_cart = wpshop_prices::calcul_discounted_price($product_into_cart, $discount_config);
3127 3127
 			}
3128 3128
 		}
3129 3129
 
3130 3130
 		// Text From indicator
3131
-		if( !empty($variations_options) && !empty($variations_options['text_from']) ) {
3131
+		if (!empty($variations_options) && !empty($variations_options['text_from'])) {
3132 3132
 			$product_into_cart['text_from'] = $variations_options['text_from'];
3133 3133
 		}
3134 3134
 		return $product_into_cart;
@@ -3143,28 +3143,28 @@  discard block
 block discarded – undo
3143 3143
 	 *
3144 3144
 	 * @return array The array containing all product options ordered as the admin configure it
3145 3145
 	 */
3146
-	public static function get_selected_variation_display( $product_definition_value, $output_order, $from_page = null, $template_part = 'wpshop', $output_type = null ) {
3146
+	public static function get_selected_variation_display($product_definition_value, $output_order, $from_page = null, $template_part = 'wpshop', $output_type = null) {
3147 3147
 		$variation_attribute_ordered = array();
3148 3148
 		$variation_attribute_ordered['prices'] = array();
3149 3149
 		$variation_attribute_ordered['attribute_list'] = array();
3150 3150
 
3151
-		if ( !empty( $product_definition_value['variation_definition'] ) && is_array( $product_definition_value['variation_definition'] ) ) {
3152
-			foreach ( $product_definition_value['variation_definition'] as $variation_attribute_code => $variation_attribute_detail ) {
3151
+		if (!empty($product_definition_value['variation_definition']) && is_array($product_definition_value['variation_definition'])) {
3152
+			foreach ($product_definition_value['variation_definition'] as $variation_attribute_code => $variation_attribute_detail) {
3153 3153
 				$variation_tpl_component = array();
3154
-				foreach ( $variation_attribute_detail as $info_name => $info_value) {
3155
-					$variation_tpl_component['VARIATION_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value)  : stripslashes($info_value);
3154
+				foreach ($variation_attribute_detail as $info_name => $info_value) {
3155
+					$variation_tpl_component['VARIATION_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value) : stripslashes($info_value);
3156 3156
 				}
3157 3157
 				$variation_tpl_component['VARIATION_ID'] = $variation_attribute_code;
3158 3158
 				$variation_tpl_component['VARIATION_ATT_CODE'] = $variation_attribute_code;
3159
-				if( !empty($output_order[$variation_attribute_code]) ){
3159
+				if (!empty($output_order[$variation_attribute_code])) {
3160 3160
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3161
-					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3161
+					if (!in_array($display_data, $variation_attribute_ordered['attribute_list'])) {
3162 3162
 						$variation_attribute_ordered['attribute_list'][$output_order[$variation_attribute_code]] = $display_data;
3163 3163
 					}
3164 3164
 				}
3165 3165
 				else {
3166 3166
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3167
-					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3167
+					if (!in_array($display_data, $variation_attribute_ordered['attribute_list'])) {
3168 3168
 						$variation_attribute_ordered['attribute_list'][] = $display_data;
3169 3169
 					}
3170 3170
 				}
@@ -3172,15 +3172,15 @@  discard block
 block discarded – undo
3172 3172
 			}
3173 3173
 		}
3174 3174
 
3175
-		if ( !empty( $product_definition_value['variations'] ) && is_array( $product_definition_value['variations'] ) ) {
3176
-			foreach ( $product_definition_value['variations'] as $variation_id => $variation_details ) {
3175
+		if (!empty($product_definition_value['variations']) && is_array($product_definition_value['variations'])) {
3176
+			foreach ($product_definition_value['variations'] as $variation_id => $variation_details) {
3177 3177
 				$variation_tpl_component = array();
3178
-				foreach ( $variation_details as $info_name => $info_value) {
3179
-					if ( $info_name != 'item_meta' ) {
3180
-						$variation_tpl_component['VARIATION_DETAIL_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value)  : stripslashes($info_value);
3178
+				foreach ($variation_details as $info_name => $info_value) {
3179
+					if ($info_name != 'item_meta') {
3180
+						$variation_tpl_component['VARIATION_DETAIL_' . strtoupper($info_name)] = in_array($info_name, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ? wpshop_display::format_field_output('wpshop_product_price', $info_value) : stripslashes($info_value);
3181 3181
 					}
3182 3182
 				}
3183
-				foreach ( $variation_details['item_meta']['variation_definition'] as $variation_attribute_code => $variation_attribute_def ) {
3183
+				foreach ($variation_details['item_meta']['variation_definition'] as $variation_attribute_code => $variation_attribute_def) {
3184 3184
 					$variation_tpl_component['VARIATION_NAME'] = stripslashes($variation_attribute_def['NAME']);
3185 3185
 					$variation_tpl_component['VARIATION_VALUE'] = stripslashes($variation_attribute_def['VALUE']);
3186 3186
 					$variation_tpl_component['VARIATION_ID'] = $variation_id;
@@ -3188,7 +3188,7 @@  discard block
 block discarded – undo
3188 3188
 
3189 3189
 					$variation_attribute_ordered['prices'][$variation_attribute_code] = $variation_tpl_component['VARIATION_DETAIL_PRODUCT_PRICE'];
3190 3190
 				}
3191
-				if( !empty($output_order[$variation_attribute_code]) ) {
3191
+				if (!empty($output_order[$variation_attribute_code])) {
3192 3192
 					$variation_attribute_ordered['attribute_list'][$output_order[$variation_attribute_code]] = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $variation_attribute_code), $template_part);
3193 3193
 				}
3194 3194
 				unset($variation_tpl_component);
@@ -3196,9 +3196,9 @@  discard block
 block discarded – undo
3196 3196
 		}
3197 3197
 
3198 3198
 		/**	Free Variation part	*/
3199
-		if ( !empty( $product_definition_value['free_variation'] ) && is_array( $product_definition_value['free_variation'] ) ) {
3200
-			foreach ( $product_definition_value['free_variation'] as $build_variation_key => $build_variation ) {
3201
-				if ( strpos($build_variation, '-_variation_val_-')) {
3199
+		if (!empty($product_definition_value['free_variation']) && is_array($product_definition_value['free_variation'])) {
3200
+			foreach ($product_definition_value['free_variation'] as $build_variation_key => $build_variation) {
3201
+				if (strpos($build_variation, '-_variation_val_-')) {
3202 3202
 					$variation_definition = explode('-_variation_val_-', $build_variation);
3203 3203
 					$attribute_code = $variation_definition[0];
3204 3204
 					$attribute_selected_value = $variation_definition[1];
@@ -3211,17 +3211,17 @@  discard block
 block discarded – undo
3211 3211
 				$free_variation_attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
3212 3212
 				$variation_tpl_component['VARIATION_NAME'] = stripslashes($free_variation_attribute_def->frontend_label);
3213 3213
 				$value_to_outut = $attribute_selected_value;
3214
-				switch ( $free_variation_attribute_def->data_type ) {
3214
+				switch ($free_variation_attribute_def->data_type) {
3215 3215
 					case 'datetime':
3216
-						$value_to_outut = mysql2date( get_option( 'date_format' ), $attribute_selected_value, true );
3216
+						$value_to_outut = mysql2date(get_option('date_format'), $attribute_selected_value, true);
3217 3217
 					break;
3218 3218
 				}
3219 3219
 				$variation_tpl_component['VARIATION_VALUE'] = stripslashes($value_to_outut);
3220 3220
 				$variation_tpl_component['VARIATION_ID'] = $attribute_code;
3221 3221
 				$variation_tpl_component['VARIATION_ATT_CODE'] = $attribute_code;
3222
-				if ( !empty($value_to_outut) && !empty($output_order[$free_variation_attribute_def->code]) ) {
3222
+				if (!empty($value_to_outut) && !empty($output_order[$free_variation_attribute_def->code])) {
3223 3223
 					$display_data = wpshop_display::display_template_element('cart_variation_detail', $variation_tpl_component, array('page' => $from_page, 'type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_code), $template_part);
3224
-					if( !in_array($display_data, $variation_attribute_ordered['attribute_list']) ) {
3224
+					if (!in_array($display_data, $variation_attribute_ordered['attribute_list'])) {
3225 3225
 						$variation_attribute_ordered['attribute_list'][$output_order[$free_variation_attribute_def->code]] = $display_data;
3226 3226
 					}
3227 3227
 				}
@@ -3232,23 +3232,23 @@  discard block
 block discarded – undo
3232 3232
 	}
3233 3233
 
3234 3234
 
3235
-	function wps_selected_variation_picture( $head_product_id, $variations ) {
3235
+	function wps_selected_variation_picture($head_product_id, $variations) {
3236 3236
 		$response = array();
3237 3237
 		/** Selected Product image **/
3238
-		$post_thumbnail_id = get_post_thumbnail_id( $head_product_id );
3239
-		if( !empty($post_thumbnail_id) ) {
3238
+		$post_thumbnail_id = get_post_thumbnail_id($head_product_id);
3239
+		if (!empty($post_thumbnail_id)) {
3240 3240
 			$response['img_id'] = $post_thumbnail_id;
3241
-			$response['img'] = wp_get_attachment_image( $post_thumbnail_id,  'wpshop-product-galery' );
3242
-			$response['img_url'] = wp_get_attachment_url( $post_thumbnail_id );
3241
+			$response['img'] = wp_get_attachment_image($post_thumbnail_id, 'wpshop-product-galery');
3242
+			$response['img_url'] = wp_get_attachment_url($post_thumbnail_id);
3243 3243
 		}
3244 3244
 
3245 3245
 		/** check if have one variation **/
3246
-		if ( !empty($variations) && count($variations) == 1 ) {
3247
-			$variation_attached_image_id = get_post_meta( $variations[0], '_wps_variation_attached_picture', true );
3248
-			if( !empty($variation_attached_image_id) ) {
3246
+		if (!empty($variations) && count($variations) == 1) {
3247
+			$variation_attached_image_id = get_post_meta($variations[0], '_wps_variation_attached_picture', true);
3248
+			if (!empty($variation_attached_image_id)) {
3249 3249
 				$response['img_id'] = $variation_attached_image_id;
3250
-				$response['img'] = wp_get_attachment_image( $variation_attached_image_id,  'wpshop-product-galery' );
3251
-				$response['img_url'] = wp_get_attachment_url( $variation_attached_image_id);
3250
+				$response['img'] = wp_get_attachment_image($variation_attached_image_id, 'wpshop-product-galery');
3251
+				$response['img_url'] = wp_get_attachment_url($variation_attached_image_id);
3252 3252
 			}
3253 3253
 		}
3254 3254
 		return $response;
@@ -3260,23 +3260,23 @@  discard block
 block discarded – undo
3260 3260
 		global $post;
3261 3261
 		$product_id = $post->ID;
3262 3262
 
3263
-		$variations = self::get_variation( $product_id );
3263
+		$variations = self::get_variation($product_id);
3264 3264
 
3265 3265
 		$sales_informations = array();
3266 3266
 		/** Query **/
3267
-		$data_to_compare = '"item_id";s:' .strlen($product_id). ':"' .$product_id. '";';
3268
-		$query_args = array( 'posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array( array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE') ) );
3269
-		$orders = new WP_Query( $query_args );
3270
-		if ( !empty($orders) && !empty($orders->posts) ) {
3271
-			foreach( $orders->posts as $order ) {
3272
-				$order_meta = get_post_meta( $order->ID, '_order_postmeta', true );
3273
-				$order_info = get_post_meta( $order->ID, '_order_info', true );
3267
+		$data_to_compare = '"item_id";s:' . strlen($product_id) . ':"' . $product_id . '";';
3268
+		$query_args = array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array(array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE')));
3269
+		$orders = new WP_Query($query_args);
3270
+		if (!empty($orders) && !empty($orders->posts)) {
3271
+			foreach ($orders->posts as $order) {
3272
+				$order_meta = get_post_meta($order->ID, '_order_postmeta', true);
3273
+				$order_info = get_post_meta($order->ID, '_order_info', true);
3274 3274
 				$sales_informations[] = array(
3275
-											'order_key' => ( !empty($order_meta) && !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : '',
3276
-											'order_date' => ( !empty($order_meta) && !empty($order_meta['order_date']) ) ? $order_meta['order_date'] : '',
3277
-											'customer_firstname' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name']) ) ? $order_info['billing']['address']['address_first_name'] : '',
3278
-											'customer_name' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name']) ) ? $order_info['billing']['address']['address_last_name'] : '',
3279
-											'customer_email' => ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : ''
3275
+											'order_key' => (!empty($order_meta) && !empty($order_meta['order_key'])) ? $order_meta['order_key'] : '',
3276
+											'order_date' => (!empty($order_meta) && !empty($order_meta['order_date'])) ? $order_meta['order_date'] : '',
3277
+											'customer_firstname' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name'])) ? $order_info['billing']['address']['address_first_name'] : '',
3278
+											'customer_name' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name'])) ? $order_info['billing']['address']['address_last_name'] : '',
3279
+											'customer_email' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email'])) ? $order_info['billing']['address']['address_user_email'] : ''
3280 3280
 										);
3281 3281
 			}
3282 3282
 		}
@@ -3284,33 +3284,33 @@  discard block
 block discarded – undo
3284 3284
 
3285 3285
 		/** If product has been ordered **/
3286 3286
 		$output = '';
3287
-		if( !empty($sales_informations) ) {
3288
-			$output .= '<p>'.__( 'This product has been ordered', 'wpshop').' :</p>';
3287
+		if (!empty($sales_informations)) {
3288
+			$output .= '<p>' . __('This product has been ordered', 'wpshop') . ' :</p>';
3289 3289
 			$output .= '<ul>';
3290
-			foreach( $sales_informations as $sales_information ) {
3291
-				$output .= '<li>' .sprintf( __( 'Ordered by %s %s (%s) on %s (Order ref. : %s)', 'wpshop'), $sales_information['customer_name'], $sales_information['customer_firstname'], $sales_information['customer_email'], $sales_information['order_date'], $sales_information['order_key'] ). '</li>';
3290
+			foreach ($sales_informations as $sales_information) {
3291
+				$output .= '<li>' . sprintf(__('Ordered by %s %s (%s) on %s (Order ref. : %s)', 'wpshop'), $sales_information['customer_name'], $sales_information['customer_firstname'], $sales_information['customer_email'], $sales_information['order_date'], $sales_information['order_key']) . '</li>';
3292 3292
 			}
3293 3293
 			$output .= '</ul>';
3294 3294
 		}
3295 3295
 		else {
3296
-			$output .= __( 'This product has never been ordered', 'wpshop');
3296
+			$output .= __('This product has never been ordered', 'wpshop');
3297 3297
 		}
3298 3298
 
3299 3299
 		echo $output;
3300 3300
 	}
3301 3301
 
3302 3302
 
3303
-	function wps_get_summary_variations_product( $product_id, $the_product, $has_variation ) {
3303
+	function wps_get_summary_variations_product($product_id, $the_product, $has_variation) {
3304 3304
 		global $wpdb, $wpshop_payment;
3305 3305
 		$output = '';
3306 3306
 		$tpl_component = array();
3307 3307
 		/**	Get attribute order for current product	*/
3308
-		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)  ) ;
3308
+		$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($product_id, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true));
3309 3309
 		$output_order = array();
3310
-		if ( count($product_attribute_order_detail) > 0 ) {
3311
-			foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
3312
-				foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
3313
-					if ( !empty($attribute_def->code) )
3310
+		if (count($product_attribute_order_detail) > 0) {
3311
+			foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
3312
+				foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) {
3313
+					if (!empty($attribute_def->code))
3314 3314
 						$output_order[$attribute_def->code] = $position;
3315 3315
 				}
3316 3316
 			}
@@ -3318,22 +3318,22 @@  discard block
 block discarded – undo
3318 3318
 		$variation_attribute_ordered = array();
3319 3319
 
3320 3320
 		/** Check if product is a variation and change his name **/
3321
-		$product_post_type = get_post_type( $the_product['product_id'] );
3322
-		if ( !empty($product_post_type) && $product_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
3323
-			$parent_infos = wpshop_products::get_parent_variation( $the_product['product_id'] );
3324
-			$parent_post = ( !empty($parent_infos) && !empty($parent_infos['parent_post']) ) ? $parent_infos['parent_post'] : array();
3321
+		$product_post_type = get_post_type($the_product['product_id']);
3322
+		if (!empty($product_post_type) && $product_post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
3323
+			$parent_infos = wpshop_products::get_parent_variation($the_product['product_id']);
3324
+			$parent_post = (!empty($parent_infos) && !empty($parent_infos['parent_post'])) ? $parent_infos['parent_post'] : array();
3325 3325
 			$the_product['product_name'] = $the_product['post_title'] = $parent_post->post_title;
3326 3326
 		}
3327 3327
 
3328
-		foreach ( $the_product as $product_definition_key => $product_definition_value ) {
3329
-			if ( $product_definition_key != 'item_meta' ) {
3328
+		foreach ($the_product as $product_definition_key => $product_definition_value) {
3329
+			if ($product_definition_key != 'item_meta') {
3330 3330
 				$tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value;
3331
-				if ( !empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
3331
+				if (!empty($wpshop_current_for_display) && in_array($product_definition_key, unserialize(WPSHOP_ATTRIBUTE_PRICES))) {
3332 3332
 					$tpl_component['PRODUCT_MAIN_INFO_' . strtoupper($product_definition_key)] = $product_definition_value;
3333 3333
 				}
3334 3334
 			}
3335 3335
 			else {
3336
-				$variation_attribute_ordered = wpshop_products::get_selected_variation_display( $product_definition_value, $output_order, 'selection_summary' );
3336
+				$variation_attribute_ordered = wpshop_products::get_selected_variation_display($product_definition_value, $output_order, 'selection_summary');
3337 3337
 			}
3338 3338
 		}
3339 3339
 
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
 
3342 3342
 		ksort($variation_attribute_ordered['attribute_list']);
3343 3343
 		$tpl_component['PRODUCT_VARIATION_SUMMARY_DETAILS'] = '';
3344
-		foreach ( $variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output ) {
3344
+		foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) {
3345 3345
 			$tpl_component['PRODUCT_VARIATION_SUMMARY_DETAILS'] .= $attribute_variation_to_output;
3346 3346
 		}
3347 3347
 
@@ -3349,36 +3349,36 @@  discard block
 block discarded – undo
3349 3349
 
3350 3350
 		/**	For security get all attributes defined as user defined or used in variation in order to set default value to empty	*/
3351 3351
 		$attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_for_variation", true);
3352
-		if ( !empty($attribute_list) ) {
3353
-			foreach ( $attribute_list as $attribute_def ) {
3352
+		if (!empty($attribute_list)) {
3353
+			foreach ($attribute_list as $attribute_def) {
3354 3354
 				$tpl_component['VARIATION_SUMMARY_ATTRIBUTE_PER_PRICE_' . strtoupper($attribute_def->code)] = '-';
3355 3355
 			}
3356 3356
 		}
3357 3357
 
3358 3358
 		/**	Fill the array with all prices for different variations	*/
3359
-		foreach ( $variation_attribute_ordered['prices'] as $attribute => $prices ) {
3359
+		foreach ($variation_attribute_ordered['prices'] as $attribute => $prices) {
3360 3360
 			$tpl_component['VARIATION_SUMMARY_ATTRIBUTE_PER_PRICE_' . strtoupper($attribute)] = $prices;
3361 3361
 		}
3362 3362
 
3363 3363
 		$tpl_component['PRODUCT_VARIATION_SUMMARY_MORE_CONTENT'] = '';
3364 3364
 		$query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
3365 3365
 		$post_list_with_options = $wpdb->get_results($query);
3366
-		if ( !empty($post_list_with_options) ) {
3366
+		if (!empty($post_list_with_options)) {
3367 3367
 			$additionnal_price = 0;
3368
-			foreach ( $post_list_with_options as $product_info) {
3368
+			foreach ($post_list_with_options as $product_info) {
3369 3369
 				$product_meta = unserialize($product_info->meta_value);
3370
-				if ( !empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes') ) {
3370
+				if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && ($product_meta['cart']['auto_add'] == 'yes')) {
3371 3371
 					$product = wpshop_products::get_product_data($product_info->post_id, true, '"publish", "draft"');
3372 3372
 
3373
-					$the_product = array_merge( array(
3373
+					$the_product = array_merge(array(
3374 3374
 							'product_id'	=> $product_info->post_id,
3375 3375
 							'product_qty' 	=> 1
3376 3376
 					), $product);
3377 3377
 
3378
-					$additionnal_price += ( !$different_currency || ($change_rate == 1) ) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate);
3378
+					$additionnal_price += (!$different_currency || ($change_rate == 1)) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate);
3379 3379
 					$tpl_component['AUTO_PRODUCT_NAME'] = $the_product['product_name'];
3380 3380
 
3381
-					$tpl_component['AUTO_PRODUCT_PRODUCT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', ( !$different_currency || ($change_rate == 1) ) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate));
3381
+					$tpl_component['AUTO_PRODUCT_PRODUCT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', (!$different_currency || ($change_rate == 1)) ? $the_product['product_price'] : ($the_product['product_price'] * $change_rate));
3382 3382
 					$tpl_component['PRODUCT_VARIATION_SUMMARY_MORE_CONTENT'] = wpshop_display::display_template_element('wpshop_product_configuration_summary_detail_auto_product', $tpl_component);
3383 3383
 				}
3384 3384
 			}
@@ -3386,14 +3386,14 @@  discard block
 block discarded – undo
3386 3386
 
3387 3387
 		$tpl_component['PRODUCT_VARIATION_SUMMARY_GRAND_TOTAL'] = '';
3388 3388
 		$tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] = '';
3389
-		if ( !empty($additionnal_price) ) {
3389
+		if (!empty($additionnal_price)) {
3390 3390
 			$tpl_component['SUMMARY_FINAL_RESULT_PRICE'] = wpshop_display::format_field_output('wpshop_product_price', $tpl_component['PRODUCT_MAIN_INFO_PRODUCT_PRICE'] + $additionnal_price);
3391 3391
 			$tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] = ($tpl_component['PRODUCT_MAIN_INFO_PRODUCT_PRICE'] + $additionnal_price);
3392 3392
 			$tpl_component['PRODUCT_VARIATION_SUMMARY_GRAND_TOTAL'] = wpshop_display::display_template_element('wpshop_product_configuration_summary_detail_final_result', $tpl_component);
3393 3393
 		}
3394 3394
 
3395 3395
 		/**	Call informtion for partial payment	*/
3396
-		$partial_payment = $wpshop_payment->partial_payment_calcul( $tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT'] );
3396
+		$partial_payment = $wpshop_payment->partial_payment_calcul($tpl_component['SUMMARY_FINAL_RESULT_PRICE_NO_FORMAT']);
3397 3397
 		$tpl_component['PARTIAL_PAYMENT_INFO'] = !empty($partial_payment['amount_to_pay']) ? $partial_payment['display'] : '';
3398 3398
 
3399 3399
 
@@ -3420,13 +3420,13 @@  discard block
 block discarded – undo
3420 3420
 	 * @param array $old_value
3421 3421
 	 * @return array $new_value
3422 3422
 	 */
3423
-	public static function update_wpshop_catalog_product_option( $new_value, $old_value ) {
3423
+	public static function update_wpshop_catalog_product_option($new_value, $old_value) {
3424 3424
 		global $wpdb;
3425
-		$query = $wpdb->prepare('SELECT post_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s AND meta_value LIKE %s', '_wpshop_variation_defining', '%' . serialize( 'follow_general_config' ) . '%' );
3426
-		foreach( $wpdb->get_results( $query ) as $wpshop_variation_defining ) {
3427
-			$wpshop_variation_defining_value = unserialize( $wpshop_variation_defining->meta_value );
3425
+		$query = $wpdb->prepare('SELECT post_id, meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s AND meta_value LIKE %s', '_wpshop_variation_defining', '%' . serialize('follow_general_config') . '%');
3426
+		foreach ($wpdb->get_results($query) as $wpshop_variation_defining) {
3427
+			$wpshop_variation_defining_value = unserialize($wpshop_variation_defining->meta_value);
3428 3428
 			$wpshop_variation_defining_value['options']['price_display'] = $new_value['price_display'];
3429
-			update_post_meta( $wpshop_variation_defining->post_id, '_wpshop_variation_defining', $wpshop_variation_defining_value );
3429
+			update_post_meta($wpshop_variation_defining->post_id, '_wpshop_variation_defining', $wpshop_variation_defining_value);
3430 3430
 		}
3431 3431
 		return $new_value;
3432 3432
 	}
Please login to merge, or discard this patch.
includes/librairies/permissions.class.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 class wpshop_permissions {
24 24
 
25 25
 	/**
26
-	*	Define the different permission for the plugin. Define an array containing the permission defined with a sub-array
27
-	*
28
-	*	@return array $permission An array with the permission list for the plugin
29
-	*/
26
+	 *	Define the different permission for the plugin. Define an array containing the permission defined with a sub-array
27
+	 *
28
+	 *	@return array $permission An array with the permission list for the plugin
29
+	 */
30 30
 	function permission_list() {
31 31
 		$permission = array();
32 32
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	/**
101
-	*	Set the different permission for the administrator role. Add all existing permission for this role.
102
-	*	@see wpshop_permissions::permission_list()
103
-	*/
101
+	 *	Set the different permission for the administrator role. Add all existing permission for this role.
102
+	 *	@see wpshop_permissions::permission_list()
103
+	 */
104 104
 	function set_administrator_role_permission() {
105 105
 		$adminRole 	= get_role('administrator');
106 106
 		$permissionList = wpshop_permissions::permission_list();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
 /**
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 	*	@see wpshop_permissions::permission_list()
103 103
 	*/
104 104
 	function set_administrator_role_permission() {
105
-		$adminRole 	= get_role('administrator');
105
+		$adminRole = get_role('administrator');
106 106
 		$permissionList = wpshop_permissions::permission_list();
107 107
 		foreach ($permissionList as $permissionName => $permissionDef) {
108
-			if ( ($adminRole != null) && !$adminRole->has_cap($permissionName) ) {
108
+			if (($adminRole != null) && !$adminRole->has_cap($permissionName)) {
109 109
 				$adminRole->add_cap($permissionName);
110 110
 			}
111 111
 		}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	function wpshop_init_roles() {
116 116
 		global $wp_roles;
117 117
 
118
-		if (class_exists('WP_Roles')) if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles();
118
+		if (class_exists('WP_Roles')) if (!isset($wp_roles)) $wp_roles = new WP_Roles();
119 119
 
120 120
 		if (is_object($wp_roles)) :
121 121
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -115,7 +117,9 @@  discard block
 block discarded – undo
115 117
 	function wpshop_init_roles() {
116 118
 		global $wp_roles;
117 119
 
118
-		if (class_exists('WP_Roles')) if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles();
120
+		if (class_exists('WP_Roles')) {
121
+			if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles();
122
+		}
119 123
 
120 124
 		if (is_object($wp_roles)) :
121 125
 
Please login to merge, or discard this patch.
includes/librairies/options/options_shipping.class.php 3 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
 /**
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	*
26 26
 	*/
27
-	function declare_options(){
27
+	function declare_options() {
28 28
 
29
-		add_settings_section('wpshop_shipping_rules', '<span class="dashicons dashicons-admin-generic"></span>'.__('Shipping general configuration', 'wpshop'), array('wpshop_shipping_options', 'plugin_section_text'), 'wpshop_shipping_rules');
29
+		add_settings_section('wpshop_shipping_rules', '<span class="dashicons dashicons-admin-generic"></span>' . __('Shipping general configuration', 'wpshop'), array('wpshop_shipping_options', 'plugin_section_text'), 'wpshop_shipping_rules');
30 30
 		register_setting('wpshop_options', 'wpshop_shipping_address_choice', array('wpshop_shipping_options', 'wpshop_shipping_address_validator'));
31 31
 		add_settings_field('wpshop_shipping_address_choice', __('Shipping address choice', 'wpshop'), array('wpshop_shipping_options', 'wpshop_shipping_address_field'), 'wpshop_shipping_rules', 'wpshop_shipping_rules');
32 32
 
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 		echo '';
47 47
 	}
48 48
 
49
-	public static function wpshop_shipping_address_validator($input){
50
-		$shipping_option = get_option( 'wpshop_shipping_address_choice' );
51
-		if( !empty($shipping_option) && !empty($shipping_option['display_model']) ) {
49
+	public static function wpshop_shipping_address_validator($input) {
50
+		$shipping_option = get_option('wpshop_shipping_address_choice');
51
+		if (!empty($shipping_option) && !empty($shipping_option['display_model'])) {
52 52
 			$input['display_model'] = $shipping_option['display_model'];
53 53
 		}
54 54
 
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	public static function wpshop_shipping_address_field() {
59 59
 		global $wpdb;
60 60
 		$choice = get_option('wpshop_shipping_address_choice', unserialize(WPSHOP_SHOP_CUSTOM_SHIPPING));
61
-		$query = $wpdb->prepare('SELECT ID FROM ' .$wpdb->posts. ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
61
+		$query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
62 62
 		$entity_id = $wpdb->get_var($query);
63 63
 
64
-		$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $entity_id);
64
+		$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
65 65
 		$content = $wpdb->get_results($query);
66 66
 
67 67
 		$input_def['name'] = 'wpshop_shipping_address_choice[choice]';
@@ -71,39 +71,39 @@  discard block
 block discarded – undo
71 71
 		$input_def['value'] = $choice['choice'];
72 72
 
73 73
 		$active = !empty($choice['activate']) ? $choice['activate'] : false;
74
-		$display_model = ( !empty($choice['display_model']) ) ? addslashes( serialize( $choice['display_model'] ) ) : '';
74
+		$display_model = (!empty($choice['display_model'])) ? addslashes(serialize($choice['display_model'])) : '';
75 75
 
76
-		echo '<input type="checkbox" name="wpshop_shipping_address_choice[activate]" id="wpshop_shipping_address_choice[activate]" '.($active ? 'checked="checked"' :null).'/> <label for="wpshop_shipping_address_choice[activate]">'.__('Activate shipping address','wpshop').'</label><br/>
77
-		<div>' .wpshop_form::check_input_type($input_def). '</div>';
76
+		echo '<input type="checkbox" name="wpshop_shipping_address_choice[activate]" id="wpshop_shipping_address_choice[activate]" ' . ($active ? 'checked="checked"' : null) . '/> <label for="wpshop_shipping_address_choice[activate]">' . __('Activate shipping address', 'wpshop') . '</label><br/>
77
+		<div>' .wpshop_form::check_input_type($input_def) . '</div>';
78 78
 
79 79
 	}
80 80
 
81 81
 	public static function wpshop_shipping_cost_from_fields() {
82 82
 		$shipping_cost_from_option = get_option('wpshop_shipping_cost_from');
83
-		$output = '<input type="checkbox" id="wpshop_shipping_cost_from" name="wpshop_shipping_cost_from" ' . ( (!empty($shipping_cost_from_option)) ? 'checked="checked"' : '') . ' /> ';
84
-		$output .= '<label for="wpshop_shipping_cost_from">' . __('Display "From" behind Shipping cost in cart while shipping address is undefined', 'wpshop'). '</label>';
83
+		$output = '<input type="checkbox" id="wpshop_shipping_cost_from" name="wpshop_shipping_cost_from" ' . ((!empty($shipping_cost_from_option)) ? 'checked="checked"' : '') . ' /> ';
84
+		$output .= '<label for="wpshop_shipping_cost_from">' . __('Display "From" behind Shipping cost in cart while shipping address is undefined', 'wpshop') . '</label>';
85 85
 		echo $output;
86 86
 	}
87 87
 
88
-	public static function wpshop_shipping_cost_from_validator( $input ) {
88
+	public static function wpshop_shipping_cost_from_validator($input) {
89 89
 
90 90
 
91 91
 		return $input;
92 92
 	}
93 93
 
94
-	public static function wpshop_limit_country_list_validator( $input ) {
94
+	public static function wpshop_limit_country_list_validator($input) {
95 95
 		return $input;
96 96
 	}
97 97
 
98 98
 	public static function wpshop_limit_country_list_fields() {
99 99
 		$output = '';
100
-		$limit_countries_list = get_option( 'wpshop_limit_country_list' );
100
+		$limit_countries_list = get_option('wpshop_limit_country_list');
101 101
 		$countries = unserialize(WPSHOP_COUNTRY_LIST);
102
-		if ( !empty ($countries) ) {
102
+		if (!empty ($countries)) {
103 103
 			$output .= '<select name="wpshop_limit_country_list[]" class="chosen_select" multiple data-placeholder="Choose a Country">';
104
-			foreach( $countries as $key => $country ) {
105
-				$is_selected = ( !empty($limit_countries_list) && is_array($limit_countries_list) && in_array($key, $limit_countries_list) ) ? true : false;
106
-				$output .= '<option value="' .$key. '" ' . ( ($is_selected) ? 'selected="selected"' : '' ) . '>' .$country. '</option>';
104
+			foreach ($countries as $key => $country) {
105
+				$is_selected = (!empty($limit_countries_list) && is_array($limit_countries_list) && in_array($key, $limit_countries_list)) ? true : false;
106
+				$output .= '<option value="' . $key . '" ' . (($is_selected) ? 'selected="selected"' : '') . '>' . $country . '</option>';
107 107
 			}
108 108
 			$output .= '</select>';
109 109
 		}
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	public static function wpshop_country_default_choice_fields() {
114
-		$default_country_choice = get_option( 'wpshop_country_default_choice' );
115
-		$output  = '<select name="wpshop_country_default_choice">';
114
+		$default_country_choice = get_option('wpshop_country_default_choice');
115
+		$output = '<select name="wpshop_country_default_choice">';
116 116
 		$countries = unserialize(WPSHOP_COUNTRY_LIST);
117
-		foreach( $countries as $key => $country ) {
118
-			$is_selected = ( !empty($default_country_choice) &&  $key == $default_country_choice ) ? true : false;
119
-			$output .= '<option value="' .$key. '" ' . ( ($is_selected) ? 'selected="selected"' : '' ) . '>' .$country. '</option>';
117
+		foreach ($countries as $key => $country) {
118
+			$is_selected = (!empty($default_country_choice) && $key == $default_country_choice) ? true : false;
119
+			$output .= '<option value="' . $key . '" ' . (($is_selected) ? 'selected="selected"' : '') . '>' . $country . '</option>';
120 120
 		}
121 121
 		$output .= '</select>';
122 122
 		echo $output;
123 123
 	}
124 124
 	
125
-	public static function wpshop_country_default_choice_validator( $input ) {
125
+	public static function wpshop_country_default_choice_validator($input) {
126 126
 		return $input;
127 127
 	}
128 128
 }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 class wpshop_advanced_settings{
24 24
 
25 25
 	/**
26
-	*
27
-	*/
26
+	 *
27
+	 */
28 28
 	function declare_options(){
29 29
 		add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options');
30 30
 			register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options'));
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/options/options_company.class.php 3 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	*
27 27
 	*/
28
-	public static function declare_options(){
29
-		add_settings_section('wpshop_company_info', '<span class="dashicons dashicons-admin-home"></span>'.__('Company info', 'wpshop'), array('wpshop_company_options', 'plugin_section_text'), 'wpshop_company_info');
28
+	public static function declare_options() {
29
+		add_settings_section('wpshop_company_info', '<span class="dashicons dashicons-admin-home"></span>' . __('Company info', 'wpshop'), array('wpshop_company_options', 'plugin_section_text'), 'wpshop_company_info');
30 30
 			register_setting('wpshop_options', 'wpshop_company_info', array('wpshop_company_options', 'wpshop_options_validate_company_info'));
31 31
 			add_settings_field('wpshop_company_legal_statut', __('Legal status', 'wpshop'), array('wpshop_company_options', 'wpshop_company_legal_statut_field'), 'wpshop_company_info', 'wpshop_company_info');
32 32
 			add_settings_field('wpshop_company_capital', __('Capital', 'wpshop'), array('wpshop_company_options', 'wpshop_company_capital_field'), 'wpshop_company_info', 'wpshop_company_info');
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	/**/
47
-	public static function plugin_section_text(){
47
+	public static function plugin_section_text() {
48 48
 
49 49
 	}
50 50
 
@@ -55,76 +55,76 @@  discard block
 block discarded – undo
55 55
 		$options = get_option('wpshop_company_info');
56 56
 
57 57
 		$legal_status = self::get_legal_status();
58
-		$legal_status = apply_filters( 'wps_legal_status_extender', $legal_status );
58
+		$legal_status = apply_filters('wps_legal_status_extender', $legal_status);
59 59
 
60 60
 		$select_legal_statut = '<select name="wpshop_company_info[company_legal_statut]">';
61
-		foreach($legal_status as $key=>$value) {
62
-			$selected = $options['company_legal_statut']==$key ? ' selected="selected"' : null;
63
-			$select_legal_statut .= '<option value="'.$key.'"'.$selected.'>'.__($value,'wpshop').'</option>';
61
+		foreach ($legal_status as $key=>$value) {
62
+			$selected = $options['company_legal_statut'] == $key ? ' selected="selected"' : null;
63
+			$select_legal_statut .= '<option value="' . $key . '"' . $selected . '>' . __($value, 'wpshop') . '</option>';
64 64
 		}
65 65
 		$select_legal_statut .= '</select>';
66
-		$select_legal_statut .= ' <a href="#" title="'.__('Legal status will appear in invoices','wpshop').'" class="wpshop_infobulle_marker">?</a>';
66
+		$select_legal_statut .= ' <a href="#" title="' . __('Legal status will appear in invoices', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
67 67
 		echo $select_legal_statut;
68 68
 	}
69 69
 	public static function wpshop_company_capital_field() {
70 70
 		$options = get_option('wpshop_company_info');
71
-		echo '<input name="wpshop_company_info[company_capital]" type="text" value="'.$options['company_capital'].'" />
72
-		<a href="#" title="'.__('Capital of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
71
+		echo '<input name="wpshop_company_info[company_capital]" type="text" value="' . $options['company_capital'] . '" />
72
+		<a href="#" title="'.__('Capital of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
73 73
 	}
74 74
 	public static function wpshop_company_name_field() {
75 75
 		$options = get_option('wpshop_company_info');
76
-		echo '<input name="wpshop_company_info[company_name]" type="text" value="'.$options['company_name'].'" />
77
-		<a href="#" title="'.__('Name of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
76
+		echo '<input name="wpshop_company_info[company_name]" type="text" value="' . $options['company_name'] . '" />
77
+		<a href="#" title="'.__('Name of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
78 78
 	}
79 79
 	public static function wpshop_company_street_field() {
80 80
 		$options = get_option('wpshop_company_info');
81
-		echo '<input name="wpshop_company_info[company_street]" type="text" value="'.$options['company_street'].'" />
82
-		<a href="#" title="'.__('Street of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
81
+		echo '<input name="wpshop_company_info[company_street]" type="text" value="' . $options['company_street'] . '" />
82
+		<a href="#" title="'.__('Street of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
83 83
 	}
84 84
 	public static function wpshop_company_postcode_field() {
85 85
 		$options = get_option('wpshop_company_info');
86
-		echo '<input name="wpshop_company_info[company_postcode]" type="text" value="'.$options['company_postcode'].'" />
87
-		<a href="#" title="'.__('Postcode of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
86
+		echo '<input name="wpshop_company_info[company_postcode]" type="text" value="' . $options['company_postcode'] . '" />
87
+		<a href="#" title="'.__('Postcode of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
88 88
 	}
89 89
 	public static function wpshop_company_city_field() {
90 90
 		$options = get_option('wpshop_company_info');
91
-		echo '<input name="wpshop_company_info[company_city]" type="text" value="'.$options['company_city'].'" />
92
-		<a href="#" title="'.__('The city in which your company is based','wpshop').'" class="wpshop_infobulle_marker">?</a>';
91
+		echo '<input name="wpshop_company_info[company_city]" type="text" value="' . $options['company_city'] . '" />
92
+		<a href="#" title="'.__('The city in which your company is based', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
93 93
 	}
94 94
 	public static function wpshop_company_country_field() {
95 95
 		$options = get_option('wpshop_company_info');
96
-		echo '<input name="wpshop_company_info[company_country]" type="text" value="'.$options['company_country'].'" />
97
-		<a href="#" title="'.__('Country of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
96
+		echo '<input name="wpshop_company_info[company_country]" type="text" value="' . $options['company_country'] . '" />
97
+		<a href="#" title="'.__('Country of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
98 98
 	}
99 99
 	public static function wpshop_company_tva_intra_field() {
100 100
 		$options = get_option('wpshop_company_info');
101
-		echo '<input name="wpshop_company_info[company_tva_intra]" type="text" value="'.$options['company_tva_intra'].'" />
102
-		<a href="#" title="'.__('Intracommunity VAT of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
101
+		echo '<input name="wpshop_company_info[company_tva_intra]" type="text" value="' . $options['company_tva_intra'] . '" />
102
+		<a href="#" title="'.__('Intracommunity VAT of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
103 103
 	}
104 104
 	public static function wpshop_company_phone_field() {
105 105
 		$options = get_option('wpshop_company_info');
106
-		echo '<input name="wpshop_company_info[company_phone]" type="text" value="'.$options['company_phone'].'" />
107
-		<a href="#" title="'.__('Phone number of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
106
+		echo '<input name="wpshop_company_info[company_phone]" type="text" value="' . $options['company_phone'] . '" />
107
+		<a href="#" title="'.__('Phone number of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
108 108
 	}
109 109
 	public static function wpshop_company_rcs_field() {
110 110
 		$options = get_option('wpshop_company_info');
111
-		echo '<input name="wpshop_company_info[company_rcs]" type="text" value="'.$options['company_rcs'].'" />
112
-		<a href="#" title="'.__('RCS of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
111
+		echo '<input name="wpshop_company_info[company_rcs]" type="text" value="' . $options['company_rcs'] . '" />
112
+		<a href="#" title="'.__('RCS of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
113 113
 	}
114 114
 	public static function wpshop_company_siret_field() {
115 115
 		$options = get_option('wpshop_company_info');
116
-		echo '<input name="wpshop_company_info[company_siret]" type="text" value="'.$options['company_siret'].'" />
117
-		<a href="#" title="'.__('SIRET of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
116
+		echo '<input name="wpshop_company_info[company_siret]" type="text" value="' . $options['company_siret'] . '" />
117
+		<a href="#" title="'.__('SIRET of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
118 118
 	}
119 119
 	public static function wpshop_company_siren_field() {
120 120
 		$options = get_option('wpshop_company_info');
121
-		echo '<input name="wpshop_company_info[company_siren]" type="text" value="'.$options['company_siren'].'" />
122
-		<a href="#" title="'.__('SIREN of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
121
+		echo '<input name="wpshop_company_info[company_siren]" type="text" value="' . $options['company_siren'] . '" />
122
+		<a href="#" title="'.__('SIREN of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
123 123
 	}
124 124
 	public static function wpshop_company_fax_field() {
125 125
 		$options = get_option('wpshop_company_info');
126
-		echo '<input name="wpshop_company_info[company_fax]" type="text" value="'.$options['company_fax'].'" />
127
-		<a href="#" title="'.__('Fax number of your company','wpshop').'" class="wpshop_infobulle_marker">?</a>';
126
+		echo '<input name="wpshop_company_info[company_fax]" type="text" value="' . $options['company_fax'] . '" />
127
+		<a href="#" title="'.__('Fax number of your company', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
128 128
 	}
129 129
 
130 130
 	/* Processing */
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				'sa' => 'SA',
148 148
 				'sas' => 'SAS',
149 149
 				'sasu' => 'SASU',
150
-				'association' => __( 'Assocation', 'wpshop'),
150
+				'association' => __('Assocation', 'wpshop'),
151 151
 				'sci' => 'SCI',
152 152
 				'scp' => 'SCP',
153 153
 				'scm' => 'SCM',
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 class wpshop_advanced_settings{
24 24
 
25 25
 	/**
26
-	*
27
-	*/
26
+	 *
27
+	 */
28 28
 	function declare_options(){
29 29
 		add_settings_section('wpshop_extra_options', '<span class="dashicons dashicons-carrot"></span>'.__('Advanced configurations', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_extra_options');
30 30
 			register_setting('wpshop_options', 'wpshop_extra_options', array('wpshop_advanced_settings', 'validate_options'));
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
includes/librairies/options/options.class.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -162,8 +162,8 @@
 block discarded – undo
162 162
 
163 163
 
164 164
 	/**
165
-	*	Declare the different options for the plugin
166
-	*/
165
+	 *	Declare the different options for the plugin
166
+	 */
167 167
 	public static function add_options(){
168 168
 		global $wpshop_display_option;
169 169
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Fichier de définition du modèle des taxinomies / File for term model definition
4 6
  *
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
 /**
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 		$groups = array();
44 44
 
45 45
 		$groups['wpshop_general_option'] =
46
-			array(	'label' => __('General', 'wpshop'),
46
+			array('label' => __('General', 'wpshop'),
47 47
 					'subgroups' => array(
48 48
 						'wpshop_general_config' => array('class' => 'wpshop_admin_box_options_general'),
49 49
 						'wpshop_company_info' => array('class' => 'wpshop_admin_box_options_company'),
50 50
 					),
51 51
 			);
52 52
 		$groups['wpshop_catalog_option'] =
53
-			array(	'label' => __('Catalog', 'wpshop'),
53
+			array('label' => __('Catalog', 'wpshop'),
54 54
 					'subgroups' => array(
55 55
 						'wpshop_catalog_product_option' => array('class' => ' wpshop_admin_box_options_product'),
56 56
 						'wpshop_catalog_main_option' => array('class' => ' wpshop_admin_box_options_catalog'),
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 					),
59 59
 			);
60 60
 		$groups['wpshop_pages_option'] =
61
-			array(	'label' => __('Pages', 'wpshop'),
61
+			array('label' => __('Pages', 'wpshop'),
62 62
 					'subgroups' => array(
63 63
 						'wpshop_pages_option' => array('class' => ' wpshop_admin_box_options_pages'),
64 64
 					),
65 65
 			);
66 66
 		$groups['wpshop_display_option'] =
67
-			array(	'label' => __('Display', 'wpshop'),
67
+			array('label' => __('Display', 'wpshop'),
68 68
 					'subgroups' => array(
69 69
 						'wpshop_display_option' => array('class' => ' wpshop_admin_box_options_display'),
70 70
 						'wpshop_customize_display_option' => array('class' => ' wpshop_admin_box_options_display'),
@@ -72,32 +72,32 @@  discard block
 block discarded – undo
72 72
 					),
73 73
 			);
74 74
 		$groups['wpshop_emails_option'] =
75
-			array(	'label' => __('Emails', 'wpshop'),
75
+			array('label' => __('Emails', 'wpshop'),
76 76
 					'subgroups' => array(
77 77
 						'wpshop_emails' => array('class' => ' wpshop_admin_box_options_email'),
78 78
 						'wpshop_messages' => array('class' => ' wpshop_admin_box_options_message'),
79 79
 					),
80 80
 			);
81 81
 
82
-		$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : '';
82
+		$wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : '';
83 83
 
84 84
 		/**	Some options are available only when sale mode is active	*/
85
-		if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation'))) :
85
+		if ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation'))) :
86 86
 			$groups['wpshop_cart_option'] =
87
-				array(	'label' => __('Cart', 'wpshop'),
87
+				array('label' => __('Cart', 'wpshop'),
88 88
 						'subgroups' => array(
89 89
 							'wpshop_cart_info' => array('class' => ' wpshop_admin_box_options_cart'),
90 90
 						),
91 91
 				);
92 92
 			$groups['wpshop_payments_option'] =
93
-				array(	'label' => __('Payments', 'wpshop'),
93
+				array('label' => __('Payments', 'wpshop'),
94 94
 						'subgroups' => array(
95 95
 							'wpshop_paymentMethod' => array('class' => ' wpshop_admin_box_options_payment_method'),
96 96
 							'wpshop_payment_partial_on_command' => array('class' => ' wpshop_admin_box_options_payment_partial'),
97 97
 						),
98 98
 				);
99 99
 			$groups['wpshop_shipping_option'] =
100
-				array(	'label' => __('Shipping', 'wpshop'),
100
+				array('label' => __('Shipping', 'wpshop'),
101 101
 						'subgroups' => array(
102 102
 							'wpshop_shipping_rules' => array('class' => ' wpshop_admin_box_options_shipping_rules')
103 103
 						),
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 		endif;
106 106
 
107 107
 		$groups['wpshop_addons_option'] =
108
-			array(	'label' => __('Addons', 'wpshop'),
108
+			array('label' => __('Addons', 'wpshop'),
109 109
 					'subgroups' => array(
110 110
 						'wpshop_addons_options' => array('class' => ' wpshop_admin_box_options_addons'),
111 111
 					),
112 112
 			);
113 113
 
114 114
 		$groups['wpshop_advanced_options'] =
115
-			array(	'label' => __('Advanced options', 'wpshop'),
115
+			array('label' => __('Advanced options', 'wpshop'),
116 116
 					'subgroups' => array(
117 117
 						'wpshop_extra_options' => array('class' => ' wpshop_admin_box_options_advanced'),
118 118
 					),
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 		ob_end_clean();
139 139
 		$tpl_component['ADMIN_OPTIONS_TAB_LIST'] = '';
140 140
 		$tpl_component['ADMIN_OPTIONS_TAB_CONTENT_LIST'] = '';
141
-		if ( !empty($options_list) ) {
142
-			foreach ( $options_list as $group_key => $group_content) {
141
+		if (!empty($options_list)) {
142
+			foreach ($options_list as $group_key => $group_content) {
143 143
 				$sub_tpl_component = array();
144
-				if ( !empty($group_content['subgroups']) && is_array($group_content['subgroups']) ) {
144
+				if (!empty($group_content['subgroups']) && is_array($group_content['subgroups'])) {
145 145
 					$sub_tpl_component['ADMIN_OPTIONS_GROUP_CONTENT'] = '';
146 146
 					$sub_tpl_component['ADMIN_OPTIONS_TAB_KEY'] = $group_key;
147
-					$sub_tpl_component['ADMIN_OPTIONS_TAB_LABEL'] = ( !empty($group_content['label']) ) ? $group_content['label'] : '';
147
+					$sub_tpl_component['ADMIN_OPTIONS_TAB_LABEL'] = (!empty($group_content['label'])) ? $group_content['label'] : '';
148 148
 					$tpl_component['ADMIN_OPTIONS_TAB_LIST'] .= wpshop_display::display_template_element('wpshop_admin_options_group_tab', $sub_tpl_component, array(), 'admin');
149
-					foreach ( $group_content['subgroups'] as $subgroup_key => $subgroup_def) {
149
+					foreach ($group_content['subgroups'] as $subgroup_key => $subgroup_def) {
150 150
 						ob_start();
151
-						do_settings_sections( $subgroup_key );
151
+						do_settings_sections($subgroup_key);
152 152
 						$sub_tpl_component['ADMIN_OPTIONS_SUBGROUP_CONTENT'] = ob_get_contents();
153 153
 						ob_end_clean();
154 154
 						$sub_tpl_component['ADMIN_OPTIONS_SUBGROUP_CLASS'] = $subgroup_def['class'];
@@ -166,21 +166,21 @@  discard block
 block discarded – undo
166 166
 	/**
167 167
 	*	Declare the different options for the plugin
168 168
 	*/
169
-	public static function add_options(){
169
+	public static function add_options() {
170 170
 		global $wpshop_display_option;
171 171
 
172 172
 
173 173
 		/*Catalog - Main	*/
174 174
 		register_setting('wpshop_options', 'wpshop_catalog_main_option', array('wpshop_options', 'wpshop_options_validate_catalog_main_option'));
175
-			add_settings_section('wpshop_catalog_main_section', '<span class="dashicons dashicons-category"></span>'.__('Catalog', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_main_option');
175
+			add_settings_section('wpshop_catalog_main_section', '<span class="dashicons dashicons-category"></span>' . __('Catalog', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_main_option');
176 176
 				add_settings_field('wpshop_catalog_empty_price_behaviour', __('Empty price', 'wpshop'), array('wpshop_options', 'wpshop_catalog_empty_price_behaviour'), 'wpshop_catalog_main_option', 'wpshop_catalog_main_section');
177 177
 		/* Catalog - Product */
178 178
 		register_setting('wpshop_options', 'wpshop_catalog_product_option', array('wpshop_options', 'wpshop_options_validate_catalog_product_option'));
179
-			add_settings_section('wpshop_catalog_product_section', '<span class="dashicons dashicons-archive"></span>'.__('Products', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_product_option');
179
+			add_settings_section('wpshop_catalog_product_section', '<span class="dashicons dashicons-archive"></span>' . __('Products', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_product_option');
180 180
 				add_settings_field('wpshop_catalog_product_slug', __('Products common rewrite param', 'wpshop'), array('wpshop_options', 'wpshop_catalog_product_slug_field'), 'wpshop_catalog_product_option', 'wpshop_catalog_product_section');
181 181
 		/* Catalog - Categories */
182 182
 		register_setting('wpshop_options', 'wpshop_catalog_categories_option', array('wpshop_options', 'wpshop_options_validate_catalog_categories_option'));
183
-		add_settings_section('wpshop_catalog_categories_section', '<span class="dashicons dashicons-portfolio"></span>'.__('Categories', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_categories_option');
183
+		add_settings_section('wpshop_catalog_categories_section', '<span class="dashicons dashicons-portfolio"></span>' . __('Categories', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_categories_option');
184 184
 		add_settings_field('wpshop_catalog_categories_slug', __('Categories common rewrite param', 'wpshop'), array('wpshop_options', 'wpshop_catalog_categories_slug_field'), 'wpshop_catalog_categories_option', 'wpshop_catalog_categories_section');
185 185
 		add_settings_field('wpshop_catalog_no_category_slug', __('Default category slug for unassociated product', 'wpshop'), array('wpshop_options', 'wpshop_catalog_no_category_slug_field'), 'wpshop_catalog_categories_option', 'wpshop_catalog_categories_section');
186 186
 
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
 		wpshop_company_options::declare_options();
192 192
 
193 193
 		/* Payments */
194
-		$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : '';
195
-		$old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : '';
196
-		if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))){
194
+		$wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : '';
195
+		$old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : '';
196
+		if ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))) {
197 197
 			wpshop_payment_options::declare_options();
198 198
 		}
199 199
 
200 200
 		/* Cart */
201
-		if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))){
201
+		if ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))) {
202 202
 			register_setting('wpshop_options', 'wpshop_cart_option', array('wpshop_options', 'wpshop_options_validate_cart'));
203
-			add_settings_section('wpshop_cart_info', '<span class="dashicons dashicons-cart"></span>'.__('Cart', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_cart_info');
203
+			add_settings_section('wpshop_cart_info', '<span class="dashicons dashicons-cart"></span>' . __('Cart', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_cart_info');
204 204
 			add_settings_field('wpshop_cart_product_added_behaviour', __('Action when produt is added succesfully into cart', 'wpshop'), array('wpshop_options', 'wpshop_cart_product_added_behaviour_field'), 'wpshop_cart_info', 'wpshop_cart_info');
205 205
 			add_settings_field('wpshop_cart_product_added_to_quotation_behaviour', __('Action when produt is added succesfully into a quotation', 'wpshop'), array('wpshop_options', 'wpshop_cart_product_added_to_quotation_behaviour_field'), 'wpshop_cart_info', 'wpshop_cart_info');
206 206
 			add_settings_field('wpshop_cart_total_item_nb', __('Allow only one product into cart', 'wpshop'), array('wpshop_options', 'wpshop_cart_total_item_nb_field'), 'wpshop_cart_info', 'wpshop_cart_info');
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$wpshop_advanced_settings->declare_options();
228 228
 
229 229
 		/* Shipping section */
230
-		if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))){
230
+		if ((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))) {
231 231
 		$wpshop_shipping_options = new wpshop_shipping_options();
232 232
 			$wpshop_shipping_options->declare_options();
233 233
 		}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		$options = get_option('wpshop_catalog_main_option');
246 246
 		echo '<input type="checkbox"' . (!empty($options['wpshop_catalog_empty_price_behaviour']) ? ' checked="checked" ' : '') . ' value="yes" name="wpshop_catalog_main_option[wpshop_catalog_empty_price_behaviour]" id="wpshop_catalog_empty_price_behaviour" /> <label for="wpshop_catalog_empty_price_behaviour" >' . __('Hide price and add to cart button when price is empty or equal to 0', 'wpshop') . '</label>';
247 247
 	}
248
-	public static function wpshop_catalog_product_slug_field(){
248
+	public static function wpshop_catalog_product_slug_field() {
249 249
 		$options = get_option('wpshop_catalog_product_option');
250 250
 		$catalog_cat_options = get_option('wpshop_catalog_categories_option');
251 251
 		echo '<input type="checkbox"' . (!empty($options['wpshop_catalog_product_slug_with_category']) ? ' checked="checked" ' : '') . ' value="yes" name="wpshop_catalog_product_option[wpshop_catalog_product_slug_with_category]" id="wpshop_catalog_product_slug_with_category" /> <label for="wpshop_catalog_product_slug_with_category">' . __('Use product category in url', 'wpshop') . '</label><br/>
@@ -253,24 +253,24 @@  discard block
 block discarded – undo
253 253
 		<div class="alignleft wpshop_options_catalog_product_rewrite" ><input type="text" name="wpshop_catalog_product_option[wpshop_catalog_product_slug]" value="' . (!empty($options['wpshop_catalog_product_slug']) ? $options['wpshop_catalog_product_slug'] : WPSHOP_CATALOG_PRODUCT_SLUG) . '" /></div>
254 254
 		<div class="alignleft wpshop_options_catalog_product_rewrite" ><span class="wpshop_catalog_product_slug_category' . (empty($options['wpshop_catalog_product_slug_with_category']) ? ' disable' : '') . '" >/' . (!empty($catalog_cat_options['wpshop_catalog_categories_slug']) ? $catalog_cat_options['wpshop_catalog_categories_slug'] : WPSHOP_CATALOG_CATEGORIES_SLUG) . '</span></div>
255 255
 		<div class="alignleft wpshop_options_catalog_product_rewrite" >/' . __('Your_product_slug', 'wpshop') . '</div>
256
-		<div class="alignleft" ><a href="#" title="'.__('This slug will be used in url to describe products page','wpshop').'" class="wpshop_infobulle_marker">?</a></div><br /><br />
257
-		<div><span style="color: red;" class="dashicons dashicons-megaphone"></span> '.__('"/" permit to disable slug of products (<b>but don\'t work with rewrites plugins</b>)','wpshop').'</div>';
256
+		<div class="alignleft" ><a href="#" title="'.__('This slug will be used in url to describe products page', 'wpshop') . '" class="wpshop_infobulle_marker">?</a></div><br /><br />
257
+		<div><span style="color: red;" class="dashicons dashicons-megaphone"></span> '.__('"/" permit to disable slug of products (<b>but don\'t work with rewrites plugins</b>)', 'wpshop') . '</div>';
258 258
 	}
259
-	public static function wpshop_catalog_categories_slug_field(){
259
+	public static function wpshop_catalog_categories_slug_field() {
260 260
 		$options = get_option('wpshop_catalog_categories_option');
261 261
 		echo '<input type="text" name="wpshop_catalog_categories_option[wpshop_catalog_categories_slug]" value="' . (!empty($options['wpshop_catalog_categories_slug']) ? $options['wpshop_catalog_categories_slug'] : WPSHOP_CATALOG_CATEGORIES_SLUG) . '" />
262
-		<a href="#" title="'.__('This slug will be used in url to describe catagories page','wpshop').'" class="wpshop_infobulle_marker">?</a>';
262
+		<a href="#" title="'.__('This slug will be used in url to describe catagories page', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
263 263
 	}
264
-	public static function wpshop_catalog_no_category_slug_field(){
264
+	public static function wpshop_catalog_no_category_slug_field() {
265 265
 		$options = get_option('wpshop_catalog_categories_option');
266 266
 		echo '<input type="text" name="wpshop_catalog_categories_option[wpshop_catalog_no_category_slug]" value="' . (!empty($options['wpshop_catalog_no_category_slug']) ? $options['wpshop_catalog_no_category_slug'] : WPSHOP_CATALOG_PRODUCT_NO_CATEGORY) . '" />
267
-		<a href="#" title="'.__('This slug will be used for products not being related to any category ','wpshop').'" class="wpshop_infobulle_marker">?</a>';
267
+		<a href="#" title="'.__('This slug will be used for products not being related to any category ', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
268 268
 	}
269 269
 
270 270
 	/* Processing */
271
-	public static function wpshop_options_validate_catalog_product_option($input){
272
-		foreach($input as $option_key => $option_value){
273
-			switch($option_key){
271
+	public static function wpshop_options_validate_catalog_product_option($input) {
272
+		foreach ($input as $option_key => $option_value) {
273
+			switch ($option_key) {
274 274
 				default:
275 275
 					$new_input[$option_key] = $option_value;
276 276
 				break;
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 
280 280
 		return $new_input;
281 281
 	}
282
-	public static function wpshop_options_validate_catalog_categories_option($input){
283
-		foreach($input as $option_key => $option_value){
284
-			switch($option_key){
282
+	public static function wpshop_options_validate_catalog_categories_option($input) {
283
+		foreach ($input as $option_key => $option_value) {
284
+			switch ($option_key) {
285 285
 				default:
286 286
 					$new_input[$option_key] = $option_value;
287 287
 				break;
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 
291 291
 		return $new_input;
292 292
 	}
293
-	public static function wpshop_options_validate_catalog_main_option($input){
293
+	public static function wpshop_options_validate_catalog_main_option($input) {
294 294
 		$new_input = $input;
295
-		if ( !empty($input) && is_array( $input ) ) {
296
-			foreach($input as $option_key => $option_value){
297
-				switch($option_key){
295
+		if (!empty($input) && is_array($input)) {
296
+			foreach ($input as $option_key => $option_value) {
297
+				switch ($option_key) {
298 298
 					default:
299 299
 						$new_input[$option_key] = $option_value;
300 300
 						break;
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 		return $new_input;
306 306
 	}
307 307
 
308
-	public static function wpshop_catalog_varition_product_field () {
308
+	public static function wpshop_catalog_varition_product_field() {
309 309
 		$catalog_product_option = get_option('wpshop_catalog_product_option');
310
-		$output  = '<input type="checkbox" name="wpshop_catalog_product_option[price_display][text_from]" id="wpshop_catalog_product_option_price_display_text_from" ' .( ( !empty($catalog_product_option) && !empty($catalog_product_option['price_display']) && !empty($catalog_product_option['price_display']['text_from']) ) ? 'checked="checked"' : '' ). ' /> ';
311
-		$output .= '<label for="wpshop_catalog_product_option_price_display_text_from">'. __('Display "price from" before basic price of product', 'wpshop').'</label><br/>';
312
-		$output .= '<input type="checkbox" name="wpshop_catalog_product_option[price_display][lower_price]" id="wpshop_catalog_product_option_price_display_lower_price" ' .( ( !empty($catalog_product_option) && !empty($catalog_product_option['price_display']) && !empty($catalog_product_option['price_display']['lower_price']) ) ? 'checked="checked"' : '' ). ' /> ';
313
-		$output .= '<label for="wpshop_catalog_product_option_price_display_lower_price">'. __('Display the lowest price of variation', 'wpshop').'</label>';
310
+		$output  = '<input type="checkbox" name="wpshop_catalog_product_option[price_display][text_from]" id="wpshop_catalog_product_option_price_display_text_from" ' . ((!empty($catalog_product_option) && !empty($catalog_product_option['price_display']) && !empty($catalog_product_option['price_display']['text_from'])) ? 'checked="checked"' : '') . ' /> ';
311
+		$output .= '<label for="wpshop_catalog_product_option_price_display_text_from">' . __('Display "price from" before basic price of product', 'wpshop') . '</label><br/>';
312
+		$output .= '<input type="checkbox" name="wpshop_catalog_product_option[price_display][lower_price]" id="wpshop_catalog_product_option_price_display_lower_price" ' . ((!empty($catalog_product_option) && !empty($catalog_product_option['price_display']) && !empty($catalog_product_option['price_display']['lower_price'])) ? 'checked="checked"' : '') . ' /> ';
313
+		$output .= '<label for="wpshop_catalog_product_option_price_display_lower_price">' . __('Display the lowest price of variation', 'wpshop') . '</label>';
314 314
 		echo $output;
315 315
 	}
316 316
 
317
-	public static function wpshop_catalog_product_variation_option_validate ($input) {
317
+	public static function wpshop_catalog_product_variation_option_validate($input) {
318 318
 		return $input;
319 319
 	}
320 320
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		$input_def['valueToPut'] = 'index';
333 333
 		$input_def['value'] = !empty($cart_option['total_nb_of_item_allowed']) ? $cart_option['total_nb_of_item_allowed'][0] : '';
334 334
 		$input_def['possible_value'] = 'yes';
335
-		$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[total_nb_of_item_allowed]') . '<a href="#" title="'.__('Check this box if you want to allow the user to add only one product into cart','wpshop').'" class="wpshop_infobulle_marker">?</a>';
335
+		$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[total_nb_of_item_allowed]') . '<a href="#" title="' . __('Check this box if you want to allow the user to add only one product into cart', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
336 336
 
337 337
 		echo $output;
338 338
 	}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		$input_def['id'] = 'wpshop_cart_option_nb_of_same_item_allowed';
346 346
 		$input_def['type'] = 'text';
347 347
 		$input_def['value'] = $cart_option['total_nb_of_same_item_allowed'][0];
348
-		$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[total_nb_of_same_item_allowed]') . '<a href="#" title="'.__('Empty for no restriction','wpshop').'" class="wpshop_infobulle_marker">?</a>';
348
+		$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[total_nb_of_same_item_allowed]') . '<a href="#" title="' . __('Empty for no restriction', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
349 349
 
350 350
 		echo $output;
351 351
 	}
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 		$input_def['options_label']['container'] = true;
365 365
 		$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[product_added_to_cart]');
366 366
 
367
-		$hide = ( (!empty($cart_option) && !empty($cart_option['product_added_to_cart'][0]) && $cart_option['product_added_to_cart'][0] == 'cart_page') ? 'wpshopHide' : null);
368
-		$output .= '<div id="wpshop_cart_option_animation_cart_type" class="' .$hide. '"><label for="wpshop_cart_option[animation_cart_type]">' .__('Cart animation type', 'wpshop'). '</label>';
367
+		$hide = ((!empty($cart_option) && !empty($cart_option['product_added_to_cart'][0]) && $cart_option['product_added_to_cart'][0] == 'cart_page') ? 'wpshopHide' : null);
368
+		$output .= '<div id="wpshop_cart_option_animation_cart_type" class="' . $hide . '"><label for="wpshop_cart_option[animation_cart_type]">' . __('Cart animation type', 'wpshop') . '</label>';
369 369
 		$output .= '<select name="wpshop_cart_option[animation_cart_type]" id="wpshop_cart_option[animation_cart_type]">';
370
-		$output .= '<option value="pop-in" ' .( ( !empty($cart_option['animation_cart_type']) && $cart_option['animation_cart_type'] == 'pop-in') ? 'selected="selected"' : null). '>' .__('Dialog box', 'wpshop'). '</option>';
371
-		$output .= '<option value="animation" ' .( ( !empty($cart_option['animation_cart_type']) && $cart_option['animation_cart_type'] == 'animation') ? 'selected="selected"' : null). '>' .__('Image animation', 'wpshop'). '</option>';
370
+		$output .= '<option value="pop-in" ' . ((!empty($cart_option['animation_cart_type']) && $cart_option['animation_cart_type'] == 'pop-in') ? 'selected="selected"' : null) . '>' . __('Dialog box', 'wpshop') . '</option>';
371
+		$output .= '<option value="animation" ' . ((!empty($cart_option['animation_cart_type']) && $cart_option['animation_cart_type'] == 'animation') ? 'selected="selected"' : null) . '>' . __('Image animation', 'wpshop') . '</option>';
372 372
 		$output .= '</select></div>';
373 373
 
374 374
 		echo $output;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 		$input_def['id'] = 'wpshop_cart_option_action_after_product_added_to_quotation';
387 387
 		$input_def['type'] = 'radio';
388 388
 		$input_def['valueToPut'] = 'index';
389
-		$input_def['value'] = ( !empty($cart_option['product_added_to_quotation']) ? $cart_option['product_added_to_quotation'] : null );
389
+		$input_def['value'] = (!empty($cart_option['product_added_to_quotation']) ? $cart_option['product_added_to_quotation'] : null);
390 390
 		$input_def['possible_value'] = array('dialog_msg' => __('Display the dialog allowing to choose between continue shopping or go to cart', 'wpshop'), 'cart_page' => __('Automaticaly send user to cart page', 'wpshop'));
391 391
 		$input_def['options_label']['original'] = true;
392 392
 		$input_def['options_label']['container'] = true;
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 
395 395
 		echo $output;
396 396
 	}
397
-	public static function wpshop_options_validate_cart( $input ) {
397
+	public static function wpshop_options_validate_cart($input) {
398 398
 
399
-		if ( empty( $input ) || empty( $input[ 'display_newsletter' ] ) || empty( $input[ 'display_newsletter' ][ 'partner_subscription' ] ) ) {
400
-			$input[ 'display_newsletter' ][ 'partner_subscription' ] = 'no';
399
+		if (empty($input) || empty($input['display_newsletter']) || empty($input['display_newsletter']['partner_subscription'])) {
400
+			$input['display_newsletter']['partner_subscription'] = 'no';
401 401
 		}
402 402
 
403
-		if ( empty( $input ) || empty( $input[ 'display_newsletter' ] ) || empty( $input[ 'display_newsletter' ][ 'site_subscription' ] ) ) {
404
-			$input[ 'display_newsletter' ][ 'site_subscription' ] = 'no';
403
+		if (empty($input) || empty($input['display_newsletter']) || empty($input['display_newsletter']['site_subscription'])) {
404
+			$input['display_newsletter']['site_subscription'] = 'no';
405 405
 		}
406 406
 
407 407
 		return $input;
Please login to merge, or discard this patch.
includes/librairies/options/options_addons.class.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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,12 +20,12 @@  discard block
 block discarded – undo
20 20
 * @package wpshop
21 21
 * @subpackage librairies
22 22
 */
23
-class wpshop_addons_settings{
23
+class wpshop_addons_settings {
24 24
 
25 25
 	/**
26 26
 	 * Déclaration des différentes options
27 27
 	 */
28
-	function declare_options(){
28
+	function declare_options() {
29 29
 // 		add_settings_section('wpshop_addons_options', __('Wpshop "addons"', 'wpshop'), array('wpshop_advanced_settings', 'plugin_section_text'), 'wpshop_addons_options');
30 30
 // 		register_setting('wpshop_options', 'wpshop_addons_options', array('wpshop_addons_settings', 'validate_options'));
31 31
 // 		add_settings_field('wpshop_addons_settings_field', '', array('wpshop_addons_settings', 'addons_definition_fields'), 'wpshop_addons_options', 'wpshop_addons_options');
@@ -42,33 +42,33 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param unknown_type $input
44 44
 	 */
45
-	public static function validate_options($input){
45
+	public static function validate_options($input) {
46 46
 
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * Définition des champs pour l'activation des addons
51 51
 	 */
52
-	function addons_definition_fields () {
52
+	function addons_definition_fields() {
53 53
 		$content = '';
54 54
 
55
-		$content .= '<input type="hidden" name="wpshop_ajax_addons_nonce" id="wpshop_ajax_addons_nonce" value="'.wp_create_nonce('wpshop_ajax_activate_addons').'" />';
55
+		$content .= '<input type="hidden" name="wpshop_ajax_addons_nonce" id="wpshop_ajax_addons_nonce" value="' . wp_create_nonce('wpshop_ajax_activate_addons') . '" />';
56 56
 
57 57
 		$addons_options = get_option('wpshop_addons', array());
58 58
 		$addons_list = unserialize(WPSHOP_ADDONS_LIST);
59 59
 		foreach ($addons_list as $addon => $addon_def) {
60 60
 			$activated_status = false;
61
-			if ( array_key_exists($addon, $addons_options) && ( $addons_options[$addon]['activate'] )) {
61
+			if (array_key_exists($addon, $addons_options) && ($addons_options[$addon]['activate'])) {
62 62
 				$activated_status = true;
63 63
 			}
64
-			$activated_string = $activated_status ? __('Activated','wpshop') : __('Desactivated','wpshop');
64
+			$activated_string = $activated_status ? __('Activated', 'wpshop') : __('Desactivated', 'wpshop');
65 65
 			$activated_class = unserialize(WPSHOP_ADDONS_STATES_CLASS);
66
-			$content .=  '<strong>' . __($addon_def[0], 'wpshop') . '</strong>: <span class="'.$activated_class[$activated_status].'" id="addon_'.$addon.'_state" >'.$activated_string.'</span>';
66
+			$content .= '<strong>' . __($addon_def[0], 'wpshop') . '</strong>: <span class="' . $activated_class[$activated_status] . '" id="addon_' . $addon . '_state" >' . $activated_string . '</span>';
67 67
 			if (!$activated_status) {
68
-				$content .=  ' <input type="text" name="'.$addon.'" id="'.$addon.'" value="" /> <input type="button" name="'.$addon.'_button" id="'.$addon.'_button" class="addons_activating_button button-primary" value="'.__('Activate this addon','wpshop').'" />';
68
+				$content .= ' <input type="text" name="' . $addon . '" id="' . $addon . '" value="" /> <input type="button" name="' . $addon . '_button" id="' . $addon . '_button" class="addons_activating_button button-primary" value="' . __('Activate this addon', 'wpshop') . '" />';
69 69
 			}
70 70
 			else {
71
-				$content .= ' <input type="button" name="'.$addon.'_button" id="'.$addon.'_button" class="addons_desactivating_button button-secondary" value="'.__('Desactivate this addon','wpshop').'" />';
71
+				$content .= ' <input type="button" name="' . $addon . '_button" id="' . $addon . '_button" class="addons_desactivating_button button-secondary" value="' . __('Desactivate this addon', 'wpshop') . '" />';
72 72
 			}
73 73
 			$content .= '<br/>';
74 74
 		}
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 ?>
3 5
 <span class="wps-mini-cart-body-title">
4 6
 <strong><?php echo $total_cart_item; ?></strong><?php _e( 'item(s)', 'wpshop'); ?><span><strong><?php echo number_format( $total_cart, 2, '.', ''); ?></strong><?php echo $currency; ?></span>
@@ -12,8 +14,7 @@  discard block
 block discarded – undo
12 14
 				$parent_post = $parent_def['parent_post'];
13 15
 				$item_id = $parent_post->ID;
14 16
 				$item_title =  $parent_post->post_title;
15
-			}
16
-			else {
17
+			} else {
17 18
 				$item_title = $item['item_name'];
18 19
 			}
19 20
 			?>
Please login to merge, or discard this patch.