Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
87 stars 33 forks source link

"Used for variations" is unchecked when Variable Subscription product is updated #480

Closed kaushikasomaiya closed 1 year ago

kaushikasomaiya commented 1 year ago

6566198-zen

Tested on latest versions of WCPay, WooCommerce and WooCommerce Subscriptions as well.

When a variable subscription product is updated without changing anything - the "Used for variations" box is unchecked.

Video: https://d.pr/v/ZCtaOt

Replicate:

  1. Create a variable subscription product using 1 attribute
  2. Publish it, everything is good up to this point
  3. Press "Update" button repeatedly without changing anything in the Product data area. (Avoid viewing Attributes or variations tab)
  4. See the issue.

On preliminary inspection, it appears that attribute_variation%5B0%5D=1 is not passed in the POST request when we do not click on Attributes or Variations tab.

mattallan commented 1 year ago

Hi @kaushikasomaiya thanks for creating an issue for this.

I'm having trouble replicating this issue on my local store but I'm curious, are you able to replicate the same behavior on a regular WooCommerce variable product as well?

From my understanding, the reason you're hvaing this issue is because you're pressing save/update while the "Used for variations" checkbox is still disabled which is then causing it to be saved as unchecked.

With changes to WC 7.9.0, this checkbox is now loaded onto the page as disabled by default and then later enabled by the JS, and in subscriptions we hook onto the same code that WC uses to enable this for variable products which is why I'm thinking this issue might also exist for non-subscription variable products.

kaushikasomaiya commented 1 year ago

Hi @mattallan

I'm having trouble replicating this issue on my local store but I'm curious, are you able to replicate the same behavior on a regular WooCommerce variable product as well?

No, the regular variable product works well - they do include attribute_variation%5B0%5D=1 in POST request.

From my understanding, the reason you're hvaing this issue is because you're pressing save/update while the "Used for variations" checkbox is still disabled which is then causing it to be saved as unchecked.

When I go to the Attributes tab - the Used for variations is not disabled.

The issue only occurs if we do not click on Variations or Attributes tab and press the Update button directly on a variable subscription product.

It can't be replicated if we click on Variations or Attributes tab and then update.

kaushikasomaiya commented 1 year ago

@mattallan Here's a new video that will help you with steps to replicate: https://d.pr/v/I1W2Mm

mattallan commented 1 year ago

Thanks @kaushikasomaiya, I've found out that I wasn't able to replicate this bug when I had WooCommerce Square installed. After deactivating that plugin, I can now reproduce it locally 🤔

nicdwilson commented 1 year ago

6578999-zen 6574159-zen

mattallan commented 1 year ago

Hey @nicdwilson & @kaushikasomaiya, this fix has been shipped in WooCommerce Subscriptions 5.3.1

Cheers!