Skip to content
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ Grow your business on Facebook and Instagram. Easily promote your products and t
- Sell from one inventory that automatically syncs to your catalog used for ads


### This is the development repository for the Facebook for WooCommerce plugin.
**We're excited to announce that the app is now owned by Meta, and we invite the developer community to join us in shaping its future through contributions.**

Grow your business on Facebook and Instagram. Easily promote your products and target accurately using powerful sales and marketing tools. Reach new customers and drive traffic to your website with seamless ad experiences, from discovery to conversion. Automatically sync your eligible products to your Meta catalog, so you can easily create ads right where your customers are.
- Help drive better ad performance by setting up a conversion pixel
- Easily set up your ads with a one-time account connection
- Sell from one inventory that automatically syncs to your catalog used for ads


### This is the development repository for the Facebook for WooCommerce plugin.

- [WooCommerce.com product page](https://woocommerce.com/products/facebook/)
Expand Down
14 changes: 14 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
*** Facebook for WooCommerce Changelog ***

= 3.4.4 - 2025-03-26 =
* Add - Create tests for ProductFeedUploads create endpoint by @ajello-meta in #2902
* Add - Create tests for ProductFeedUploads read endpoint by @ajello-meta in #2903
* Tweak - Remove phpcs:ignoreFile annotation + Enable code coverage report generation with phpunit by @sol-loup in #2897 and #2901
* Fix - Restores the original dynamic property behavior in the AsyncRequest class by @sol-loup in #2921
* Tweak - Changing APP to PLUGIN on README.MD by @SayanPandey in #2916
* Tweak - Update README.md - Added noification for ownership transfer by @SayanPandey in #2910
* Tweak - Added is_multisite logging to the update_plugin_version_configuration request by @carterbuce in #2955
* Tweak - Add woo_commerce_retailer_id to products API request by @crisojog in #2958
* Tweak - Syncing plugin version info by @vinkmeta in #2960
* Fix - sync products out of stock to meta despite visibility config by @francorisso in #2952
* Fix - Update woo_commerce_retailer_id to existing field external_variant_id by @crisojog in #2963
* Tweak - Update readme.txt by @vinkmeta in #2949

= 3.4.3 - 2025-03-19 =
* Add - Items batch request and response tests by @nrostrow-meta in #2917
* Tweak - Always run PHP-based github workflows by @carterbuce in #2926
Expand Down
39 changes: 34 additions & 5 deletions facebook-config-warmer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
*
Expand All @@ -11,9 +10,39 @@

defined( 'ABSPATH' ) || exit;

/**
* Class WC_Facebookcommerce_WarmConfig
*
* This class stores pre-configured Facebook Pixel settings that can be used
* to initialize the Facebook Pixel when user settings are not yet available.
* It serves as a configuration warmer for Facebook integration with WooCommerce.
*/
class WC_Facebookcommerce_WarmConfig {
static $fb_warm_pixel_id = null;
static $fb_warm_is_advanced_matching_enabled = null;
static $fb_warm_use_s2s = null;
static $fb_warm_access_token = null;
/**
* Facebook Pixel ID for tracking
*
* @var string|null
*/
public static $fb_warm_pixel_id = null;

/**
* Whether advanced matching is enabled for the Facebook Pixel
*
* @var bool|null
*/
public static $fb_warm_is_advanced_matching_enabled = null;

/**
* Whether server-side (S2S) events are enabled
*
* @var bool|null
*/
public static $fb_warm_use_s2s = null;

/**
* Facebook API access token
*
* @var string|null
*/
public static $fb_warm_access_token = null;
}
9 changes: 3 additions & 6 deletions facebook-for-woocommerce.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
*
Expand All @@ -11,7 +10,7 @@
* Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
* Author: Facebook
* Author URI: https://www.facebook.com/
* Version: 3.4.3
* Version: 3.4.4
* Requires at least: 5.6
* Requires PHP: 7.4
* Text Domain: facebook-for-woocommerce
Expand All @@ -33,7 +32,7 @@
// HPOS compatibility declaration.
add_action(
'before_woocommerce_init',
function() {
function () {
if ( class_exists( FeaturesUtil::class ) ) {
FeaturesUtil::declare_compatibility( 'custom_order_tables', plugin_basename( __FILE__ ), true );
}
Expand All @@ -49,7 +48,7 @@ class WC_Facebook_Loader {
/**
* @var string the plugin version. This must be in the main plugin file to be automatically bumped by Woorelease.
*/
const PLUGIN_VERSION = '3.4.3'; // WRCS: DEFINED_VERSION.
const PLUGIN_VERSION = '3.4.4'; // WRCS: DEFINED_VERSION.

// Minimum PHP version required by this plugin.
const MINIMUM_PHP_VERSION = '7.4.0';
Expand Down Expand Up @@ -318,8 +317,6 @@ public static function instance() {

return self::$instance;
}


}

// fire it up!
Expand Down
12 changes: 9 additions & 3 deletions includes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,18 @@ public function get_business_configuration( $external_business_id ) {
*
* @param string $external_business_id external business ID
* @param string $plugin_version The plugin version.
* @return API\Response|API\FBE\Configuration\Update\Response
* @throws WooCommerce\Facebook\Framework\Api\Exception
*
* @return Response|API\FBE\Configuration\Update\Response
* @throws ApiException
*/
public function update_plugin_version_configuration( string $external_business_id, string $plugin_version ): API\FBE\Configuration\Update\Response {
$request = new API\FBE\Configuration\Update\Request( $external_business_id );
$request->set_plugin_version( $plugin_version );
$request->set_external_client_metadata(
array(
'version_id' => $plugin_version,
'is_multisite' => is_multisite(),
)
);
$this->set_response_handler( API\FBE\Configuration\Update\Response::class );
return $this->perform_request( $request );
}
Expand Down
19 changes: 9 additions & 10 deletions includes/API/FBE/Configuration/Update/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ public function __construct( $external_business_id ) {
$this->data['fbe_external_business_id'] = $external_business_id;
}


/**
* Sets the plugin version for configuration update request.
* Sets the external client metadata for logging
*
* @since 3.4.4
*
* @since 3.0.10
* @param array $metadata map of metadata to include. Example: array ('version_id' => '0.0.0', 'is_multisite' => True)
*
* @param string $plugin_version current plugin version.
* @return void
*/
public function set_plugin_version( string $plugin_version ) {

public function set_external_client_metadata( array $metadata ) {
$this->data['business_config'] = array(
'external_client' =>
array(
'version_id' => "$plugin_version",
),
'external_client' => $metadata,
);

is_multisite();
}
}
3 changes: 1 addition & 2 deletions includes/Admin/Settings_Screens/Product_Sets.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
*
Expand All @@ -11,7 +10,7 @@

namespace WooCommerce\Facebook\Admin\Settings_Screens;

defined( 'ABSPATH' ) or exit;
defined( 'ABSPATH' ) || exit;

use WooCommerce\Facebook\Admin\Abstract_Settings_Screen;

Expand Down
6 changes: 2 additions & 4 deletions includes/Commerce.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
*
Expand All @@ -11,7 +10,7 @@

namespace WooCommerce\Facebook;

defined( 'ABSPATH' ) or exit;
defined( 'ABSPATH' ) || exit;

/**
* Base handler for Commerce-specific functionality.
Expand All @@ -28,7 +27,7 @@ class Commerce {
/**
* Gets the plugin-level fallback Google product category ID.
*
* This will be used when the category or product-level settings dont override it.
* This will be used when the category or product-level settings don't override it.
*
* @since 2.1.0
*
Expand Down Expand Up @@ -61,5 +60,4 @@ public function update_default_google_product_category_id( $id ) {

update_option( self::OPTION_GOOGLE_PRODUCT_CATEGORY_ID, is_string( $id ) ? $id : '' );
}

}
3 changes: 0 additions & 3 deletions includes/Debug/ProfilingLogger.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
// phpcs:ignoreFile

namespace WooCommerce\Facebook\Debug;

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -101,5 +99,4 @@ public function stop( $process_name ) {
protected function log( $message ) {
wc_get_logger()->log( 'debug', $message, array( 'source' => 'facebook_for_woocommerce_profiling' ) );
}

}
2 changes: 0 additions & 2 deletions includes/Debug/ProfilingLoggerProcess.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile

namespace WooCommerce\Facebook\Debug;

Expand Down Expand Up @@ -51,5 +50,4 @@ public function get_memory_used() {
public function get_time_used() {
return $this->stop_time - $this->start_time;
}

}
9 changes: 4 additions & 5 deletions includes/Events/AAMSettings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
*
Expand All @@ -11,7 +10,7 @@

namespace WooCommerce\Facebook\Events;

defined( 'ABSPATH' ) or exit;
defined( 'ABSPATH' ) || exit;

/**
* Base Automatic advanced matching settings object
Expand Down Expand Up @@ -121,7 +120,7 @@ public function get_pixel_id() {
* Sets the enable automatic matching flag
*
* @since 2.0.3
*
* @param bool $enable_automatic_matching Whether automatic matching is enabled
* @return AAMSettings
*/
public function set_enable_automatic_matching( $enable_automatic_matching ) {
Expand All @@ -133,7 +132,7 @@ public function set_enable_automatic_matching( $enable_automatic_matching ) {
* Sets the enabled automatic matching fields flag
*
* @since 2.0.3
*
* @param string[] $enabled_automatic_matching_fields Array of enabled matching fields
* @return AAMSettings
*/
public function set_enabled_automatic_matching_fields( $enabled_automatic_matching_fields ) {
Expand All @@ -145,7 +144,7 @@ public function set_enabled_automatic_matching_fields( $enabled_automatic_matchi
* Sets the pixel id
*
* @since 2.0.3
*
* @param string $pixel_id The Facebook pixel ID
* @return AAMSettings
*/
public function set_pixel_id( $pixel_id ) {
Expand Down
9 changes: 1 addition & 8 deletions includes/ExternalVersionUpdate/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Update {
* @since 3.0.10
*/
public function __construct() {
add_action( Heartbeat::HOURLY, array( $this, 'maybe_update_external_plugin_version' ) );
add_action( Heartbeat::DAILY, array( $this, 'maybe_update_external_plugin_version' ) );
}

/**
Expand All @@ -59,13 +59,6 @@ public function maybe_update_external_plugin_version() {
* @return bool
*/
public function should_update_version() {
$latest_version_sent = get_option( self::LATEST_VERSION_SENT, '0.0.0' );

if ( WC_Facebookcommerce_Utils::PLUGIN_VERSION === $latest_version_sent ) {
// Up to date. Nothing to do.
return false;
}

$plugin = facebook_for_woocommerce();

if ( ! $plugin->get_connection_handler()->is_connected() ) {
Expand Down
25 changes: 8 additions & 17 deletions includes/Feed/FeedConfigurationDetection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile

namespace WooCommerce\Facebook\Feed;

Expand Down Expand Up @@ -183,22 +182,15 @@ private function get_data_source_feed_tracker_info() {
/**
* Given catalog id this function fetches all feed configurations defined for this catalog.
*
* @throws Error Feed configurations fetch was not successful.
* @param String $catalog_id Facebook Catalog ID.
*
* @param string $product_catalog_id Facebook Catalog ID.
* @return array Array of feed configurations.
*/

/**
* @param string $product_catalog_id
*
* @return array Facebook Product Feeds.
* @throws Request_Limit_Reached
* @throws ApiException
* @throws Request_Limit_Reached When API request limit is reached.
* @throws ApiException When there is an error in the API request.
* @throws Error Feed configurations fetch was not successful.
*/
private function get_feed_nodes_for_catalog( string $product_catalog_id ) {
try {
$response = facebook_for_woocommerce()->get_api()->read_feeds($product_catalog_id);
$response = facebook_for_woocommerce()->get_api()->read_feeds( $product_catalog_id );
} catch ( \Exception $e ) {
$message = sprintf( 'There was an error trying to get feed nodes for catalog: %s', $e->getMessage() );
facebook_for_woocommerce()->log( $message );
Expand All @@ -213,8 +205,8 @@ private function get_feed_nodes_for_catalog( string $product_catalog_id ) {
* @param string $feed_id Facebook Product Feed ID.
*
* @return Response
* @throws Request_Limit_Reached
* @throws ApiException
* @throws Request_Limit_Reached When API request limit is reached.
* @throws ApiException When there is an error in the API request.
*/
private function get_feed_metadata( string $feed_id ) {
return facebook_for_woocommerce()->get_api()->read_feed( $feed_id );
Expand All @@ -230,13 +222,12 @@ private function get_feed_metadata( string $feed_id ) {
*/
private function get_feed_upload_metadata( $upload_id ) {
try {
$response = facebook_for_woocommerce()->get_api()->read_upload($upload_id);
$response = facebook_for_woocommerce()->get_api()->read_upload( $upload_id );
} catch ( \Exception $e ) {
$message = sprintf( 'There was an error trying to get feed upload metadata: %s', $e->getMessage() );
facebook_for_woocommerce()->log( $message );
return false;
}
return $response;
}

}
3 changes: 1 addition & 2 deletions includes/Framework/Plugin/Exception.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
// phpcs:ignoreFile
/**
* Facebook for WooCommerce.
*/

namespace WooCommerce\Facebook\Framework\Plugin;

defined( 'ABSPATH' ) or exit;
defined( 'ABSPATH' ) || exit;

/**
* Plugin Framework Exception - generic Exception
Expand Down
Loading