Merge pull request #1432 from nathanielks/master

woocommerce_create_term returns Notice
This commit is contained in:
Mike Jolley 2012-08-25 01:19:03 -07:00
commit 6a320fb942
1 changed files with 14 additions and 9 deletions

View File

@ -316,17 +316,22 @@ function woocommerce_create_term( $term_id, $tt_id, $taxonomy ) {
$term = get_term($term_id, $taxonomy);
// gets the sibling terms
$siblings = get_terms($taxonomy, "parent={$term->parent}&menu_order=ASC&hide_empty=0");
foreach ($siblings as $sibling) {
if( $sibling->term_id == $term_id ) continue;
$next_id = $sibling->term_id; // first sibling term of the hierarchy level
break;
if ( $term != null ){
// gets the sibling terms
$siblings = get_terms($taxonomy, "parent={$term->parent}&menu_order=ASC&hide_empty=0");
foreach ($siblings as $sibling) {
if( $sibling->term_id == $term_id ) continue;
$next_id = $sibling->term_id; // first sibling term of the hierarchy level
break;
}
// reorder
woocommerce_order_terms( $term, $next_id, $taxonomy );
}
// reorder
woocommerce_order_terms( $term, $next_id, $taxonomy );
}