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?
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
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
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.
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.
@Abdul Pathan 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
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.
Hi @Abdul Pathan ,
Thanks for understanding
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.