Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CartView cartDiscounts doesn't show ORDER_ITEM_PROMOTION_ADJUSTMENT, ORDER_UNIT_PROMOTION_ADJUSTMENT discounts #689

Open
diimpp opened this issue Nov 23, 2020 · 0 comments

Comments

@diimpp
Copy link
Member

diimpp commented Nov 23, 2020

When using promotion with Item percentage discount or Item fixed discount actions, then adjustments are applied on AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT (or ORDER_UNIT_PROMOTION_ADJUSTMENT, didn't check) level.

In such case CartView

    "cartDiscounts": []

is empty, while totals->promotion is correctly filled.
(Do ignore non-standard output, this is artifact of my project)

    "totals": {
        "total": {
            "current": 12000,
            "currency": "EUR"
        },
        "items": {
            "current": 12000,
            "currency": "EUR"
        },
        "taxes": {
            "current": 2000,
            "currency": "EUR"
        },
        "shipping": {
            "current": 0,
            "currency": "EUR"
        },
        "promotion": {
            "current": -6100,
            "currency": "EUR"
        }
    },

Problem is with mismatch between adjustments levels for those properties.
Totals->promotion uses

$totalsView->promotion = $cart->getOrderPromotionTotal();

which works by all three adjustment levels

     /** 
      * Returns amount of order discount. Does not include shipping discounts.
      */ 
     public function getOrderPromotionTotal(): int
     {
         return
             $this->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT) +
             $this->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT) +
             $this->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)
         ;
     }

and cartDiscounts only checks for order level

foreach ($cart->getAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT) as $adjustment) {

I'm going to fix this in my project and see how it will go, but so far it looks like an error, rather than design decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants