@@ -86,10 +86,13 @@ public function addOrder($data) {
86
86
$ this ->db ->query ("INSERT INTO " . DB_PREFIX . "order_product SET order_id = ' " . (int )$ order_id . "', product_id = ' " . (int )$ order_product ['product_id ' ] . "', name = ' " . $ this ->db ->escape ($ order_product ['name ' ]) . "', model = ' " . $ this ->db ->escape ($ order_product ['model ' ]) . "', quantity = ' " . (int )$ order_product ['quantity ' ] . "', price = ' " . (float )$ order_product ['price ' ] . "', total = ' " . (float )$ order_product ['total ' ] . "', tax = ' " . (float )$ order_product ['tax ' ] . "', reward = ' " . (int )$ order_product ['reward ' ] . "' " );
87
87
88
88
$ order_product_id = $ this ->db ->getLastId ();
89
+
90
+ $ this ->db ->query ("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int )$ order_product ['quantity ' ] . ") WHERE product_id = ' " . (int )$ order_product ['product_id ' ] . "' AND subtract = '1' " );
89
91
90
92
if (isset ($ order_product ['order_option ' ])) {
91
93
foreach ($ order_product ['order_option ' ] as $ order_option ) {
92
94
$ this ->db ->query ("INSERT INTO " . DB_PREFIX . "order_option SET order_id = ' " . (int )$ order_id . "', order_product_id = ' " . (int )$ order_product_id . "', product_option_id = ' " . (int )$ order_option ['product_option_id ' ] . "', product_option_value_id = ' " . (int )$ order_option ['product_option_value_id ' ] . "', name = ' " . $ this ->db ->escape ($ order_option ['name ' ]) . "', `value` = ' " . $ this ->db ->escape ($ order_option ['value ' ]) . "', `type` = ' " . $ this ->db ->escape ($ order_option ['type ' ]) . "' " );
95
+ $ this ->db ->query ("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int )$ order_product ['quantity ' ] . ") WHERE product_option_value_id = ' " . (int )$ order_option ['product_option_value_id ' ] . "' AND subtract = '1' " );
93
96
}
94
97
}
95
98
@@ -179,7 +182,23 @@ public function editOrder($order_id, $data) {
179
182
} else {
180
183
$ payment_zone = '' ;
181
184
}
182
-
185
+
186
+ $ order_query = $ this ->db ->query ("SELECT * FROM ` " . DB_PREFIX . "order` WHERE order_status_id > '0' AND order_id = ' " . (int )$ order_id . "' " );
187
+
188
+ if ($ order_query ->num_rows ) {
189
+ $ product_query = $ this ->db ->query ("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = ' " . (int )$ order_id . "' " );
190
+
191
+ foreach ($ product_query ->rows as $ product ) {
192
+ $ this ->db ->query ("UPDATE ` " . DB_PREFIX . "product` SET quantity = (quantity + " . (int )$ product ['quantity ' ] . ") WHERE product_id = ' " . (int )$ product ['product_id ' ] . "' AND subtract = '1' " );
193
+
194
+ $ option_query = $ this ->db ->query ("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = ' " . (int )$ order_id . "' AND order_product_id = ' " . (int )$ product ['order_product_id ' ] . "' " );
195
+
196
+ foreach ($ option_query ->rows as $ option ) {
197
+ $ this ->db ->query ("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity + " . (int )$ product ['quantity ' ] . ") WHERE product_option_value_id = ' " . (int )$ option ['product_option_value_id ' ] . "' AND subtract = '1' " );
198
+ }
199
+ }
200
+ }
201
+
183
202
$ this ->db ->query ("UPDATE ` " . DB_PREFIX . "order` SET firstname = ' " . $ this ->db ->escape ($ data ['firstname ' ]) . "', lastname = ' " . $ this ->db ->escape ($ data ['lastname ' ]) . "', email = ' " . $ this ->db ->escape ($ data ['email ' ]) . "', telephone = ' " . $ this ->db ->escape ($ data ['telephone ' ]) . "', fax = ' " . $ this ->db ->escape ($ data ['fax ' ]) . "', payment_firstname = ' " . $ this ->db ->escape ($ data ['payment_firstname ' ]) . "', payment_lastname = ' " . $ this ->db ->escape ($ data ['payment_lastname ' ]) . "', payment_company = ' " . $ this ->db ->escape ($ data ['payment_company ' ]) . "', payment_company_id = ' " . $ this ->db ->escape ($ data ['payment_company_id ' ]) . "', payment_tax_id = ' " . $ this ->db ->escape ($ data ['payment_tax_id ' ]) . "', payment_address_1 = ' " . $ this ->db ->escape ($ data ['payment_address_1 ' ]) . "', payment_address_2 = ' " . $ this ->db ->escape ($ data ['payment_address_2 ' ]) . "', payment_city = ' " . $ this ->db ->escape ($ data ['payment_city ' ]) . "', payment_postcode = ' " . $ this ->db ->escape ($ data ['payment_postcode ' ]) . "', payment_country = ' " . $ this ->db ->escape ($ payment_country ) . "', payment_country_id = ' " . (int )$ data ['payment_country_id ' ] . "', payment_zone = ' " . $ this ->db ->escape ($ payment_zone ) . "', payment_zone_id = ' " . (int )$ data ['payment_zone_id ' ] . "', payment_address_format = ' " . $ this ->db ->escape ($ payment_address_format ) . "', payment_method = ' " . $ this ->db ->escape ($ data ['payment_method ' ]) . "', payment_code = ' " . $ this ->db ->escape ($ data ['payment_code ' ]) . "', shipping_firstname = ' " . $ this ->db ->escape ($ data ['shipping_firstname ' ]) . "', shipping_lastname = ' " . $ this ->db ->escape ($ data ['shipping_lastname ' ]) . "', shipping_company = ' " . $ this ->db ->escape ($ data ['shipping_company ' ]) . "', shipping_address_1 = ' " . $ this ->db ->escape ($ data ['shipping_address_1 ' ]) . "', shipping_address_2 = ' " . $ this ->db ->escape ($ data ['shipping_address_2 ' ]) . "', shipping_city = ' " . $ this ->db ->escape ($ data ['shipping_city ' ]) . "', shipping_postcode = ' " . $ this ->db ->escape ($ data ['shipping_postcode ' ]) . "', shipping_country = ' " . $ this ->db ->escape ($ shipping_country ) . "', shipping_country_id = ' " . (int )$ data ['shipping_country_id ' ] . "', shipping_zone = ' " . $ this ->db ->escape ($ shipping_zone ) . "', shipping_zone_id = ' " . (int )$ data ['shipping_zone_id ' ] . "', shipping_address_format = ' " . $ this ->db ->escape ($ shipping_address_format ) . "', shipping_method = ' " . $ this ->db ->escape ($ data ['shipping_method ' ]) . "', shipping_code = ' " . $ this ->db ->escape ($ data ['shipping_code ' ]) . "', comment = ' " . $ this ->db ->escape ($ data ['comment ' ]) . "', order_status_id = ' " . (int )$ data ['order_status_id ' ] . "', affiliate_id = ' " . (int )$ data ['affiliate_id ' ] . "', date_modified = NOW() WHERE order_id = ' " . (int )$ order_id . "' " );
184
203
185
204
$ this ->db ->query ("DELETE FROM " . DB_PREFIX . "order_product WHERE order_id = ' " . (int )$ order_id . "' " );
@@ -191,10 +210,13 @@ public function editOrder($order_id, $data) {
191
210
$ this ->db ->query ("INSERT INTO " . DB_PREFIX . "order_product SET order_product_id = ' " . (int )$ order_product ['order_product_id ' ] . "', order_id = ' " . (int )$ order_id . "', product_id = ' " . (int )$ order_product ['product_id ' ] . "', name = ' " . $ this ->db ->escape ($ order_product ['name ' ]) . "', model = ' " . $ this ->db ->escape ($ order_product ['model ' ]) . "', quantity = ' " . (int )$ order_product ['quantity ' ] . "', price = ' " . (float )$ order_product ['price ' ] . "', total = ' " . (float )$ order_product ['total ' ] . "', tax = ' " . (float )$ order_product ['tax ' ] . "', reward = ' " . (int )$ order_product ['reward ' ] . "' " );
192
211
193
212
$ order_product_id = $ this ->db ->getLastId ();
213
+
214
+ $ this ->db ->query ("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int )$ order_product ['quantity ' ] . ") WHERE product_id = ' " . (int )$ order_product ['product_id ' ] . "' AND subtract = '1' " );
194
215
195
216
if (isset ($ order_product ['order_option ' ])) {
196
217
foreach ($ order_product ['order_option ' ] as $ order_option ) {
197
218
$ this ->db ->query ("INSERT INTO " . DB_PREFIX . "order_option SET order_option_id = ' " . (int )$ order_option ['order_option_id ' ] . "', order_id = ' " . (int )$ order_id . "', order_product_id = ' " . (int )$ order_product_id . "', product_option_id = ' " . (int )$ order_option ['product_option_id ' ] . "', product_option_value_id = ' " . (int )$ order_option ['product_option_value_id ' ] . "', name = ' " . $ this ->db ->escape ($ order_option ['name ' ]) . "', `value` = ' " . $ this ->db ->escape ($ order_option ['value ' ]) . "', `type` = ' " . $ this ->db ->escape ($ order_option ['type ' ]) . "' " );
219
+ $ this ->db ->query ("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int )$ order_product ['quantity ' ] . ") WHERE product_option_value_id = ' " . (int )$ order_option ['product_option_value_id ' ] . "' AND subtract = '1' " );
198
220
}
199
221
}
200
222
0 commit comments