VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: hazael on August 29, 2023, 10:17:41 AM

Title: discount inheritance - bug
Post by: hazael on August 29, 2023, 10:17:41 AM
If I set a discount (15%) for one product in the cart, this discount is also transferred to the price for products added to the cart in a quantity greater than 1.
If I give a discount for more than 1 products, these discounts are not counted at all

This is a bug - this cart counts everything wrong for me.
The problem is not related to the PHP function, because the result is correct. This is the fault of badly written Javascript from the frontend

This is the only important thing that has never worked well in this component.
Title: Re: discount inheritance - bug
Post by: hazael on August 29, 2023, 11:02:27 AM
Now I know what causes the bug with these prices. The problem is the Virtuemart - Multi Variant plugin. If this plugin is in the field with the add to cart button, the script does not refresh the prices correctly

I made an example in this video:

https://piekielko.com/images/prices.mp4

6621 zł - this is the wrong price after page load. This is the price for a single product in the cart.
By default, the price for 2 products in the cart should be loaded: 6290 zł

if i press the minus button then the correct price will appear. If the product does not use the "Multi Variant" custom field, this problem does not occur

I want to correct it after page reload. Which javascript is responsible for refreshing these prices in the cart?
Title: Re: discount inheritance - bug
Post by: hazael on August 29, 2023, 11:29:09 AM
my simple solution - Automatic click on the quantity-minus button - and after the problem  :)

Quote<button aria-label="minus" id="rem" type="button" class="quantity-controls cc btn btn-default">
               <span class="fa fa-minus"></span>
            </button>

Quote<stript>
window.onload = function(){
  document.getElementById('rem').click();
}</script>
Title: Re: discount inheritance - bug
Post by: Milbo on September 05, 2023, 19:15:29 PM
The discount is per variant. Any variant is an own product. If you want to combine them, you need a more advanced tool https://extensions.virtuemart.net/quantity-related-price-calculation-detail
Title: Re: discount inheritance - bug
Post by: hazael on September 05, 2023, 23:24:58 PM
Good to know - I'll check it out.
I also care about the quick export of such prices. Does this plugin work with the RO CSVI component?