WC_Deprecated_Action_Hooks::trigger_hook()
Fire off a legacy hook with it's args.
Method of the class: WC_Deprecated_Action_Hooks{}
Hooks from the method
Return
Mixed
.
Usage
// protected - for code of main (parent) or child class $result = $this->trigger_hook( $old_hook, $new_callback_args );
- $old_hook(string) (required)
- Old hook name.
- $new_callback_args(array) (required)
- New callback args.
WC_Deprecated_Action_Hooks::trigger_hook() WC Deprecated Action Hooks::trigger hook code WC 9.4.2
protected function trigger_hook( $old_hook, $new_callback_args ) { switch ( $old_hook ) { case 'woocommerce_order_add_shipping': case 'woocommerce_order_add_fee': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Shipping' ) || is_a( $item, 'WC_Order_Item_Fee' ) ) { do_action( $old_hook, $order_id, $item_id, $item ); } break; case 'woocommerce_order_add_coupon': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Coupon' ) ) { do_action( $old_hook, $order_id, $item_id, $item->get_code(), $item->get_discount(), $item->get_discount_tax() ); } break; case 'woocommerce_order_add_tax': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Tax' ) ) { do_action( $old_hook, $order_id, $item_id, $item->get_rate_id(), $item->get_tax_total(), $item->get_shipping_tax_total() ); } break; case 'woocommerce_add_shipping_order_item': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Shipping' ) ) { do_action( $old_hook, $order_id, $item_id, $item->legacy_package_key ); } break; case 'woocommerce_add_order_item_meta': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Product' ) ) { do_action( $old_hook, $item_id, $item->legacy_values, $item->legacy_cart_item_key ); } break; case 'woocommerce_add_order_fee_meta': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Fee' ) ) { do_action( $old_hook, $order_id, $item_id, $item->legacy_fee, $item->legacy_fee_key ); } break; case 'woocommerce_order_edit_product': $item_id = $new_callback_args[0]; $item = $new_callback_args[1]; $order_id = $new_callback_args[2]; if ( is_a( $item, 'WC_Order_Item_Product' ) ) { do_action( $old_hook, $order_id, $item_id, $item, $item->get_product() ); } break; default: do_action_ref_array( $old_hook, $new_callback_args ); break; } }