最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - I am trying to make a field show and save from quickedit screen

matteradmin5PV0评论

I have a select box with some options. It appears in the normal product edit screen with the following code.

function we_skroutzxml_custom_availability() {
    woocommerce_wp_select(
        array(
            'id'          => 'we_skroutzxml_custom_availability',
            'placeholder' => __('Choose',$this->plugin_slug),
            'label'       => __('Availability',$this->plugin_slug),
            'options' => array( '' => __( 'Default', $this->plugin_slug ),'Άμεση παραλαβή / Παράδoση 1 έως 3 ημέρες' => __( 'Available in store / Delivery 1 to 3 days', $this->plugin_slug ),'Παράδοση σε 1 - 3 ημέρες' => __( 'Delivery 1 to 3 days', $this->plugin_slug ),'Παράδοση σε 4 - 10 ημέρες' => __( 'Delivery 4 to 10 days', $this->plugin_slug ), 'Κατόπιν Παραγγελίας' => __( 'Upon order', $this->plugin_slug ))
    ));
}

function we_skroutzxml_custom_availability_save_data($post_id) {
    $custom_availability = $_POST['we_skroutzxml_custom_availability'];
    if ( ! empty( $custom_availability ) ) {
        update_post_meta( $post_id, 'we_skroutzxml_custom_availability',$custom_availability);
    }else {
        delete_post_meta( $post_id, 'we_skroutzxml_custom_availability');
    }
}

What must i do to show it in the quickedit screen and save it as well?Thank you

I have a select box with some options. It appears in the normal product edit screen with the following code.

function we_skroutzxml_custom_availability() {
    woocommerce_wp_select(
        array(
            'id'          => 'we_skroutzxml_custom_availability',
            'placeholder' => __('Choose',$this->plugin_slug),
            'label'       => __('Availability',$this->plugin_slug),
            'options' => array( '' => __( 'Default', $this->plugin_slug ),'Άμεση παραλαβή / Παράδoση 1 έως 3 ημέρες' => __( 'Available in store / Delivery 1 to 3 days', $this->plugin_slug ),'Παράδοση σε 1 - 3 ημέρες' => __( 'Delivery 1 to 3 days', $this->plugin_slug ),'Παράδοση σε 4 - 10 ημέρες' => __( 'Delivery 4 to 10 days', $this->plugin_slug ), 'Κατόπιν Παραγγελίας' => __( 'Upon order', $this->plugin_slug ))
    ));
}

function we_skroutzxml_custom_availability_save_data($post_id) {
    $custom_availability = $_POST['we_skroutzxml_custom_availability'];
    if ( ! empty( $custom_availability ) ) {
        update_post_meta( $post_id, 'we_skroutzxml_custom_availability',$custom_availability);
    }else {
        delete_post_meta( $post_id, 'we_skroutzxml_custom_availability');
    }
}

What must i do to show it in the quickedit screen and save it as well?Thank you

Share Improve this question edited Mar 30, 2019 at 11:19 selidamou.gr asked Mar 30, 2019 at 10:56 selidamou.grselidamou.gr 71 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

You have to register your quick edit custom box:

function display_custom_quickedit_book( $column_name, $post_type ) {
    // it would be a good idea to add a nonce here
    ?>
    <fieldset class="inline-edit-col-right inline-edit-book">
      <div class="inline-edit-col column-<?php echo $column_name; ?>">
        <label class="inline-edit-group">
        <!-- here goes your input -->
        </label>
      </div>
    </fieldset>
    <?php
}
add_action( 'quick_edit_custom_box', 'display_custom_quickedit_book', 10, 2 );

And then you have to process the input value while saving post. But if that field is already a custom box, then you've already modified save_post to process it, I guess...

And there are a few more tricks with setting values and so on. You can read more on that on Codex: https://codex.wordpress/Plugin_API/Action_Reference/quick_edit_custom_box

Post a comment

comment list (0)

  1. No comments so far