Support Forum » User Profile

Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • in reply to: How to show up the custom column in grouped meta #9472
    downloadtakydownloadtaky
    Participant

    This is the code I used while the date where in string (before all the group madness) to retrieve the meta_key_value.
    It echoes the value in a new column inside edit screen and also let me modify It using quick edit.
    The problem is that it can't work with my actual configuration.
    Anyway, here is my code:
    https://pastebin.com/ZqvmHcye

    And this is the code I use to generate metaboxes. I've added a couple of comments to try to explain what I would like to extract and being able to modify.
    https://pastebin.com/4BgTUcRM

    Do you think is there a way to rearrange old code to be compatible with the new one?
    Thank you.

    in reply to: How to show up the custom column in grouped meta #9471
    downloadtakydownloadtaky
    Participant

    Ok, now I have nested, clonable, groups, let's try to see if it works

    in reply to: How to show up the custom column in grouped meta #9470
    downloadtakydownloadtaky
    Participant

    Can I clone a group?
    var SIZE has defined values (37.5cl/50cl/75cl/magnum/keg)
    but inside same sizes I can have different batches and these aren't fixed values (we are talking about a huge craft beer cellar where some beers are from 1999/2000/2001/2002....)
    Obviously any combination has a different price and availability.
    So if I was able to do something like a multidimensional loop (pseudo code ahead):
    foreach ($size as $sizes){foreach ($37 as $37s){2017=10€=10;2015=12€=5;2013=15€=3};};
    It would help a lot, maybe a conditional 'clone' or something like that?

    in reply to: How to show up the custom column in grouped meta #9446
    downloadtakydownloadtaky
    Participant

    Is there also a way to correlate values?
    My metas are in Italian, anyway what I am working is something like an Inventory for beers in my cellar (I am a pub owner).
    Cantina is the italian word for cellar.
    Let's imagine we have a beer named (nome_birra): Cantillon Gueuze .
    This beer can have 3 different sizes (formato_birra):
    37.5cl / 75cl / Magnum
    But it can also be from a different batch (annata_birra) so we can have as an example:
    37.5cl -2013/2015
    75cl - 2017
    Magnum - 2014
    So I can have different amount of bottles for each size and batch (quantita_birra):
    37.5cl - 2013 :1
    37.5cl - 2015 :3
    75cl - 2017:5
    Magnum - 2014: 2
    And each combination has obviously a differente price (prezzo_birra).
    So, how can I create such a multidimentional array and then show the values in the custom column?

    in reply to: How to show up the custom column in grouped meta #9445
    downloadtakydownloadtaky
    Participant

    How can I make it sortable and how can I use quick edit to modify it?

    in reply to: How to show up the custom column in grouped meta #9444
    downloadtakydownloadtaky
    Participant

    Actually I managed to show it like this, this is in functions.php:

    /**
         * Registra admin columns Nuovo METODO
         */
        add_action( 'admin_init', 'et2018_add_custom_columns', 20 );
        function et2018_add_custom_columns() {
            require_once get_template_directory() . '/template-parts/admin/customcolumn-nuovo.php';
            new et2018_Custom_Admin_Columns( 'post', array() );
        }

    This is the file I require:

    <?php
        /**
         *
         * TODO Inserire codice per le colonne
         */
        class et2018_Custom_Admin_Columns extends MB_Admin_Columns_Post {
            public function columns( $columns ) {
                $columns  = parent::columns( $columns );
                $position = '';
                $target   = '';
                $this->add( $columns, 'column_id', 'Column Title', $position, $target );
                // Add more if you want
                return $columns;
            }
            public function show( $column, $post_id ) {
                switch ( $column ) {
                    case 'column_id';
                        global $post;
                        $passaggiocantina = get_post_meta( $post->ID, 'gruppo_cantina', true );
                        if ( isset( $passaggiocantina['et2018-quantita_birra'] ) ) {
                            $quantita = $passaggiocantina['et2018-quantita_birra'];
                            foreach ($quantita as $quanto){echo $quanto.'-';}
                        };
                        break;
                    // More columns
                }
            }
        }

    Actually it works, is it the right way or there is a better one?

    downloadtakydownloadtaky
    Participant

    Really can't understand why but if I do this:
    $birra = isset( $passaggio['et2018-nome_birra'] ) ? $passaggio['et2018-nome_birra'] : '<a href="'.get_the_permalink().'" title="'.get_the_title().'"><p>Birra: '.$birra.'</p></a>';

    it doesn't work.

    If I do like this, instead:

    if (isset($passaggio['et2018-nome_birra'])){
                        $birra = $passaggio['et2018-nome_birra'];
                    }
    echo '<a href="'.get_the_permalink().'" title="'.get_the_title().'"><p>Birra: '.$birra.'</p></a>';

    It works.

    downloadtakydownloadtaky
    Participant

    Ok, it works like this:

    <?php $passaggio = get_post_meta($post->ID, 'gruppo_birra', true);
                    if (isset($passaggio['et2018-nome_birra'])){
                        $birra = $passaggio['et2018-nome_birra'];
                    }
                    if (isset($passaggio['et2018-nome_birrificio'])){
                        $birrificio = $passaggio['et2018-nome_birrificio'];
                    };
                    if (isset($passaggio['et2018-gradazione'])){
                        $gradazione = $passaggio['et2018-gradazione'];
                    };
                    if(isset($passaggio['et2018-stile_birra'])){
                        $stile = $passaggio['et2018-stile_birra'];
                    };
                    if (isset($passaggio['et2018-gusto_prevalente'])){
                        $macrogusto = $passaggio['et2018-gusto_prevalente'];
                    };
                    if (isset($passaggio['et2018-gusto_prevalente'])){
                        $annate = $passaggio['et2018-annata_birra'];
                    };
                    if (isset($passaggio['et2018-gusto_descrittori'])){
                        $descrittori = $passaggio['et2018-gusto_descrittori'];
                    };
                    if (isset($passaggio['et2018-prezzo_birra'])){
                        $prezzo = $passaggio['et2018-prezzo_birra'];
                    };
                    if (isset ($passaggio['et2018-disponibilita'])){
                        $disponibilita = $passaggio['et2018-disponibilita'];
                    };
                    if (isset ($passaggio['et2018-formato_birra'])){
                        $formato = $passaggio['et2018-formato_birra'];
                    };
                    if (isset ($passaggio['et2018-quantita_birra'])){
                        $quantita = $passaggio['et2018-quantita_birra'];
                    };
                    if (isset ($passaggio['et2018-annata_birra'])){
                        $annata = $passaggio['et2018-annata_birra'];
                    };
                    echo '<a href="'.get_the_permalink().'" title="'.get_the_title().'"><p>Birra: '.$birra.'</p></a>';
                    echo '<p>Birrificio: '.$birrificio.'</p>';
                    echo '<p>Gradazione: '.$gradazione.'%</p>';
                    echo '<p>Stile: '.$stile.'</p>';
                    echo '<p>Macro descrittore: '.$macrogusto.'</p>';
                    echo 'Annate disponibili: <ul>';
                        foreach ($annata as $anno){echo '<li>'.$anno.'</li>';};
                    echo '</ul>';
                    echo 'Costo: <ul>';
                    foreach ($prezzo as $prezzi){echo '<li>'.$prezzi.'</li>';};
                    echo '</ul>';
                ?>
    downloadtakydownloadtaky
    Participant

    Thank you very much, now, how can I retrieve the data?
    I've slightly modified your code to add a prefix: et2018-
    https://pastebin.com/QruNZEzY
    Let's say I would like to find the value in: et2018-nome_birra
    Actually if I would like to retrieve the data I use:

    $passaggio = get_post_meta($post->ID, 'gruppo_birra', true);
    $birra = $passaggio['et2018-nome_birra'];
                    echo '<p>Birra: '.$birra.'</p>';

    Obviusly it works, but what if the var $birra is empty or worst, what if
    $passaggio['et2018-nome_birra'] is empty?
    If I try to use this:

    <?php $passaggio = get_post_meta($post->ID, 'gruppo_birra', true);
                if (isset ($passaggio['et-2018-nome_birra'])){
                    $birra = $passaggio['et2018-nome_birra'];
                    echo '<p>Birra: '.$birra.'</p>';
                }

    It shows nothing even if the variable is set.
    Maybe it is a stupid PHP problem, but I can't solve it.
    Thank you.

Viewing 9 posts - 1 through 9 (of 9 total)