id = 'ppl_afw_new_commission'; $this->title = __( 'New commission', 'affireo-affiliates-for-woocommerce' ); $this->description = __( 'Sent to an affiliate when a new commission is recorded on their account.', 'affireo-affiliates-for-woocommerce' ); $this->customer_email = true; $this->heading = __( 'You earned a new commission', 'affireo-affiliates-for-woocommerce' ); $this->subject = __( 'You earned a new commission', 'affireo-affiliates-for-woocommerce' ); add_action( 'ppl_afw_referral_created', array( $this, 'trigger' ), 20, 3 ); parent::__construct(); } /** * Triggers the email. * * @since 1.0.0 * @param int $referral_id Referral id. * @param object $affiliate Affiliate row. * @param \WC_Order $order Order object. */ public function trigger( $referral_id, $affiliate, $order ) { $this->setup_locale(); $this->affiliate = $affiliate; $referral = ppl_afw()->container->get( 'referrals.repository' )->find( $referral_id ); if ( $referral ) { $this->amount = (float) $referral->amount; $this->currency = (string) $referral->currency; } $user = $affiliate ? get_userdata( (int) $affiliate->user_id ) : null; if ( $user ) { $this->recipient = $user->user_email; $this->dispatch(); } $this->restore_locale(); } /** * Body content. * * @since 1.0.0 * @return string */ protected function get_body() { $amount = wc_price( $this->amount, $this->currency ? array( 'currency' => $this->currency ) : array() ); return '
' . sprintf( /* translators: %s: commission amount */ esc_html__( 'Nice work! A new commission of %s was just recorded on your account. It will be payable once the review period ends.', 'affireo-affiliates-for-woocommerce' ), wp_kses_post( $amount ) ) . '
' . $this->dashboard_link(); } }