Site icon Hip-Hop Website Design and Development

Php snippet for importing merchandise matching with classes

I exploit an import plugin to replace my WooCommerce merchandise from an XML file, after I used to have Major Classes and restricted to 1 Baby Classes I used a small php snippet to match the class from XML which is given in formal like this A1.B1 which on WooCommerce matches my customized class slug and used to map them collectively, now I want have 2 baby classes the PHP snippet I made to get my job performed is not mapping effectively the slugs of classes with xml classes I’ve tried a number of strategies I current bellow and my previous code used to work with 1 major & 1 baby

Instance of class and slug
Animals>Farm>Horse & from slug perspective a1>a1.b1>a1.b1.c1

see the code bellow any concepts to replace appropriately my code to deal with 2 baby classes .

// $personal_category get's a string like A1.B1.C1 from an xml file
// classes slugs are for instance like this a1 mum or dad class a1-b1 & a1-b1-c1 are the kid ones 

perform return_personal_categories($personal_category){

    
    if($personal_category == '-1'){
        return '';
    }else{
        $pers_cat = strtolower($personal_category);
        $pers_cat = str_replace("." , "-", $pers_cat);
        
        $time period = get_term_by('slug', $pers_cat, 'custom_category'); 
        $slug_term = $term->slug;
        $identify= term->
        //a technique however I coudn't lower the slug in 3 elements $first = strtok($slug_term, '-');
        /*different means utilizing even with constructive and unfavourable $items = explode("-", $pers_cat);
        after which utilizing  $id_nums = implode("- ", $id_nums); for concatenation 
        */

         
        /* I attempted additionally get_category_parents( $pers_cat, true, ' > ' );*/
        
        
  
    }
}

/* class instance class names : Animals>Farm>Cow & slug names a1  & a1-b1 & a1-b1-c1 */

/* code for 1 major class & one baby */

<?php


perform return_personal_categories($personal_category){

    
    if($personal_category == '-1'){
        return '';
    }else{
        $pers_cat = strtolower($personal_category);
        $pers_cat = str_replace("." , "-", $pers_cat);
        
        $time period = get_term_by('slug', $pers_cat, 'personal_categories'); 
        $slug_term = $term->slug;
        $first = strtok($slug_term, '-');
         
        if($first == 'a1'){
            $identify = "categoryname > ".$term->identify;
            return  $identify;
        
        }
        elseif ( $first == 'a3'){
            $identify = "lorem ipsum > ".$term->identify;
            return $identify;
            
        }

        else{
        $identify = $term->identify;
        return $identify;
        }
  
    }
}


perform replace_dot($slug){
    $new_slug = strtolower($slug);
    $new_slug = str_replace("." , "-", $new_slug);
    return $new_slug;
}

?>