Hello,
Could you please help me configure the search functionality to include the GTIN meta field so that products can be searched by their GTIN?
Thank you!
This topic has 6 replies, 3 voices, and was last updated 9 months, 4 weeks ago ago by Luca Rossi
Hello,
Could you please help me configure the search functionality to include the GTIN meta field so that products can be searched by their GTIN?
Thank you!
Hello Alpha111,
Thank you for reaching out to us with your request.
Unfortunately, we are unable to fulfill your request at this time. However, we encourage you to submit your feature request on our task board at https://www.8theme.com/taskboard/. This will allow our development team to review it directly.
Best Regards,
8Theme’s Team
can you help me takle it with custom code ?
Hello Alpha111,
Additional customization is outside the scope of our basic support.
Should you require personalized customization services, we invite you to submit a request through our customization panel at the following link: https://www.8theme.com/account/#etheme_customization_panel. This will allow you to engage directly with our technical team.
Please note that customization services are subject to additional charges. The exact amount will be determined after a detailed review of your request.
Best Regards,
8Theme’s Team
i tried this
function custom_product_search($search_results, $term, $query_args) {
if (!empty($term)) {
global $wpdb;
$gtin_results = $wpdb->get_col($wpdb->prepare("
SELECT DISTINCT p.ID FROM {$wpdb->posts} p
JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id
WHERE p.post_type = 'product'
AND p.post_status = 'publish'
AND pm.meta_key = '_et_gtin'
AND pm.meta_value LIKE %s
", '%' . $wpdb->esc_like($term) . '%'));
if (!empty($gtin_results)) {
$search_results = array_unique(array_merge($search_results, $gtin_results));
}
}
return $search_results;
}
add_filter('woocommerce_product_search_results', 'custom_product_search', 10, 3);
Hi @Alpha111,
Please try with this code instead: https://wordpress.stackexchange.com/a/309900/22807.
Any issues related to this custom codes must be directed to the author.
Hope it helps!
The issue related to '‘Enable Product Search by GTIN in WooCommerce’' has been successfully resolved, and the topic is now closed for further responses