VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: EvanGR on August 12, 2022, 10:23:59 AM

Title: How are prices calculated with Custom Fields? (code)
Post by: EvanGR on August 12, 2022, 10:23:59 AM
Hello,

In the "add to cart" section, custom fields can have an effect on product price.

I know this section contains a <form> with html inputs, selects etc....

How can I create my own custom select element that will affect the product price, directly within the template?
(without going through VM's custom fields system)

e.g. I want to create a select box, with an option that will increase the product price by 10 euros.

Thanks
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: PRO on August 14, 2022, 01:28:13 AM
why?


what do you want to accomplish?
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: EvanGR on August 15, 2022, 11:30:58 AM
I am trying to add a custom JS app, which inserts its own fields in the addtocart section.
It works fine so far, but I cannot add fields that affect product pricing.
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: pinochico on August 15, 2022, 14:33:46 PM
It's sound like custom developping, maybe custom custom field?
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: Studio 42 on August 15, 2022, 18:08:21 PM
You can use this custom field plugin https://shop.st42.fr/en/products/shortcodes.htm and implement your own system.
Of course the logic is the same as other plugin but it's more flexible
See the logic here https://shop.st42.fr/en/shorcodes-english-doc#cart_color
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: EvanGR on August 17, 2022, 09:02:32 AM
Thank you!

Is there a starting point to develop a VM plugin for the product page/add to cart section?

Thanks
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: Studio 42 on August 17, 2022, 12:21:36 PM
EvanGr, i do not how you want set the options and price
I read : I am trying to add a custom JS app, which inserts its own fields in the addtocart section.
This is hard to do because you need to find a way to convert the options to real VM values to calculate the price.
My plugin can simplify this part but in any case you have to create your own code to do the rendering > conversion to make it compatible with Virtuemart because price calc, so if you do not have PHP skills, i do not mean you can achieve this
Title: Re: How are prices calculated with Custom Fields? (code)
Post by: EvanGR on August 18, 2022, 08:28:27 AM
Thank you Studio for your help.

We do have PHP and JS skills, but little experience with the VM architecture.
I checked your plugin, and it may be helpful (do not know yet).

However we are exploring ways to do it as simple as possible without extra layers of complexity.
Integrating directly with VM would be ideal.

Thanks!