VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: lbar on October 15, 2012, 18:47:50 PM

Title: Custom Plugin required
Post by: lbar on October 15, 2012, 18:47:50 PM
VM: 2.0.10
JOOMLA: 2.5.6

Hi guys, i'm gonna to develop a custom plugin for my virtuemart.
Basically it's a copy of textinput (with cart modification true), that i wanna become a required field (actually if the user doesn't write anything on this field the product will be added however on the cart, instead i want that the user must write something there).

I'm trying to bind  .submit() function with jquery on tmpl/default.php file but no luck. It's look like that the .submit() of the form is before.

Someone can put me on the right direction on how can do that?

Thank you for your support.
:)
Title: Re: Custom Plugin required
Post by: PolishedGeek on October 15, 2012, 20:55:25 PM
Hi, do you have any experience with Breezing Forms?  If you do, you could do this with an embedded Breezing Form inside the product page, rather than a custom plugin.  We have shared some info here in the 3rd party extension forum: http://forum.virtuemart.net/index.php?topic=108824.msg364211#msg364211
Title: Re: Custom Plugin required
Post by: lbar on October 16, 2012, 09:32:26 AM
Thank you, but i prefer develop plugin myself.

Someone can put me on the right direction on this matter?

Thank you.
Title: Re: Custom Plugin required
Post by: lbar on October 16, 2012, 12:04:11 PM
Solved, with a tuning of /com_virtuemart/assets/js/vmprices.js, inside:

product : function(carts) {
.....

added:

if (jQuery('input.required_attr').exists()){
                                                 required  = jQuery('input.required_attr').val();
                                                 if (required==""){
                                                   alert("Please insert the data");
                                                   return false;
                                                 }
                                                }

just before Virtuemart.sendtocart(cart);
In my virtuemart plugin added "required_attr" in the field added....
Not sure that this is the better way, but actually works... :)

Title: Re: Custom Plugin required
Post by: PolishedGeek on October 17, 2012, 03:16:53 AM
Congrats! Simple solutions are always good.