Onox'un hook sistemi eklentilerin core davranışını genişletmesini sağlar.
Hook Türleri
- Action Hook: Bir noktada kod çalıştır (yan etki)
- Filter Hook: Veriyi değiştir ve geri dön
Mevcut Hook Noktaları
Storefront
storefront.header.before storefront.header.after storefront.footer.before storefront.product.price (filter) storefront.cart.item.added storefront.checkout.before storefront.checkout.completed
Admin
admin.menu.register admin.dashboard.widgets admin.order.status.changed admin.product.saved
Sistem
payment.channels.register shipping.carriers.register marketplace.integration.sync
Hook Kullanımı
// Aksiyon dinle
$this->hook('storefront.cart.item.added', function($item) {
Logger::info('Sepete eklendi: ' . $item['name']);
});
// Filtre uygula
$this->filter('storefront.product.price', function($price, $product) {
if ($product['category'] === 'indirimli') {
return $price * 0.8; // %20 indirim
}
return $price;
});