cancel
Showing results for 
Search instead for 
Did you mean: 

Need a cart rule extension that doesnt touch custom options!

SOLVED

Need a cart rule extension that doesnt touch custom options!

Hi there.. does anyone know of a shopping cart rule extenstion that leaves the price for custom options untouched?

 

At the moment if I apply a 10% off to an item in the checkout its also taking 10% of any custom options applied... these custom options have a fixed price for us and I need it to stay that way!

 

I need a cart rule that can take 10% off the product ONLY .. and leave the price for the custom options untouched!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Need a cart rule extension that doesnt touch custom options!

Hello @matt_ayres ,

You can do it by yourself by a little bit of customization.

Magento\SalesRule\Model\Validator::getItemPrice($item) is responsible for returning the item price on which the discount is applied.

You can override this function or create a beforePlugin for this function. Please apply the check as 

 

 /**
     * Return item price
     *
     * @param AbstractItem $item
     * @return float
     */
    public function getItemPrice($item)
    {
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $product = $_objectManager->get('\Magento\Catalog\Model\Product')->load($item->getProductId());
        $options = $product->getTypeInstance()->hasOptions($product);
        if ($options == 1)
            return $item->getOriginalPrice();
        
        $price = $item->getDiscountCalculationPrice();
        $calcPrice = $item->getCalculationPrice();
        return $price === null ? $calcPrice : $price;
    }

Now it check if your item has custom options then it return the original price of product or else it works as it was working before.

 

Note:

  1. Please create custom module for either creating plugin or overriding this function.
  2. Don't use object manager, inject it in your constructor.

I hope this works for you.

If it helps you, please give kudos and accept it as solution.

Regards.

View solution in original post

7 REPLIES 7

Re: Need a cart rule extension that doesnt touch custom options!

Hi @matt_ayres,

You can try the following extension.

It has very advanced features.

https://amasty.com/special-promotions-for-magento-2.html

You can check the demo first of this extension before buying it.

I hope it will help you!

Re: Need a cart rule extension that doesnt touch custom options!

Nope... just tried the demo and unfortunately there is no way to exclude the price of the custom options with any discount rules

Re: Need a cart rule extension that doesnt touch custom options!

Hi @matt_ayres,

Did you tried "Check special custom option value"= Yes

Under General tab extension configuration.

For more info:

https://amasty.com/docs/doku.php?id=magento_2%3Aspecial-promotions&utm_source=extension&utm_medium=l...

Re: Need a cart rule extension that doesnt touch custom options!

Yes Vimal.. I can see that option and it does present itself on the cart rule page... But it does not help me in my quest to... APPLY the discount to the PRODUCT, and NOT the product PLUS the custom options.

 

eg:

 

TEST_PRODUCT = £100

Custom Option I select for the product = £10

 

I want my rule to just discount 10% from the PRODUCT

 

I want the price to be £90 (100 - 10%)

 

Instead I get £99 (100 - 10%)

 

So frustrating!

Re: Need a cart rule extension that doesnt touch custom options!

Hello @matt_ayres ,

You can do it by yourself by a little bit of customization.

Magento\SalesRule\Model\Validator::getItemPrice($item) is responsible for returning the item price on which the discount is applied.

You can override this function or create a beforePlugin for this function. Please apply the check as 

 

 /**
     * Return item price
     *
     * @param AbstractItem $item
     * @return float
     */
    public function getItemPrice($item)
    {
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $product = $_objectManager->get('\Magento\Catalog\Model\Product')->load($item->getProductId());
        $options = $product->getTypeInstance()->hasOptions($product);
        if ($options == 1)
            return $item->getOriginalPrice();
        
        $price = $item->getDiscountCalculationPrice();
        $calcPrice = $item->getCalculationPrice();
        return $price === null ? $calcPrice : $price;
    }

Now it check if your item has custom options then it return the original price of product or else it works as it was working before.

 

Note:

  1. Please create custom module for either creating plugin or overriding this function.
  2. Don't use object manager, inject it in your constructor.

I hope this works for you.

If it helps you, please give kudos and accept it as solution.

Regards.

Re: Need a cart rule extension that doesnt touch custom options!

Thanks I will try it

Re: Need a cart rule extension that doesnt touch custom options!

It's not working when product has special price