When trying to enable or disable commission types I get this error and even though it says in the status message that it was successfully enabled or disabled, it's clear that it wasn't as it remains at the default. Trying to enable again yields the same error over and over. Tested on two separate installs.

Notice: Undefined index: commission_type in commerce_affiliate_ui_enable_commission_type_form_submit() (line 135 of \commerce_affiliate\includes\commerce_affiliate_ui.commission_types.inc).

Comments

deggertsen’s picture

Issue summary: View changes
deggertsen’s picture

Issue summary: View changes
deggertsen’s picture

Title: Error when trying to enable "Product commission" commission type » Error when trying to enable or disable commission types
deggertsen’s picture

OK, I've at least found the problem. Not sure the best way to fix it. For some reason $form_state['commission_type'] is not being passed from commerce_affiliate_ui_enable_commission_type_form() to commerce_affiliate_ui_enable_commission_type_form_submit(). I tried to simply get rid of commerce_affiliate_ui_enable_commission_type_form_submit() and put the necessary stuff into commerce_affiliate_ui_enable_commission_type_form() and it worked. Of course it skipped the confirmation step and it also didn't redirect back, but at least it enabled the commission type.

Still trying to figure out a more permanent solution and write a patch.

deggertsen’s picture

Status: Active » Needs review
StatusFileSize
new3.62 KB

ok, here's a first run at a patch. The main problem with the patch is that it doesn't redirect back to the commission types page, but everything else seems to be working. I removed the confirmation page as I see very little reason to have one as it's inconsequential to enable/disable a commission type and I couldn't figure out how to get the commission_type to pass through the confirm_form() function in order to fix the error. Removing the extra step makes it so I can actually enable/disable commission types.

This definitely needs review from someone who knows what they're doing. =)

liliplanet’s picture

Hi! Watching the progress daily as the affiliate system is so important for my next phase. Its been very quiet since June, is there perhaps any news of a stable version?

Most most appreciate your expert work on this :)

deggertsen’s picture

@Liliplanet, tests are helpful! That's the only thing this patch is working on. I could go ahead and commit it myself, but I would like others to test first.

As far as a stable release, we have three issues outstanding (including this one) shown on the project page that we'd love to have your help on!

jedihe’s picture

@deggertsen: I think the original issue is caused by $form_state not being passed by reference to the form constructor. I tested your patch in simplytest.me and it got the commission type enabled/disabled, but I think it's much better practice to keep the confirmation form.

I'm attaching a patch with my proposed fix. Will test in simplytest.me and report back the results.

jedihe’s picture

Missed the disable form in my previous patch. Adding that now and posting in order to test.

jedihe’s picture

Status: Needs review » Reviewed & tested by the community

#9 worked flawlessly in simplytest.me. If you want to see the details, please watch: https://drive.google.com/file/d/0B2jEubEfYfP2X2tQWTdrTzR6dmM/view?pli=1 (runtime: 2:38)

As a final note, form constructors are expected to set $form_state by reference, please see example code in the docs: https://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7

@deggertsen: moving to RTBC, please check and let me know if it looks good for you to commit :D. Thanks!

deggertsen’s picture

@jedihe, yes! I think that's probably all it was. I don't have time to test right now, but I'll go ahead and commit it to dev as it looks good to me. If anyone finds any problems with it they can post here and we can fix it.

  • deggertsen committed 79474aa on 7.x-1.x authored by jedihe
    Issue #2506639 by jedihe, deggertsen: Error when trying to enable or...
deggertsen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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