添加订单和产品hook

This commit is contained in:
Edward Yang 2023-02-07 09:51:01 +08:00
parent 6eeeea11cc
commit 65c65a11fb
5 changed files with 9 additions and 5 deletions

View File

@ -69,7 +69,7 @@ class OrderController extends Controller
public function show(Request $request, Order $order)
{
$order->load(['orderTotals', 'orderHistories', 'orderShipments']);
$data = hook_filter('admin_order_detail', ['order' => $order, 'html_items' => []]);
$data = hook_filter('admin.order.show.data', ['order' => $order, 'html_items' => []]);
$data['statuses'] = StateMachineService::getInstance($order)->nextBackendStatuses();
return view('admin::pages.orders.form', $data);

View File

@ -40,6 +40,8 @@ class ProductRepo
}
$product->load('description', 'skus', 'masterSku', 'brand', 'relations');
hook_filter('repo.product.get_detail', $product);
return $product;
}

View File

@ -52,9 +52,9 @@ class OrderController extends Controller
{
$customer = current_customer();
$order = OrderRepo::getOrderByNumber($number, $customer);
$html = hook_filter('account_order_detail', ['order' => $order, 'html_items' => []]);
$data = hook_filter('account.order.show.data', ['order' => $order, 'html_items' => []]);
return view('account/order_info', $html);
return view('account/order_info', $data);
}
/**

View File

@ -25,7 +25,8 @@ class ProductController extends Controller
'product' => (new ProductDetail($product))->jsonSerialize(),
'relations' => ProductRepo::getProductsByIds($relationIds)->jsonSerialize(),
];
$data = hook_filter('product.show', $data);
$data = hook_filter('product.show.data', $data);
return view('product', $data);
}

View File

@ -111,11 +111,12 @@ class CheckoutService
try {
DB::beginTransaction();
$order = OrderRepo::create($checkoutData);
StateMachineService::getInstance($order)->changeStatus(StateMachineService::UNPAID, '', true);
CartRepo::clearSelectedCartProducts($customer);
hook_action('checkout.order.confirm.after', ['order' => $order, 'cart' => $this->cart]);
hook_action('service.checkout.confirm.after', ['order' => $order, 'cart' => $this->cart]);
DB::commit();
} catch (\Exception $e) {