Magento 2 - 我应该观察什么事件 change/intercept 计算购物车上的小计

Magento 2 - what event should I observe to change/intercept the calculation of subtotals on Cart

我正在使用 Magento 2。 我制作了一个观察器,可以在任何时候将新商品添加到购物车中进行观察。观察者正常工作,我也成功地用这个观察者创建了一个单品折扣,这里是events.xml文件:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_cart_product_add_after">
    <observer name="PerfectStorm_Pricecalculations_Addtocart" instance="PerfectStorm\Pricecalculations\Observer\PricecalculationsAfterAddtoCart" />
</event>

问题是,我想做同样的事情,以便更改和拦截购物车中每个项目的小计计算。但我不知道我应该观察什么事件。

能请教一下吗?

谢谢

你可以利用这个活动

sales_quote_load_after

或者你可以参考vendor/magento/module-sales-rule看看

vendor/magento/module-sales-rule/etc/sales.xml

vendor/magento/module-sales-rule/Model/Quote/Discount.php

查看 Magento 原生折扣如何运作

谢谢