cancel
Showing results for 
Search instead for 
Did you mean: 

Applying A Negative Value Cart Rule (Apply price increase rather than discount)

Highlighted

Applying A Negative Value Cart Rule (Apply price increase rather than discount)

I'm trying to be able to apply a negative value as a catalog price rule, so as to increase the price of a product rather than decrease it.

 

I've followed the steps from the answer listed here https://magento.stackexchange.com/questions/306382/negative-cart-price-rules-magento2, but it doesn't seem to have an effect, there's still some front-end validation happening that prevents you from saving the rule.

 

Any suggestions on how to get this functionality working?

5 REPLIES 5
Highlighted

Re: Applying A Negative Value Cart Rule (Apply price increase rather than discount)

@codestr 

 

The cart price rules are used to discount some amount, there is no approach so far to make any product price higher than the original product price from cart-price rule.

And logically this is incorrect to apply cart rule to make any product price higher, you can set amount of origin product which you wanted to make higher after cart rule and later you can add cart-price rule to make it for Sale on some discount.

 

Check this documentation for more details :

https://docs.magento.com/user-guide/marketing/price-rules-cart.html

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !
Highlighted

Re: Applying A Negative Value Cart Rule (Apply price increase rather than discount)

I just tried on my end by commenting line 143-145 in `Magento/Rule/Model/AbstractModel` and it worked. 

 

/*if ((int)$this->getDiscountAmount() < 0) {
throw new \Magento\Framework\Exception\LocalizedException(__('Please choose a valid discount amount.'));
}*/

Try it to see if it works on your end. If it works then make sure you override this beforeSave(), since it is a core file.

If it doesn't works then try to find if this method is already overridden somewhere in your code. I didn't found any JS validation for this in default Magento setup.

 

Hope if helps.

Thanks

Highlighted

Re: Applying A Negative Value Cart Rule (Apply price increase rather than discount)

@abdulpathan 

 

From this way we can make it working to save cart price rule, but at many places we compare the price of item with original price and then we are processing, your code will impact all other areas of checkout and sale.

 

Screenshot 2020-06-27 at 1.19.15 PM.png

 

The above function I found which is checking the price should be less than original price and this function was later used to create invoice.

 


@abdulpathan wrote:

I just tried on my end by commenting line 143-145 in `Magento/Rule/Model/AbstractModel` and it worked. 

 

/*if ((int)$this->getDiscountAmount() < 0) {
throw new \Magento\Framework\Exception\LocalizedException(__('Please choose a valid discount amount.'));
}*/

Try it to see if it works on your end. If it works then make sure you override this beforeSave(), since it is a core file.

If it doesn't works then try to find if this method is already overridden somewhere in your code. I didn't found any JS validation for this in default Magento setup.

 

Hope if helps.

Thanks




Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !
Highlighted

Re: Applying A Negative Value Cart Rule (Apply price increase rather than discount)

Hi @gaurav_harsh1 ,

Thanks for putting your view on it, I can understand your concern since this is not an standard approach to do so. But I tried on my end and I was able to create order, invoice , shipment and credit memo successfully with negative discount price and without any issue. I might be missing some scenarios. Also the screenshot you added is not visible for me so I was not able to verify the code which you were concerned about. Please see if you can add a screenshot so that I can verify from my end as well.

 

Thanks a lot.

Smiley Happy

 

Highlighted

Re: Applying A Negative Value Cart Rule (Apply price increase rather than discount)

Hi @abdulpathan ,

 

Thanks for understanding Smiley Happy

The file is 

Vertex\Tax\Model\Api\Utility\PriceForTax.php

and the function name is getPriceForTaxCalculationFromOrderItem(), I have worked on Magento RMA extension where also I found this condition as well.

 

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !