From 793847b2500ce327dbaba77c99f27c1059be7c31 Mon Sep 17 00:00:00 2001 From: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:36:12 +0800 Subject: [PATCH] Don't display Upsells collection if there's no upsells --- .../woocommerce/src/Blocks/BlockTypes/ProductCollection.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php index 13f1f69e79d..42c8e7465d3 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection.php @@ -1887,8 +1887,10 @@ class ProductCollection extends AbstractBlock { ); } + $upsells = $product->get_upsell_ids(); + return array( - 'post__in' => $product->get_upsell_ids(), + 'post__in' => empty( $upsells ) ? array( -1 ) : $upsells, ); }, function ( $collection_args, $query ) {