$meta ) {
if ( isset( $meta->key ) && '_renew_subscrpt' !== $meta->key ) {
$temp_metas[ $key ] = $meta;
}
}
return $temp_metas;
}
/**
* Enqueue admin assets.
*
* @return void
*/
public function enqueue_scripts() {
wp_enqueue_style( 'subscrpt_admin_css' );
wp_enqueue_style( 'subscrpt_status_css' );
}
/**
* Remove default post actions.
*
* @param array $actions Actions.
*
* @return array
*/
public function post_row_actions( $actions ) {
global $current_screen;
if ( 'subscrpt_order' !== $current_screen->post_type ) {
return $actions;
}
unset( $actions['inline hide-if-no-js'] );
unset( $actions['view'] );
unset( $actions['trash'] );
unset( $actions['edit'] );
return $actions;
}
/**
* Register custom columns.
*
* @param array $columns Columns.
*
* @return array
*/
public function add_custom_columns( $columns ) {
$columns['subscrpt_start_date'] = __( 'Start Date', 'sdevs_subscrpt' );
$columns['subscrpt_customer'] = __( 'Customer', 'sdevs_subscrpt' );
$columns['subscrpt_next_date'] = __( 'Next Date', 'sdevs_subscrpt' );
$columns['subscrpt_status'] = __( 'Status', 'sdevs_subscrpt' );
unset( $columns['date'] );
unset( $columns['cb'] );
return $columns;
}
/**
* Display column data.
*
* @param string $column Column.
* @param int $post_id Post Id.
*
* @return void
*/
public function add_custom_columns_data( $column, $post_id ) {
$order_id = get_post_meta( $post_id, '_subscrpt_order_id', true );
$order = wc_get_order( $order_id );
if ( $order ) {
if ( 'subscrpt_start_date' === $column ) {
$start_date = get_post_meta( $post_id, '_subscrpt_start_date', true );
echo ! empty( $start_date ) ? esc_html( gmdate( 'F d, Y', $start_date ) ) : '-';
} elseif ( 'subscrpt_customer' === $column ) {
?>
get_formatted_billing_full_name() ); ?>
get_billing_email() ); ?>
get_billing_phone() ) ) : ?>
Phone : get_billing_phone() ); ?>
label ); ?>
ID;
global $wpdb;
$table_name = $wpdb->prefix . 'subscrpt_order_relation';
// @phpcs:ignore
$order_histories = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE subscription_id=%d', array( $table_name, $subscription_id ) ) );
include 'views/order-history.php';
}
/**
* Display Order Activities
*
* @param \WP_Post $post Post Object.
*
* @return void
*/
public function order_activities( $post ) {
if ( function_exists( 'subscrpt_pro_activated' ) ) :
if ( subscrpt_pro_activated() ) :
do_action( 'subscrpt_order_activities', $post->ID );
else :
?>
__( 'Activate Subscription', 'sdevs_subscrpt' ),
'value' => 'active',
),
array(
'label' => __( 'Pending Subscription', 'sdevs_subscrpt' ),
'value' => 'pending',
),
array(
'label' => __( 'Expire Subscription', 'sdevs_subscrpt' ),
'value' => 'expired',
),
array(
'label' => __( 'Pending Cancel Subscription', 'sdevs_subscrpt' ),
'value' => 'pe_cancelled',
),
array(
'label' => __( 'Cancel Subscription', 'sdevs_subscrpt' ),
'value' => 'cancelled',
),
);
$status = get_post_status( get_the_ID() );
include 'views/subscription-save-meta.php';
}
/**
* Display Customer Info
*
* @param \WP_Post $post Post Object.
*
* @return void
*/
public function customer_info( $post ) {
$order_id = get_post_meta( $post->ID, '_subscrpt_order_id', true );
$order = wc_get_order( $order_id );
if ( ! $order ) {
return;
}
include 'views/subscription-customer.php';
}
/**
* Display subscription info.
*
* @return void
*/
public function subscrpt_order_info() {
$order_id = get_post_meta( get_the_ID(), '_subscrpt_order_id', true );
$order_item_id = get_post_meta( get_the_ID(), '_subscrpt_order_item_id', true );
$trial = get_post_meta( get_the_ID(), '_subscrpt_trial', true );
$start_date = get_post_meta( get_the_ID(), '_subscrpt_start_date', true );
$next_date = get_post_meta( get_the_ID(), '_subscrpt_next_date', true );
$trial_start_date = get_post_meta( get_the_ID(), '_subscrpt_trial_started', true );
$trial_end_date = get_post_meta( get_the_ID(), '_subscrpt_trial_ended', true );
$trial_mode = get_post_meta( get_the_ID(), '_subscrpt_trial_mode', true );
$order = wc_get_order( $order_id );
if ( ! $order ) {
return;
}
$order_item = $order->get_item( $order_item_id );
$product_name = $order_item->get_name();
$product_link = get_the_permalink( $order_item->get_product_id() );
$rows = array(
'product' => array(
'label' => __( 'Product', 'sdevs_subscrpt' ),
'value' => '' . esc_html( $product_name ) . '',
),
'cost' => array(
'label' => __( 'Cost', 'sdevs_subscrpt' ),
'value' => Helper::format_price_with_order_item( get_post_meta( get_the_ID(), '_subscrpt_price', true ), $order_item->get_id() ),
),
'quantity' => array(
'label' => __( 'Qty', 'sdevs_subscrpt' ),
'value' => "x{$order_item->get_quantity()}",
),
'start_date' => array(
'label' => __( 'Started date', 'sdevs_subscrpt' ),
'value' => ! empty( $start_date ) ? gmdate( 'F d, Y', $trial && $trial_start_date ? $trial_start_date : $start_date ) : '-',
),
'next_date' => array(
'label' => __( 'Payment due date', 'sdevs_subscrpt' ),
'value' => ! empty( $next_date ) ? gmdate( 'F d, Y', $trial && $trial_end_date && 'on' === $trial_mode ? $trial_end_date : ( $next_date ?? '-' ) ) : '-',
),
'status' => array(
'label' => __( 'Status', 'sdevs_subscrpt' ),
'value' => '' . get_post_status_object( get_post_status() )->label . '',
),
'payment_method' => array(
'label' => __( 'Payment Method', 'sdevs_subscrpt' ),
'value' => empty( $order->get_payment_method_title() ) ? '-' : $order->get_payment_method_title(),
),
'billing_address' => array(
'label' => __( 'Billing', 'sdevs_subscrpt' ),
'value' => $order->get_formatted_billing_address() ? $order->get_formatted_billing_address() : __( 'No billing address set.', 'sdevs_subscrpt' ),
),
'shipping_address' => array(
'label' => __( 'Shipping', 'sdevs_subscrpt' ),
'value' => $order->get_formatted_shipping_address() ? $order->get_formatted_shipping_address() : __( 'No shipping address set.', 'sdevs_subscrpt' ),
),
);
if ( $trial ) {
$rows = array_slice( $rows, 0, 3, true ) + array(
'trial' => array(
'label' => __( 'Trial', 'sdevs_subscrpt' ),
'value' => $trial,
),
'trial_period' => array(
'label' => __( 'Trial Period', 'sdevs_subscrpt' ),
'value' => ( $trial_start_date && $trial_end_date ? ' [ ' . gmdate( 'F d, Y', $trial_start_date ) . ' - ' . gmdate( 'F d, Y', $trial_end_date ) . ' ] ' : __( 'Trial isn\'t activated yet! ', 'sdevs_subscrpt' ) ),
),
) + array_slice( $rows, 3, count( $rows ) - 1, true );
}
if ( class_exists( 'WC_Stripe' ) && 'stripe' === $order->get_payment_method() ) {
$is_auto_renew = get_post_meta( get_the_ID(), '_subscrpt_auto_renew', true );
$new_rows = array();
foreach ( $rows as $key => $value ) {
$new_rows[ $key ] = $value;
if ( 'payment_method' === $key ) {
$new_rows['stripe_auto_renewal'] = array(
'label' => __( 'Stripe Auto Renewal', 'sdevs_subscrpt' ),
'value' => '0' !== $is_auto_renew ? 'On' : 'Off',
);
}
}
$rows = $new_rows;
}
$rows = apply_filters( 'subscrpt_admin_info_rows', $rows, get_the_ID(), $order );
include 'views/subscription-info.php';
}
/**
* Include some styles.
*
* @return void
*/
public function some_styles() {
global $post;
if ( 'subscrpt_order' === $post->post_type ) :
?>
post_type ) :
?>
$post_id,
'post_status' => $action,
)
);
$order_id = get_post_meta( $post_id, '_subscrpt_order_id', true );
if ( 'active' === $action ) {
$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
Action::status( $action, $post_id, false );
} else {
Action::status( $action, $post_id );
}
}
}