VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Mole_LR on October 05, 2013, 00:46:02 AM

Title: Return with JS custom calculated Price for product into Cart
Post by: Mole_LR on October 05, 2013, 00:46:02 AM
Hi!

Joomla 2.5.14 and VM 2.0.22e

I have to create shop for products which prices are different for every single quantity depending on quantity levels (so, single item price for 1 item is not the same as single item price for 2 items; and these rules are different for quantity levels, 1-20, 21-50 etc). So, therefore I had had no options for using any calculation plugin or customfields for this...

So far I've done calculation with JS wich returns me the value as element <b id="custom_price"></b>. This is in category view.

So, the interesting question I have - is it possible to set this element value to the price parameter....I do not know, for example, $product->prices['salesPrice'] or whatever which is correct (so - to override the value that is already set from DB)? I need this custom calculated price to be set also in the Cart! At this moment have no idea - is it possible and how it could be done... Therefore any Hint would be helpfull!

I hope it can be possible! ;-)

Thank You!
Title: Re: Return with JS custom calculated Price for product into Cart
Post by: Maxim Pishnyak on October 06, 2013, 13:36:52 PM
Quote from: Mole_LR on October 05, 2013, 00:46:02 AM
is it possible to set this element value to the price parameter....I do not know, for example, $product->prices['salesPrice'] or whatever which is correct (so - to override ...
... it in template overrides?
Title: Re: Return with JS custom calculated Price for product into Cart
Post by: Mole_LR on October 06, 2013, 22:56:54 PM
Yes, so far changes for this custom price calculation are done in category view template override!

I'm sure it can be done - because CustomFields also AJAX change Price (I suppose $tmpPrice) if CustomField have additional Price.. ;-)
Title: Re: Return with JS custom calculated Price for product into Cart
Post by: Mole_LR on October 09, 2013, 21:30:07 PM
Hi!

So far no suggestions, ideas, hints?

I know - it's more that just templating...

But I want to understand - how in Virtuemart it is made to return calculated price to the cart (through session, or returning value in the url; as these are 2 ways how javascript can "give" value to server script parameters)?
Title: Re: Return with JS custom calculated Price for product into Cart
Post by: Maxim Pishnyak on October 11, 2013, 22:42:29 PM
Quote from: Mole_LR on October 05, 2013, 00:46:02 AM
single item price for 1 item is not the same as single item price for 2 items; and these rules are different for quantity levels, 1-20, 21-50 etc
You can't use this quantity rules in Product Edit form?