そのコードがあるだけで、あなたがWooCommerce 3以上でそれを使用したい場合、あなたはこのようなものを使用する必要がありますWooCommerce 2.3以下
で動作します:
?>
<p class="form-field">
<label for="related_ids"><?php _e('Name of te field', 'woocommerce'); ?></label>
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="related_ids" name="related_ids[]" data-placeholder="<?php esc_attr_e('Search for a product…', 'woocommerce'); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval($post->ID); ?>">
<?php
foreach ($product_ids as $product_id) {
$product = wc_get_product($product_id);
if (is_object($product)) {
echo '<option value="' . esc_attr($product_id) . '"' . selected(true, true, false) . '>' . wp_kses_post($product->get_formatted_name()) . '</option>';
}
}
?>
</select> <?php echo wc_help_tip(__('Tooltip text', 'woocommerce')); ?>
</p>
<?php
乾杯を!