Automattic / woocommerce-subscriptions-core

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

Fix subscription product sync options for yearly products not being editable #576

Closed james-allan closed 3 months ago

james-allan commented 3 months ago

Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4588

Description

In https://github.com/Automattic/woocommerce-subscriptions-core/pull/508, the number input elements that enable store admin to select the day of the month for which yearly subscription products are synced to was changed from a <input type="number" ... > to a select2 (by giving it the wc-enhanced-select class. This essentially broke these elements because attempting to turn input elements into a select2 powered element didn't work - ie they had no options.

Screenshot 2024-03-09 at 10 43 12 am

This PR fixes this by turning these elements into true select2 elements via <select> and <option> elements.

Screenshot 2024-03-09 at 3 35 06 pm

How to test this PR

Simple Subscription.

  1. Go to Products → Add new
  2. Choose Simple subscription from the product type dropdown.
  3. Enter a price and choose "yearly" as the subscription period.
  4. In the "Synchronise renewals" section choose a month
  5. Try to set a day.
  6. On trunk you'll notice the dropdown is empty.
  7. On this branch it should have all the days of the chosen month. eg
    • 28 for February
    • 30 for September
    • 31 for January
Before After
Screenshot 2024-03-14 at 3 48 28 pm Screenshot 2024-03-14 at 3 54 13 pm
  1. Confirm that saving the synchronisation product is correctly sets the product as a synced product to that date.
  2. Confirm that unselecting a month option unsets the synchronisation property from the product.
  3. Confirm that weekly, monthly products are unaffected by this change.

Variable Subscription

  1. Go to Products → Add new
  2. Choose Variable subscription from the product type dropdown.
  3. Create variations
  4. Enter a price and choose "yearly" as the subscription period.
  5. In the "Synchronise renewals" section choose a month (eg January)
  6. Try to set a day.
  7. On trunk you'll notice the date selector is a number input.
  8. On this branch it should be select2 with all the days of the chosen month as options. eg
    • 28 for February
    • 30 for September
    • 31 for January
Before After
Screenshot 2024-03-14 at 4 14 05 pm Screenshot 2024-03-14 at 4 15 13 pm

Product impact

james-allan commented 3 months ago

I didn't realise the fields I changed in this PR were that off. I guess everything else being out of line made that harder to see.

I've pushed a few commits that fix those alignment issues.

Simple Subscription

Screenshot 2024-03-18 at 4 26 25 pm
Weekly products only have 1 sync element Screenshot 2024-03-18 at 4 27 05 pm Yearly products only have 2 sync elements

Variable Subscription

Screenshot 2024-03-18 at 2 29 58 pm

james-allan commented 3 months ago

Hey Matt. I think I've fixed all those issues now. 😅

Simple product

Yearly (2 sync fields) Weekly (1 sync field)
Screenshot 2024-03-21 at 5 47 00 pm Screenshot 2024-03-21 at 5 46 52 pm

Variable product

Yearly (2 sync fields) Weekly (1 sync field)
Screenshot 2024-03-21 at 5 49 01 pm Screenshot 2024-03-21 at 5 49 21 pm