Closed (works as designed)
Project:
Ubercart Event Registration
Version:
6.x-1.x-dev
Component:
Main Module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
10 May 2011 at 00:25 UTC
Updated:
4 Oct 2011 at 21:58 UTC
Comments
Comment #1
Rob_Feature commentedThere's currently no way to see them on one screen, this would be a fuller implementation that we're doing right now.
Comment #2
ChrisLaFrancis commentedIn a post under the issue for including product attribute support in this module, user portulaca alludes to using hidden webform fields to store the attribute values in the webform data. Any idea as to how this is being accomplished?
Comment #3
Rob_Feature commentedI'd suggest jumping over there and asking. I got the impression he was just suggesting it was possible, not that he was doing it.
While it's possible to do that, I honestly don't see this module having a long enough life in D6 for that development to happen since Commerce module is the future.
Comment #4
ChrisLaFrancis commentedThanks for the advice.
Comment #5
ChrisLaFrancis commentedFor anyone who might be interested in this, I came up with a very quick-and-dirty solution going somewhat off of this post.
Basically, I created hidden form fields for each Ubercart attribute, then I created a "markup" field on the webform and wrote some JavaScript that would set the values of the hidden fields to the values of the attribute fields upon form submission.
Certainly not the best way, but it seems to be working.
Comment #6
portulacaHere's what we did:
The concept is to create hidden webform fields that will store attribute values. The data is saved in UC and in webfrom hidden fields at the same time. This means you have to create a hidden field in the webform for each attribute and name it after the attribute label.
We modified the UC event registration module - added a piece of code that reads attributes and on submit looks for form elements with names that match the attribute labels.
We also needed to use Quantity on some attributes and we had to modify the UC Quantity to make it work. The ajax price box from this module also didn't work for us, we commented them out so they don't interfere with our custom solution.
To store the Quantity in webform you create a hidden field for each option and name it [attribute label]|[option label].
Additional benefit was that with this approach we could intersperse attributes with webform fields - by making them all attributes without price and adding the matching hidden webform fields. Before the change webform fields would always be rendered first and then came the attributes. We needed some extra information that is not price related but the information is related to an attribute so we needed some kind of visual proximity between them.
Basically your solution is the same only we use PHP to do the matching and saving, it's not as hard-coded as your solution and it should always work (doesn't depend on js).
We're not happy with our solution, ideally UC event registration module would automatically create hidden fields, connecting attributes with correct webform fields is tricky when done manually. Maybe another tab should be added to the paid event CT that allows you to choose which attributes to make available inside the webform (defaults to all.)
This is just a quick reply because I don't have time now to elaborate. Does this answer your question? Do you have any suggestions or more questions?
Comment #7
ChrisLaFrancis commentedThanks, portulaca. I definitely like the fact that your solution is on the server-side rather than the client-side. Are you considering creating a patch with the changes you've made?
Maybe the simplest solution would be to create another tab where each attribute is displayed and for each attribute one can select the corresponding webform field (hidden only?) in which the attribute's value should be stored. The hidden webform fields would have to be created manually, but at least the code wouldn't rely on naming conventions to match up attributes and their respective webform fields.
Comment #8
Saoirse1916 commented@portulaca How did you manage to do this? I'm looking to do the same thing, but according to this (http://drupal.org/node/288199) you have to put the $form['#submit'][] = 'uc_event_registration_client_submit'; in between the two existing submit calls in webform.module: $form['#submit'] = array('webform_client_form_pages', 'webform_client_form_submit');
If you do that, you can populate hidden fields and they show up in the table -- but your forms don't get added to the cart, at least if they're multi-paged forms. Single page forms do get added but the visitor then has to go to their cart, the form doesn't redirect them.
Comment #9
Saoirse1916 commentedNever mind, I figured it out -- just do a db_query. If anyone else is interested in this and needs more details, here's what I did. I'm not done, as I'm still having problems with radio button attributes and I haven't sorted out text inputs at all, but it's a start:
Comment #10
joedonjohn commentedHi @Saoirse1916,
Can you show all the steps you did to get this working, I just cant seem to get it. Do you create the hidden fields within the webform tab in the drupal ui or in the webform module.
I just cant seem to wrap my head around it.
Thanks in advance
Comment #11
Saoirse1916 commentedYes, I just created hidden fields using the Webform UI -- the trick is that they have to match the attribute names exactly. Then the code I posted above runs through the list of webform fields looking for matches and updates the values with what was submitted in attributes. Then you can query all the fields either through the basic Webform reports or through a View using MySQL Views and a few other modules.
It's not exactly an ideal situation as was posted before. You're doubling your efforts if you have attributes that you want to report on -- but it does work.
Comment #12
Saoirse1916 commentedI found a bug in my method, which is that if the user saves a draft of their webform or hits the Previous Page button on a multi-page form, it doesn't update the attributes properly (or throws an error). The reason is because on an update there is no
$form_state['webform']['component_tree']['children']; rather, the correct array is$form_state['storage']['component_tree']['children'].So to handle this you will need to do an
if(isset($form_state['webform']['component_tree']['children'])){and a corresponding}elseif(isset($form_state['storage']['component_tree']['children'])){check to see what you're dealing with.Hope this helps someone!
Comment #13
Saoirse1916 commentedOne more update, in case anyone's using this method. It was all working fine for me for a few weeks at which point we updated several modules, Webform among them. After the round of updates, it turned out that something would delete and then re-save every webform component but it would not update the hidden fields that I used to save attributes, presumably because they are hidden. Something now calls the function webform_submission_update -- I don't think Webform itself is to blame since I looked back through old versions of the module and nothing changed in that function -- but when it's called everything gets wiped out.
So, the solution is to move the attribute/hidden fields updating routine to the conditional actions file and have it called once the order is paid. I expanded the uc_event_registration.ca.inc file to add in a few other conditional actions that send a confirmation, add in the order number, final price, etc. Here's what I did:
The first bit deals with the results from another module, uc_discount_coupons, but the rest should make sense.
Comment #14
Breen commented@Saoirse1916
I'm still a bit confused by your two code snippets. I'm trying to implement them but I'm not exactly sure where they should go. I can see in the latter snippet you mention uc_event_registration.ca.inc, should it go in a particular place in that file? For the first snippet does that get placed in the main webform.module?
Thanks!
Comment #15
Saoirse1916 commentedNo, forget the first one -- it worked for a while but some update broke it. The second one goes in uc_event_registration.ca.inc, which is included in the UC Event Registration module. This function is called when an order gets marked as completed. It cycles through the list of webform fields and updates them with the value of any matching attributes.
Comment #16
Breen commentedThanks for the update. I actually ended up going in a different direction with this but I really appreciate your response.