Support from Acquia helps fund testing for Drupal Acquia logo

Comments

warpedrive’s picture

Agreed - This would be very useful from my user's perspective.

AaronBauman’s picture

+1
my users really need some way to see which submissions correspond to which orders, preferably by uc order id.

AaronBauman’s picture

Status: Active » Needs review
FileSize
3.27 KB

Here's a patch:

  • Add join table {uc_event_registration_submissions} with an update to hook_schema and relevant hook_update_N
  • Add hook_order ( uc_event_registration_order() ) to keep join table up to date when order is updated.

I have purposely left out a script that populates the join table from existing orders, because for sites with a great number of orders this could be inefficient and cause the update script to timeout or memory out or fail otherwise. If people are interested in this, i'd suggest a drush script or similar that populates the data. (I'll be writing one of these for my own use case that i will post.)

To dos:

  • expose order id on webform submissions
  • expose submission id on orders
  • expose these data to views through webform views and uc views
AndyF’s picture

Status: Needs review » Needs work
FileSize
6.27 KB

@aaronbauman Thanks for getting the ball rolling on this!

I have purposely left out a script that populates the join table from existing orders, because for sites with a great number of orders this could be inefficient and cause the update script to timeout or memory out or fail otherwise.

I've modified the update to use the batch API (and some other small changes, including rerolling against latest). I think that's nicer than supplying a drush script. I wasn't sure what would be the best batch size though: I've opted for 25 rather arbitrarily.

To dos:

  • expose order id on webform submissions
  • expose submission id on orders

Any specific ideas on how you'd do this?

Thanks again,

AndyF’s picture

Oops, the line reading:

$sandbox['max'] = db_result(db_query("SELECT COUNT(*) FROM {uc_order_products}"));

should be:

$sandbox['max'] = db_result(db_query("SELECT COUNT(*) FROM {uc_order_products} op INNER JOIN {node} n ON op.nid = n.nid WHERE n.type = 'paidevent'"));
AndyF’s picture

I've just taken a quick look at the Ubercart side of things, and think the best way to add the link will be via hook_product_description(). This means that the link will be visible on the cart and checkout pages (for those with the right permission), which seems fine to me. The only alternative I can see would be by using the table API which is uglier imho.

AndyF’s picture

Here's a patch which shows links via hook_product_description(). Haven't added the return link from Webform to order yet though.

AaronBauman’s picture

Thanks for the patch.
However, for me i need this for reporting, so just sticking an anchor in the product description is not sufficient.
I need the uc order id exposed to webform views or in the default webform reports,
and i need the submission id exposed to uc views or in the default ubercart reports.

AndyF’s picture

just sticking an anchor in the product description is not sufficient.

And yet that's precisely what this issue description asks for! (Note that I also need to add a corresponding link from the webform to the order.)

I need the uc order id exposed to webform views or in the default webform reports,
and i need the submission id exposed to uc views or in the default ubercart reports.

Regarding Views integration see #1301998: Create Views relationship linking order to webform submitted data which is dependent on #680386: Views integration for the webform_submitted_data table. Regarding modifying the default ubercart/webform reports, could you start a new issue and put in some detail about exactly what you'd like to see where?

Also attaching #7 with fix from #5.

Thanks

AndyF’s picture

Status: Needs work » Fixed
FileSize
9.59 KB

Added the link on the submission screen. Would welcome testing and feedback. Note I've removed the indexes from {uc_event_registration_submissions}.

Thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

warpedrive’s picture

Category: feature » task
Status: Closed (fixed) » Active

... So the issue was:

The users need to see the actual order from the webform results list. Has this been accomplished? I really don't care as much about listing the submission from order.. The users don't care about that. They want to see if someoneone who registered fro an event checked out and paid.. !

does the patch actually accomplish that?

AndyF’s picture

Status: Active » Closed (fixed)

does the patch actually accomplish that?

IIUC yes! On the webform submission screen (node/%/submission/%) there's a link View containing order (and on admin/store/orders/% there's a View submitted form data link for each paidevent). Btw the patch is committed to the latest dev.

4kant’s picture

@AndyF:
I see the link "View containing order" on the webform´s submission page. I can click it and go to admin/store/orders/%.
But here I cannot see the link "View submitted form data".

Where should it be?

(Have the latest dev)

Thanks!

warpedrive’s picture

The idea was: Instead of just paid / unpaid status (not actual order status, btw, confusing) on the webform results.. there was supposed to be a link from the webform result tab line item.. to the order.. or at the least, the order id so you could track down the order..

Uh - so there still isn't a link from webform results to the actual order, correct? How is this then fixed / closed?

4kant’s picture

@warpedrive: in case you´re answering my comment: the link from the webform result to the order is OK but not "vice versa". That is the link from the order to the webform result. It´s simply not there.

AndyF’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

@4kant Thanks for reporting the issue, but I can't reproduce it myself. The link should appear in the Product column at the end of the description (and after any attributes). Could you ensure you've cleared caches and tried as user #1? If you still have problems, can you let me know if the issue's just with old orders or with new ones as well? I should mention that I have some largeish changes to push, including some modifications to updates 6103 and 6104, so please be careful with your database/site!

@warpedrive Do you mind seeing if you can reproduce 4kant's issue? Thanks.

4kant’s picture

Thanks AndyF for your response.
I checked everything as you told me, but still no link in the order screen to the webform submission.
You say the link should appear in the product column at the end of the description - I have only the title of the product here. Maybe I´m missing something?
A screenshot with a functional link would perhaps open my eyes...

Thanks again

warpedrive’s picture

Status: Postponed (maintainer needs more info) » Active

Well.. I installed and ran the latest -dev update.. and the updater crashed.. got a number of warnings, and..
Still no link or even a listing of an order id in the webform results table.. or anywhere else.
Did seem to add an attendee attributes field to some - but not all - of the existing classes.
Going to have to say that this is open , and the updater isn't in good shape..

AndyF’s picture

@4kant I'm fairly sure you'd see it if it were there! I'm working on a repo that's a couple of commits ahead of the one here (including a bugfix in an update function) so I'm going to work on that a bit more and get it pushed today (ideally). I'll let you know when it's done and ask you to have another go. Thanks.

@warpedrive Please leave the status. For future reference, 'the updater crashed.. got a number of warnings' is next to useless. A detailed description of both would be very helpful (more details). Thanks.

AndyF’s picture

Status: Active » Postponed (maintainer needs more info)

I've pushed the latest changes. It takes a while for the Drupal packager to archive the latest changes, but if you use Git you can get the changes immediately. I've tested on one site that's running v1.5 with quite a few existing paidevent orders and it seems to update painlessly and work fine. There was a bug in the schema definition for table uc_event_registration_submissions in dev - if you have that table already, then please run the following query:

ALTER TABLE uc_event_registration_submissions
  DROP PRIMARY KEY,
  ADD PRIMARY KEY (sid, order_product_id);

Otherwise I think everything should be ok: please let me know how it works for you.

Thanks

4kant’s picture

AndyF,

  1. fetched your new version (checked that)
  2. updated database --> OK
  3. updated schema definition of table uc_event_registration_submissions with your query
  4. cleared all caches
  5. ordered a new product of content type "paidevent"

Still no link from the order screen to the webform submission. Everything remained as before the update...

Thanks again!

AndyF’s picture

@4kant Sorry to hear that. Have you tried looking at existing paid event orders and seeing if a link displays there?

Could you post the results of the following queries, replacing $order_id with the order number of the new order you made.

SELECT * FROM uc_orders WHERE order_id = $order_id;
SELECT * FROM uc_order_products WHERE order_id = $order_id;
SELECT * FROM uc_event_registration_submissions WHERE order_id = $order_id;
DESCRIBE uc_event_registration_submissions;
AndyF’s picture

@4kant Just saw a potential cause of the problem: in your list of steps in #22 step 3 should be done before step 2. Would you mind going through that process a second time in the correct order, and if that still doesn't work respond to #23? Thanks (and fingers crossed!).

4kant’s picture

@AndiF,
did the whole thing once again and switched step 3 and 2 - sorry - no difference - no matter whether old or new orders..
Here are the results of your queries:

Query: SELECT * FROM uc_orders WHERE order_id = $order_id;
Result:

"order_id";"uid";"order_status";"order_total";"product_count";"primary_email";"delivery_first_name";"delivery_last_name";"delivery_phone";"delivery_company";"delivery_street1";"delivery_street2";"delivery_city";"delivery_zone";"delivery_postal_code";"delivery_country";"billing_first_name";"billing_last_name";"billing_phone";"billing_company";"billing_street1";"billing_street2";"billing_city";"billing_zone";"billing_postal_code";"billing_country";"payment_method";"data";"created";"modified";"host";"currency"
"7";"1";"pending";"200.00000";"1";;;;;;;;;"0";;"840";;;;;;;;"0";;"840";"check";"a:1:{s:13:\"complete_sale\";s:9:\"logged_in\";}";"1340798667";"1340798671";"...";"USD"

Query: SELECT * FROM uc_order_products WHERE order_id = $order_id;
Result:

"order_product_id";"order_id";"nid";"title";"manufacturer";"model";"qty";"cost";"price";"weight";"data"
"16";"7";"195";"Kunden-Finder-Analyse";;"KFA";"1";"0.00000";"200.00000";"0";"a:3:{s:10:\"attributes\";a:0:{}s:21:\"uc_event_registration\";a:1:{s:3:\"sid\";s:3:\"262\";}s:6:\"module\";s:10:\"uc_product\";}"

Query: SELECT * FROM uc_event_registration_submissions WHERE order_id = $order_id;
Result:

"sid";"order_id";"order_product_id"
"262";"7";"16"

Query: DESCRIBE uc_event_registration_submissions;
Result:

"Field","Type","Null","Key","Default","Extra",,
"sid","int(10) unsigned","NO","PRI","NULL",,," "
"order_id","int(10) unsigned","NO"," ","NULL",,," "
"order_product_id","int(10) unsigned","NO","PRI","NULL",,," "

Hope that helps...

AndyF’s picture

Everything there looks good. Could you check the markup source to ensure that the link doesn't exist in case it's hidden away somehow visually. Entering $('.uc-event-registration-submission-link').size() into your browser's JS console on the admin/store/orders/7 screen should return 1 if the link's present, zero otherwise. If the link definitely isn't there, could you apply the attached patch (make sure you have devel enabled) and refresh the order screen and report back the contents of the message area. Thanks.

4kant’s picture

AndiF,
JavaScript Console says "zero".

Here´s the message after applying the patch and reloading the order screen of order 7:

product =>

... (Object) stdClass
order_product_id (String, 2 characters ) 16
order_id (String, 1 characters ) 7
nid (String, 3 characters ) 195
title (String, 21 characters ) Kunden-Finder-Analyse
manufacturer (String, 0 characters )
model (String, 3 characters ) KFA
qty (String, 1 characters ) 1
cost (String, 7 characters ) 0.00000
price (String, 9 characters ) 200.00000
weight (String, 1 characters ) 0
data (Array, 3 elements)
order_uid (String, 1 characters ) 1
Called from /var/customers/webs/Leicht/entwicklung/sites/all/modules/uc_event_registration/uc_event_registration.module, line 297  

submission =>

... (Object) stdClass
sid (String, 3 characters ) 262
nid (String, 3 characters ) 195
submitted (String, 10 characters ) 1340798654
remote_addr (String, 14 characters ) 188.194.41.210
uid (String, 1 characters ) 1
name (String, 8 characters ) wbdesign
is_draft (String, 1 characters ) 0
data (Array, 5 elements)
Called from /var/customers/webs/Leicht/entwicklung/sites/all/modules/uc_event_registration/uc_event_registration.module, line 302  

And of course:
Success

AndyF’s picture

Hmmn, weirdness. Everything looks fine, except of course the link isn't displaying. Do you have any display-related UC modules enabled? It might be an idea to disable non-essential UC modules and switch the theme to garland. If that doesn't help, try this new patch that adds a die() to the link's theme function. If the patch has an effect then the order screen should error out with the message theme function.

4kant’s picture

"display-related UC modules"? examples?
Patch didn´t change anything - no error, no message, except those of devel ;-)
I´m actually using Garland...
Sorry for not having positive news.

AndyF’s picture

I'm stumped then :/ I've tried the latest version on a site which was already using uc_event_registration, and on one that wasn't: both show the links correctly.

I don't have any specific examples of display-related modules, it's just that there's a hook_product_description_alter() that can be used by modules to modify a product's display and that could remove the link. You could try dpm()ing $description in a hook_product_description_alter and try it once with a very low module weight and then again with a very high one. $description should have a child called uc_event_registration_submission_link. If you can see it with a low module weight but not with a high one that would imply a module's modifying the description in a hook_product_description_alter.

Sorry I don't have anything more useful.

4kant’s picture

Status: Fixed » Postponed (maintainer needs more info)

AndiF,
thanks for your hint concerning display-related modules.
It´s definitely the ECO - module that causes the disappearing of the link.
Found the hook_product_description_alter() in the file eco.module. I did not try to switch module weights. I simply uninstalled ECO - and the Link "View submitted form data" appeared.
Don´t know whether swtiching module weight would make both modules work together? (I don´t really need ECO anymore as soon as uc_event_registration works... - and don´t know how to switch the weight of modules...)
If there´s something I can still do for you, let me now (eg. switch module´s weights?)
Thanks for your support!
Wiegand

AndyF’s picture

Status: Postponed (maintainer needs more info) » Fixed

Great news! I've created an issue for this (#1664108: Play nicely with other modules that modify the product's description) which includes a patch for you to use until something more permanent can be found.

Status: Postponed (maintainer needs more info) » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.