1

I am a beginner with Magento 2 and need some help with creating a new rule for cart price rules. The rule should check if any discount or previously set cart price rule was already applied to the cart items and if it was, next rule should be excluded (not applied to the cart).

1

You can check this using below code.

public function __construct(
        ...
        \Magento\Checkout\Model\Session $session
        ...
    ) {
        ...
        $this->session = $session;
        ...
    }

public function yourFunction()
{
    if($this->session->getQuote()->getAppliedRuleIds()) {
       echo "rule applied";
    } else {
       echo " no rule applied"
    }
}

let me know if you need further help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.