Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
80 stars 29 forks source link

Add `highlightChecked` prop to the `ShippingRatesControlPackage` in WC Blocks integration #593

Closed opr closed 2 months ago

opr commented 2 months ago

This PR is part of https://github.com/woocommerce/woocommerce/pull/46150 and should be merged in time for WC 8.9. Ideally WC Subscriptions will ship this patch before WC 8.9 is released.

Description

This PR adds new props to the ShippingRatesControlPackage used to display the recurring shipping packages. The purpose of them are to allow the selected method to be highlighted in the Checkout block.

context is whether the component is rendered in the Cart or Checkout block and highlightChecked determines if the checked option should be highlighted.

This change needs to be made here as well as in WC Core because we default to not highlighting the selected item to preserve backward compatibility with any other consumers of the component.

How to test this PR

  1. Be using https://github.com/woocommerce/woocommerce/pull/46150 or latest WC Core trunk if that is merged already.
  2. Create 3 subscription items with different lengths, (weekly, yearly, monthly)
  3. Add them to your cart and go to the Cart block.
  4. Ensure the shipping options in the sidebar show correctly, i.e. without borders around each rate.
image
  1. Go to the Checkout block. Ensure you can see the additional packages, and that they do have borders around each rate
image
  1. Switch back to WC Core trunk and run the tests again, the borders won't show but please ensure the shipping selectors for recurring packages still work and can change the method.

Product impact

opr commented 2 months ago

@james-allan thanks a lot for the review, and for the confirmation and screenshots of each step, that's great.

I would prefer to get the WC Blocks PR merged first (just so we know that the approach is correct, and the highlightChecked prop will be added to the component).

When is the next release after April 11?

Thanks!

james-allan commented 2 months ago

When is the next release after April 11?

We release on the second Thursday of each month so May 9th will be the next scheduled release.

opr commented 2 months ago

That's fantastic, thanks. WC 8.9 is slated for release on May 9th, so this works OK. I will see if we can't get it merged before 11th April though.