woof_husky_txt_option
Filtert jede gerenderte HTML-Option im Husky-Textsuch-Autocomplete-Dropdown und ermöglicht so die Anpassung einzelner Suchergebnisse.
Parameter
$html (string) — Die gerenderte HTML-Zeichenfolge für eine einzelne Suchergebnisoption aus dem Template
$data (array) — Assoziatives Array von Produktdaten, einschließlich: id, title, permalink, thumbnail, excerpt, breadcrumb, labels und options
Quelldatei
ext/by_text/index.php:1066
Code-Beispiel
add_filter('woof_husky_txt_option', function($html, $data) {
// Add a price badge to each result
$product = wc_get_product($data['id']);
if ($product) {
$price = wc_price($product->get_price());
$html = str_replace('</a>', '</a> <span class="price-badge">' . $price . '</span>', $html);
}
return $html;
}, 10, 2);
Hinweise zur Verwendung
- Wird nur ausgelöst, wenn ein gültiger Template-Pfad existiert.
- Das $data Array enthält click_target (how_to_open_links), options und Produkt-Metadaten.
- Teil der Husky-Suchfunktion der 'by_text' Erweiterung.