BSF_Update_Manager::bsf_is_product_bundled( array $bsf_product, string $search_by = 'id' )
Check if product is bundled.
Description
Parameters
- $bsf_product
-
(array) (Required) Product.
- $search_by
-
(string) (Optional) Search By.
Default value: 'id'
Return
($product_parent.)
Source
File: admin/bsf-core/class-bsf-update-manager.php
public static function bsf_is_product_bundled( $bsf_product, $search_by = 'id' ) { $brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() ); $product_parent = array(); foreach ( $brainstrom_bundled_products as $parent => $products ) { foreach ( $products as $key => $product ) { if ( 'init' === $search_by ) { if ( $product->init === $bsf_product ) { $product_parent[] = $parent; } } elseif ( 'id' === $search_by ) { if ( $product->id === $bsf_product ) { $product_parent[] = $parent; } } elseif ( 'name' === $search_by ) { if ( strcasecmp( $product->name, $bsf_product ) === 0 ) { $product_parent[] = $parent; } } } } $product_parent = apply_filters( 'bsf_is_product_bundled', array_unique( $product_parent ), $bsf_product, $search_by ); return $product_parent; }
Expand full source code Collapse full source code View on Trac