'payout',
'plural' => 'payouts',
)
);
}
/**
* Columns.
*
* @return array
*/
public function get_columns() {
return array(
'invoice' => __( 'Invoice', 'affireo-affiliates-for-woocommerce' ),
'affiliate' => __( 'Affiliate', 'affireo-affiliates-for-woocommerce' ),
'amount' => __( 'Amount', 'affireo-affiliates-for-woocommerce' ),
'method' => __( 'Method', 'affireo-affiliates-for-woocommerce' ),
'status' => __( 'Status', 'affireo-affiliates-for-woocommerce' ),
'reference' => __( 'Reference', 'affireo-affiliates-for-woocommerce' ),
'created' => __( 'Date', 'affireo-affiliates-for-woocommerce' ),
);
}
/**
* Loads rows.
*/
public function prepare_items() {
$result = $this->container->get( 'payouts.repository' )->query(
array(
'affiliate_id' => absint( $this->get_filter( 'affiliate_id' ) ),
'status' => sanitize_key( $this->get_filter( 'status' ) ),
'page' => $this->current_page(),
'per_page' => $this->per_page,
)
);
$this->items = $result['rows'];
$this->set_pagination_args(
array(
'total_items' => $result['total'],
'per_page' => $this->per_page,
)
);
$this->_column_headers = array( $this->get_columns(), array(), array() );
}
/**
* Filter dropdown.
*
* @param string $which top or bottom.
*/
protected function extra_tablenav( $which ) {
if ( 'top' !== $which ) {
return;
}
$status = sanitize_key( $this->get_filter( 'status' ) );
?>
id );
$actions = array(
'invoice' => '' . esc_html__( 'View invoice', 'affireo-affiliates-for-woocommerce' ) . '',
);
if ( 'failed' === $item->status && current_user_can( 'ppl_afw_manage_payouts' ) ) {
$retry = wp_nonce_url( admin_url( 'admin-post.php?action=ppl_afw_payout_retry&payout_id=' . (int) $item->id ), 'ppl_afw_payout_retry' );
$actions['retry'] = '' . esc_html__( 'Retry', 'affireo-affiliates-for-woocommerce' ) . '';
}
if ( 'processing' === $item->status && current_user_can( 'ppl_afw_manage_payouts' ) ) {
$sent = wp_nonce_url( admin_url( 'admin-post.php?action=ppl_afw_payout_status&do=sent&payout_id=' . (int) $item->id ), 'ppl_afw_payout_status' );
$cancel = wp_nonce_url( admin_url( 'admin-post.php?action=ppl_afw_payout_status&do=cancel&payout_id=' . (int) $item->id ), 'ppl_afw_payout_status' );
$actions['sent'] = '' . esc_html__( 'Mark as sent', 'affireo-affiliates-for-woocommerce' ) . '';
$actions['cancel'] = '' . esc_html__( 'Cancel', 'affireo-affiliates-for-woocommerce' ) . '';
}
return '' . esc_html( $item->invoice_number ) . '' . $this->row_actions( $actions );
}
/**
* Default column renderer.
*
* @param object $item Row.
* @param string $column_name Column key.
* @return string
*/
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'affiliate':
return $this->affiliate_label( (int) $item->affiliate_id );
case 'amount':
return wp_kses_post( wc_price( (float) $item->amount, array( 'currency' => $item->currency ) ) );
case 'method':
return esc_html( $item->method );
case 'status':
$out = $this->badge( $item->status );
if ( in_array( $item->status, array( 'failed', 'processing', 'cancelled' ), true ) && $item->notes ) {
$out .= '
' . esc_html( $item->notes ) . '';
}
return $out;
case 'reference':
return $item->gateway_reference ? '' . esc_html( $item->gateway_reference ) . '' : '-';
case 'created':
return esc_html( mysql2date( get_option( 'date_format' ) . ' H:i', $item->created_at ) );
}
return '';
}
}