Hi Ubercart maintainers,
I'm trying to pass a custom form validation function for a quantity field on an add to cart form.
Essentially, my clients do not want to have any user be able to purchase more than 10 products from them, and if they enter more than 10, be prompted with a message that instructs the customer to call the sales department. This would normally be as straightforward as passing a validation function with a message if the form_state quantity is greater than 10, but it seems that Ubercart for Drupal 7 appends the NID for each form ID, making them unique. So, instead of being able to set a validation function for uc_add_to_cart_form as the form ID, as I see it I'd have to write a function for every product, which is pretty unsustainable.
Any idea how I can fetch a global form ID for a product's add to cart form?
Also, none of the contrib modules for this task work in any capacity, so a custom solution is the only way at this point.
Thanks!
Comments
Comment #1
rc2020 CreditAttribution: rc2020 commentedFor the record, I built a working prototype that works something like this:
However, passing in the $nid from the arg() function is kinda dirty. Any alternatives come to mind?
Comment #2
longwaveUse http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...
You should be able to simplify your code to:
Comment #3
rc2020 CreditAttribution: rc2020 commentedThanks!!