Last active
March 26, 2025 08:47
-
-
Save IliaDi/4c3611486ef0c124647ded72f3ac7857 to your computer and use it in GitHub Desktop.
display bundles that the currently viewed product is included in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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