get children when searching for products

This commit is contained in:
Mike Jolley 2012-04-16 13:52:28 +01:00
parent 96f6301edf
commit 5438b79c35
3 changed files with 15 additions and 3 deletions

View File

@ -28,6 +28,8 @@ function woocommerce_add_category_thumbnail_field() {
</div>
<script type="text/javascript">
window.send_to_editor_default = window.send_to_editor;
window.send_to_termmeta = function(html) {
jQuery('body').append('<div id="temp_image">' + html + '</div>');
@ -43,6 +45,8 @@ function woocommerce_add_category_thumbnail_field() {
jQuery('#temp_image').remove();
tb_remove();
window.send_to_editor = window.send_to_editor_default;
}
jQuery('.upload_image_button').live('click', function(){

View File

@ -875,7 +875,7 @@ function woocommerce_json_search_products( $x = '', $post_types = array('product
if (empty($term)) die();
if (is_numeric($term)) {
if ( is_numeric( $term ) ) {
$args = array(
'post_type' => $post_types,
@ -885,7 +885,15 @@ function woocommerce_json_search_products( $x = '', $post_types = array('product
'fields' => 'ids'
);
$posts = get_posts( $args );
$args2 = array(
'post_type' => $post_types,
'post_status' => 'publish',
'posts_per_page' => -1,
'post_parent' => $term,
'fields' => 'ids'
);
$posts = array_unique(array_merge( get_posts( $args ), get_posts( $args2 ) ));
} else {

View File

@ -16,7 +16,7 @@
* @category Core
* @author WooThemes
*/
if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( !class_exists( 'Woocommerce' ) ) {