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

Load HTML in product name on shipping rates #762

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

alefesouza
Copy link
Member

@alefesouza alefesouza commented Jan 11, 2025

Fixes woocommerce/woocommerce-subscriptions#4128

Description

This PR fixes raw HTML being shown to the user on the shipping rates section of the classic cart and checkout page when the product name contains HTML.

This fix for the cart and checkout blocks is included on woocommerce/woocommerce#54386.

Before After
Screenshot 2025-01-10 at 9 40 16 PM Screenshot 2025-01-10 at 9 39 24 PM
Screenshot 2025-01-10 at 9 48 11 PM Screenshot 2025-01-10 at 9 48 28 PM

How to test this PR

  1. Create a subscription with HTML in the name.
  2. Add this subscription to the cart.
  3. Add a normal product to the cart.
  4. Access the classic cart or checkout page.
  5. The HTML in the product name for the shipping rate is not loaded.

Product impact

  • Added changelog entry (or does not apply)
  • Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
  • Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
  • Added deprecated functions, hooks or classes to the spreadsheet

@alefesouza alefesouza requested a review from mattallan January 11, 2025 00:57
@@ -108,7 +108,7 @@ function wcs_cart_totals_shipping_html() {
<?php wcs_cart_print_shipping_input( $recurring_cart_package_key, $shipping_method ); ?>
<?php do_action( 'woocommerce_after_shipping_rate', $shipping_method, $recurring_cart_package_key ); ?>
<?php if ( ! empty( $show_package_details ) ) : ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $package_details ) ) . '</small></p>'; ?>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same approach used by the product name on the cart page here.

Copy link
Contributor

@mattallan mattallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @alefesouza for fixing this!

  • One small thing, do you mind adding a changelog entry for this one before merging it?

Code looks good and tests well. Approving this :)


This fix for the cart and checkout blocks is included on woocommerce/woocommerce#54386.

Amazing 💯

Old Fixed
image image

Also confirmed shortcode checkout page:
image

@alefesouza alefesouza merged commit 418e032 into trunk Jan 14, 2025
9 checks passed
@alefesouza alefesouza deleted the fix/allow-html-on-shipping-rates branch January 14, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants