Automattic / woocommerce-subscriptions-core

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

Shipping Method Selection Conflict with Local Pickup Block #399

Open mikejolley opened 1 year ago

mikejolley commented 1 year ago

Describe the bug

WooCommerce Blocks has a dedicated block for selecting Local Pickup during checkout. There is a dedicated P2 about this functionality here for reference.

Due to the way subscriptions splits carts into multiple carts to handle recurring billing, there is a conflict when it comes to shipping method selection. This screenshot shows the behaviour you see:

Screenshot 2023-01-30 at 11 28 34

To Reproduce

  1. Go to Settings > Shipping > Local Pickup. Enable it and create some pickup locations.
  2. Ensure another shipping method, such as a flat rate, is also enabled.
  3. Add both subscription and regular products to your cart.
  4. Go to checkout.
  5. Select Local Pickup.
  6. See how the rates are not updated for recurring carts (see above screenshot).

Expected behavior

When you select Local Pickup, the shipping method for the recurring carts should also switch to Local Pickup.

Actual behavior

When you select Local Pickup, the shipping method for the recurring carts remains as default and cannot be changed.

Product impact

Additional context

A potential/partial solution to keep recurring and regular carts in sync was created here https://github.com/Automattic/woocommerce-subscriptions-core/pull/264 however this is no longer applicable because we're not passing a null package ID. The action would receive package ID 0 (when local pickup is used, only one package is supported).

Therefore the logic in subscriptions needs to be either:

  1. A local pickup rate ID was returned, so set all recurring carts to local pickup.

or

  1. Create (via slot fills) an interface to select shipping methods (or pickup) for each recurring package separately.

cc @senadir

opr commented 1 year ago

Hey folks, I have pushed some changes on add/blocks-local-pickup which can be used to kick start the work on integrating with WC blocks.

Please note the PR in WC blocks to add LocalPickupSelect is still under review, so no guarantee it will be merged yet.

To summarise the changes so far on that branch:

Let me know if this is a good approach, or if you need help with anything, I'll be happy to assist.