Skip to content

Commit

Permalink
Release 3.3.2 (#2861)
Browse files Browse the repository at this point in the history
* Update php-unit-tests.yml to install SVN (#2859)

* Fix: get_global_unique_id function compatibility check (#2856)

Summary:
Fixed a bug that arose from our reliance on the plugin version compatibility tag for the public function get_global_unique_id. This function was actually introduced in WooCommerce version 9.2, but was incorrectly tagged as being available from version 9.1 onwards.
To ensure correct functionality, we have replaced the use of Compatibility::is_wc_version_gte() with method_exists(), which checks for the availability of specific public methods rather than relying on version numbers

Differential Revision: D68424348

* Update catalog link to navigate to correct tab in Commerce Manager (#2848)

* Update catalog link to navigate to correct tab in Commerce Manager

Co-authored-by: Marian Shymon <[email protected]>

---------

Co-authored-by: David Evbodaghe <[email protected]>
Co-authored-by: Marian Shymon <[email protected]>

* Fixed product url links (#2852)

* Fix - Removed the  "Sell on Instagram" checkbox from UX and cleaned up the backend (#2854)

* Removed the  Sell on Instagram UX and cleane dup the backend.

* Update php-unit-tests.yml to install SVN (#2859)

---------

Co-authored-by: Marian Shymon <[email protected]>
Co-authored-by: Halil Ozan Akgül <[email protected]>

* feat: Add custom fields to product data structure (#2836)

* feat: Add custom fields to product data structure

---------

Co-authored-by: David Evbodaghe <[email protected]>

* Fixed Category specific attributes related issues (#2860)

* Start `release/3.3.2`.

* updated the changelog and stable version

* Updated the current version

* Updated the WC supported version to 9.6

* Updated the stable version

---------

Co-authored-by: Halil Ozan Akgül <[email protected]>
Co-authored-by: vinkmeta <[email protected]>
Co-authored-by: David <[email protected]>
Co-authored-by: David Evbodaghe <[email protected]>
Co-authored-by: Marian Shymon <[email protected]>
Co-authored-by: Marian Shymon <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vahid Kaykhaei <[email protected]>
Co-authored-by: vahidkay-meta <[email protected]>
  • Loading branch information
9 people authored Jan 22, 2025
1 parent e416c2e commit d9df5cd
Show file tree
Hide file tree
Showing 17 changed files with 399 additions and 221 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/php-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
wp-version: [latest]

steps:
- name: Install SVN
run: sudo apt-get install subversion -y

- name: Checkout repository
uses: actions/checkout@v3

Expand Down
69 changes: 41 additions & 28 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
*** Facebook for WooCommerce Changelog ***

= 3.3.0 - 2024-11-07 =
* Add - Extension navigation tabs on Product Sets screens.
* Tweak - Tooltips, config labels, documentation links.
* Tweak - WC 9.4 compatibility.
* Tweak - WP 6.7 compatibility.

= 3.2.10 - 2024-09-30 =
* Update - Remove Marketing Products Sets menu entry.

= 3.2.9 - 2024-09-12 =
* Break - Removes WooCommerce navigation items.
* Tweak - WC 9.3 compatibility.

= 3.2.8 - 2024-09-03 =
* Update - Access Token retrieval procedure.
* Update - Use get_title() for content_name to match catalog name.

= 3.2.7 - 2024-08-13 =
* Dev - Updated `phpcs` ruleset.
* Fix - Update failing due to undefined constant error in Lifecycle.
* Tweak - WC 9.2 compatibility.

= 3.2.6 - 2024-07-23 =
* Add - Filter facebook_for_woocommerce_fb_product_description.
* Fix - Remove deprecated FILTER_SANITIZE_STRING usage.
* Tweak - Align PHP require version to composer.json.

= 3.2.5 - 2024-07-10 =
= 3.3.2 - 2025-01-21 =
* Fix - a bug that arose from reliance on the plugin version compatibility tag by @vinkmeta in #2856
* Fix - Update catalog link in connections tab to point to Catalog by @devbodaghe in #2848
* Fix - Product URL links now point to items tab by @vinkmeta in #2852
* Tweak - Removed sell on Instagram by @mshymon in #2854
* Tweak - Add custom fields to product data structure by @devbodaghe in #2836
* Fix - Multiple issues with Fixed FB Attribute Syncing by @vinkmeta in #2860

= 3.3.1 - 2024-12-06 =
* Fix - Sale price effective date by @vinkmeta in #2809
* Fix - Sync stock quantity when available by @mshymon in #2811
* Fix - Sync product GTIN when available by @mshymon in #2810

= 3.3.0 - 2024-11-07 =
* Add - Extension navigation tabs on Product Sets screens.
* Tweak - Tooltips, config labels, documentation links.
* Tweak - WC 9.4 compatibility.
* Tweak - WP 6.7 compatibility.

= 3.2.10 - 2024-09-30 =
* Update - Remove Marketing Products Sets menu entry.

= 3.2.9 - 2024-09-12 =
* Break - Removes WooCommerce navigation items.
* Tweak - WC 9.3 compatibility.

= 3.2.8 - 2024-09-03 =
* Update - Access Token retrieval procedure.
* Update - Use get_title() for content_name to match catalog name.

= 3.2.7 - 2024-08-13 =
* Dev - Updated `phpcs` ruleset.
* Fix - Update failing due to undefined constant error in Lifecycle.
* Tweak - WC 9.2 compatibility.

= 3.2.6 - 2024-07-23 =
* Add - Filter facebook_for_woocommerce_fb_product_description.
* Fix - Remove deprecated FILTER_SANITIZE_STRING usage.
* Tweak - Align PHP require version to composer.json.

= 3.2.5 - 2024-07-10 =
* Tweak - WC 9.1 compatibility.
* Tweak - WP 6.6 compatibility.

Expand Down
6 changes: 4 additions & 2 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,10 @@ public function display_batch_api_completed( $post ) {

if ( $fb_product_item_id ) {
$this->display_success_message(
'Created product <a href="https://facebook.com/' . $fb_product_item_id .
'" target="_blank">' . $fb_product_item_id . '</a> on Facebook.'
'<a href="https://business.facebook.com/commerce/catalogs/'.
$this->get_product_catalog_id().
'/products/'. '" target="_blank">' .
'View product on Meta catalog</a>'
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions facebook-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,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.3.1
* Version: 3.3.2
* Requires at least: 5.6
* Requires PHP: 7.4
* Text Domain: facebook-for-woocommerce
* Requires Plugins: woocommerce
* Tested up to: 6.7
* WC requires at least: 6.4
* WC tested up to: 9.4
* WC tested up to: 9.6
*
* @package FacebookCommerce
*/
Expand Down Expand Up @@ -49,7 +49,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.3.1'; // WRCS: DEFINED_VERSION.
const PLUGIN_VERSION = '3.3.2'; // WRCS: DEFINED_VERSION.

// Minimum PHP version required by this plugin.
const MINIMUM_PHP_VERSION = '7.4.0';
Expand Down
12 changes: 0 additions & 12 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1278,18 +1278,6 @@ public function add_product_settings_tab_content() {
);
?>
</div>
<?php
$commerce_handler = facebook_for_woocommerce()->get_commerce_handler();
?>
<?php if ( $commerce_handler->is_connected() && $commerce_handler->is_available() ) : ?>
<div class='wc-facebook-commerce-options-group options_group'>
<?php
if ( $product instanceof \WC_Product ) {
\WooCommerce\Facebook\Admin\Products::render_commerce_fields( $product );
}
?>
</div>
<?php endif; ?>
<div class='wc-facebook-commerce-options-group options_group'>
<?php \WooCommerce\Facebook\Admin\Products::render_google_product_category_fields_and_enhanced_attributes( $product ); ?>
</div>
Expand Down
3 changes: 1 addition & 2 deletions includes/Admin/Product_Sync_Meta_Box.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public static function output() {

?>

<?php echo esc_html__( 'Facebook ID:', 'facebook-for-woocommerce' ); ?>
<a href="https://facebook.com/<?php echo esc_attr( $fb_product_id ); ?>" target="_blank"><?php echo esc_html( $fb_product_id ); ?></a>
<a href="https://business.facebook.com/commerce/catalogs/<?php echo esc_attr( $fb_integration->get_product_catalog_id() ); ?>/products/" target="_blank"><?php echo esc_html( 'View product on Meta catalog' ); ?></a>

<?php if ( \WC_Facebookcommerce_Utils::is_variable_type( $fb_product->get_type() ) ) : ?>

Expand Down
46 changes: 0 additions & 46 deletions includes/Admin/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,51 +177,6 @@ function ( $attribute ) use ( $product ) {
);
}

/**
* Renders the Commerce settings fields.
*
* @internal
*
* @since 2.1.0
*
* @param \WC_Product $product product object
*/
public static function render_commerce_fields( \WC_Product $product ) {
?>
<p class="form-field <?php echo esc_attr( self::FIELD_COMMERCE_ENABLED ); ?>_field">
<label for="<?php echo esc_attr( self::FIELD_COMMERCE_ENABLED ); ?>">
<?php echo esc_html_e( 'Sell on Instagram', 'facebook-for-woocommerce' ); ?>
<span class="woocommerce-help-tip"
data-tip="<?php echo esc_attr_e( 'Enable to sell this product on Instagram. Products that are hidden in the Facebook catalog can be synced, but won’t be available for purchase.', 'facebook-for-woocommerce' ); ?>"></span>
</label>
<input type="checkbox" class="enable-if-sync-enabled"
name="<?php echo esc_attr( self::FIELD_COMMERCE_ENABLED ); ?>"
id="<?php echo esc_attr( self::FIELD_COMMERCE_ENABLED ); ?>" value="yes"
checked="<?php echo Products_Handler::is_commerce_enabled_for_product( $product ) ? 'checked' : ''; ?>">
</p>

<div id="product-not-ready-notice" style="display:none;">
<p>
<?php esc_html_e( 'This product does not meet the requirements to sell on Instagram.', 'facebook-for-woocommerce' ); ?>
<a href="#" id="product-not-ready-notice-open-modal"><?php esc_html_e( 'Click here to learn more.', 'facebook-for-woocommerce' ); ?></a>
</p>
</div>

<div id="variable-product-not-ready-notice" style="display:none;">
<p>
<?php
printf(
/* translators: Placeholders %1$s - strong opening tag, %2$s - strong closing tag */
esc_html__( 'To sell this product on Instagram, at least one variation must be synced to Facebook. You can control variation sync on the %1$sVariations%2$s tab with the %1$sFacebook Sync%2$s setting.', 'facebook-for-woocommerce' ),
'<strong>',
'</strong>'
);
?>
</p>
</div>
<?php
}

/**
* Saves the Commerce settings.
*
Expand All @@ -243,7 +198,6 @@ public static function save_commerce_fields( \WC_Product $product ) {
// hence if it's unset we should clear the term meta for it.
Products_Handler::update_product_enhanced_catalog_attribute( $product, Enhanced_Catalog_Attribute_Fields::OPTIONAL_SELECTOR_KEY, null );
}
Products_Handler::update_commerce_enabled_for_product( $product, $commerce_enabled );
if ( Products_Handler::get_google_product_category_id( $product ) !== $google_product_category_id ) {
Products_Handler::update_google_product_category_id( $product, $google_product_category_id );
}
Expand Down
15 changes: 11 additions & 4 deletions includes/Admin/Settings_Screens/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,23 @@ public function render() {
);

// if the catalog ID is set, update the URL and try to get its name for display
if ( $catalog_id = $static_items['catalog']['value'] ) {

$static_items['catalog']['url'] = "https://facebook.com/products/catalogs/{$catalog_id}";

$catalog_id = $static_items['catalog']['value'];
if ( !empty( $catalog_id ) ) {
$static_items['catalog']['url'] = "https://www.facebook.com/commerce/catalogs/{$catalog_id}/products/";
try {
$response = facebook_for_woocommerce()->get_api()->get_catalog( $catalog_id );
if ( $name = $response->name ) {
$static_items['catalog']['value'] = $name;
}
} catch ( ApiException $exception ) {
// Log the exception with additional information
facebook_for_woocommerce()->log(
sprintf(
'Connection failed for catalog %s: %s ',
$catalog_id,
$exception->getMessage(),
)
);
}
}

Expand Down
48 changes: 0 additions & 48 deletions includes/Commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,52 +62,4 @@ public function update_default_google_product_category_id( $id ) {
update_option( self::OPTION_GOOGLE_PRODUCT_CATEGORY_ID, is_string( $id ) ? $id : '' );
}


/**
* Determines whether Commerce features should be available.
*
* @since 2.1.0
*
* @return bool whether Commerce features should be available
*/
public function is_available() {

list( $country ) = explode( ':', get_option( 'woocommerce_default_country' ) );

/**
* Filters whether Commerce features should be available.
*
* @since 2.1.0
*
* @param bool $available whether commerce features should be available
* @param string $country country code
* @param Commerce $commerce commerce handler instance
*/
return (bool) apply_filters( 'wc_facebook_commerce_is_available', 'US' === $country, $country, $this );
}


/**
* Determines whether the site is connected.
*
* @since 2.1.0
*
* @return bool whether the site is connected
*/
public function is_connected() {

$connection_handler = facebook_for_woocommerce()->get_connection_handler();

$connected = (bool) strlen( $connection_handler->get_page_access_token() ) && ! empty( $connection_handler->get_commerce_manager_id() );

/**
* Filters whether the site is connected.
*
* @since 2.1.0
*
* @param bool $connected whether the site is connected
* @param Commerce $commerce commerce handler instance
*/
return (bool) apply_filters( 'wc_facebook_commerce_is_connected', $connected, $this );
}
}
36 changes: 2 additions & 34 deletions includes/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class Products {
/** @var string product image source option to use the parent product image in Facebook */
const PRODUCT_IMAGE_SOURCE_CUSTOM = 'custom';

/** @var string the meta key used to flag if Commerce is enabled for the product */
const COMMERCE_ENABLED_META_KEY = '_wc_facebook_commerce_enabled';

/** @var string the meta key used to store the Google product category ID for the product */
const GOOGLE_PRODUCT_CATEGORY_META_KEY = '_wc_facebook_google_product_category';

Expand Down Expand Up @@ -377,36 +374,6 @@ public static function is_product_ready_for_commerce( \WC_Product $product ) {
}


/**
* Determines whether Commerce is enabled for the product.
*
* @since 2.1.0
*
* @param \WC_Product $product the product object
* @return bool
*/
public static function is_commerce_enabled_for_product( \WC_Product $product ) {
if ( $product->is_type( 'variation' ) ) {
$product = wc_get_product( $product->get_parent_id() );
}
return $product instanceof \WC_Product && wc_string_to_bool( $product->get_meta( self::COMMERCE_ENABLED_META_KEY ) );
}


/**
* Enables or disables Commerce for a product.
*
* @since 2.1.0
*
* @param \WC_Product $product the product object
* @param bool $is_enabled whether or not Commerce is to be enabled
*/
public static function update_commerce_enabled_for_product( \WC_Product $product, $is_enabled ) {
$product->update_meta_data( self::COMMERCE_ENABLED_META_KEY, wc_bool_to_string( $is_enabled ) );
$product->save_meta_data();
}


/**
* Gets the Google product category ID stored for the product.
*
Expand Down Expand Up @@ -985,7 +952,8 @@ public static function get_enhanced_catalog_attribute( $key, \WC_Product $produc
$attr_val = $product->get_attribute( $slug );
}

if ( \WC_Facebookcommerce_Utils::sanitize_variant_name( $attr_name, false ) === $key ) {
$sanitized_attr_name = \WC_Facebookcommerce_Utils::sanitize_attribute_name( \WC_Facebookcommerce_Utils::sanitize_variant_name( $attr_name, false ) );
if ( $sanitized_attr_name === $key ) {
$value = $attr_val;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/Products/FBCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function is_valid_value_for_attribute( $category_id, $attribute_key, $val
// TODO: can perform more validations here.
switch ( $attribute['type'] ) {
case 'enum':
return in_array( $value, $attribute['enum_values'] );
return in_array( strtolower( $value ), $attribute['enum_values'] );
case 'boolean':
return in_array( $value, array( 'yes', 'no' ) );
default:
Expand Down
Loading

0 comments on commit d9df5cd

Please sign in to comment.