Hello,
our client wanted to have 2 product SKU’s because they had an old ERP and a new one. They have a lot of customers using their old Product Catalogues and those catalogues have printed on the old product codes. So, using the snippet below we’ve managed to create a secondary SKU:
// Add secondary SKU field
add_action('woocommerce_product_options_sku', 'add_secondary_sku_field');
function add_secondary_sku_field() {
woocommerce_wp_text_input(array(
'id' => 'secondary_sku',
'label' => __('Κωδικός Entersoft', 'woocommerce'),
'desc_tip' => true,
'description' => __('Enter the secondary SKU code.', 'woocommerce'),
));
}
// Save the secondary SKU
add_action('woocommerce_process_product_meta', 'save_secondary_sku_field');
function save_secondary_sku_field($post_id) {
$secondary_sku = isset($_POST['secondary_sku']) ? sanitize_text_field($_POST['secondary_sku']) : '';
update_post_meta($post_id, 'secondary_sku', $secondary_sku);
}
How can we make the ajax search bar to also include that custom field within the search results?
Thank you once again, you are amazing!