+ `;
+ $('#events-error-notice').html(errorNoticeHtml).show();
+ }
+ });
+ });
+
+ function getEventLanguage(event) {
+ switch (event) {
+ case "ORDER_PLACED":
+ return facebook_for_woocommerce_whatsapp_events.order_placed_language;
+ case "ORDER_FULFILLED":
+ return facebook_for_woocommerce_whatsapp_events.order_fulfilled_language;
+ case "ORDER_REFUNDED":
+ return facebook_for_woocommerce_whatsapp_events.order_refunded_language;
+ default:
+ return null;
+ }
+ }
+});
\ No newline at end of file
diff --git a/assets/js/admin/whatsapp-finish.js b/assets/js/admin/whatsapp-finish.js
new file mode 100644
index 000000000..98d22e8ea
--- /dev/null
+++ b/assets/js/admin/whatsapp-finish.js
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
+ *
+ * This source code is licensed under the license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @package FacebookCommerce
+ */
+
+jQuery( document ).ready( function( $ ) {
+ // handle the whatsapp finish button click
+ $( '#wc-whatsapp-onboarding-finish' ).click( function( event ) {
+ // call the connect API to create configs and check payment
+ $.post( facebook_for_woocommerce_whatsapp_finish.ajax_url, {
+ action: 'wc_facebook_whatsapp_finish_onboarding',
+ nonce: facebook_for_woocommerce_whatsapp_finish.nonce
+ }, function ( response ) {
+ if ( response.success ) {
+ // If success, redirect to utility settings page
+ let url = new URL(window.location.href);
+ let params = new URLSearchParams(url.search);
+ params.set('view', 'utility_settings');
+ url.search = params.toString();
+ window.location.href = url.toString();
+ console.log( 'Whatsapp Connect Success', response );
+ } else {
+ var message;
+ const error = response.data;
+ console.log( 'Whatsapp Connect Failure', response );
+
+ switch (error) {
+ case "Incorrect payment setup":
+ message = facebook_for_woocommerce_whatsapp_finish.i18n.payment_setup_error;
+ break;
+ case "Onboarding is not complete or has failed.":
+ message = facebook_for_woocommerce_whatsapp_finish.i18n.onboarding_incomplete_error;
+ break;
+ default:
+ message = facebook_for_woocommerce_whatsapp_finish.i18n.generic_error;
+ }
+
+
+ const errorNoticeHtml = `
+
+
${message}
+
+ `;
+ $( '#payment-method-error-notice' ).html( errorNoticeHtml ).show();
+ }
+ } );
+ });
+
+} );
diff --git a/assets/js/admin/whatsapp-templates.js b/assets/js/admin/whatsapp-templates.js
new file mode 100644
index 000000000..5fd150242
--- /dev/null
+++ b/assets/js/admin/whatsapp-templates.js
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
+ *
+ * This source code is licensed under the license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @package FacebookCommerce
+ */
+
+jQuery( document ).ready( function( $ ) {
+ // handle whatsapp view insights link click should open template insights in WhatsSpp Manager
+ $( '#woocommerce-whatsapp-manager-insights' ).click( function( event ) {
+ $.post( facebook_for_woocommerce_whatsapp_templates.ajax_url, {
+ action: 'wc_facebook_whatsapp_fetch_url_info',
+ nonce: facebook_for_woocommerce_whatsapp_templates.nonce
+ }, function ( response ) {
+ console.log(response);
+ if ( response.success ) {
+ console.log( 'Whatsapp Template Insights Info was fetched successfully', response );
+ var business_id = response.data.business_id;
+ var asset_id = response.data.waba_id;
+ const MANAGE_TEMPLATES_URL = `https://business.facebook.com/latest/whatsapp_manager/message_templates?business_id=${business_id}&asset_id=${asset_id}`;
+ window.open(MANAGE_TEMPLATES_URL);
+ }
+ else {
+ console.log( 'Whatsapp Template Insights Info fetch call failed', response );
+ }
+ } );
+ });
+} );
diff --git a/changelog.txt b/changelog.txt
index 4cbba4b58..d1a709b73 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,5 +1,27 @@
*** Facebook for WooCommerce Changelog ***
+= 3.4.9 - 2025-05-14 =
+* Add - Support for rollout switches in the plugin to control feature rollouts from meta side @francorisso in #3126
+* Fix - Tests in the rollout switches file by @francorisso in #3146
+* Fix - RolloutSwitches Init by @carterbuce in #3157
+* Add - Integrate Whatsapp Utility Messaging for WooCommerce Order Update Notifications by @sharunaanandraj in #3164
+* Tweak - Improve Test Filter Management with AbstractWPUnitTestWithSafeFiltering by @sol-loup in #2944
+* Fix - Namespacing issue causing some tests to be skipped @sol-loup in #3037
+* Tweak - Additional logs and timeout for Utility Message Flows by @woo-ardsouza in #3171
+* Fix - The WAUM payment progress to only Show Up after Consent Collection is Enabled by @sharunaanandraj in #3175
+* Tweak - Update language dropdown based on supported_languages in GET api response by @woo-ardsouza in #3178
+* Add - Error notice to gracefully handle errors in Manage Events view by @woo-ardsouza in #3179
+* Fix - The Status on the Whatsapp Consent Collection Pill and Button @sharunaanandraj in #3183
+* Tweak - Update Message Sending API from Messages to Message Events by @woo-ardsouza in #3182
+* Tweak - Update the Authentication mechanism for Whatsapp Webhook by @sharunaanandraj #3186
+* Tweak - Minor design updates to Utility Event Settings card by @woo-ardsouza in #3193
+* Add - Admin notice for WhatsApp utility messaging recruitment @iodic in #3177
+* Fix - The product sync button showing up twice by @sharunaanandraj in #3199
+* Tweak - Bump WooCommerce and WordPress compatibility by @iodic in #3200
+* Add - An automated process that synchronizes all WooCommerce product categories with Meta, creating catalog product sets for each category. The synchronization process ensures that any changes made to the WooCommerce product categories are reflected in the corresponding Meta catalog product sets by @mshymon in #3168
+* Add - A banner in product sets tab to explain recent changes to product sets sync by @mshymon in #3207
+* Add - Admin notice for WhatsApp utility messaging recruitment by @iodic in #3211
+
= 3.4.8 - 2025-05-06 =
* Add - Feature to sync global attributes to Meta and test API format by @devbodaghe in #3050
* Fix - Facebook attribute dropdown display and syncing issues by @devbodaghe in #3051
diff --git a/class-wc-facebookcommerce.php b/class-wc-facebookcommerce.php
index 119b63133..9d30fa266 100644
--- a/class-wc-facebookcommerce.php
+++ b/class-wc-facebookcommerce.php
@@ -82,6 +82,9 @@ class WC_Facebookcommerce extends WooCommerce\Facebook\Framework\Plugin {
private $sync_background_handler;
/** @var WooCommerce\Facebook\ProductSets\Sync product sets sync handler */
+ private $legacy_product_sets_sync_handler;
+
+ /** @var WooCommerce\Facebook\ProductSets\ProductSetSync product sets sync handler */
private $product_sets_sync_handler;
/** @var WooCommerce\Facebook\Handlers\Connection connection handler */
@@ -90,6 +93,9 @@ class WC_Facebookcommerce extends WooCommerce\Facebook\Framework\Plugin {
/** @var WooCommerce\Facebook\Handlers\WebHook webhook handler */
private $webhook_handler;
+ /** @var WooCommerce\Facebook\Handlers\Whatsapp_WebHook whatsapp webhook handler */
+ private $whatsapp_webhook_handler;
+
/** @var WooCommerce\Facebook\Commerce commerce handler */
private $commerce_handler;
@@ -111,6 +117,9 @@ class WC_Facebookcommerce extends WooCommerce\Facebook\Framework\Plugin {
/** @var WooCommerce\Facebook\Products\FBCategories instance. */
private $fb_categories;
+ /** @var WooCommerce\Facebook\RolloutSwitches instance. */
+ private $rollout_switches;
+
/**
* The Debug tools instance.
*
@@ -160,6 +169,7 @@ public function init() {
add_action( 'init', array( $this, 'get_integration' ) );
add_action( 'init', array( $this, 'register_custom_taxonomy' ) );
add_action( 'add_meta_boxes_product', array( $this, 'remove_product_fb_product_set_metabox' ), 50 );
+ add_action( 'woocommerce_init', array($this, 'add_whatsapp_consent_checkout_fields'));
add_filter( 'fb_product_set_row_actions', array( $this, 'product_set_links' ) );
add_filter( 'manage_edit-fb_product_set_columns', array( $this, 'manage_fb_product_set_columns' ) );
@@ -183,16 +193,16 @@ public function init() {
$this->heartbeat = new Heartbeat( WC()->queue() );
$this->heartbeat->init();
-
- $this->product_feed = new WooCommerce\Facebook\Products\Feed();
- $this->products_stock_handler = new WooCommerce\Facebook\Products\Stock();
- $this->products_sync_handler = new WooCommerce\Facebook\Products\Sync();
- $this->sync_background_handler = new WooCommerce\Facebook\Products\Sync\Background();
- $this->configuration_detection = new WooCommerce\Facebook\Feed\FeedConfigurationDetection();
- $this->product_sets_sync_handler = new WooCommerce\Facebook\ProductSets\Sync();
- $this->commerce_handler = new WooCommerce\Facebook\Commerce();
- $this->fb_categories = new WooCommerce\Facebook\Products\FBCategories();
- $this->external_version_update = new WooCommerce\Facebook\ExternalVersionUpdate\Update();
+ $this->product_feed = new WooCommerce\Facebook\Products\Feed();
+ $this->products_stock_handler = new WooCommerce\Facebook\Products\Stock();
+ $this->products_sync_handler = new WooCommerce\Facebook\Products\Sync();
+ $this->sync_background_handler = new WooCommerce\Facebook\Products\Sync\Background();
+ $this->configuration_detection = new WooCommerce\Facebook\Feed\FeedConfigurationDetection();
+ $this->legacy_product_sets_sync_handler = new WooCommerce\Facebook\ProductSets\Sync();
+ $this->product_sets_sync_handler = new WooCommerce\Facebook\ProductSets\ProductSetSync();
+ $this->commerce_handler = new WooCommerce\Facebook\Commerce();
+ $this->fb_categories = new WooCommerce\Facebook\Products\FBCategories();
+ $this->external_version_update = new WooCommerce\Facebook\ExternalVersionUpdate\Update();
if ( wp_doing_ajax() ) {
$this->ajax = new WooCommerce\Facebook\AJAX();
@@ -213,23 +223,28 @@ public function init() {
$this->connection_handler = new WooCommerce\Facebook\Handlers\Connection( $this );
$this->webhook_handler = new WooCommerce\Facebook\Handlers\WebHook( $this );
+ $this->whatsapp_webhook_handler = new WooCommerce\Facebook\Handlers\Whatsapp_Webhook( $this );
$this->tracker = new WooCommerce\Facebook\Utilities\Tracker();
+ $this->rollout_switches = new WooCommerce\Facebook\RolloutSwitches( $this );
+
// Init jobs
$this->job_manager = new WooCommerce\Facebook\Jobs\JobManager();
add_action( 'init', [ $this->job_manager, 'init' ] );
+ add_action( 'admin_init', [ $this->rollout_switches, 'init' ] );
// Instantiate the debug tools.
$this->debug_tools = new DebugTools();
// load admin handlers, before admin_init
if ( is_admin() ) {
- $this->admin_settings = new WooCommerce\Facebook\Admin\Settings( $this->connection_handler->is_connected() );
+ $this->admin_settings = new WooCommerce\Facebook\Admin\Settings( $this );
}
}
}
+
/**
* Initializes the admin handling.
*
@@ -588,6 +603,17 @@ public function get_products_sync_handler() {
return $this->products_sync_handler;
}
+ /**
+ * Gets the products sync handler.
+ *
+ * @since 3.4.9
+ *
+ * @return WooCommerce\Facebook\ProductSets\ProductSetSync
+ */
+ public function get_product_sets_sync_handler() {
+ return $this->product_sets_sync_handler;
+ }
+
/**
* Gets the products sync background handler.
@@ -770,6 +796,15 @@ public function get_asset_build_dir_url() {
return $this->get_plugin_url() . '/assets/build';
}
+ /**
+ * Gets the connection handler.
+ *
+ * @return WooCommerce\Facebook\RolloutSwitches
+ */
+ public function get_rollout_switches() {
+ return $this->rollout_switches;
+ }
+
/** Conditional methods ***************************************************************************************/
@@ -843,6 +878,30 @@ protected function get_current_page_id() {
}
return $current_screen_id;
}
+
+ /**
+ * Add checkout fields to collect whatsapp consent if consent collection is enabled
+ *
+ * @since 2.3.0
+ *
+ * @param array $fields
+ *
+ * @return array
+ */
+ function add_whatsapp_consent_checkout_fields($fields) {
+ if (get_option('wc_facebook_whatsapp_consent_collection_setting_status', 'disabled') === 'enabled') {
+ woocommerce_register_additional_checkout_field(
+ array(
+ 'id' => 'wc_facebook/whatsapp_consent_checkbox', // id = namespace/field_name
+ 'label' => esc_html('Get order updates on WhatsApp'),
+ 'location' => 'address',
+ 'type' => 'checkbox',
+ 'optionalLabel' => esc_html('Get order updates on WhatsApp')
+ )
+ );
+ }
+ return $fields;
+ }
}
diff --git a/facebook-commerce-admin-banner.php b/facebook-commerce-admin-banner.php
new file mode 100644
index 000000000..d134cf561
--- /dev/null
+++ b/facebook-commerce-admin-banner.php
@@ -0,0 +1,128 @@
+ admin_url( 'admin-ajax.php' ),
+ 'nonce' => wp_create_nonce( self::BANNER_ID ),
+ 'banner_id' => self::BANNER_ID,
+ )
+ );
+ }
+
+ /**
+ * AJAX handler to dismiss the banner.
+ */
+ public function ajax_dismiss_banner() {
+ check_ajax_referer( self::BANNER_ID, 'nonce' );
+ update_user_meta(
+ get_current_user_id(),
+ self::BANNER_ID,
+ 1
+ );
+ }
+
+ /**
+ * Output the banner HTML if it should be shown.
+ */
+ public function render_banner() {
+ // Check if the WhatsApp admin banner should be shown.
+ if ( strtotime( 'now' ) > strtotime( '2025-06-15 23:59:59' ) ) {
+ return;
+ }
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ return;
+ }
+
+ if ( get_user_meta(
+ get_current_user_id(),
+ self::BANNER_ID,
+ true
+ ) ) {
+ return;
+ }
+
+ $banner_html = '
';
+ $banner_html .= '';
+ $banner_html .= '
Sign up to test WhatsApp’s new integration with '
+ . 'WooCommerce
';
+ $banner_html .= '
We’re launching a brand new WhatsApp integration for '
+ . 'WooCommerce allowing businesses to send order tracking notifications '
+ . 'on WhatsApp. Sign up for a chance to join our testing program and get '
+ . 'early access to this new feature. As a thank you, participants who '
+ . 'complete testing will receive a $500 ad credit.
+ Sign up for our testing program and get early access now!",
+ 'facebook-for-woocommerce'
+ ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ ),
+ )
+ ),
+ 'https://facebookpso.qualtrics.com/jfe/form/SV_0SVseus9UADOhhQ'
+ );
+ ?>
+
+
+ 'ORDER_PLACED',
+ 'completed' => 'ORDER_FULFILLED',
+ 'refunded' => 'ORDER_REFUNDED',
+ );
+
+ public function __construct() {
+ if ( ! $this->is_whatsapp_utility_enabled() ) {
+ return;
+ }
+ add_action( 'woocommerce_order_status_changed', array( $this, 'process_wc_order_status_changed' ), 10, 3 );
+ }
+
+ /**
+ * Determines if WhatsApp Utility Messages are enabled
+ * TODO: Update this function to check for gating logic for Alpha businesses
+ *
+ * @since 2.3.0
+ *
+ * @return bool
+ */
+ private function is_whatsapp_utility_enabled() {
+ return true;
+ }
+
+
+ /**
+ * Hook to process Order Processing, Order Completed and Order Refunded events for WhatsApp Utility Messages
+ *
+ * @param string $order_id Order id
+ * @param string $old_status Old Order Status
+ * @param string $new_status New Order Status
+ *
+ * @return void
+ * @since 2.3.0
+ */
+ public function process_wc_order_status_changed( $order_id, $old_status, $new_status ) {
+ // WhatsApp Utility Messages are supported only for Processing status
+ $supported_statuses = array_keys( self::ORDER_STATUS_TO_EVENT_MAPPING );
+ if ( ! in_array( $new_status, $supported_statuses, true ) ) {
+ return;
+ }
+
+ wc_get_logger()->info(
+ sprintf(
+ /* translators: %s $order_id */
+ __( 'Processing Order id %1$s to send Whatsapp Utility messages', 'facebook-for-woocommerce' ),
+ $order_id,
+ )
+ );
+ $event = self::ORDER_STATUS_TO_EVENT_MAPPING[ $new_status ];
+
+ // Check WhatsApp Event Config is active
+ $event_config_id_option_name = implode( '_', array( WhatsAppUtilityConnection::WA_UTILITY_OPTION_PREFIX, strtolower( $event ), 'event_config_id' ) );
+ $event_config_language_option_name = implode( '_', array( WhatsAppUtilityConnection::WA_UTILITY_OPTION_PREFIX, strtolower( $event ), 'language' ) );
+ $event_config_id = get_option( $event_config_id_option_name, null );
+ $language_code = get_option( $event_config_language_option_name, null );
+ if ( empty( $event_config_id ) || empty( $language_code ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ /* translators: %s $order_id */
+ __( 'Messages Post API call for Order id %1$s skipped due to no active event config', 'facebook-for-woocommerce' ),
+ $order_id,
+ )
+ );
+ return;
+ }
+
+ $order = wc_get_order( $order_id );
+ // Check WhatsApp Consent Checkbox is selected in shipping and billing
+ $billing_consent_value = $order->get_meta( '_wc_billing/wc_facebook/whatsapp_consent_checkbox' );
+ $shipping_consent_value = $order->get_meta( '_wc_shipping/wc_facebook/whatsapp_consent_checkbox' );
+ $has_whatsapp_consent = $billing_consent_value && $shipping_consent_value;
+ // Get WhatsApp Phone number from entered Billing and Shipping phone number
+ $billing_phone_number = $order->get_billing_phone();
+ $shipping_phone_number = $order->get_shipping_phone();
+ $phone_number = ( isset( $billing_phone_number ) && $billing_consent_value ) ? $billing_phone_number : $shipping_phone_number;
+ // Get Customer first name
+ $first_name = $order->get_billing_first_name();
+ // Get Total Refund Amount for Order Refunded event
+ $total_refund = 0;
+ foreach ( $order->get_refunds() as $refund ) {
+ $total_refund += $refund->get_amount();
+ }
+ $currency = $order->get_currency();
+ $refund_amount = $total_refund * 1000;
+ if ( empty( $phone_number ) || ! $has_whatsapp_consent || empty( $event ) || empty( $first_name ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ /* translators: %s $order_id */
+ __( 'Messages Post API call for Order id %1$s skipped due to missing whatsapp consent or Order info', 'facebook-for-woocommerce' ),
+ $order_id,
+ )
+ );
+ return;
+ }
+
+ // Check Access token and WACS is available
+ $bisu_token = get_option( 'wc_facebook_wa_integration_bisu_access_token', null );
+ $wacs_id = get_option( 'wc_facebook_wa_integration_wacs_id', null );
+ if ( empty( $bisu_token ) || empty( $wacs_id ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ /* translators: %s $order_id */
+ __( 'Messages Post API call for Order id %1$s Failed due to missing access token or wacs info', 'facebook-for-woocommerce' ),
+ $order_id,
+ )
+ );
+ return;
+ }
+ WhatsAppUtilityConnection::post_whatsapp_utility_messages_events_call( $event, $event_config_id, $language_code, $wacs_id, $order_id, $phone_number, $first_name, $refund_amount, $currency, $bisu_token );
+ }
+}
diff --git a/facebook-commerce.php b/facebook-commerce.php
index be88640c3..3fa6ce39b 100644
--- a/facebook-commerce.php
+++ b/facebook-commerce.php
@@ -23,6 +23,9 @@
require_once 'facebook-config-warmer.php';
require_once 'includes/fbproduct.php';
require_once 'facebook-commerce-pixel-event.php';
+require_once 'facebook-commerce-admin-notice.php';
+
+new WC_Facebookcommerce_Admin_Notice();
class WC_Facebookcommerce_Integration extends WC_Integration {
@@ -173,6 +176,9 @@ class WC_Facebookcommerce_Integration extends WC_Integration {
/** @var WC_Facebook_Product_Feed instance. */
private $fbproductfeed;
+ /** @var WC_Facebookcommerce_Whatsapp_Utility_Event instance. */
+ private $wa_utility_event_processor;
+
/**
* Init and hook in the integration.
*
@@ -360,6 +366,9 @@ public function __construct( WC_Facebookcommerce $facebook_for_woocommerce ) {
// Product Set hooks.
add_action( 'fb_wc_product_set_sync', [ $this, 'create_or_update_product_set_item' ], 99, 2 );
add_action( 'fb_wc_product_set_delete', [ $this, 'delete_product_set_item' ], 99 );
+
+ // Init Whatsapp Utility Event Processor
+ $this->wa_utility_event_processor = $this->load_whatsapp_utility_event_processor();
}
/**
@@ -849,27 +858,27 @@ private function save_facebook_product_attributes( $woo_product ) {
if ( isset( $_POST[ WC_Facebook_Product::FB_SIZE ] ) ) {
$woo_product->set_fb_size( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_SIZE ] ) ) );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_COLOR ] ) ) {
$woo_product->set_fb_color( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_COLOR ] ) ) );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_MATERIAL ] ) ) {
$woo_product->set_fb_material( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_MATERIAL ] ) ) );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_PATTERN ] ) ) {
$woo_product->set_fb_pattern( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_PATTERN ] ) ) );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_AGE_GROUP ] ) ) {
$woo_product->set_fb_age_group( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_AGE_GROUP ] ) ) );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_GENDER ] ) ) {
$woo_product->set_fb_gender( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_GENDER ] ) ) );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_PRODUCT_CONDITION ] ) ) {
$woo_product->set_fb_condition( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_PRODUCT_CONDITION ] ) ) );
}
@@ -901,7 +910,7 @@ private function save_product_settings( WC_Product $product ) {
$woo_product->set_description( sanitize_text_field( wp_unslash( $_POST[ self::FB_PRODUCT_DESCRIPTION ] ) ) );
$woo_product->set_rich_text_description( $_POST[ self::FB_PRODUCT_DESCRIPTION ] );
}
-
+
if ( isset( $_POST[ WC_Facebook_Product::FB_PRODUCT_PRICE ] ) ) {
$woo_product->set_price( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_PRODUCT_PRICE ] ) ) );
}
@@ -3027,4 +3036,19 @@ public function ajax_display_test_result() {
wp_die();
}
+ /**
+ * Init WhatsApp Utility Event Processor.
+ *
+ * @return void
+ */
+ public function load_whatsapp_utility_event_processor() {
+ // Attempt to load WhatsApp Utility Event Processor
+ include_once 'facebook-commerce-whatsapp-utility-event.php';
+ if ( class_exists( 'WC_Facebookcommerce_Whatsapp_Utility_Event' ) ) {
+ if ( ! isset( $this->wa_utility_event_processor ) ) {
+ $this->wa_utility_event_processor = new WC_Facebookcommerce_Whatsapp_Utility_Event( $this );
+ }
+ }
+ }
+
}
diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php
index 24f73984b..e66c3d9a7 100644
--- a/facebook-for-woocommerce.php
+++ b/facebook-for-woocommerce.php
@@ -10,14 +10,14 @@
* 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.8
+ * Version: 3.4.9
* Requires at least: 5.6
* Requires PHP: 7.4
* Text Domain: facebook-for-woocommerce
* Requires Plugins: woocommerce
- * Tested up to: 6.7
+ * Tested up to: 6.8.1
* WC requires at least: 6.4
- * WC tested up to: 9.6
+ * WC tested up to: 9.8.5
*
* @package FacebookCommerce
*/
@@ -38,6 +38,20 @@ function () {
}
}
);
+
+if ( is_admin() ) {
+ add_action(
+ 'admin_init',
+ function () {
+ if ( ! class_exists( 'WC_Facebookcommerce_Admin_Banner' ) ) {
+ require_once plugin_dir_path( __FILE__ ) .
+ 'facebook-commerce-admin-banner.php';
+ }
+ new WC_Facebookcommerce_Admin_Banner();
+ }
+ );
+}
+
/**
* The plugin loader class.
*
@@ -48,7 +62,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.8'; // WRCS: DEFINED_VERSION.
+ const PLUGIN_VERSION = '3.4.9'; // WRCS: DEFINED_VERSION.
// Minimum PHP version required by this plugin.
const MINIMUM_PHP_VERSION = '7.4.0';
diff --git a/includes/AJAX.php b/includes/AJAX.php
index b92243f1d..1f55794f5 100644
--- a/includes/AJAX.php
+++ b/includes/AJAX.php
@@ -14,6 +14,7 @@
use WooCommerce\Facebook\Framework\Helper;
use WooCommerce\Facebook\Admin\Settings_Screens\Product_Sync;
use WooCommerce\Facebook\Framework\Plugin\Exception as PluginException;
+use WooCommerce\Facebook\Handlers\WhatsAppUtilityConnection;
defined( 'ABSPATH' ) or exit;
@@ -46,8 +47,35 @@ public function __construct() {
// get the current sync status
add_action( 'wp_ajax_wc_facebook_get_sync_status', array( $this, 'get_sync_status' ) );
+ // check the status of whatsapp onboarding and update the progress
+ add_action( 'wp_ajax_wc_facebook_whatsapp_onboarding_progress_check', array( $this, 'whatsapp_onboarding_progress_check' ) );
+
+ // update the wp_options with wc_facebook_whatsapp_consent_collection_setting_status to enabled
+ add_action( 'wp_ajax_wc_facebook_whatsapp_consent_collection_enable', array( $this, 'whatsapp_consent_collection_enable' ) );
+
+ // fetch url info - waba id and business id
+ add_action( 'wp_ajax_wc_facebook_whatsapp_fetch_url_info', array( $this, 'wc_facebook_whatsapp_fetch_url_info' ) );
+
+ // action to fetch required info and make api call to meta to finish onboarding
+ add_action( 'wp_ajax_wc_facebook_whatsapp_finish_onboarding', array( $this, 'wc_facebook_whatsapp_finish_onboarding' ) );
+
+ // fetch configured library template info
+ add_action( 'wp_ajax_wc_facebook_whatsapp_fetch_library_template_info', array( $this, 'whatsapp_fetch_library_template_info' ) );
+
+ // action to create or update utility event config info
+ add_action( 'wp_ajax_wc_facebook_whatsapp_upsert_event_config', array( $this, 'whatsapp_upsert_event_config' ) );
+
// search a product's attributes for the given term
add_action( 'wp_ajax_' . self::ACTION_SEARCH_PRODUCT_ATTRIBUTES, array( $this, 'admin_search_product_attributes' ) );
+
+ // update the wp_options with wc_facebook_whatsapp_consent_collection_setting_status to disabled
+ add_action( 'wp_ajax_wc_facebook_whatsapp_consent_collection_disable', array( $this, 'whatsapp_consent_collection_disable' ) );
+
+ // disconnect whatsapp account from woocommcerce app
+ add_action( 'wp_ajax_wc_facebook_disconnect_whatsapp', array( $this, 'wc_facebook_disconnect_whatsapp' ) );
+
+ // get supported languages for whatsapp templates
+ add_action( 'wp_ajax_wc_facebook_whatsapp_fetch_supported_languages', array( $this, 'whatsapp_fetch_supported_languages' ) );
}
@@ -156,6 +184,269 @@ public function get_sync_status() {
wp_send_json_success( $remaining_products );
}
+ /**
+ * Get data for creating the billing or whatsapp manager url for whatsapp account.
+ *
+ * @internal
+ *
+ * @since 1.10.0
+ */
+ public function wc_facebook_whatsapp_fetch_url_info() {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Fetching url info(WABA ID+BusinessID) for whatsapp pages', 'facebook-for-woocommerce' )
+ )
+ );
+ facebook_for_woocommerce()->log( '' );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-billing-nonce', 'nonce', false ) && ! check_ajax_referer( 'facebook-for-wc-whatsapp-templates-nonce', 'nonce', false ) && ! check_ajax_referer( 'facebook-for-wc-whatsapp-disconnect-nonce', 'nonce', false ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Nonce Verification Error while Fetching Url Info', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+
+ $waba_id = get_option( 'wc_facebook_wa_integration_waba_id', null );
+ $business_id = get_option( 'wc_facebook_wa_integration_business_id', null );
+
+ if ( empty( $waba_id ) || empty( $business_id ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Missing Waba ID + Business ID during Fetch Url Info. Whatsapp Onboarding is not complete or has failed.', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Whatsapp onboarding is not complete or has failed.' );
+ }
+
+ $response = array(
+ 'waba_id' => $waba_id,
+ 'business_id' => $business_id,
+ );
+
+ wp_send_json_success( $response );
+ }
+
+ /**
+ * Get data for for finish onboarding call and make api call.
+ *
+ * @internal
+ *
+ * @since 1.10.0
+ */
+ public function wc_facebook_whatsapp_finish_onboarding() {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Getting data for Whatsapp Finish Onboarding Done Button Click', 'facebook-for-woocommerce' )
+ )
+ );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-finish-nonce', 'nonce', false ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Nonce Verification Error in Finish Onboarding Flow', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ $external_business_id = get_option( 'wc_facebook_external_business_id', null );
+ $wacs_id = get_option( 'wc_facebook_wa_integration_wacs_id', null );
+ $waba_id = get_option( 'wc_facebook_wa_integration_waba_id', null );
+ $bisu_token = get_option( 'wc_facebook_wa_integration_bisu_access_token', null );
+ if ( empty( $external_business_id ) || empty( $wacs_id ) || empty( $waba_id ) || empty( $bisu_token ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Finish Onboarding - Onboarding is not complete or has failed.', 'facebook-for-woocommerce' ),
+ )
+ );
+ wp_send_json_error( 'Onboarding Flow is not complete or has failed.' );
+ }
+ WhatsAppUtilityConnection::wc_facebook_whatsapp_connect_utility_messages_call( $waba_id, $wacs_id, $external_business_id, $bisu_token );
+ }
+
+
+ /**
+ * Checks if the onboarding for whatsapp is complete once business has initiated onboarding.
+ *
+ * @internal
+ *
+ * @since 1.10.0
+ */
+ public function whatsapp_onboarding_progress_check() {
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-onboarding-progress-nonce', 'nonce', false ) ) {
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ $waba_id = get_option( 'wc_facebook_wa_integration_waba_id', null );
+ $is_payment_setup = (bool) get_option( 'wc_facebook_wa_integration_is_payment_setup', null );
+ if ( ! empty( $waba_id ) ) {
+ wp_send_json_success(
+ array(
+ 'message' => 'WhatsApp onboarding is complete',
+ 'is_payment_setup' => $is_payment_setup,
+ )
+ );
+ }
+ wp_send_json_error( 'WhatsApp onboarding is not complete' );
+ }
+
+ public function whatsapp_consent_collection_enable() {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Enabling Whatsapp Consent Collection in Checkout Flow', 'facebook-for-woocommerce' )
+ )
+ );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-consent-nonce', 'nonce', false ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Nonce Verification Error in Whatsapp Consent Collection', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ if ( get_option( 'wc_facebook_whatsapp_consent_collection_setting_status' ) !== 'enabled' ) {
+ update_option( 'wc_facebook_whatsapp_consent_collection_setting_status', 'enabled' );
+ }
+ $is_payment_setup = (bool) get_option( 'wc_facebook_wa_integration_is_payment_setup', null );
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Whatsapp Consent Collection Enabled Successfully in Checkout Flow', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_success(
+ array(
+ 'message' => 'Whatsapp Consent Collection Enabled Successfully in Checkout Flow',
+ 'is_payment_setup' => $is_payment_setup,
+ )
+ );
+ }
+
+ public function whatsapp_consent_collection_disable() {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Disabling Whatsapp Consent Collection in Utility Settings View', 'facebook-for-woocommerce' )
+ )
+ );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-consent-disable-nonce', 'nonce', false ) ) {
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ if ( get_option( 'wc_facebook_whatsapp_consent_collection_setting_status' ) !== 'disabled' ) {
+ update_option( 'wc_facebook_whatsapp_consent_collection_setting_status', 'disabled' );
+ }
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Whatsapp Consent Collection Disabled Successfully in Utility Settings View', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_success();
+ }
+
+ /**
+ * Disconnect Whatsapp from WooCommerce.
+ *
+ * @internal
+ *
+ * @since 1.10.0
+ */
+ public function wc_facebook_disconnect_whatsapp() {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Diconnecting Whatsapp From Woocommerce', 'facebook-for-woocommerce' )
+ )
+ );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-disconnect-nonce', 'nonce', false ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Nonce Verification Failed while Diconnecting Whatsapp From Woocommerce', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+
+ $integration_config_id = get_option( 'wc_facebook_wa_integration_config_id', null );
+ $bisu_token = get_option( 'wc_facebook_wa_integration_bisu_access_token', null );
+ $waba_id = get_option( 'wc_facebook_wa_integration_waba_id', null );
+ if ( empty( $integration_config_id ) || empty( $bisu_token ) || empty( $waba_id ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Missing Integration Config ID, BISU token, WABA ID while Diconnecting Whatsapp From Woocommerce', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Missing integration_config_id or bisu_token or waba_id for Disconnect API call' );
+ }
+ WhatsAppUtilityConnection::wc_facebook_disconnect_whatsapp( $waba_id, $integration_config_id, $bisu_token );
+ }
+
+ public function whatsapp_fetch_library_template_info() {
+ facebook_for_woocommerce()->log( 'Fetching library template data for whatsapp utility event' );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-events-nonce', 'nonce', false ) ) {
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ $bisu_token = get_option( 'wc_facebook_wa_integration_bisu_access_token', null );
+ if ( empty( $bisu_token ) ) {
+ wp_send_json_error( 'Missing access token for Library template API call' );
+ }
+ // Get POST parameters from the request
+ $event = isset( $_POST['event'] ) ? wc_clean( wp_unslash( $_POST['event'] ) ) : '';
+ WhatsAppUtilityConnection::get_template_library_content( $event, $bisu_token );
+ }
+
+ public function whatsapp_fetch_supported_languages() {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Fetching supported languages for WhatsApp Utility Templates', 'facebook-for-woocommerce' )
+ )
+ );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-events-nonce', 'nonce', false ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Nonce Verification Failed while fetching supported languages for WhatsApp Utility Templates', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ $bisu_token = get_option( 'wc_facebook_wa_integration_bisu_access_token', null );
+ $integration_config_id = get_option( 'wc_facebook_wa_integration_config_id', null );
+ if ( empty( $bisu_token ) || empty( $integration_config_id ) ) {
+ wc_get_logger()->info(
+ sprintf(
+ __( 'Missing Integration Config ID, BISU token, WABA ID for Integration Config Get API call', 'facebook-for-woocommerce' )
+ )
+ );
+ wp_send_json_error( 'Missing integration_config_id or bisu_token for Integration Config Get API call', 'facebook-for-woocommerce' );
+ }
+ WhatsAppUtilityConnection::get_supported_languages_for_templates( $integration_config_id, $bisu_token );
+ }
+
+ /**
+ * Creates or Updates WhatsApp Utility Event Configs
+ *
+ * @internal
+ *
+ * @since 1.10.0
+ */
+ public function whatsapp_upsert_event_config() {
+ facebook_for_woocommerce()->log( 'Calling POST API to upsert whatsapp utility event' );
+ if ( ! check_ajax_referer( 'facebook-for-wc-whatsapp-events-nonce', 'nonce', false ) ) {
+ wp_send_json_error( 'Invalid security token sent.' );
+ }
+ // Get BISU token
+ $bisu_token = get_option( 'wc_facebook_wa_integration_bisu_access_token', null );
+ if ( empty( $bisu_token ) ) {
+ wp_send_json_error( 'Missing access token for Event Configs POST API call' );
+ }
+ // Get Integration Config id
+ $integration_config_id = get_option( 'wc_facebook_wa_integration_config_id', null );
+ if ( empty( $integration_config_id ) ) {
+ wp_send_json_error( 'Missing Integration Config for Event Configs POST API call' );
+ }
+ // Get POST parameters from the request
+ $event = isset( $_POST['event'] ) ? wc_clean( wp_unslash( $_POST['event'] ) ) : '';
+ $language = isset( $_POST['language'] ) ? wc_clean( wp_unslash( $_POST['language'] ) ) : '';
+ $status = isset( $_POST['status'] ) ? wc_clean( wp_unslash( $_POST['status'] ) ) : '';
+ if ( empty( $event ) || empty( $language ) || empty( $status ) ) {
+ wp_send_json_error( 'Missing request parameters for Event Configs POST API call' );
+ }
+ WhatsAppUtilityConnection::post_whatsapp_utility_messages_event_configs_call( $event, $integration_config_id, $language, $status, $bisu_token );
+ }
/**
* Maybe triggers a modal warning when the merchant toggles sync enabled status in bulk.
diff --git a/includes/API.php b/includes/API.php
index cc8d4dc94..ad7f67da7 100644
--- a/includes/API.php
+++ b/includes/API.php
@@ -278,6 +278,29 @@ public function get_business_configuration( $external_business_id ) {
return $this->perform_request( $request );
}
+ /**
+ * Gets rollout switches
+ *
+ * @param string $external_business_id
+ * @return API\FBE\RolloutSwitches\Response
+ * @throws ApiException
+ */
+ public function get_rollout_switches( string $external_business_id ) {
+ if(!$this->get_access_token()) {
+ return null;
+ }
+
+ $request = new API\FBE\RolloutSwitches\Request( $external_business_id );
+ $request->set_params(
+ array(
+ 'access_token' => $this->get_access_token(),
+ 'fbe_external_business_id'=> $external_business_id
+ )
+ );
+ $this->set_response_handler( API\FBE\RolloutSwitches\Response::class );
+ return $this->perform_request( $request );
+ }
+
/**
* Updates the plugin version configuration.
*
@@ -496,6 +519,19 @@ public function delete_product_set_item( string $product_set_id, bool $allow_liv
return $this->perform_request( $request );
}
+ /**
+ * @param string $product_catalog_id
+ * @param array $data
+ * @return API\Response|API\ProductCatalog\ProductSets\Read\Response
+ * @throws ApiException
+ * @throws API\Exceptions\Request_Limit_Reached
+ */
+ public function read_product_set_item( string $product_catalog_id, string $retailer_id ): API\ProductCatalog\ProductSets\Read\Response {
+ $request = new API\ProductCatalog\ProductSets\Read\Request( $product_catalog_id, $retailer_id );
+ $this->set_response_handler( API\ProductCatalog\ProductSets\Read\Response::class );
+ return $this->perform_request( $request );
+ }
+
/**
* @param string $product_catalog_id
* @return API\Response|API\ProductCatalog\ProductFeeds\ReadAll\Response
diff --git a/includes/API/FBE/RolloutSwitches/Request.php b/includes/API/FBE/RolloutSwitches/Request.php
new file mode 100644
index 000000000..be72f2391
--- /dev/null
+++ b/includes/API/FBE/RolloutSwitches/Request.php
@@ -0,0 +1,20 @@
+response_data['data'] ?? [];
+ }
+}
diff --git a/includes/API/ProductCatalog/ProductSets/Read/Request.php b/includes/API/ProductCatalog/ProductSets/Read/Request.php
new file mode 100644
index 000000000..349557bc0
--- /dev/null
+++ b/includes/API/ProductCatalog/ProductSets/Read/Request.php
@@ -0,0 +1,28 @@
+ Product Sets > Get Graph Api.
+ *
+ * @link https://developers.facebook.com/docs/marketing-api/reference/product-catalog/product_sets/
+ */
+class Request extends ApiRequest {
+
+ /**
+ * @param string $product_catalog_id Facebook Product Catalog ID.
+ * @param string $retailer_id Facebook Product Set Retailer ID.
+ */
+ public function __construct( string $product_catalog_id, string $retailer_id ) {
+ parent::__construct( "/{$product_catalog_id}/product_sets", 'GET' );
+ parent::set_params(
+ array( 'retailer_id' => $retailer_id )
+ );
+ }
+}
diff --git a/includes/API/ProductCatalog/ProductSets/Read/Response.php b/includes/API/ProductCatalog/ProductSets/Read/Response.php
new file mode 100644
index 000000000..88be20974
--- /dev/null
+++ b/includes/API/ProductCatalog/ProductSets/Read/Response.php
@@ -0,0 +1,29 @@
+ Product Groups > Get Graph Api.
+ *
+ * @link https://developers.facebook.com/docs/marketing-api/reference/product-catalog/product_sets/
+ * @property-read string id Facebook Product Set ID.
+ *
+ * @since 3.4.9
+ */
+class Response extends ApiResponse {
+
+ /**
+ * Returns the fb product set ID.
+ *
+ * @return ?string
+ * @since 3.4.9
+ */
+ public function get_product_set_id(): ?string {
+ return $this->data[0]['id'] ?? null;
+ }
+}
diff --git a/includes/Admin/Product_Sets.php b/includes/Admin/Product_Sets.php
index e829d26f2..65cb1a000 100644
--- a/includes/Admin/Product_Sets.php
+++ b/includes/Admin/Product_Sets.php
@@ -13,6 +13,7 @@
defined( 'ABSPATH' ) || exit;
use WP_Term;
+use WooCommerce\Facebook\RolloutSwitches;
/**
* General handler for the product set admin functionality.
@@ -65,8 +66,30 @@ public function __construct() {
// save custom field data
add_action( 'created_fb_product_set', array( $this, 'save_custom_field' ), 10, 2 );
add_action( 'edited_fb_product_set', array( $this, 'save_custom_field' ), 10, 2 );
+ // show a banner about chnages to product sets sync
+ add_action( 'admin_notices', array( $this, 'display_fb_product_sets_banner' ) );
}
+ public function display_fb_product_sets_banner() {
+ if ( isset( $_GET['taxonomy'] ) && 'fb_product_set' === $_GET['taxonomy'] ) {
+ $is_product_sets_sync_enbaled = facebook_for_woocommerce()->get_rollout_switches()->is_switch_enabled(
+ RolloutSwitches::SWITCH_PRODUCT_SETS_SYNC_ENABLED
+ );
+ if ( $is_product_sets_sync_enbaled ) {
+ $fb_catalog_id = facebook_for_woocommerce()->get_integration()->get_product_catalog_id();
+
+ ?>
+
+
Your categories now automatically sync as product sets on Facebook
+
To make changes to automatically synced sets going forward, you should edit your categories on WooCommerce. This may take some time to update initially, but then will automatically sync every few minutes. There are no changes to any sets you previously created.
+ To see what’s synced, go to sets in Commerce Manager.
+
+ plugin = $plugin;
- $this->screens = $this->build_menu_item_array( $is_connected );
+ $this->screens = $this->build_menu_item_array();
+ add_action( 'admin_init', array( $this, 'add_extra_screens' ) );
add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
add_action( 'wp_loaded', array( $this, 'save' ) );
add_filter( 'parent_file', array( $this, 'set_parent_and_submenu_file' ) );
@@ -58,15 +66,15 @@ public function __construct( bool $is_connected ) {
/**
* Arranges the tabs. If the plugin is connected to FB, Advertise tab will be first, otherwise the Connection tab will be the first tab.
*
- * @param bool $is_connected is Facebook connected
* @since 3.0.7
*/
- private function build_menu_item_array( bool $is_connected ): array {
+ public function build_menu_item_array(): array {
$advertise = [ Settings_Screens\Advertise::ID => new Settings_Screens\Advertise() ];
$connection = [ Settings_Screens\Connection::ID => new Settings_Screens\Connection() ];
- $first = ( $is_connected ) ? $advertise : $connection;
- $last = ( $is_connected ) ? $connection : $advertise;
+ $is_connected = $this->plugin->get_connection_handler()->is_connected();
+ $first = ( $is_connected ) ? $advertise : $connection;
+ $last = ( $is_connected ) ? $connection : $advertise;
$screens = array(
Settings_Screens\Product_Sync::ID => new Settings_Screens\Product_Sync(),
@@ -76,6 +84,15 @@ private function build_menu_item_array( bool $is_connected ): array {
return array_merge( array_merge( $first, $screens ), $last );
}
+ public function add_extra_screens(): void {
+ $rollout_switches = $this->plugin->get_rollout_switches();
+ $is_connected = $this->plugin->get_connection_handler()->is_connected();
+ $is_whatsapp_utility_messaging_enabled = $rollout_switches->is_switch_enabled( RolloutSwitches::WHATSAPP_UTILITY_MESSAGING );
+ if ( true === $is_connected && true === $is_whatsapp_utility_messaging_enabled ) {
+ $this->screens[ Settings_Screens\Whatsapp_Utility::ID ] = new Settings_Screens\Whatsapp_Utility();
+ }
+ }
+
/**
* Adds the Facebook menu item.
*
@@ -219,7 +236,18 @@ public function render_tabs( $current_tab ) {
?>
get_plugin_url() . '/assets/css/admin/facebook-for-woocommerce-advertise.css', array(), \WC_Facebookcommerce::VERSION );
+ wp_enqueue_style( 'wc-facebook-admin-whatsapp-banner', facebook_for_woocommerce()->get_plugin_url() . '/assets/css/admin/facebook-for-woocommerce-whatsapp-banner.css', array(), \WC_Facebookcommerce::VERSION );
}
@@ -209,7 +210,11 @@ public function render() {
$fbe_extras = wp_json_encode( $this->get_lwi_ads_configuration_data() );
+ $wa_banner = new \WC_Facebookcommerce_Admin_Banner();
+ $wa_banner->render_banner();
+ $wa_banner->enqueue_banner_script();
?>
+