0

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

0

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.org/Plugin_API/Action_Reference/quick_edit_custom_box

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.