Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure bundles are not treated as virtual product on product_sync #2334

Merged
merged 1 commit into from
Oct 21, 2022
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
10 changes: 5 additions & 5 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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).
Expand Down
4 changes: 3 additions & 1 deletion includes/fbproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down