| @@ -281,8 +281,29 @@ | ||
| 281 | 281 | ]; |
| 282 | 282 | |
| 283 | 283 | $totalAmount = $orderData['subtotal'] - $orderData['coupon_discount_total'] - $orderData['manual_discount_total'] + $orderData['shipping_total'] + $orderData['tax_total']; |
| 284 | 284 | $orderData['total_amount'] = $totalAmount > 0 ? $totalAmount : 0; |
| 285 | + | |
| 286 | + /** | |
| 287 | + * Filter the prepared order data before it is used for order creation. | |
| 288 | + * | |
| 289 | + * This mirrors the frontend checkout hook so integrations can adjust | |
| 290 | + * order payload fields consistently for manual admin orders too. | |
| 291 | + * | |
| 292 | + * @param array $orderData Prepared order data array. | |
| 293 | + * @param array $context { | |
| 294 | + * Additional context for the filter. | |
| 295 | + * | |
| 296 | + * @type array $items Formatted order items with prices and quantities. | |
| 297 | + * @type array $args Admin order arguments: customer data, payment | |
| 298 | + * method, shipping, tax, notes, and IP data. | |
| 299 | + * } | |
| 300 | + */ | |
| 301 | + $orderData = apply_filters('fluent_cart/checkout/order_data', $orderData, [ | |
| 302 | + 'items' => $this->formattedIOrderItems, | |
| 303 | + 'args' => $this->args, | |
| 304 | + ]); | |
| 305 | + | |
| 285 | 306 | $this->orderData = $orderData; |
| 286 | 307 | } |
| 287 | 308 | |
| 288 | 309 | |