| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace Longyi\ShippingInsurance\Providers;
- use Illuminate\Support\Facades\Event;
- use Illuminate\Support\ServiceProvider;
- use Longyi\Pay\Applepay\Events\CollectingAmountBreakdown;
- class EventServiceProvider extends ServiceProvider
- {
- /**
- * Bootstrap services.
- */
- public function boot(): void
- {
- // 运费险计算:监听购物车总计收集事件
- Event::listen('checkout.cart.collect.totals.after', 'Longyi\ShippingInsurance\Listeners\ShippingInsuranceHandler@applyShippingInsurance');
- // 购物车页面:在 tax 之后、grand total 之前显示运费险
- Event::listen('bagisto.shop.checkout.cart.summary.tax.after', function ($viewRenderEventManager) {
- $viewRenderEventManager->addTemplate('shippinginsurance::components.shipping-insurance-cartsummary');
- });
- // 结账页面:在 tax 之后、grand total 之前显示运费险
- Event::listen('bagisto.shop.checkout.onepage.summary.tax.after', function ($viewRenderEventManager) {
- $viewRenderEventManager->addTemplate('shippinginsurance::components.shipping-insurance-cartsummary');
- });
- // 后台订单详情:在 discount 之后、grand total 之前显示运费险金额
- // 参考礼品卡的 OrderViewHandler 方式:从路由获取订单后 echo 渲染组件
- Event::listen('bagisto.admin.sales.order.view.discount.after', 'Longyi\ShippingInsurance\Listeners\OrderViewHandler@renderShippingInsurance');
- // 前台会员中心订单详情:在 discount 之后、grand total 之前显示运费险金额
- Event::listen('bagisto.shop.customers.account.orders.view.information.discount.after', 'Longyi\ShippingInsurance\Listeners\OrderViewHandler@renderShippingInsurance');
- // 将运费险金额映射进 Apple Pay breakdown
- Event::listen(CollectingAmountBreakdown::class, 'Longyi\ShippingInsurance\Listeners\ApplepayBreakdownHandler@collect');
- }
- }
|