WooCommerce 제품에이 질문/답변에 맞춤 입력란을 추가했습니다 :
Display a custom product field before short description in WooCommerce.WooCommerce에서 관리자 제품 일괄 수정 양식에 제품 맞춤 입력란을 추가하십시오.
이 사용자 정의 필드를 제품 일괄 수정 특수 페이지 (관리 제품 목록 페이지에서 액세스 가능)에 추가 할 수 있습니까?
WooCommerce 제품에이 질문/답변에 맞춤 입력란을 추가했습니다 :
Display a custom product field before short description in WooCommerce.WooCommerce에서 관리자 제품 일괄 수정 양식에 제품 맞춤 입력란을 추가하십시오.
이 사용자 정의 필드를 제품 일괄 수정 특수 페이지 (관리 제품 목록 페이지에서 액세스 가능)에 추가 할 수 있습니까?
네, 그것은 (연결된 질문/대답으로) 사용자 정의 필드 '_text_field'
에 대한 대량 편집 제품에 가능합니다.
이 사용자 정의 필드는 편집 페이지의 처음 또는 끝에 추가 할 수 있습니다. 이 훅 사용 시작을 위해
woocommerce_product_bulk_edit_start
woocommerce_product_bulk_edit_end
(사용자 정의 필드는 여기서 시작 부분에) 코드 :
// Add a custom field to product bulk edit special page
add_action('woocommerce_product_bulk_edit_start', 'custom_field_product_bulk_edit', 10, 0);
function custom_field_product_bulk_edit() {
?>
<div class="inline-edit-group">
<label class="alignleft">
<span class="title"><?php _e('T. dostawy', 'woocommerce'); ?></span>
<span class="input-text-wrap">
<select class="change_t_dostawy change_to" name="change_t_dostawy">
<?php
$options = array(
'' => __('— No change —', 'woocommerce'),
'1' => __('Change to:', 'woocommerce'),
);
foreach ($options as $key => $value) {
echo '<option value="' . esc_attr($key) . '">' . $value . '</option>';
}
?>
</select>
</span>
</label>
<label class="change-input">
<input type="text" name="_t_dostawy" class="text t_dostawy" placeholder="<?php _e('Enter Termin dostawy', 'woocommerce'); ?>" value="" />
</label>
</div>
<?php
}
// Save the custom fields data when submitted for product bulk edit
add_action('woocommerce_product_bulk_edit_save', 'save_custom_field_product_bulk_edit', 10, 1);
function save_custom_field_product_bulk_edit($product){
if ($product->is_type('simple') || $product->is_type('external')){
$product_id = method_exists($product, 'get_id') ? $product->get_id() : $product->id;
if (isset($_REQUEST['_t_dostawy']))
update_post_meta($product_id, '_text_field', sanitize_text_field($_REQUEST['_t_dostawy']));
}
}
코드는 활성 자식 테마 (또는 테마)의 function.php 파일 또는 모든 플러그인 파일에 있습니다.
이 코드는 테스트되었으며 작동합니다.
감사합니다 !!! :) – interlaw
당신이 대량으로 무엇을 의미합니까 : 당신이받을 수 있습니까? – Reigel
@Reigel 여러 제품을 선택하고 가로 메뉴에서 편집을 선택합니다. 너는 본다 : 1. https://ibb.co/jqd0wv - "편집"단추를 선정하고 누르 십시요. 2 - 한 번에 여러 제품을 수정할 수 있습니다. https://ibb.co/cT0KpF – interlaw
Google에서 'wordpress bulk action tut'을 검색합니다. – Reigel