Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTML Rendering Issues in WooCommerce PostFinanceCheckout Plugin #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

seodev-org
Copy link

This update addresses HTML rendering issues in the PostFinanceCheckout plugin for WooCommerce. Previously, HTML tags were displayed as raw text due to incorrect usage of escaping functions, impacting the display of form elements in the WooCommerce settings page. Key changes include:

•	Replacing esc_html() with wp_kses_post() in specific areas to allow proper HTML rendering.
•	Adjusting var_export usage for data attributes to ensure valid HTML attribute values.

These changes improve the display and functionality of form elements and other HTML structures in the WooCommerce admin settings.

@andrewrowanwallee
Copy link
Contributor

@seodev-org can you provide reproduction steps, that will produce the bug, so we can verify the changes you've made here?

@seodev-org
Copy link
Author

Steps to Reproduce HTML Rendering Issues in WooCommerce with PostFinanceCheckout Plugin:

1.	Issue 1: Raw HTML in Product Attributes Page
•	Navigation: Go to WooCommerce > Products > Attributes.
•	Observation: At the bottom of the “Add new attribute” section, before the “Add attribute” button, raw HTML code is displayed instead of rendering form elements.
•	Cause: This is due to improper escaping of HTML, where esc_html() is used instead of functions that allow safe HTML rendering. This issue is visible in the attributes page whenever adding a new attribute.

Screenshot provided to illustrate the raw HTML output below the “Add Attribute” button.
Screenshot Raw HTML in Product Attributes Page

2.	Issue 2: Raw HTML in Payment Method Settings
•	Navigation: Go to WooCommerce > Settings > Payments, then select any payment method (e.g., PostFinance E-finance) to edit.
•	Observation: Inside the payment method settings, HTML tags are displayed as text instead of rendering properly as form elements. This includes helper text and labels, which appear as plain text with visible HTML tags.
•	Cause: Similar to the first issue, this occurs because of incorrect escaping of HTML content in the settings fields for individual payment methods.

Screenshot provided to demonstrate the raw HTML output in the payment settings screen.
Screenshot Raw HTML in Payment Method Settings

Solution Implemented:

•	Adjusted the code to replace esc_html() with wp_kses_post() or output directly where appropriate, ensuring the HTML is rendered correctly instead of being displayed as plain text.

These changes should prevent raw HTML from displaying in both the Product Attributes and Payment Method Settings sections, providing a cleaner user experience in the WooCommerce admin.

@seodev-org
Copy link
Author

I’ve added you as a collaborator to my fork with write permissions. Feel free to make adjustments directly as needed.

@seodev-org
Copy link
Author

Additional Issue: Attribute Data Not Saving in PostFinanceCheckout Settings

In addition to the HTML rendering issues, I’ve encountered a problem with data persistence when modifying attributes, specifically with the “Send attribute to PostFinance Checkout” option.

Steps to Reproduce:

1.	Go to Attribute Settings: Navigate to WooCommerce > Products > Attributes, select an attribute (e.g., “Color”) and click to edit it.
2.	Attempt to Save the PostFinanceCheckout Setting:
•	In the attribute settings, check the option labeled “Send attribute to PostFinance Checkout.”
•	Click “Update” to save changes.
3.	Observe Data Persistence Issue:
•	After the page reloads, the checkbox remains unchecked, even though it was previously selected.
•	This indicates that the setting is not being saved correctly, as the value reverts to its default state after each update.

This issue affects the usability of the PostFinanceCheckout integration, as users are unable to save custom attribute settings related to product data sent to PostFinanceCheckout.

Could you investigate and address this data persistence issue in addition to the HTML rendering fix?

Thank you for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants