add_action('rest_api_init', function () { register_rest_route( 'custom/v1', '/category-meta/(?P[\w-]+)', [ 'methods' => WP_REST_Server::READABLE, 'callback' => 'tecoyo_get_category_meta', 'permission_callback' => function ( WP_REST_Request $request ) { $current_user = wp_get_current_user(); if ( $current_user && $current_user->exists() && ( in_array( 'administrator', (array) $current_user->roles ) || in_array( 'shop_manager', (array) $current_user->roles ) ) ) { return true; } return new WP_Error( 'rest_forbidden', esc_html__( 'You are not allowed to access this endpoint.' ), [ 'status' => 401 ] ); }, ] ); } ); /** * Callback: Fetches WooCommerce product_cat term and its metadata. * * URL patterns: * GET /wp-json/custom/v1/category-meta/123 * GET /wp-json/custom/v1/category-meta/my-category-slug */ function tecoyo_get_category_meta( WP_REST_Request $request ) { $identifier = $request->get_param( 'identifier' ); // Try interpreting as ID; if not numeric, treat as slug. if ( is_numeric( $identifier ) ) { $term = get_term( (int) $identifier, 'product_cat' ); } else { $term = get_term_by( 'slug', sanitize_text_field( $identifier ), 'product_cat' ); } if ( ! $term || is_wp_error( $term ) ) { return new WP_Error( 'invalid_category', sprintf( 'Product category "%s" not found.', esc_html( $identifier ) ), [ 'status' => 404 ] ); } $term_id = $term->term_id; // Core fields $data = [ 'id' => $term_id, 'name' => $term->name, 'slug' => $term->slug, 'description' => $term->description, 'count' => $term->count, ]; // WooCommerce‐specific display type $thumbnail_id = get_term_meta( $term_id, 'thumbnail_id', true ); $image_url = $thumbnail_id ? wp_get_attachment_url( $thumbnail_id ) : ''; $data['display_type'] = get_term_meta( $term_id, 'display_type', true ); $data['image_id'] = $thumbnail_id; $data['image_url'] = $image_url; // All other term meta (custom fields) as key => [ values ] $all_meta = get_term_meta( $term_id ); // Optionally, remove thumbnail_id & display_type if you want to avoid duplication: unset( $all_meta['thumbnail_id'], $all_meta['display_type'] ); $data['meta'] = $all_meta; return rest_ensure_response( $data ); } Events - The Ticket Shop

Events

Alle Events

Ergebnisse 1 – 9 von 21 werden angezeigt

1
  • Die Menge von „TestProdukt“ darf nicht höher als 10 sein, um eine Bestellung aufzugeben.
1
Your Cart
Platzhalter
2+ shoppers have bought this
TestProdukt
prezzo: 1,00
- +
11,00
  • Die Menge von „TestProdukt“ darf nicht höher als 10 sein, um eine Bestellung aufzugeben.

Support