|
13 | 13 | use Gw\AutoCustomerGroup\Model\AutoCustomerGroup as AutoCustomerGroupModel; |
14 | 14 |
|
15 | 15 | /** |
16 | | - * AutoCustomerGroup totals collector, configured from sales.xml which runs at the end of the stack |
17 | | - * of collectors. If the group has changed, then the tax collectors must be re-run as the tax to be |
18 | | - * applied will now be different. The collectors to be rerun can be configured in di.xml |
| 16 | + * Magento Vanilla Collectors sequence |
| 17 | + * |
| 18 | + * 100 Magento\Quote\Model\Quote\Address\Total\Subtotal |
| 19 | + * 200 Magento\Tax\Model\Sales\Total\Quote\Subtotal |
| 20 | + * 225 Magento\Weee\Model\Total\Quote\Weee |
| 21 | + * 300 Magento\SalesRule\Model\Quote\Discount |
| 22 | + * 325 <-- This is a good place for us to be. Product discounts already applied |
| 23 | + * 350 Magento\Quote\Model\Quote\Address\Total\Shipping |
| 24 | + * 375 Magento\Tax\Model\Sales\Total\Quote\Shipping |
| 25 | + * 400 Magento\SalesRule\Model\Quote\Address\Total\ShippingDiscount |
| 26 | + * 450 Magento\Tax\Model\Sales\Total\Quote\Tax |
| 27 | + * 460 Magento\Weee\Model\Total\Quote\WeeeTax |
| 28 | + * 550 Magento\Quote\Model\Quote\Address\Total\Grand |
| 29 | + * AutoCustomerGroup totals collector, configured from sales.xml |
| 30 | + * What happens if we switch groups to a group where discount no longer applies? Should we re-run |
| 31 | + * the discount collectors, what if that then changes the order total. We need to re-evaluate groups again. |
| 32 | + * For now, lets just re-run all collectors that came before us, and carry on |
19 | 33 | * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) |
20 | 34 | */ |
21 | 35 | class AutoCustomerGroup extends AbstractTotal |
@@ -227,9 +241,10 @@ private function updateGroup($newGroup, Quote $quote, $customer, $shippingAssign |
227 | 241 | ); |
228 | 242 | $quote->setCustomerGroupId($newGroup); |
229 | 243 |
|
230 | | - //The group has changed. We need to rerun the Tax collectors. |
231 | | - foreach ($this->additionalCollectors as $collector) { |
| 244 | + //The group has changed. Which collectors should we re-run |
| 245 | + foreach ($this->additionalCollectors as $code => $collector) { |
232 | 246 | if ($collector) { |
| 247 | + $collector->setCode($code); |
233 | 248 | $collector->collect($quote, $shippingAssignment, $total); |
234 | 249 | } |
235 | 250 | } |
|
0 commit comments