| @@ -211,9 +211,12 @@ | ||
| 211 | 211 | ], 400); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
| 215 | - $requestData = $request->getSafe($request->sanitize()); | |
| 215 | + $requestData = array_intersect_key( | |
| 216 | + $request->getSafe($request->sanitize()), | |
| 217 | + $request->all() | |
| 218 | + ); | |
| 216 | 219 | |
| 217 | 220 | $totalPaid = Arr::get($request->all(), 'total_paid'); |
| 218 | 221 | $updatedTotal = Arr::get($requestData, 'total_amount'); |
| 219 | 222 | |
| @@ -234,9 +237,9 @@ | ||
| 234 | 237 | // if new shipping total is already adjusted in total amount, then no need to adjust again, right now not adjusted before |
| 235 | 238 | // ToDo: adjust changed shipping total in total amount prior to this |
| 236 | 239 | $shippingTotal = Arr::get($requestData, 'shipping_total', 0); |
| 237 | 240 | $oldShippingTotal = Arr::get($order, 'shipping_total', 0); |
| 238 | - if ($shippingTotal != $oldShippingTotal) { | |
| 241 | + if (array_key_exists('shipping_total', $requestData) && $shippingTotal != $oldShippingTotal) { | |
| 239 | 242 | $diff = $shippingTotal - $oldShippingTotal; |
| 240 | 243 | if ($diff < 0) { |
| 241 | 244 | $requestData['total_amount'] = $updatedTotal - abs($diff); |
| 242 | 245 | } else { |
| @@ -907,12 +910,8 @@ | ||
| 907 | 910 | ->where('order_id', $locked->id) |
| 908 | 911 | ->whereIn('status', Status::getTransactionSuccessStatuses()) |
| 909 | 912 | ->sum('total'); |
| 910 | 913 | |
| 911 | - $note = sanitize_text_field($request->get('mark_paid_note', '')); | |
| 912 | - if ($note) { | |
| 913 | - $locked->note = $note; | |
| 914 | - } | |
| 915 | 914 | $locked->save(); |
| 916 | 915 | |
| 917 | 916 | $db->commit(); |
| 918 | 917 | } catch (\Throwable $e) { |
| @@ -920,8 +919,18 @@ | ||
| 920 | 919 | throw $e; |
| 921 | 920 | } |
| 922 | 921 | |
| 923 | 922 | (new StatusHelper($locked))->syncOrderStatuses($transaction); |
| 923 | + | |
| 924 | + $paymentNote = sanitize_textarea_field($request->get('mark_paid_note', '')); | |
| 925 | + if ($paymentNote) { | |
| 926 | + $locked->addLog( | |
| 927 | + __('Payment note', 'fluent-cart'), | |
| 928 | + nl2br(esc_html($paymentNote)), | |
| 929 | + 'info', | |
| 930 | + wp_get_current_user()->display_name | |
| 931 | + ); | |
| 932 | + } | |
| 924 | 933 | |
| 925 | 934 | return $this->response->sendSuccess([ |
| 926 | 935 | 'message' => __('Order has been marked as paid', 'fluent-cart') |
| 927 | 936 | ]); |