Skip to content

Fix product variation fields not saving correctly#3090

Closed
devbodaghe wants to merge 3 commits intofacebook:mainfrom
devbodaghe:fix/variation-fields-saving
Closed

Fix product variation fields not saving correctly#3090
devbodaghe wants to merge 3 commits intofacebook:mainfrom
devbodaghe:fix/variation-fields-saving

Conversation

@devbodaghe
Copy link
Copy Markdown
Contributor

Fix Product Variation Fields Not Saving Correctly

Description

This PR fixes an issue where product variation custom fields for Facebook for WooCommerce were not being properly saved and displayed. Specifically, the MPN (Manufacturer Part Number) and custom image URL values weren't being preserved when saving product variations.

The issue was caused by two main problems:

  1. The MPN field was being incorrectly formatted as a decimal number with wc_format_decimal() when rendered, which is inappropriate for an alphanumeric identifier
  2. The custom image URL was potentially being overwritten due to variable reuse in the save logic

These bugs prevented merchants from properly configuring their product variations for Facebook Catalog sync.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
  • I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
  • I followed general Pull Request best practices. Meta employees to follow this wiki.
  • I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
  • I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
  • I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this wiki.

Changelog entry

Fix issue where product variation MPN and custom image URL fields weren't being properly saved and displayed.

Test Plan

  1. Create a variable product with at least one variation
  2. Enable Facebook sync for the variation
  3. Set a custom MPN value (e.g., "ABC12345") and a custom image URL
  4. Save the product
  5. Reload the product edit page
  6. Verify that the MPN and custom image URL values have been preserved

Screenshots

Before

When saving product variations, the MPN field and custom image URL would not persist after saving.

After

The MPN field and custom image URL now correctly display and save the values entered by users.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@devbodaghe merged this pull request in 80b9ecf.

tzahgr pushed a commit that referenced this pull request Apr 28, 2025
Summary:
# Fix Product Variation Fields Not Saving Correctly

## Description

This PR fixes an issue where product variation custom fields for Facebook for WooCommerce were not being properly saved and displayed. Specifically, the MPN (Manufacturer Part Number) and custom image URL values weren't being preserved when saving product variations.

The issue was caused by two main problems:
1. The MPN field was being incorrectly formatted as a decimal number with `wc_format_decimal()` when rendered, which is inappropriate for an alphanumeric identifier
2. The custom image URL was potentially being overwritten due to variable reuse in the save logic

These bugs prevented merchants from properly configuring their product variations for Facebook Catalog sync.

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
- [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
- [x] I followed general Pull Request best practices. Meta employees to follow this [wiki](https://fburl.com/wiki/2cgfduwc).
- [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
- [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
- [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki](https://fburl.com/wiki/nhx73tgs).

## Changelog entry

Fix issue where product variation MPN and custom image URL fields weren't being properly saved and displayed.

Pull Request resolved: #3090

Test Plan:
1. Create a variable product with at least one variation
2. Enable Facebook sync for the variation
3. Set a custom MPN value (e.g., "ABC12345") and a custom image URL
4. Save the product
5. Reload the product edit page
6. Verify that the MPN and custom image URL values have been preserved

## Screenshots
### Before

 https://pxl.cl/74Rzv

When saving product variations, the MPN field and custom image URL would not persist after saving.

### After

https://pxl.cl/74Rzk

The MPN field and custom image URL now correctly display and save the values entered by users.

Reviewed By: carterbuce

Differential Revision:
D73611087

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 5308dfb808e63055d033b3da847fde32d0b62885
devbodaghe pushed a commit to devbodaghe/facebook-for-woocommerce that referenced this pull request May 1, 2025
Summary:
# Fix Product Variation Fields Not Saving Correctly

## Description

This PR fixes an issue where product variation custom fields for Facebook for WooCommerce were not being properly saved and displayed. Specifically, the MPN (Manufacturer Part Number) and custom image URL values weren't being preserved when saving product variations.

The issue was caused by two main problems:
1. The MPN field was being incorrectly formatted as a decimal number with `wc_format_decimal()` when rendered, which is inappropriate for an alphanumeric identifier
2. The custom image URL was potentially being overwritten due to variable reuse in the save logic

These bugs prevented merchants from properly configuring their product variations for Facebook Catalog sync.

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
- [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
- [x] I followed general Pull Request best practices. Meta employees to follow this [wiki](https://fburl.com/wiki/2cgfduwc).
- [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
- [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
- [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki](https://fburl.com/wiki/nhx73tgs).

## Changelog entry

Fix issue where product variation MPN and custom image URL fields weren't being properly saved and displayed.

Pull Request resolved: facebook#3090

Test Plan:
1. Create a variable product with at least one variation
2. Enable Facebook sync for the variation
3. Set a custom MPN value (e.g., "ABC12345") and a custom image URL
4. Save the product
5. Reload the product edit page
6. Verify that the MPN and custom image URL values have been preserved

## Screenshots
### Before

 https://pxl.cl/74Rzv

When saving product variations, the MPN field and custom image URL would not persist after saving.

### After

https://pxl.cl/74Rzk

The MPN field and custom image URL now correctly display and save the values entered by users.

Reviewed By: carterbuce

Differential Revision:
D73611087

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 5308dfb808e63055d033b3da847fde32d0b62885
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants