Skip to content

[New Feature] Adding Commerce Partner Integration repair and update API endpoint#3091

Closed
jczhuoMeta wants to merge 16 commits intomainfrom
cpi-repair-and-update
Closed

[New Feature] Adding Commerce Partner Integration repair and update API endpoint#3091
jczhuoMeta wants to merge 16 commits intomainfrom
cpi-repair-and-update

Conversation

@jczhuoMeta
Copy link
Copy Markdown
Contributor

@jczhuoMeta jczhuoMeta commented Apr 24, 2025

Description

  1. For sellers onboarded before the Shops release, they won't have CPI created for them
  2. The extension will send configs to Meta to help Meta provide more reliable Shops integration

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

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

Add Commerce Integration repair and updating capability

Test Plan

  • Added new test

Manual

Using the following script in wp-console for testing:

$fb_plugin = facebook_for_woocommerce();

// Get the connection handler
$connection = $fb_plugin->get_connection_handler();
echo "Commerce Partner Integration ID: " . $connection->get_commerce_partner_integration_id() . "\n";

// Test the repair_or_update_commerce_integration_data function
try {
    $connection->repair_or_update_commerce_integration_data();
    echo "Successfully executed repair_or_update_commerce_integration_data\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

// Print out the current commerce integration data for verification
echo "\nCurrent Commerce Integration Data:\n";
echo "Commerce Partner Integration ID: " . $connection->get_commerce_partner_integration_id() . "\n";
echo "Commerce Merchant Settings ID: " . $connection->get_commerce_merchant_settings_id() . "\n";
echo "Business Manager ID: " . $connection->get_business_manager_id() . "\n";
echo "External Business ID: " . $connection->get_external_business_id() . "\n";

Output:

Commerce Partner Integration ID: 2477569805929631
Successfully executed repair_or_update_commerce_integration_data

Current Commerce Integration Data:
Commerce Partner Integration ID: 2477569805929631
Commerce Merchant Settings ID: 1119731910169300
Business Manager ID: 1507232916668297
External Business ID: woometa-67e6db5c280b9

Tested cases:

  1. Updating fields in existing CPI
  2. Delete wc_facebook_commerce_partner_integration_id in wc db, the id will be retrieved from Meta and backfill into wc db
  3. Deleted CPI ent from Meta side. Call repair endpoint it will create a new one

@facebook-github-bot
Copy link
Copy Markdown
Contributor

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

@jczhuoMeta jczhuoMeta marked this pull request as ready for review April 24, 2025 20:59
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@jczhuoMeta 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

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

facebook-github-bot pushed a commit that referenced this pull request May 1, 2025
…3091)

Summary:
## Description
1. For sellers onboarded before the Shops release, they won't have CPI created for them
2. The extension will send configs to Meta to help Meta provide more reliable Shops integration

### Type of change

Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)

## 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]([url](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]([url](https://fburl.com/wiki/nhx73tgs)).


## Changelog entry

Add Commerce Integration repair and updating capability


Test Plan:
* Added new test

### Manual
Using the following script in wp-console for testing:
```
$fb_plugin = facebook_for_woocommerce();

// Get the connection handler
$connection = $fb_plugin->get_connection_handler();
echo "Commerce Partner Integration ID: " . $connection->get_commerce_partner_integration_id() . "\n";

// Test the repair_or_update_commerce_integration_data function
try {
    $connection->repair_or_update_commerce_integration_data();
    echo "Successfully executed repair_or_update_commerce_integration_data\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

// Print out the current commerce integration data for verification
echo "\nCurrent Commerce Integration Data:\n";
echo "Commerce Partner Integration ID: " . $connection->get_commerce_partner_integration_id() . "\n";
echo "Commerce Merchant Settings ID: " . $connection->get_commerce_merchant_settings_id() . "\n";
echo "Business Manager ID: " . $connection->get_business_manager_id() . "\n";
echo "External Business ID: " . $connection->get_external_business_id() . "\n";
```

Output:
```
Commerce Partner Integration ID: 2477569805929631
Successfully executed repair_or_update_commerce_integration_data

Current Commerce Integration Data:
Commerce Partner Integration ID: 2477569805929631
Commerce Merchant Settings ID: 1119731910169300
Business Manager ID: 1507232916668297
External Business ID: woometa-67e6db5c280b9
```

Tested cases:
1. Updating fields in existing CPI
2. Delete `wc_facebook_commerce_partner_integration_id` in wc db, the id will be retrieved from Meta and backfill into wc db
3. Deleted CPI ent from Meta side. Call repair endpoint it will create a new one

**!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!**
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V3 
https://internalfb.com/intern/testinfra/testrun/10696049195492144
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V3 
https://internalfb.com/intern/testinfra/testrun/9570149288637452

Reviewed By: carterbuce

Differential Revision: D73615792

Pulled By: jczhuoMeta
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D73615792

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@jczhuoMeta 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

@jczhuoMeta 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

@jczhuoMeta merged this pull request in 71ba69f.

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