ID, 'post_id' ); } // add the meta box only if reservations are enabled if ( get_option( 'dbem_rsvp_enabled' ) && $em_event->can_manage( 'manage_bookings', 'manage_others_bookings' ) ) { add_meta_box( 'aem-event-referral-rate', __( 'Affiliates', 'affiliates-events-manager' ), array( __CLASS__, 'meta_box_affiliates' ), 'event', 'normal', 'high' ); // We do not add it to recurring events (posts of type 'event-recurring') as these can't really be booked. // Recurring events just create normal events and that is where we would set a rate. } } /** * Meta box output * * @param WP_Post $post */ public static function meta_box_affiliates( $post ) { echo '
'; $rates = Affiliates_Rate::get_rates( array( 'integration' => 'affiliates-events-manager', 'object_id' => $post->ID ) ); if ( function_exists( 'em_get_event' ) ) { $em_event = em_get_event( $post->ID, 'post_id' ); $categories = $em_event->get_categories(); foreach ( $categories as $category ) { $term_rates = Affiliates_Rate::get_rates( array( 'integration' => 'affiliates-events-manager', 'term_id' => $category->id ) ); } } echo '

'; echo esc_html( __( 'Rates', 'affiliates-events-manager' ) ); echo '

'; if ( count( $rates ) > 0 ) { echo '

'; echo esc_html( _n( 'This specific rate applies to this event', 'These specific rates apply to this event.', count( $rates ), 'affiliates-events-manager' ) ); echo '

'; $odd = true; $is_first = true; echo ''; foreach ( $rates as $rate ) { if ( $is_first ) { // @codingStandardsIgnoreStart echo $rate->view( array( 'style' => 'table', 'titles' => true, 'exclude' => 'integration', 'prefix_class' => 'odd' ) ); // @codingStandardsIgnoreStart } else { // @codingStandardsIgnoreStart echo $rate->view( array( 'style' => 'table', 'exclude' => 'integration', 'prefix_class' => $odd ? 'odd' : 'even' ) ); // @codingStandardsIgnoreEnd } $is_first = false; $odd = !$odd; } echo '
'; } else { echo '

'; echo esc_html( __( 'This event has no specific applicable rates.', 'affiliates-events-manager' ) ); echo '

'; } if ( current_user_can( AFFILIATES_ADMINISTER_OPTIONS ) && !empty( $post ) && !empty( $post->post_status ) && $post->post_status !== 'auto-draft' ) { echo '

'; $url = wp_nonce_url( add_query_arg( array( 'object_id' => $post->ID, 'integration' => 'affiliates-events-manager', 'action' => 'create-rate' ), admin_url( 'admin.php?page=affiliates-admin-rates' ) ) ); echo sprintf( '', esc_url( $url ) ); echo esc_html__( 'Create a rate', 'affiliates-events-manager' ); echo ''; echo '

'; } else { echo '

'; echo esc_html__( 'Once you save this event, you can create a rate from here.', 'affiliates-woocommerce' ); echo '

'; } echo '
'; } } Affiliates_EM_Booking::init();