I have two payment methods active: uc_adyen & uc_bank_transfer. Thanks to this very nice module (thanks :)) "bank transfer" is only displayed to customers with a billing country in which Adyen doesn't offer bank transfers. So far so good.
Now on the checkout page I set everything including a billing country where "bank transfer" will be available, select it as payment method and click "Review order"
-> I get "An illegal choice has been detected. Please contact the site administrator." and the checkout page is shown again.
-> of the two available payment methods none is selected. I select bank transfer again and click review order -> now I get to the review page without a further error message.
what I have found so far:
- if "bank transfer" is available for the default country, then the problem doesn't exist (in other words when the payment method is shown when the page is built the first time, the it will be accepted on first "Review order")
- the error message comes from Drupal core, there are three occurrences of this exact message, the one we get here is the one from form.inc, v 1.265.2.32 line 711 (that is Drupal 6.16)
Comments
Comment #1
jasonlau commentedYes, I was experiencing the same problem. I setup a condition that paypal payment method is only available to US customers. As soon as I clicked "review order", I got the "An illegal choice has been detected. Please contact the site administrator." error message, and the checkout was shown again. The "State/Province" field was highlighted, indicating that an error occurred there. I had to update the "State/Province" field again and resubmit the order form. Then, it got accepted and directed to the "Review order" page. I disable/enabled different modules and isolated the problem. I believe "Ubercart Conditional Payment" module was causing this problem.
Comment #2
Juhani commentedThis bug has many similarities to what was with Ubercart Addresses module http://drupal.org/node/376632, with explanation: "Drupal generates this error because the form being submitted is different from the form on the cache. When you submit a form, drupal compares the submitted against the one on the cache but since the form has been altered (zones) when you select a different country the form doesn't match and thus generates the error."
Great if this would get fixed..
Comment #3
carlitus commentedI've have the same bug...
any news for this?
Comment #4
allartk commentedNot a solution but some kind of work arround. The module removes the disabled choice from the form, I decided to hide it instead.
To do this in .module comment out
and add below
in uc_conditional_payment.js replace part of the ajax succes call
Note, the field is only hidden.
Comment #5
darshanchoudhary commentedI am getting the same error when i use COD option only for a particular city.
Has anyone found out what can be the issue?
Please share if you have a solution.
Thanks in advance
Comment #6
danisha commentedMy friend allartk...... I first thought that your code is working fine, but later discovered that it isnt working properly. It allows you to move ahead after checkout but the conditional payment stops working as it doesnt hide the gateway. Banged my head onto it and later came out with a solution.
For those who just want a single payment gateway to be hidden on selection of a city or whatever should do the following in the uc_conditional_payment.module:-
if ($predicate && !ca_evaluate_conditions($predicate, $arguments)) {
$("#edit-panes-payment-payment-method-cod-wrapper").hide();//unset($form['panes']['payment']['payment_method']['#options'][$method['id']]);
$form['panes']['payment']['payment_method']['#options'][$method['id']] = '
';
Here I added a single javascript line to hide the payment gateway i wish to hide.
Remember that in line $("#edit-panes-payment-payment-method-cod-wrapper"), cod is the id of the payment gateway which you can find with the help of firebug.
Can hide multiple payment gateways by this. Although its not advisable, but it seems to be working correctly with just one payment gateway hiding.
And there is no need to add anything in the uc_conditional_payment.js file
Please do let me know if there is any permanent solution for this..
Comment #7
smartparty commentedIn response to the fix in #4 which did not work for me because of one minor detail.
The form attributes already have a class associated with them. This class should be appended, so instead of adding this code as suggested in #4...
$form['panes']['payment']['payment_method']['#attributes'] = array('class' => 'hide-'.$method['id']);Adding this code...
$form['panes']['payment']['payment_method']['#attributes']['class'] .= ' hide-'.$method['id'];...will then allow proper choice of payment method and display the correct payment information below as applicable, allowing the user to continue to checkout review without the validation error.
Comment #8
sin commentedConfirm # worked for me twice. Using #7 for the last site.