From 81ee26495361cba1df73b342eb9fde85a53fcc11 Mon Sep 17 00:00:00 2001 From: Rodrigue Tusse Date: Thu, 20 Oct 2022 15:37:52 +0200 Subject: [PATCH] Ensure bundles are not treated as virtual product on product_sync --- facebook-commerce.php | 10 +++++----- includes/fbproduct.php | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index 9a8c03405..fb2c573dd 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -883,7 +883,7 @@ public function on_product_save( $wp_id ) { $sync_mode = isset( $_POST['wc_facebook_sync_mode'] ) ? $_POST['wc_facebook_sync_mode'] : Admin::SYNC_MODE_SYNC_DISABLED; $sync_enabled = Admin::SYNC_MODE_SYNC_DISABLED !== $sync_mode; - if ( Admin::SYNC_MODE_SYNC_AND_SHOW === $sync_mode && $product->is_virtual() ) { + if ( Admin::SYNC_MODE_SYNC_AND_SHOW === $sync_mode && $product->is_virtual() && 'bundle' !== $product->get_type() ) { // force to Sync and hide $sync_mode = Admin::SYNC_MODE_SYNC_AND_HIDE; } @@ -1526,14 +1526,14 @@ private function get_product_group_default_variation( $woo_product, $fb_product_ $default_attributes = $woo_product->woo_product->get_default_attributes( 'edit' ); $default_variation = null; - + // Fetch variations that exist in the catalog. $existing_catalog_variations = $this->find_variation_product_item_ids( $fb_product_group_id ); $existing_catalog_variations_retailer_ids = array_keys( $existing_catalog_variations ); - + // All woocommerce variations for the product. $product_variations = $woo_product->woo_product->get_available_variations(); - + if ( ! empty( $default_attributes ) ) { $best_match_count = 0; @@ -1566,7 +1566,7 @@ private function get_product_group_default_variation( $woo_product, $fb_product_ } } - + /** * Filter product group default variation. * This can be used to customize the choice of a default variation (e.g. choose one with the lowest price). diff --git a/includes/fbproduct.php b/includes/fbproduct.php index 408c0369d..97aa572f4 100644 --- a/includes/fbproduct.php +++ b/includes/fbproduct.php @@ -637,7 +637,9 @@ public function prepare_product( $retailer_id = null, $type_to_prepare_for = sel // Exclude variations that are "virtual" products from export to Facebook && // No Visibility Option for Variations - if ( true === $this->get_virtual() ) { + // get_virtual() returns true for "unassembled bundles", so we exclude + // bundles from this check. + if ( true === $this->get_virtual() && 'bundle' !== $this->get_type() ) { $product_data['visibility'] = \WC_Facebookcommerce_Integration::FB_SHOP_PRODUCT_HIDDEN; }