VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: nickwiebe on May 06, 2013, 17:36:51 PM

Title: Price Overrides
Post by: nickwiebe on May 06, 2013, 17:36:51 PM
I'm trying to use the price override function to move a product from the normal price of 1200 to sales price of 1000 and that part is working fine.  I my page you see the the discount of 200 when I set it up this way.  The problem I'm having is I have a custom field that if selected is supposed to add 180 to the price of the product and this works fine when I'm not using the override, but when I am using the override the 180 gets added to the discount rather than the price of the product when selected in the custom field.

How can I use a price override and have this custom field still add to the price rather than the discount?

I'm using Joomla 2.5 and the latest version of VM2.

thanks,

Nick
Title: Re: Price Overrides
Post by: jedzon on May 13, 2013, 10:02:07 AM
Have the same problem... Hope someone from VM team see this and give us some tricks to solve it... I think it's serious bug in VM. My VM version is 2.20
Title: Re: Price Overrides
Post by: nickwiebe on May 13, 2013, 20:51:56 PM
It's been a week since I posted this, is there anybody out there that can help with this?
Title: Re: Price Overrides
Post by: Milbo on May 14, 2013, 00:40:57 AM
So when you use the price override it is always overriden, regardless the variant?

Hmmm
Title: Re: Price Overrides
Post by: jedzon on May 14, 2013, 07:09:47 AM
Hi Milbo, Hi Nickwiebe,

We have probably similar problem with Nickwiebe (please confirm if it's true).
I tryed hundred of solutions and nothing working...

Please look at:
http://www.e-slubny.com.pl/index.php/component/virtuemart/suknie-slubne/suknie-slubne2013-03-12-09-13-24/elegancka-suknia-do-slubu-wykonana-z-organza-i-satyny-typ-sukni-to-linia-a-bez-ramiaczek-suknia-posiada-naturalna-talie-i-jest-warstwowa-detail?Itemid=0


when custom field is selected additional pric is added only to net price instead of price with VAT, what doeasnt make sens in my opinion.

Can you help me with this Milbo.

Nickwiebe, please confirm if we have similar problem.

Thank you in advance,
Karol
Title: Re: Price Overrides
Post by: nickwiebe on May 16, 2013, 18:50:18 PM
Yes Milbo,

I'm using a custom field where the field type is a cart variant and cart attribute is YES.  Normal price of the product is 1200, price override is set to 1000 so you see a discount of 200.  When you select the cart attribute, it is supposed to add 180 to the price for a price of 1180 but instead it adds the 180 to the discount so the discount is 380 and the final price is still 1000.

The override appears to force the price to stay at the set override amount.  Any way around this?

thanks,

Nick
Title: Re: Price Overrides
Post by: nickwiebe on May 16, 2013, 19:44:10 PM
Jedzon,

It does appear that we are having the same problem.

Nick
Title: Re: Price Overrides
Post by: nickwiebe on May 16, 2013, 19:49:13 PM
Here is the product that I'm having the trouble with.  I will only leave it up for the day since it is not working correctly.

https://pacificad.com/software/autodesk/autocadlt-detail

thanks,

Nick
Title: Re: Price Overrides
Post by: nickwiebe on May 21, 2013, 19:19:17 PM
Any news on this post?  I really need this to work properly.  Can anybody help with this problem?
Title: Re: Price Overrides
Post by: jedzon on May 22, 2013, 11:02:13 AM
Hi Nickwiebe,

I think, I have solution... After tree weeks.. I was try everything and...

Please open:
administrator/componensts/com_virtuemart/helpers/calculationh.php

find line similar to this: (around line 353)
$this->productPrices['salesPrice'] = $product_override_price

and change it to:
$this->productPrices['salesPrice'] = $product_override_price + $salesPrice - $costPrice*1.23 ;

(where 1.23 is tax in my country).

I found solution few minutes ago so I'm not sure if it's best one, but for me at the moment looks good :-)
Of course tax should be changed with variable, but for now it's just for testing...
Please, let me know if it working for you too. (I changed lot of code before I found this easiest soultion, so maybe some more changes you need to add - just let me know).
Hope this will work...

Regards,
Karol
Title: Re: Price Overrides
Post by: nickwiebe on May 24, 2013, 21:44:51 PM
Jezdon,

Thank you for sharing this.  I think you are on the right track.  I am trying to get the cart variant to be added into the product price rather than the tax...not sure what to use for code name, maybe something like this:

$this->productPrices['salesPrice'] = $product_override_price + $CartVariant ;

Do you think this would work?

thanks,

Nick

Title: Re: Price Overrides
Post by: jedzon on May 26, 2013, 09:10:02 AM
Hi,

I belive that is exacly what we are looking for. Please look at: http://e-slubny.com.pl/index.php/component/virtuemart/suknie-slubne/elegancka-suknia-do-slubu-wykonana-z-organza-i-satyny-typ-sukni-to-linia-a-bez-ramiaczek-suknia-posiada-naturalna-talie-i-jest-warstwowa-detail?Itemid=0

I can not find function coresponding for variant cost so I add few other variables which gave me same effect:

$product_override_price - this is price with discount
$salesPrice - this is price without the discount but with cart variant value
$costPrice - this is net price without cart variant value

For example:
Oryginal product is 2000
Discounted prodvuct value is: 1500
Additional fee: 50

$this->productPrices['salesPrice'] = $product_override_price + $salesPrice - $costPrice*1.23 ;

And we have: 1500 (discounted) + 2050 (price with additional fee) - 1626 (net price before discount and without additional fee) * 1.23 (this is tax in my country so I need to make price with tax) = 1550 (discounted price with additional fee)

If think you need same rules, but if you need price without tax you just should remove tax frome code.

Hopy you will understand what I'm mean becouse my english is not perfect :-)

Hope this will work for you too.
Please let me know.


Regards,
Karol
Title: Re: Price Overrides
Post by: nickwiebe on May 28, 2013, 20:21:05 PM
Karol,

Thank you so much for helping with this.  You solution has worked perfectly for me as long as I check "Overwrite Final" rather than "Overwrite Price to be Taxed" in the product pricing section of the product.  I'm using avalara for tax calculations, and for some reason it is apply tax to the total price rather than the discounted price, but I think I can work that out with them.

This has been such a big help, and your English is very good :)

thanks,

Nick
Title: Re: Price Overrides
Post by: woop on August 28, 2013, 13:09:56 PM
#### SOLVED!!!! ######
I had a similar problem. I´m using Joomla 2.5 + VM version 2.0.22b

My problem was that when a product has a discount + prices modifier (type DBTax) + personalized fields (for example an extra of 20€ if you want your product inside a really nice box) the discount also was afecting to the price of the choosed personalized fields.
So for example if the product costs 100€ and has a 10% discount + you choose the nice box for 20€ the calculation that is done is -> (100€ + 20€ ) - 10%
For me the correct calculation has to be (100€ - 10%) + 20€

I solved that doing some changes on administrator/components/com_virtuemart/helpers/calculationh.php
Hear by I attached my modified file so everyone can check the changes. Just look for the lines with "BY WOOP" due the changes are allways lines just below my comments

My comments are in Spanish but I hope that comparing the original file with my modification it´s easy to see the changes I´ve done :)

I hope that this will help others developers that might be facing the same sition I do & if Milbo thinks that this functionality it´s more logic than the one that it has now he could include it on the VM project (or at least create another calculation rule that works as the one I´ve modified for DBTax).

Wish everyone to have a great day!!

[attachment cleanup by admin]
Title: Re: Price Overrides
Post by: woop on September 01, 2013, 13:57:48 PM
just found a bug in my modificaction that was causing trouble with the calculation for those products without discount. I just solved it!!! :D
Attached the new modified file ;)


[attachment cleanup by admin]
Title: Re: Price Overrides
Post by: vassilis3 on November 12, 2013, 21:35:49 PM
Neither of the above two solutions (Jedson, Woop) was very helpful... It seems that Jedson's solution is closer to solving the problem, which is described below:
I was using the previous version of VirtueMart but I had to migrate (using the Migrator extension that migrates attributes) to the new one due to security reasons. The problem is that this extension didn't migrate the discount percentage on the prices as rules specific to product groups, as I suppose it should have, but rather as final discounted prices as overrides of the previous ones. So what should happen, and was happening with the older VirtueMart version is this:

(Core price – discount) + (additional cost due to product variation – discount) = final product price
http://www.diavgia.gr/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=1235&category_id=9&option=com_virtuemart&Itemid=73

Instead, below is what happens with the new version after having applied this rule [$this->productPrices['salesPrice'] = $product_override_price*1.23 + $salesPrice - $costPrice*1.23 ;]

(Core price – discount) + additional cost due to product variation.
http://www.fotistika.net/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1235&virtuemart_category_id=31&Itemid=

I am all ears!
Title: Re: Price Overrides
Post by: woop on November 12, 2013, 21:45:50 PM
Hi Basilis,

Do not understand what u´re looking for exactly... but i promise you that with the solution I posted (even if it´s hacking VM2 core) I got exactly what I am discribing (the problem I had and the solution I got). The info it´s just as an example (solved) of my case. I´m sorry this didn´t help u as you expected :P

If you wanna check the website where I did applied that you can go to www.gasfriocalor.com do the experiment with some product with a discount applied if you wanna experience the difference.

Lots of light dudes!!
Title: Re: Price Overrides
Post by: vassilis3 on November 16, 2013, 19:53:14 PM
Thanks for the reply but it still dosent work
Title: Re: Price Overrides
Post by: tomas.strans on April 06, 2014, 19:44:19 PM
Hi guys...

I tried all of yours tips and still doesn't work! Even I tried to copy calculationh.php from WOOP, nothing happen!

I'm using JOOMLA 2.5.19 and VM 2.0.26d

So do you have any idea what can I try to fix it??? Or if anybody have a working this funkcion (overwrited final price include price of custom fields), can you send me files making this change?


Thanks, Tom
Title: Re: Price Overrides
Post by: kalaxal on April 07, 2014, 22:29:21 PM
I can confirm that this worked for my situation but seriously Virtuemart Team you guys need to address this. The fact that it has been reported 20 or so versions ago. Come on
Title: Re: Price Overrides
Post by: woop on April 07, 2014, 22:53:01 PM
Quote from: kalaxal on April 07, 2014, 22:29:21 PM
I can confirm that this worked for my situation but seriously Virtuemart Team you guys need to address this. The fact that it has been reported 20 or so versions ago. Come on
Kalaxal, I agree with u but we still have to be happy with the excelent work of VMTeam and keep posting issues we find + post solutions we find :)

Quote from: tomas.strans on April 06, 2014, 19:44:19 PM
Hi guys...
I tried all of yours tips and still doesn't work! Even I tried to copy calculationh.php from WOOP, nothing happen!
I'm using JOOMLA 2.5.19 and VM 2.0.26d
So do you have any idea what can I try to fix it??? Or if anybody have a working this funkcion (overwrited final price include price of custom fields), can you send me files making this change?
Thanks, Tom
Tomas.strans regarding the solution I found and post in hear (at leat works perfectly for me on my versions of Joomla+VM) please note I´m using prices modifier (type DBTax) I wanna appoint you this strongly due the type of "price modifier" you use is important in my hack due that´s the only case where it´s applied :P ...you can also open my files and check/modify ;)
Title: Re: Price Overrides
Post by: rido21 on April 28, 2014, 01:45:35 AM
This solution worked for me!
J. 2.5.19 with VM 2.6.0

However, I solved one more problem that I had.
This was that the value of custom field is influenced by default tax rules.

My solution for this problem:
Edit the line 1628 in administrator/components/com_virtuemart/helpers/calculationh.php

$modificatorSum = $modificatorSum + $productCustomsPrice->custom_price;

and add this:
$modificatorSum = $modificatorSum + ($productCustomsPrice->custom_price / 1.23);


(1.23 is the tax in my country)

Quote from: jedzon on May 26, 2013, 09:10:02 AM
Hi,

I belive that is exacly what we are looking for. Please look at: http://e-slubny.com.pl/index.php/component/virtuemart/suknie-slubne/elegancka-suknia-do-slubu-wykonana-z-organza-i-satyny-typ-sukni-to-linia-a-bez-ramiaczek-suknia-posiada-naturalna-talie-i-jest-warstwowa-detail?Itemid=0

I can not find function coresponding for variant cost so I add few other variables which gave me same effect:

$product_override_price - this is price with discount
$salesPrice - this is price without the discount but with cart variant value
$costPrice - this is net price without cart variant value

For example:
Oryginal product is 2000
Discounted prodvuct value is: 1500
Additional fee: 50

$this->productPrices['salesPrice'] = $product_override_price + $salesPrice - $costPrice*1.23 ;

And we have: 1500 (discounted) + 2050 (price with additional fee) - 1626 (net price before discount and without additional fee) * 1.23 (this is tax in my country so I need to make price with tax) = 1550 (discounted price with additional fee)

If think you need same rules, but if you need price without tax you just should remove tax frome code.

Hopy you will understand what I'm mean becouse my english is not perfect :-)

Hope this will work for you too.
Please let me know.


Regards,
Karol
Title: Re: Price Overrides
Post by: jjferre on December 01, 2014, 20:13:42 PM
Hello , I have the same problem. When a VM product has custom fields with variable carriage , the amount of custom field is added to the sale price , but not the final price.

You can tell me please what is the I took a month trying to fix it and do not like solution.

The VM version I'm using is 2.6.10

Attached here the file I edited unsuccessfully in : administrator / components / com_virtuemart / helpers / calculationh.php

https://www.dropbox.com/s/4syrcheusrwaz35/calculationh.php?dl=0

Thank you very much , I hope for your answer.
Title: Re: Price Overrides
Post by: alinajenon on February 18, 2015, 19:29:14 PM
Thank you!  These are the answers I needed!!! Much gratitude. :)
Title: Re: Price Overrides
Post by: DayCounts on July 17, 2016, 16:38:26 PM
I have a solution without hack available there:
https://www.daycounts.com/shop/virtuemart-3/price-override-w-attribute-fix.htm

Just need to install a plugin and create a new calculation rule and you are good to go.
Works only with "override price to be taxed"
Title: {***} SOLUTION !!!
Post by: savvy on August 20, 2016, 14:08:50 PM
Hi ,

just open "/administrator/components/com_virtuemart/helpers/calculations.php"

find this : "return $this->productPrices;"
AND put above it :


if($this->productPrices['variantModification']!=0) {
         
         $this->productPrices['discountAmount'] += $this->productPrices['variantModification']  ; // for displaying !
         $this->productPrices['salesPrice'] += $this->productPrices['variantModification']  ; // for paymeny
         $this->productPrices['basePrice'] -= $this->productPrices['variantModification']  ; // optional
         
      }

Title: Re: Price Overrides
Post by: Henrik Holm Nielsen on September 26, 2016, 16:41:44 PM
savvy,

Thanx for this hack - however it seems the hack does not take any taxrules into account :(
For now I have modified the rules manually, by just hardcoding my taxrate into the rules - but do you have a take on how this could be done, if one wants to use the taxrules in the system instead?

Cheers