autoship_get_account_scheduled_orders_actions (function)

(src/scheduled-orders.php) Used to get account Scheduled Order actions. It takes the $order_number, $status, and $context as its parameters and returns the $actions

Function

/**
 * Get account schedule orders actions.
 * Values can be modified through {@see autoship_get_account_scheduled_orders_actions}
 * filter
 * @param  int $order_number The Autoship Schedule Order Number.
 * @param  string $status Scheduled Order instance Status.
 * @param  string $context Context in which the actions are being displayed.
 *                         Default 'orders'.
 * @return array
 */
function autoship_get_account_scheduled_orders_actions( $order_number, $status, $context = 'orders' ) {

	$actions = array(
		'Paused'    => array(
			'url'  => autoship_get_scheduled_order_status_change_url( $order_number, 'Paused' ),
      'title'=> __( 'Pause Autoship Order', 'autoship' ),
			'name' => __( 'Pause', 'autoship' ),
		),
		'Active'   => array(
			'url'  => autoship_get_scheduled_order_status_change_url( $order_number, 'Active' ),
      'title'=> __( 'Resume Autoship Order', 'autoship' ),
			'name' => __( 'Resume', 'autoship' ),
		),
		'Failed'   => array(
			'url'  => autoship_get_scheduled_order_status_change_url( $order_number, 'Failed' ),
      'title'=> __( 'Fail Autoship Order', 'autoship' ),
			'name' => __( 'Mark as Failed', 'autoship' ),
		),
		'Pending'   => array(
			'url'  => autoship_get_scheduled_order_status_change_url( $order_number, 'Pending' ),
      'title'=> __( 'Mark Autoship Order as Pending', 'autoship' ),
			'name' => __( 'Mark as Pending', 'autoship' ),
		),
		'Deleted'   => array(
			'url'  => autoship_get_scheduled_order_delete_url( $order_number ),
      'title'=> __( 'Delete Autoship Order', 'autoship' ),
			'name' => __( 'Delete', 'autoship' ),
		),
		'Edit'   => array(
			'url'  => autoship_get_scheduled_order_url( $order_number ),
      'title'=> __( 'Edit / View Autoship Order', 'autoship' ),
			'name' => __( 'Edit', 'autoship' ),
		),
		'View'   => array(
			'url'  => autoship_get_view_scheduled_order_url( $order_number ),
      'title'=> __( 'View Autoship Order', 'autoship' ),
			'name' => __( 'View', 'autoship' ),
		),
	);

  // Remove actions for non-amdins.
  // By default only admins can see other users' accounts
  if ( !autoship_rights_checker( 'autoship_admin_account_scheduled_orders_actions' ) ) {
    unset( $actions['Failed'] );
    unset( $actions['Pending'] );
  }

  // Based on current status remove non-relavent actions
  if ( isset( $actions[$status] ) )
  unset( $actions[$status] );

  if ( 'Deleted' == $status ){

    $actions = array(
      'View' => $actions['View'],
    );

  } else if ( 'Failed' == $status ) {
    unset( $actions['Paused'] );
  } else if ( 'Pending' == $status ){
    unset( $actions['Edit'] );
  } else {
    unset( $actions['View'] );
  }

	return apply_filters( 'autoship_get_account_scheduled_orders_actions', $actions, $status, $context );
}