krokedil / klarna-checkout-for-woocommerce

Klarna Checkout for WooCommerce plugin
15 stars 23 forks source link

Display the Woo error message inside the Klarna modal #582

Closed mntzrr closed 2 months ago

mntzrr commented 2 months ago

When the customer clicks on the buy button, the validation_callback event will be triggered. Initially, I thought we could perform validation before we respond, but at this point, the modal is already open, and there is no event that is in-between the click event and the modal opening. Thus, we cannot prevent it from appearing. However, there is a different option: we can display the error message inside the modal (see screenshot) which is what this PR addresses.

image

If multiple checkout errors happens, it won't look very pretty, though.

image

And we cannot send any marking in the text since Klarna escapes all HTML, so we have to remove it.

image

task: https://app.clickup.com/t/8694jn5hy