• Resolved alfredo1216

    (@alfredo1216)


    Hi,

    I am having the following problem:

    I have a custom code (snippet) on my page, which verifies if certain conditions are met in the ordered items when clicking “Place order”. For this I am using the “woocommerce_checkout_process” hook. If the conditions are not met, it does not allow the order to be placed and displays an error message.

    What happens? My code works perfectly with all payment methods, except PayPal. I was reviewing their documentation but they only have a basic validation of the data from the form, plus we did not add them.

    https://github.com/woocommerce/woocommerce-paypal-payments/wiki/Actions-and-Filters#basic-checkout-form-field-validation-before-creating-the-paypal-order

    I wonder, how can I correct this problem?

    Is there any way that when they click the paypal buttons my snippet is executed?

    Stay tuned to your comments.

    Thank you.

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

    (@niklasinpsyde)

    Hi @alfredo1216

    Apologies for the delayed response. PayPal Payments provides two different validation mechanisms.
    Due to technical limitations, it is currently not possible to trigger the entire WooCommerce checkout validation when clicking the PayPal button.

    The “basic validation” (disabled by default) only checks for required checkout fields via JavaScript. There is no server-side validation before opening the PayPal popup when only the basic validation is enabled.

    Beyond the basic validation, PayPal Payments also provides an “early WC validation” (enabled by default).
    This early validation triggers a server-side validation, but there are limitations.

    The hook woocommerce_checkout_process is called only after creating the PayPal order, so it would not be taken into account when clicking the PayPal button.

    Instead, you could try it with the hook woocommerce_after_checkout_validation because validate_checkout is called before opening the popup window.

    I hope this information helps you out to adapt your code in a way that works with PayPal Payments.
    Please let us know if any questions remain.
    Thanks!

    Kind regards,
    Niklas

    Thread Starter alfredo1216

    (@alfredo1216)

    Don’t worry. If I visualize the two validation mechanisms with what they currently have.

    Unfortunately, neither of the two mechanisms works as required and using the “woocommerce_after_checkout_validation” hook I still have the problem since the popup window continues to open without verifying the conditions of my custom code.

    I understand the issue of technical limitations, for this reason I would like to wait for a possible solution/update in which all validations can be made when clicking on the PayPal payment buttons with the corresponding hook.

    Thanks and regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“Custom” validations at checkout before creating the PayPal order’ is closed to new replies.