Zenia Store

Gestión

[insert_php]
if ( is_user_logged_in() ) {
//PARA PROBLEMAS CON GLOBAL wpdb
require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-load.php’ );
global $wpdb;
$url=get_home_url();
$current_user = wp_get_current_user();
//$current_user_id = get_current_user_id();

$allowed_roles = array(‘administrator’,’editor’);
$taxonomy=’product_cat’;

$nicename=$current_user->user_nicename ;
$current_user_id=$current_user->ID;

if( array_intersect($allowed_roles, $current_user->roles ) ) {

if(isset($_GET[‘eliminar’]) && isset($_GET[‘id’])){
wp_delete_term( $_GET[‘id’], ‘product_cat’ );

echo ““;
}

if(isset($_POST[‘anadir’]) && isset($_POST[‘subcat_nombre’])){
//$term = wp_insert_term( $nombre_restaurante, ‘product_cat’, [ ‘description’=> ”, ‘parent’ => $cat_id ]);
$term =wp_insert_term(
$_POST[‘subcat_nombre’], // the term
$taxonomy, // the taxonomy
array(
‘parent’ => $cat_id,
)
);

echo ““;
}

$categories = get_terms( [‘taxonomy’ => ‘product_cat’, ‘parent’ => 0,’hide_empty’ => false] );

// Iterate through all subcategories to display each individual subcategory
$i=0;

echo ‘

‘;
foreach ( $categories as $category ) {

$cat_name = $category->name;
$cat_id = $category->term_id;
$cat_slug = $category->slug;
$zonas0=array(“España”,”Francia”,”Inglaterra”,”Arabia Saudi”,”China”,”Holanda”,”Galicia”,”Alemania”,”Italia”,”Noruega”,”Portugal”,”Rusia”,”Eslovenia”,”Turquia”,”Ucrania”);
echo “

“;
foreach ( $zonas0 as $zona0 ) {
echo ““.$zona0.”“;
}
echo “

“;
$subcategories = get_terms(
array(
‘taxonomy’ => ‘product_cat’,
‘parent’ => $cat_id, // <-- The parent is the current category 'orderby' => ‘term_id’,
‘hide_empty’ => false
)
);
foreach ( $subcategories as $subcategory ) {
$subcat_name = $subcategory->name;
$subcat_id = $subcategory->term_id;
$subcat_slug = $subcategory->slug;

$zonas=array(“España”,”Francia”,”Inglaterra”,”Arabia Saudi”,”China”,”Holanda”,”Galicia”,”Alemania”,”Italia”,”Noruega”,”Portugal”,”Rusia”,”Eslovenia”,”Turquia”,”Ucrania”);
echo “

“;
foreach ( $zonas as $zona ) {
echo ““.$zona.”“;
}
echo “

“;

}

}
echo “

“;

}

}

[/insert_php]