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 badge1 Answer
Reset to default 1You 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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745643863a4637853.html
评论列表(0条)