I'm using this form to sell advertisements and services. Customers supply information needed for their order via webform. Occasionally clients need to revise information submitted. I have tried editing submissions to updated information but it does not work. When I do this the component data is unchanged but the webforms payment status is reset to unpaid. I can't even figure out where/how to reset the payment status to paid.

It appears that status is set to unpaid anytime webform submission is saved as apposed to when it is first created.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Collins405’s picture

I can confirm this problem.

The Rule to update the payment status is only run after completing checkout, so perhaps there is a way of cloning the rule, or getting it to run on an updated submission.

KarinG’s picture

Imagine the scenario where a submission is edited and now more money is due or perhaps you need to issue a refund. I made a Mark commerce webform as paid (after editing order) - b/c then certain/specific admin staff can confirm that the monies are fine before the submissions are re-marked as paid.

Condition:
if("[commerce-order:status]" == "completed" && "[commerce-order-unchanged:status]" != "[commerce-order:status]" && [site:current-user] == 'superadminuser') {
return TRUE;
}

So the workflow is:

submission is edited -> everything is unpaid again
admin staff -> toggles order to pending status
admin staff evaluates Order - did any fields change that require additional payment or perhaps a refund action? If so act on it.
If all is well: superadminuser -> toggles order to completed - this then triggers the Mark commerce webform as paid (after editing Order)

It would be nice it things were more automated - but in this case I like it that there is a pair of eyes involved to do simply review the Order.

Collins405’s picture

@KarinG Did you set that up as a custom event? Or were you able to create it using data inputs?

If so, could you possibly export that rule for me?

When I am creating a rule, as a clone of "Mark commerce webform as paid", but replacing the event with "After a webform submission has been updated", I get the error: Data selector commerce-order for parameter node is invalid. Probably because it isnt getting the associated order ID with the updated submission.

KarinG’s picture

Note that the event should be:
After updating an existing commerce order

As it's superadmin that updates the commerce order - after evaluation if the monies are fine - after a commerce webform submission edit has happened.

So depending on who is allowed to to edit a commerce webform submission you may also want to add a rule that sends out an email to a staff/admin - so that superadmin will know to evaluate the commerce order that is associated with that commerce webform submission.

Collins405’s picture

Ah, perfect. Thank you very much.

This will serve as a good solution for the moment, but I will try and find the time to patch the current issue so it is more automated.

KarinG’s picture

Be careful though - you'd have to involve some math to ensure Order total still makes sense.

Collins405’s picture

In my use case for this issue, there is only one payment option on my webform, which is a deposit of £100.

Therefore, after a webform submission is updated by an admin, there is no need for the submission to marked as unpaid.

I am struggling to see where a submission is marked as unpaid again, and why.

In the database, it is stored in webform_submitted_data table as {"product_id":"1","quantity":1,"order_id":"8","line_item_id":"10","paid":true}

I can see this being a very popular option, as the majority of webform use cases will be for a simple event registration, or fixed amount. If I can find where that is set, I can add a simple checkbox option into a settings page as a patch, so admins installing the module can state whether the price is ever likely to be updated or not.

If there is only one fixed price: Submission is never set as unpaid again.
If there are multiple price options: Module will work as it currently does.

Kcannick’s picture

It appears this answer is more complicated than my question. I had assumed most people were using the module like myself and @Collins405. We have a form where users submit information for advertisements and make payment via this module. Occasionally they will call in with a change. we go in to manually edit submission information with changes and now the webform entry is marked as UNPAID. This makes it difficult for us to rely on the webform data to manage ad purchases and placements.

TrevorBradley’s picture

I have to chime in here with the other half (95% in my case) of Kcannick's problem. In my case, I don't care about the Paid/Unpaid status yet. What's crippling is that I can't change any of the other field data. We have staff that will be reviewing the webform submission and make additions to hidden fields. At the moment any changes to the fields of an existing submission are discarded, without error.

I've tried disabling all rules related to the commerce_webform module, and it still rejects edits. But if I clone the webform and remove the commerce_webform field, I can edit the submission just fine.

TrevorBradley’s picture

Verified that the fault lies in commerce_webform_update_webform_submission_productfield. Commenting out the following code allows webforms to be re-submitted:

              // Delete all old submission component data.
              db_delete('webform_submitted_data')
                ->condition('sid', $webform_submission->sid)
                ->execute();
              // Read submission component data.
              $webform_submission->is_new = FALSE;
              webform_submission_insert($node, $webform_submission);
              // Do NOT return - but loop through all
              // We need to find all items with this $product_id
              // and give it the $line_item_id so that when Rule
              // "Mark commerce webform as paid" is executed
              // it will also be marked as paid.

Now... How to disable this "glitch" without breaking any existing functionality...

TrevorBradley’s picture

I just ended up commenting out this section, then hiding the "Paid/Unpaid" status with the theme_webform_display_productfield hook. I genuinely don't care what the webform has to say about the Order, I just need it to leapfrog the process of creating an order, for the order data to be accurate, and for the webform to store and have editable supplimentary information.

robbdavis’s picture

Same issue here. I have admins edit hidden fields to mark the order as complete and mark down any notes about the order. When they update the form, the Paid link on the view page switches to Unpaid.

This is very bad as the order has obviously already been paid but now shows as unpaid.

I haven't dug into the guts of this yet; I'll post a solution if I find one.

R.

johnennew’s picture

Version: 7.x-1.0-beta6 » 7.x-2.x-dev

Acknowledged this is a problem in the 7.x-2.x version.

Submission editing is a tricky business since the edit might change the products on the form - what does Paid / unpaid mean in such a situation?

I'll have to run through some scenarios to work out what makes sense. It might be that once PAID the form can no longer have any of its product fields modified.

The basic use case is likely to edit non-product fields - more complex cases might need dealing with in another issue.

Kcannick’s picture

What about hiding product field on edit page.

johnennew’s picture

Hi @Kcannick, I think thats probably the best idea - anything else would need a new form submission.

Just looking at the code now to see if the value of the productfield element can be protected on submission edit.

Collins405’s picture

Greying out the product field on the submission edit page sounds like the best idea, or maybe that the status is only set to unpaid if the product field has been altered.

johnennew’s picture

Status: Active » Needs review
FileSize
5.68 KB

Here is a patch which does as suggested.

Once an order has been created and linked to a submission, the products in the submission cannot be edited from the webform submission.

The problem is that the hook webform provides to format data after saving a webform submission does not provide the previous values stored in the webform submission, so we cannot make a decision to use the already set values of order_id and product_id.

Feedback welcome.

johnennew’s picture

Here is a screen shot showing what the submission edit form now looks like. The text field is still editable, but the product field is not.

Collins405’s picture

Cool! I look forward to trying it out! Thanks!

johnennew’s picture

Status: Needs review » Needs work

Setting back to needs work as seen that its not working when multiple and allow user to choose quantity is set.

johnennew’s picture

Status: Needs work » Needs review
FileSize
17.23 KB

OK, here's a a patch I believe works in all cases. This includes a number of refactors to make the code a little easier to read.

johnennew’s picture

Slightly better patch attached!

johnennew’s picture

Status: Needs review » Reviewed & tested by the community

After testing I am satisfied this is working.

  • ceng committed 89cb77d on 7.x-2.x
    Issue #2306303 by ceng, Collins405, Kcannick, KarinG, TrevorBradley,...
johnennew’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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