WCMp bundle is available at a slashed price

Grab It Now

Add locations for sellers and buyers

Add locations for sellers and buyers2019-03-09T14:14:20-05:00

Home Support Forum WCMp Core Add locations for sellers and buyers

WCMp Core

Add locations for sellers and buyers Open

  • Author
    Posts
  • aexchile
    Participant
    Post count: 22

    Hello, I’m interested in adding locations so that sellers can also select this option, since buyers select the location in front of the site. As previously read. I am using PHP 7.2 localhost and 7.3 en server. The code below I pasted it in function php it gives me syntax error. I added image

    add_action (‘init’, ‘create_provincia_hierarchical_taxonomy’, 0);

    $ labels = array (
    ‘nombre’ => _x (‘Localidad:’, ‘nombre general de taxonomía’),
    ‘singular_name’ => _x (‘Localidad’, ‘taxonomía nombre singular’),
    ‘search_items’ => __ ( ‘Buscar localidad’),
    ‘all_items’ => __ (‘Todos los localidad’),
    ‘parent_item’ => __ (‘Localidad padre’),
    ‘parent_item_colon’ => __ (‘Localidad padre:’),
    ‘edit_item’ => __ (‘Editar localidad’),
    ‘update_item’ => __ (‘Actualizar localidad’),
    ‘add_new_item’ => __ (‘Añadir nueva localidad’),
    ‘new_item_name’ => __ (‘Nombre del nuevo pueblo experiencia ‘),
    ‘ menu_name ‘=> __ (‘ Localidad ‘),
    );

    register_taxonomy (‘localidad’, array (‘producto’), array (
    ‘hierarchical’ => true,
    ‘labels’ => $ labels,
    ‘show_ui’ => true,
    ‘show_admin_column’ => true,
    ‘query_var’ => true ,
    ‘rewrite’ => array (‘slug’ => ‘en’),
    ));

    }

    add_action (‘woocommerce_single_product_summary’, ‘show_product_localidad’, 25);

    función show_product_localidad () {

    the_terms ($ post-> ID, ‘localidad’, ‘Localidad:’, ‘,’, ‘<br />’);
    }

    Guidance is greatly appreciated

    Attachments:
  • Raju The Cool Guy
    Moderator
    Post count: 136

    Hi @aexchile,the issue you were facing is because there was a gap between $ and value(i.e. $ labels ).So please use this $labels

  • aexchile
    Participant
    Post count: 22

    Hi rajsekharchatterjee, thank for answering.

    1 -I tried that, and it did not work, I realized that a piece of code was missing, now I added it, but it throws me the following error: FATAL ERROR syntax error, unexpected ‘:’, expecting ‘,’ or ‘)’ on line number 9 (add image)

    2 -Another question: is it correct to add the code in function php?

    Your attention is appreciated

    I copy again:

    <?phpadd_action( ‘init’, ‘create_provincia_hierarchical_taxonomy’, 0 );

    //definimos la función
    function create_provincia_hierarchical_taxonomy() {

    // Añadimos el nombre de la taxonomía en las diferentes formas que pide WordPress

    $labels = array(
    ‘name’ => _x( ‘Localidad:’, ‘taxonomy general name’ ),
    ‘singular_name’ => _x( ‘Localidad’, ‘taxonomy singular name’ ),
    ‘search_items’ => __( ‘Buscar localidad’ ),
    ‘all_items’ => __( ‘Todos los localidad’ ),
    ‘parent_item’ => __( ‘Localidad padre’ ),
    ‘parent_item_colon’ => __( ‘Localidad padre:’ ),
    ‘edit_item’ => __( ‘Editar localidad’ ),
    ‘update_item’ => __( ‘Actualizar localidad’ ),
    ‘add_new_item’ => __( ‘Añadir nuevo localidad’ ),
    ‘new_item_name’ => __( ‘Nombre del nuevo localidad’ ),
    ‘menu_name’ => __( ‘Localidad’ ),
    );

    // Registramos la taxonomía para ‘product’ el custom post type utilizado por WooCommerce
    // Definimos la taxonomía como jerárquica para poder descolgar de ella subtemas

    register_taxonomy(‘localidad’,array(‘product’), array(
    ‘hierarchical’ => true,
    ‘labels’ => $labels,
    ‘show_ui’ => true,
    ‘show_admin_column’ => true,
    ‘Something is wrong_var’ => true,
    ‘rewrite’ => array( ‘slug’ => ‘en’ ),
    ));

    }

    rajsekharchatterjee11

    // Ya están creadas las taxonomías, ahora toca mostrarlas en las páginas de producto
    // Mostrar el localidad en la página de producto

    add_action( ‘woocommerce_single_product_summary’, ‘show_product_localidad’, 25 );

    function show_product_localidad(){

    the_terms( $post->ID, ‘localidad’, ‘Localidad: ‘, ‘, ‘, ‘<br />’ );
    }

    Attachments:
  • Raju The Cool Guy
    Moderator
    Post count: 136

    Hi @aexchile,use this code snippet

    add_action( 'init', 'create_book_taxonomies');
    
    // create two taxonomies, genres and writers for the post type "book"
    function create_book_taxonomies() {
        // Add new taxonomy, make it hierarchical (like categories)
        $labels = array(
            'name'              => _x( 'terms', 'taxonomy general name' ),
            'singular_name'     => _x( 'term', 'taxonomy singular name' ),
            'search_items'      => __( 'Search terms' ),
            'all_items'         => __( 'All terms' ),
            'parent_item'       => __( 'Parent term' ),
            'parent_item_colon' => __( 'Parent term:' ),
            'edit_item'         => __( 'Edit term' ),
            'update_item'       => __( 'Update term' ),
            'add_new_item'      => __( 'Add New term' ),
            'new_item_name'     => __( 'New term Name' ),
            'menu_name'         => __( 'term' ),
        );
    
        $args = array(
            'hierarchical'      => true,
            'labels'            => $labels,
            'show_ui'           => true,
            'show_admin_column' => true,
            'query_var'         => true,
            'rewrite'           => array( 'slug' => 'term' )
        );
    
        register_taxonomy( 'term', array( 'product' ), $args );
    
    }

    2.yes you can add the code in function.php

  • aexchile
    Participant
    Post count: 22

    Thanks rajsekharchatterjee;
    Added code in function php.

    Question: Where and how can I create the locality categories?
    Instinctively I went to the category of publication, but I did not add the category of locality in the option of the seller, I verified to create a new product, to edit a product, details of the product … but nothing …

    Where can I create the locality categories and where can the seller select it?

    Thank you so much

  • Tech Tycoon Debleena
    Keymaster
    Post count: 501

    Hi @aexchile, please refer to this code snippet to add category in the vendor add product page :

    add_action('after_wcmp_product_tags_metabox_panel','add_new_field');
    function add_new_field(){
    //add your catagory here
    }
  • aexchile
    Participant
    Post count: 22

    Hello Debleena, I added the code below in php function. Now I am trying to add the city to visualize it.
    I wrote it in 2 ways:

    add_action(‘after_wcmp_product_tags_metabox_panel’,’add_new_field’);
    function add_new_field(){
    City
    }

    It shows the following: analysis: syntax error, ‘}’ unexpected in C: \ xampp \ htdocs \ store \ wp-content \ themes \ generatepress_child \ functions.php on line 83
    Fatal error: An exception occurs without a stack frame in Unknown on line 0

    I also wrote continuing the text:
    {
    //City
    }

    But I did not get results: added image
    Another question: to write several cities, what separation do you use ?: Ex: City_City2_City3_

    Thank you so much

  • NerdySupportExpert Moumita
    Keymaster
    Post count: 4600

    @aexchile, you need to add your own custom code, by referring to this code snippet :
    https://wc-marketplace.com/support-forum/topic/add-locations-for-sellers-and-buyers/#post-55862

Please LOGIN to reply to this topic