function handmade_woocommerce_order( $order_id ) {
if( ! $order_id ) return;
// Get order
$order = wc_get_order( $order_id );
// get order items = each product in the order
$items = $order->get_items();
// Set variable
$found = false;
foreach ( $items as $item ) {
// Get product id
$product = wc_get_product( $item['product_id'] );
// Is virtual
$is_virtual = $product->is_virtual();
// Is_downloadable
$is_downloadable = $product->is_downloadable();
// Backorders allowed
$backorders_allowed = $product->backorders_allowed();
if( $is_virtual && $is_downloadable && $backorders_allowed ) {
$found = true;
// true, break loop
break;
}
}
// true
if( $found ) {
$order->update_status( 'processing' );
}
}
add_action('woocommerce_thankyou', 'handmade_woocommerce_order', 10, 1 );
上面的代码将针对我的层次结构中的每个视图执行。
如何仅针对特定视图接收.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification))