• Resolved bociakrodyl

    (@bociakrodyl)


    Hello!

    We have two checkboxes to mark when placing an order on our website.
    Both fields are required – these are very important fields.

    But customer is able to login to PayPal without checking both checkboxes.

    Situation is like this:

    • On order page I choose to pay with PayPal.
    • I don’t check the both consents.
    • Than I can click on the yellow PayPal button and PayPal login window opens – here is problem.
    • Next I am able to login into PayPal, I make the payment, then system take me back to the order page.
    • And only than on the order page both consents will be marked in red and a message will be displayed that I did not select consents. So the order is not accepted.

    The problem is in the yellow PayPal payment button.
    The old PayPal plugin was working through WooCommerce place order button.
    So in the old plugin it was not possible to log in to PayPal and make a payment without checking the consents on order page.

    If I choose bank transfer and I don’t check both checkboxes, then after clicking on place order button WooCommerce works fine – the consents will be marked in red, the page will scroll up to display a message about unselected checkboxes.

    The matter is serious, because such behavior of the website causes confusion for customers. Then they contact us nervous because the problem is with their money.

    I hope you can find a solution for this.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @bociakrodyl

    So in the old plugin it was not possible to log in to PayPal and make a payment without checking the consents on order page.

    Users may be able to log into their PayPal account, but no payment would be processed, as the error message about the missing field would occur after the popup window was closed. This depends on the timing of the validation for these custom fields.

    How are you adding these custom checkboxes? With a plugin or with custom code? If you are using a plugin, please let us know which one.
    If you are using custom code, I suggest using the hook woocommerce_after_checkout_validation for the validation. Then the checkboxes would also be validated on button click.

    So for example, when adding a field called my_custom_checkbox, the validation should look similar to this:

    add_action( 'woocommerce_after_checkout_validation', 'validate_my_custom_checkbox' );
    function validate_my_custom_checkbox() {
    if ( ! isset( $_POST['my_custom_checkbox'] ) ) {
    wc_add_notice( __( 'The custom checkox was not checked.' ), 'error' );
    }
    }

    I hope this helps!

    Kind regards,
    Niklas

    Thread Starter bociakrodyl

    (@bociakrodyl)

    Hi and thanks for fast reply!

    I used the “woocommerce_checkout_process” hook.

    Now I have:

    add_action( 'woocommerce_after_checkout_validation', 'bt_add_checkout_checkbox_warning' );
    function bt_add_checkout_checkbox_warning() {
        if ( !isset( $_POST['checkout_checkbox'] ) ) {
            wc_add_notice( __( 'Prosz? wyrazi? zgod? na otrzymywanie faktur drog? elektroniczn?.' ), 'error' );
        }
    }

    Unfortunately, the yellow button still opens the login window.

    Thread Starter bociakrodyl

    (@bociakrodyl)

    Hello,

    any chance for further help?

    Kind regards,
    Tom

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @bociakrodyl

    The hook woocommerce_checkout_process happens too late, so the early validation not triggering with this would be expected.
    I am using code like this to generate an example checkbox: https://gist.github.com/InpsydeNiklas/2fdbce5ac664fea113cdd0b0a1bad22c

    Then it is validated as expected upon clicking the PayPal button: see this example video

    Also, with the example you shared, it also works for me. Could you please share with us the complete code you use to create the checkbox, so we can give it another try?
    Thanks!

    Kind regards,
    Niklas

    Thread Starter bociakrodyl

    (@bociakrodyl)

    Hi Niklas!

    Actually everything works fine with your code.
    Oh, this was my mistake. I had a little oversight.

    Thank you so much for help!

    Kind regards
    Tom

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi Tom,

    Thanks for the feedback. I’m glad to hear you could figure it out.

    If you have any doubts or further questions, please do not hesitate to let us know, as the team is happy to help. And if you are satisfied with the plugin and our support, a review is highly appreciated as well.

    Thank you!

    Kind regards,
    Niklas

    Thread Starter bociakrodyl

    (@bociakrodyl)

    Sure thing, review just flew. Thanks again!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘You can go to PayPal without checking consents’ is closed to new replies.