/**
  * Load scripts for use by QV on non-product pages.
  *
  * @return  void
  */
 public static function load_scripts()
 {
     if (!is_product()) {
         WC_PB()->display->woo_bundles_frontend_scripts();
         wp_enqueue_script('wc-add-to-cart-bundle');
         wp_enqueue_style('wc-bundle-css');
     }
 }
 /**
  * OPC Single-product bundle-type add-to-cart template.
  *
  * @param  int  $opc_post_id
  * @return void
  */
 public static function opc_single_add_to_cart_bundle($opc_post_id)
 {
     global $product;
     // Enqueue script
     wp_enqueue_script('wc-add-to-cart-bundle');
     wp_enqueue_style('wc-bundle-css');
     if ($product->is_purchasable()) {
         ob_start();
         wc_get_template('single-product/add-to-cart/bundle.php', array('available_variations' => $product->get_available_bundle_variations(), 'attributes' => $product->get_bundle_variation_attributes(), 'selected_attributes' => $product->get_selected_bundle_variation_attributes(), 'bundle_price_data' => $product->get_bundle_price_data(), 'bundled_items' => $product->get_bundled_items()), false, WC_PB()->woo_bundles_plugin_path() . '/templates/');
         echo str_replace(array('<form method="post" enctype="multipart/form-data"', '</form>'), array('<div', '</div>'), ob_get_clean());
     }
 }
/**
 * Bundled variation template.
 *
 * @param  int             $product_id
 * @param  WC_Bundled_Item $bundled_item
 * @return void
 */
function wc_bundles_single_variation($product_id, $bundled_item)
{
    wc_get_template('single-product/bundled-variation.php', array('bundled_item' => $bundled_item, 'bundle_fields_prefix' => apply_filters('woocommerce_product_bundle_field_prefix', '', $bundled_item->bundle_id)), false, WC_PB()->woo_bundles_plugin_path() . '/templates/');
}
<?php

/**
 * Bundled Variation Product Template.
 *
 * Override this template by copying it to 'yourtheme/woocommerce/single-product/bundled-variation.php'.
 *
 * On occasion, this template file may need to be updated and you (the theme developer) will need to copy the new files to your theme to maintain compatibility.
 * We try to do this as little as possible, but it does happen.
 * When this occurs the version of the template file will be bumped and the readme will list any important changes.
 *
 * @version  4.12.0
 */
// Exit if accessed directly.
if (!defined('ABSPATH')) {
    exit;
}
?>
<div class="woocommerce-variation single_variation bundled_item_cart_details"></div>
<div class="woocommerce-variation-add-to-cart variations_button bundled_item_button">
	<input type="hidden" class="variation_id" name="<?php 
echo $bundle_fields_prefix . 'bundle_variation_id_' . $bundled_item->item_id;
?>
" value=""/><?php 
wc_get_template('single-product/bundled-item-quantity.php', array('bundled_item' => $bundled_item, 'bundle_fields_prefix' => $bundle_fields_prefix), false, WC_PB()->woo_bundles_plugin_path() . '/templates/');
?>
</div>
 /**
  * Hook into 'woocommerce_composited_add_to_cart' to trigger 'woo_bundles_add_bundle_to_cart'.
  *
  * @param string  $cart_item_key
  * @param int     $product_id
  * @param int     $quantity
  * @param int     $variation_id
  * @param array   $variation
  * @param array   $cart_item_data
  */
 public static function add_bundle_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data)
 {
     WC_PB()->cart->woo_bundles_add_bundle_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data);
 }
 /**
  * A bundle requires user input if: ( is nyp ) or ( has required addons ) or ( has items with variables ).
  *
  * @return boolean  true if it needs configuration before adding to cart
  */
 public function requires_input()
 {
     if (!$this->is_synced()) {
         $this->sync_bundle();
     }
     $requires_input = false;
     if ($this->is_nyp || WC_PB()->compatibility->has_required_addons($this->id) || $this->items_require_input) {
         $requires_input = true;
     }
     return apply_filters('woocommerce_bundle_requires_input', $requires_input, $this);
 }
            // Update from previous versions.
            // Delete old option.
            delete_option('woocommerce_product_bundles_active');
            // Delete old transients.
            $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE ('_transient_wc_bundled_item_%') OR `option_name` LIKE ('_transient_timeout_wc_bundled_item_%')");
        } elseif (version_compare($version, $this->version, '<')) {
            update_option('woocommerce_product_bundles_version', $this->version);
        }
    }
    /**
     * Deactivate extension.
     *
     * @return void
     */
    public function deactivate()
    {
        delete_option('woocommerce_product_bundles_version');
    }
}
/**
 * Returns the main instance of WC_Bundles to prevent the need to use globals.
 *
 * @since  4.11.4
 * @return WooCommerce Product Bundles
 */
function WC_PB()
{
    return WC_Bundles::instance();
}
$GLOBALS['woocommerce_bundles'] = WC_PB();
 /**
  * Visibility of bundled item in cart.
  *
  * @param  boolean $visible
  * @param  array   $cart_item
  * @param  string  $cart_item_key
  * @return boolean
  */
 public function woo_bundles_cart_item_visible($visible, $cart_item, $cart_item_key)
 {
     if (WC_PB()->cart->is_bundled_cart_item($cart_item)) {
         if ($bundle_container_item = WC_PB()->cart->get_bundled_cart_item_container($cart_item)) {
             $bundle = $bundle_container_item['data'];
             $bundled_item_id = $cart_item['bundled_item_id'];
             if ($bundled_item = $bundle->get_bundled_item($bundled_item_id)) {
                 $visible = $bundled_item->is_visible('cart');
             }
         }
     }
     return $visible;
 }
 /**
  * Add bundle info meta to order items.
  *
  * @param  int      $order_item_id      order item id
  * @param  array    $cart_item_values   cart item data
  * @param  strong   $cart_item_key      cart item key
  * @return void
  */
 public function woo_bundles_add_order_item_meta($order_item_id, $cart_item_values, $cart_item_key)
 {
     if (isset($cart_item_values['bundled_by'])) {
         wc_add_order_item_meta($order_item_id, '_bundled_by', $cart_item_values['bundled_by']);
         if (isset($cart_item_values['bundled_item_id'])) {
             wc_add_order_item_meta($order_item_id, '_bundled_item_id', $cart_item_values['bundled_item_id']);
             $bundled_item_id = $cart_item_values['bundled_item_id'];
             $visible = true;
             if ($bundle_container_item = WC_PB()->cart->get_bundled_cart_item_container($cart_item_values)) {
                 $bundle = $bundle_container_item['data'];
                 $bundled_item_id = $cart_item_values['bundled_item_id'];
                 if ($bundled_item = $bundle->get_bundled_item($bundled_item_id)) {
                     $visible = $bundled_item->is_visible('order');
                 }
             }
             if (!$visible) {
                 wc_add_order_item_meta($order_item_id, '_bundled_item_hidden', 'yes');
             }
             if (isset($cart_item_values['stamp'][$bundled_item_id]['title'])) {
                 $title = $cart_item_values['stamp'][$bundled_item_id]['title'];
                 wc_add_order_item_meta($order_item_id, '_bundled_item_title', $title);
             }
         }
     }
     if (isset($cart_item_values['stamp']) && !isset($cart_item_values['bundled_by'])) {
         if (isset($cart_item_values['bundled_items'])) {
             wc_add_order_item_meta($order_item_id, '_bundled_items', $cart_item_values['bundled_items']);
         }
         if ($cart_item_values['data']->is_priced_per_product() == true) {
             wc_add_order_item_meta($order_item_id, '_per_product_pricing', 'yes');
         } else {
             wc_add_order_item_meta($order_item_id, '_per_product_pricing', 'no');
         }
         if ($cart_item_values['data']->is_shipped_per_product() == true) {
             wc_add_order_item_meta($order_item_id, '_per_product_shipping', 'yes');
         } else {
             wc_add_order_item_meta($order_item_id, '_per_product_shipping', 'no');
         }
     }
     if (isset($cart_item_values['stamp'])) {
         wc_add_order_item_meta($order_item_id, '_stamp', $cart_item_values['stamp']);
         wc_add_order_item_meta($order_item_id, '_bundle_cart_key', $cart_item_key);
         // Store shipping data - useful when exporting order content
         foreach (WC()->cart->get_shipping_packages() as $package) {
             foreach ($package['contents'] as $pkg_item_id => $pkg_item_values) {
                 if ($pkg_item_id === $cart_item_key) {
                     $bundled_shipping = $pkg_item_values['data']->needs_shipping() ? 'yes' : 'no';
                     $bundled_weight = $pkg_item_values['data']->get_weight();
                     wc_add_order_item_meta($order_item_id, '_bundled_shipping', $bundled_shipping);
                     if ($bundled_shipping === 'yes') {
                         wc_add_order_item_meta($order_item_id, '_bundled_weight', $bundled_weight);
                     }
                 }
             }
         }
     }
 }
 /**
  * Support scanning for template overrides in extension.
  *
  * @param  array   $paths paths to check
  * @return array          modified paths to check
  */
 public function woo_bundles_template_scan_path($paths)
 {
     $paths['WooCommerce Product Bundles'] = WC_PB()->woo_bundles_plugin_path() . '/templates/';
     return $paths;
 }
 /**
  * Check if the product has variables to adjust before adding to cart.
  * Conditions: ( is NYP ) or ( has required addons ) or ( has options )
  *
  * @return boolean  true if the item has variables to adjust before adding to cart
  */
 public function requires_input()
 {
     if ($this->is_nyp() || WC_PB()->compatibility->has_required_addons($this->product_id) || $this->product->product_type === 'variable' || $this->product->product_type === 'variable-subscription') {
         return true;
     }
     return false;
 }