$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', 'subscription' ); $columns['subscrpt_customer'] = __( 'Customer', 'subscription' ); $columns['subscrpt_next_date'] = __( 'Next Date', 'subscription' ); $columns['subscrpt_status'] = __( 'Status', 'subscription' ); 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 ) { // HPOS: Safe. Only retrieves WooCommerce order via CRUD, and subscription meta via post meta. $order_id = get_post_meta( $post_id, '_subscrpt_order_id', true ); // HPOS: Only subscription meta, not order meta. $order = wc_get_order( $order_id ); // HPOS: Safe, uses WooCommerce CRUD. if ( $order ) { if ( 'subscrpt_start_date' === $column ) { $start_date = get_post_meta( $post_id, '_subscrpt_start_date', true ); echo ! empty( $start_date ) ? esc_html( wp_date( '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 ORDER BY id DESC', 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 : ?>
🚀 Upgrade to WPSubscription Pro
Unlock advanced features, automation, and priority support. Take your subscription business to the next level!
Upgrade to Pro
array( 'label' => __( 'Activate Subscription', 'subscription' ), 'value' => 'active', ), 'pending' => array( 'label' => __( 'Pending Subscription', 'subscription' ), 'value' => 'pending', ), 'expire' => array( 'label' => __( 'Expire Subscription', 'subscription' ), 'value' => 'expired', ), 'pe_cancelled' => array( 'label' => __( 'Pending Cancel Subscription', 'subscription' ), 'value' => 'pe_cancelled', ), 'cancelled' => array( 'label' => __( 'Cancel Subscription', 'subscription' ), 'value' => 'cancelled', ), ); $map_actions = array( 'pending' => array( 'active', 'cancelled' ), 'active' => array( 'pe_cancelled', 'cancelled' ), 'pe_cancelled' => array( 'active', 'cancelled' ), 'cancelled' => array( 'active' ), 'expired' => array(), ); $status = get_post_status( get_the_ID() ); $actions = $map_actions[ $status ]; 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() ); // Get payment information $product_id = $order_item->get_product_id(); // get_post_meta( get_the_ID(), '_subscrpt_product_id', true ); $max_payments = subscrpt_get_max_payments( get_the_ID() ) ?: 0; $payments_made = subscrpt_count_payments_made( get_the_ID() ); $rows = array( 'product' => array( 'label' => __( 'Product', 'subscription' ), 'value' => '' . esc_html( $product_name ) . '', ), 'cost' => array( 'label' => __( 'Cost', 'subscription' ), 'value' => Helper::format_price_with_order_item( get_post_meta( get_the_ID(), '_subscrpt_price', true ), $order_item->get_id() ), ), 'quantity' => array( 'label' => __( 'Qty', 'subscription' ), 'value' => "x{$order_item->get_quantity()}", ), ); // Add payment information if max_payments is set and not unlimited if ( ! empty( $max_payments ) && $max_payments > 0 ) { $rows['total_payments'] = array( 'label' => __( 'Total Payments', 'subscription' ), 'value' => esc_html( $payments_made ) . ' / ' . esc_html( $max_payments ), ); } $rows += array( 'start_date' => array( 'label' => __( 'Started date', 'subscription' ), 'value' => ! empty( $start_date ) ? wp_date( 'F d, Y', $trial && $trial_start_date ? $trial_start_date : $start_date ) : '-', ), 'next_date' => array( 'label' => __( 'Payment due date', 'subscription' ), 'value' => ! empty( $next_date ) ? wp_date( 'F d, Y', $trial && $trial_end_date && 'on' === $trial_mode ? $trial_end_date : ( $next_date ?? '-' ) ) : '-', ), 'status' => array( 'label' => __( 'Status', 'subscription' ), 'value' => '' . get_post_status_object( get_post_status() )->label . '', ), 'payment_method' => array( 'label' => __( 'Payment Method', 'subscription' ), 'value' => empty( $order->get_payment_method_title() ) ? '-' : $order->get_payment_method_title(), ), 'billing_address' => array( 'label' => __( 'Billing', 'subscription' ), 'value' => $order->get_formatted_billing_address() ? $order->get_formatted_billing_address() : __( 'No billing address set.', 'subscription' ), ), 'shipping_address' => array( 'label' => __( 'Shipping', 'subscription' ), 'value' => $order->get_formatted_shipping_address() ? $order->get_formatted_shipping_address() : __( 'No shipping address set.', 'subscription' ), ), ); if ( $trial ) { $rows = array_slice( $rows, 0, 3, true ) + array( 'trial' => array( 'label' => __( 'Trial', 'subscription' ), 'value' => $trial, ), 'trial_period' => array( 'label' => __( 'Trial Period', 'subscription' ), 'value' => ( $trial_start_date && $trial_end_date ? ' [ ' . wp_date( 'F d, Y', $trial_start_date ) . ' - ' . wp_date( 'F d, Y', $trial_end_date ) . ' ] ' : __( 'Trial isn\'t activated yet! ', 'subscription' ) ), ), ) + 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', 'subscription' ), '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'; } /** * Display a prominent subscription details section. * * @param \WP_Post $post The post object. * * @return void */ public function display_subscription_details_section( $post ) { // Only display for subscription post type if ( 'subscrpt_order' !== $post->post_type ) { return; } $subscription_id = $post->ID; $subscription_data = Helper::get_subscription_data( $subscription_id ); $order_id = $subscription_data['order']['order_id'] ?? 0; $order = $order_id ? wc_get_order( $order_id ) : null; $order_item_id = $subscription_data['order']['order_item_id'] ?? 0; $order_item = $order ? $order->get_item( $order_item_id ) : null; if ( ! $order || ! $order_item ) { return; } $product_id = $subscription_data['product']['product_id'] ?? 0; $max_payments = ! empty( subscrpt_get_max_payments( $subscription_id ) ) ? subscrpt_get_max_payments( $subscription_id ) : 0; $payments_made = subscrpt_count_payments_made( $subscription_id ); // Get subscription details $product = wc_get_product( $product_id ); $subscrpt_type = $subscription_data['schedule']['timing_option'] ?? ''; $subscrpt_time = $subscription_data['schedule']['timing_per'] ?? ''; $trial_type = $subscription_data['trial']['timing_option'] ?? 'days'; $trial_time = $subscription_data['trial']['timing_per'] ?? 0; $signup_fee = $subscription_data['signup_fee'] ?? ''; $quantity = (int) $order_item->get_quantity(); $cost = (float) ( $subscription_data['price'] ?? 0 ) * max( 1, $quantity ); $cost = empty( $cost ) ? (float) $order_item->get_total() : $cost; $price_excl_tax = (float) $order_item->get_total(); $tax_amount = (float) $order_item->get_total_tax(); if ( $tax_amount > 0 ) { $cost = $price_excl_tax + $tax_amount; $cost = number_format( (float) $cost, 2, '.', '' ); } $subscrpt_status = $subscription_data['status'] ?? ''; $verbose_status = Helper::get_verbose_status( $subscrpt_status ); $started_date = $subscription_data['start_date'] ?? ''; $started_date = ! empty( $started_date ) ? wp_date( 'F j, Y - g:i A', strtotime( $started_date ) ) : '-'; $next_payment_date = $subscription_data['next_date'] ?? ''; $next_payment_date = ! empty( $next_payment_date ) ? wp_date( 'F j, Y - g:i A', strtotime( $next_payment_date ) ) : '-'; $is_grace_period = isset( $subscription_data['grace_period'] ); $grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0; $grace_end_date = $subscription_data['grace_period']['end_date'] ?? ''; $grace_end_date = ! empty( $grace_end_date ) ? wp_date( 'F j, Y - g:i A', strtotime( $grace_end_date ) ) : ''; ?>

ID ); echo esc_html( $text ); ?>

0 ) : ?> Active
get_name() ); ?>

0 ) : ?>
/ 1 ? $subscrpt_time . '-' : '' ); ?>

post_type ) : ?> post_type ) : ?> $post_id, 'post_status' => $action, ) ); if ( $old_status !== $action ) { $old_status_object = get_post_status_object( $old_status ); $new_status_object = get_post_status_object( $action ); WC()->mailer(); do_action( 'subscrpt_status_changed_admin_email_notification', $post_id, $old_status_object->label, $new_status_object->label ); } $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 ); } else { Action::status( $action, $post_id ); } } public function add_subscription_filter_select() { // Implementation of add_subscription_filter_select method } public function add_overview_submenu() { // Remove and re-add submenu to ensure Overview is first remove_submenu_page( 'edit.php?post_type=subscrpt_order', 'edit.php?post_type=subscrpt_order' ); add_submenu_page( 'edit.php?post_type=subscrpt_order', __( 'Overview', 'subscription' ), __( 'Overview', 'subscription' ), 'manage_options', 'subscription_overview', array( $this, 'render_overview_page' ), 0 ); add_submenu_page( 'edit.php?post_type=subscrpt_order', __( 'All Subscriptions', 'subscription' ), __( 'All Subscriptions', 'subscription' ), 'manage_options', 'edit.php?post_type=subscrpt_order', '', 1 ); if ( ! class_exists( 'Sdevs_Wc_Subscription_Pro' ) ) { add_submenu_page( 'edit.php?post_type=subscrpt_order', __( 'Go Pro', 'subscription' ), __( 'Go Pro', 'subscription' ), 'manage_options', 'wp_subscription_go_pro', array( $this, 'render_go_pro_page' ), 99 ); } } public function render_overview_page() { ?>

Easy Setup

Get started in minutes with our intuitive onboarding wizard.

Multiple Gateways

Support for Stripe, PayPal, and Paddle out of the box.

Flexible Plans

Create and manage various subscription types and delivery schedules.

Comprehensive Dashboard

Monitor and manage all subscriptions in one place.

Pro is already active.'; return; } ?>

Free Pro
Simple subscription products ✔️ ✔️
Automated recurring billing ✔️ ✔️
Multiple payment gateways ✔️ ✔️
Customer self-service portal ✔️ ✔️
Priority support ✔️
Advanced reporting & analytics ✔️
Variable product support ✔️
post_type !== 'subscrpt_order' ) { return; } $list_url = admin_url( 'admin.php?page=wp-subscription' ); ?>