Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ class WC_Facebookcommerce_Integration extends WC_Integration {
/** @var string the WordPress option name where the merchant access token is stored */
const OPTION_MERCHANT_ACCESS_TOKEN = 'wc_facebook_merchant_access_token';

/** @var string the WordPress option name where the business manager ID is stored */
const OPTION_BUSINESS_MANAGER_ID = 'wc_facebook_business_manager_id';

/** @var string the WordPress option name where the ad account ID is stored */
const OPTION_AD_ACCOUNT_ID = 'wc_facebook_ad_account_id';

/** @var string the WordPress option name where the system user ID is stored */
const OPTION_SYSTEM_USER_ID = 'wc_facebook_system_user_id';

/** @var string the WordPress option name where the commerce merchant settings ID is stored */
const OPTION_COMMERCE_MERCHANT_SETTINGS_ID = 'wc_facebook_commerce_merchant_settings_id';

Expand Down
11 changes: 11 additions & 0 deletions includes/API/FBE/Installation/Read/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ public function get_commerce_merchant_settings_id() {
return $this->get_data()['commerce_merchant_settings_id'] ?? '';
}

/**
* Gets the commerce partner integration ID.
*
* @since 3.5.0
*
* @return string
*/
public function get_commerce_partner_integration_id() {
return $this->get_data()['commerce_partner_integration_id'] ?? '';
}


/**
* Gets the profiles.
Expand Down
8 changes: 8 additions & 0 deletions includes/API/Plugin/Settings/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ private function map_params_to_options( array $params ): array {
$options[ \WC_Facebookcommerce_Integration::OPTION_PROFILES ] = $params['profiles'];
}

if ( ! empty( $params['business_manager_id'] ) ) {
$options[ \WC_Facebookcommerce_Integration::OPTION_BUSINESS_MANAGER_ID ] = $params['business_manager_id'];
}

return $options;
}

Expand Down Expand Up @@ -239,6 +243,10 @@ private function update_connection_status( array $params ) {
private function clear_integration_options() {
$options = [
\WC_Facebookcommerce_Integration::OPTION_ACCESS_TOKEN,
\WC_Facebookcommerce_Integration::OPTION_BUSINESS_MANAGER_ID,
\WC_Facebookcommerce_Integration::OPTION_AD_ACCOUNT_ID,
\WC_Facebookcommerce_Integration::OPTION_SYSTEM_USER_ID,
\WC_Facebookcommerce_Integration::OPTION_FEED_ID,
\WC_Facebookcommerce_Integration::OPTION_COMMERCE_MERCHANT_SETTINGS_ID,
\WC_Facebookcommerce_Integration::OPTION_COMMERCE_PARTNER_INTEGRATION_ID,
\WC_Facebookcommerce_Integration::OPTION_ENABLE_MESSENGER,
Expand Down
8 changes: 6 additions & 2 deletions includes/Admin/Settings_Screens/Shops.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ public function generate_inline_enhanced_onboarding_script() {
const messageEvent = message.event;

if (messageEvent === 'CommerceExtension::INSTALL' && message.success) {
const cms_id = message.installed_features.find( ( f ) => 'fb_shop' === f.feature_type )?.connected_assets?.commerce_merchant_settings_id ||
message.installed_features.find( ( f ) => 'ig_shopping' === f.feature_type )?.connected_assets?.commerce_merchant_settings_id || '';
const ad_account_id = message.installed_features.find( ( f ) => 'ads' === f.feature_type )?.connected_assets?.ad_account_id || '';

const requestBody = {
access_token: message.access_token,
merchant_access_token: message.access_token,
Expand All @@ -394,8 +398,8 @@ public function generate_inline_enhanced_onboarding_script() {
pixel_id: message.pixel_id,
page_id: message.page_id,
business_manager_id: message.business_manager_id,
commerce_merchant_settings_id: message.installed_features.find(f => f.feature_type === 'fb_shop')?.connected_assets?.commerce_merchant_settings_id || '',
ad_account_id: message.installed_features.find(f => f.feature_type === 'ads')?.connected_assets?.ad_account_id || '',
commerce_merchant_settings_id: cms_id,
ad_account_id: ad_account_id,
commerce_partner_integration_id: message.commerce_partner_integration_id || '',
profiles: message.profiles,
installed_features: message.installed_features
Expand Down
6 changes: 6 additions & 0 deletions includes/Handlers/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ private function update_installation_data() {
if ( $response->get_commerce_merchant_settings_id() ) {
$this->update_commerce_merchant_settings_id( sanitize_text_field( $response->get_commerce_merchant_settings_id() ) );
}

if ( $response->get_commerce_partner_integration_id() ) {
$this->update_commerce_partner_integration_id( sanitize_text_field( $response->get_commerce_partner_integration_id() ) );
} else {
$this->update_commerce_partner_integration_id( "" );
}
}


Expand Down