Skip to content

Instantly share code, notes, and snippets.

@IliaDi
Last active March 26, 2025 08:47
Show Gist options
  • Save IliaDi/4c3611486ef0c124647ded72f3ac7857 to your computer and use it in GitHub Desktop.
Save IliaDi/4c3611486ef0c124647ded72f3ac7857 to your computer and use it in GitHub Desktop.
display bundles that the currently viewed product is included in
<?php
add_action('woocommerce_after_add_to_cart_form', 'wc_pb_display_bundles');
function wc_pb_display_bundles(){
global $product;
$product_id = $product->get_id();
$bundle_ids = wc_pb_get_bundled_product_map( $product_id, false );
if (!empty( $bundle_ids)){
$bundle_ids_list = implode( ",", $bundle_ids );
echo "Also found in these Bundles:\n";
echo do_shortcode('[products ids="'.$bundle_ids_list.'"]');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment