deleteMe() ) { $pmpro_msg = sprintf( __( 'Order %s deleted successfully.', 'paid-memberships-pro' ), $dorder_code ); $pmpro_msgt = 'success'; } else { $pmpro_msg = __( 'Error deleting order.', 'paid-memberships-pro' ); $pmpro_msgt = 'error'; } } // Refund this order if ( ! empty( $_REQUEST['refund'] ) ) { // Check nonce for refunding. $nonceokay = true; if ( empty( $_REQUEST['pmpro_orders_nonce'] ) || ! check_admin_referer( 'refund_order', 'pmpro_orders_nonce' ) ) { $nonceokay = false; } $rorder = new MemberOrder( (int) $_REQUEST['refund'] ); if ( $nonceokay && !empty( $rorder ) && pmpro_allowed_refunds( $rorder ) ) { if( pmpro_refund_order( $rorder ) ) { $pmpro_msg = __( 'Order refunded successfully.', 'paid-memberships-pro' ); $pmpro_msgt = 'success'; } else { $pmpro_msg = __( 'Error refunding order. Please check the order notes for more information.', 'paid-memberships-pro' ); $pmpro_msgt = 'error'; } } else { $pmpro_msg = __( 'Error refunding order. Please check the order notes for more information.', 'paid-memberships-pro' ); $pmpro_msgt = 'error'; } } $thisyear = date( 'Y', $now ); // this array stores fields that should be read only $read_only_fields = apply_filters( 'pmpro_orders_read_only_fields', array( 'code', 'payment_transaction_id', 'subscription_transaction_id', ) ); // if this is a new order or copy of one, let's make all fields editable // Checking orderby as order could be the order ID or whether the List Table should be sorted ascending or descending. if ( ( ! empty( $_REQUEST['order'] ) && $_REQUEST['order'] < 0 ) && ! isset( $_REQUEST['orderby'] ) ) { $read_only_fields = array(); } // saving? if ( ! empty( $_REQUEST['save'] ) ) { // start with old order if applicable $order_id = intval( $_REQUEST['order'] ); if ( $order_id > 0 ) { $order = new MemberOrder( $order_id ); } else { $order = new MemberOrder(); $order->billing = new stdClass(); } // update values if ( ! in_array( 'code', $read_only_fields ) && isset( $_POST['code'] ) ) { $order->code = sanitize_text_field( $_POST['code'] ); } if ( ! in_array( 'user_id', $read_only_fields ) && isset( $_POST['user_id'] ) ) { $order->user_id = intval( $_POST['user_id'] ); } if ( ! in_array( 'membership_id', $read_only_fields ) && isset( $_POST['membership_id'] ) ) { $order->membership_id = intval( $_POST['membership_id'] ); } if ( ! in_array( 'billing_name', $read_only_fields ) && isset( $_POST['billing_name'] ) ) { $order->billing->name = sanitize_text_field( wp_unslash( $_POST['billing_name'] ) ); } if ( ! in_array( 'billing_street', $read_only_fields ) && isset( $_POST['billing_street'] ) ) { $order->billing->street = sanitize_text_field( wp_unslash( $_POST['billing_street'] ) ); } if ( ! in_array( 'billing_city', $read_only_fields ) && isset( $_POST['billing_city'] ) ) { $order->billing->city = sanitize_text_field( wp_unslash( $_POST['billing_city'] ) ); } if ( ! in_array( 'billing_state', $read_only_fields ) && isset( $_POST['billing_state'] ) ) { $order->billing->state = sanitize_text_field( wp_unslash( $_POST['billing_state'] ) ); } if ( ! in_array( 'billing_zip', $read_only_fields ) && isset( $_POST['billing_zip'] ) ) { $order->billing->zip = sanitize_text_field( $_POST['billing_zip'] ); } if ( ! in_array( 'billing_country', $read_only_fields ) && isset( $_POST['billing_country'] ) ) { $order->billing->country = sanitize_text_field( wp_unslash( $_POST['billing_country'] ) ); } if ( ! in_array( 'billing_phone', $read_only_fields ) && isset( $_POST['billing_phone'] ) ) { $order->billing->phone = sanitize_text_field( $_POST['billing_phone'] ); } if ( ! in_array( 'subtotal', $read_only_fields ) && isset( $_POST['subtotal'] ) ) { $order->subtotal = sanitize_text_field( $_POST['subtotal'] ); } if ( ! in_array( 'tax', $read_only_fields ) && isset( $_POST['tax'] ) ) { $order->tax = sanitize_text_field( $_POST['tax'] ); } if ( ! in_array( 'total', $read_only_fields ) && isset( $_POST['total'] ) ) { $order->total = sanitize_text_field( $_POST['total'] ); } if ( ! in_array( 'payment_type', $read_only_fields ) && isset( $_POST['payment_type'] ) ) { $order->payment_type = sanitize_text_field( $_POST['payment_type'] ); } if ( ! in_array( 'cardtype', $read_only_fields ) && isset( $_POST['cardtype'] ) ) { $order->cardtype = sanitize_text_field( $_POST['cardtype'] ); } if ( ! in_array( 'accountnumber', $read_only_fields ) && isset( $_POST['accountnumber'] ) ) { $order->accountnumber = sanitize_text_field( $_POST['accountnumber'] ); } if ( ! in_array( 'expirationmonth', $read_only_fields ) && isset( $_POST['expirationmonth'] ) ) { $order->expirationmonth = sanitize_text_field( $_POST['expirationmonth'] ); } if ( ! in_array( 'expirationyear', $read_only_fields ) && isset( $_POST['expirationyear'] ) ) { $order->expirationyear = sanitize_text_field( $_POST['expirationyear'] ); } if ( ! in_array( 'status', $read_only_fields ) && isset( $_POST['status'] ) ) { $order->status = pmpro_sanitize_with_safelist( $_POST['status'], pmpro_getOrderStatuses() ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized } if ( ! in_array( 'gateway', $read_only_fields ) && isset( $_POST['gateway'] ) ) { $order->gateway = sanitize_text_field( $_POST['gateway'] ); } if ( ! in_array( 'gateway_environment', $read_only_fields ) && isset( $_POST['gateway_environment'] ) ) { $order->gateway_environment = sanitize_text_field( $_POST['gateway_environment'] ); } if ( ! in_array( 'payment_transaction_id', $read_only_fields ) && isset( $_POST['payment_transaction_id'] ) ) { $order->payment_transaction_id = sanitize_text_field( $_POST['payment_transaction_id'] ); } if ( ! in_array( 'subscription_transaction_id', $read_only_fields ) && isset( $_POST['subscription_transaction_id'] ) ) { $order->subscription_transaction_id = sanitize_text_field( $_POST['subscription_transaction_id'] ); } if ( ! in_array( 'notes', $read_only_fields ) && isset( $_POST['notes'] ) ) { global $allowedposttags; $order->notes = wp_kses( wp_unslash( $_REQUEST['notes'] ), $allowedposttags ); } if ( ! in_array( 'timestamp', $read_only_fields ) && isset( $_POST['ts_year'] ) && isset( $_POST['ts_month'] ) && isset( $_POST['ts_day'] ) && isset( $_POST['ts_hour'] ) && isset( $_POST['ts_minute'] ) ) { $year = intval( $_POST['ts_year'] ); $month = intval( $_POST['ts_month'] ); $day = intval( $_POST['ts_day'] ); $hour = intval( $_POST['ts_hour'] ); $minute = intval( $_POST['ts_minute'] ); $date = get_gmt_from_date( $year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':00' , 'U' ); $order->timestamp = $date; // Passed 'U' to get_gmt_from_date() so that we get a Unix timestamp. } // affiliate stuff $affiliates = apply_filters( 'pmpro_orders_show_affiliate_ids', false ); if ( ! empty( $affiliates ) ) { if ( ! in_array( 'affiliate_id', $read_only_fields ) ) { $order->affiliate_id = sanitize_text_field( $_POST['affiliate_id'] ); } if ( ! in_array( 'affiliate_subid', $read_only_fields ) ) { $order->affiliate_subid = sanitize_text_field( $_POST['affiliate_subid'] ); } } // check nonce for saving $nonceokay = true; if ( empty( $_REQUEST['pmpro_orders_nonce'] ) || ! check_admin_referer( 'save', 'pmpro_orders_nonce' ) ) { $nonceokay = false; } // save if ( $nonceokay && false !== $order->saveOrder() ) { $order_id = $order->id; $pmpro_msg = __( 'Order saved successfully.', 'paid-memberships-pro' ); $pmpro_msgt = 'success'; } else { $pmpro_msg = __( 'Error saving order.', 'paid-memberships-pro' ); $pmpro_msgt = 'error'; } // also update the discount code if needed if( isset( $_REQUEST['discount_code_id'] ) ) { $order->updateDiscountCode( intval( $_REQUEST['discount_code_id'] ) ); } } else { // order passed? // Checking orderby as order could be the order ID or whether the List Table should be sorted ascending or descending. if ( ! empty( $_REQUEST['order'] ) && ! isset( $_REQUEST['orderby'] ) ) { $order_id = intval( $_REQUEST['order'] ); if ( $order_id > 0 ) { $order = new MemberOrder( $order_id ); } elseif ( ! empty( $_REQUEST['copy'] ) ) { $order = new MemberOrder( intval( $_REQUEST['copy'] ) ); // new id $order->id = null; // new code $order->code = $order->getRandomCode(); } else { $order = new MemberOrder(); // new order // defaults $order->code = $order->getRandomCode(); $order->user_id = ''; $order->membership_id = ''; $order->billing = new stdClass(); $order->billing->name = ''; $order->billing->street = ''; $order->billing->city = ''; $order->billing->state = ''; $order->billing->zip = ''; $order->billing->country = ''; $order->billing->phone = ''; $order->discount_code = ''; $order->subtotal = ''; $order->tax = ''; $order->total = ''; $order->payment_type = ''; $order->cardtype = ''; $order->accountnumber = ''; $order->expirationmonth = ''; $order->expirationyear = ''; $order->status = 'success'; $order->gateway = get_option( 'pmpro_gateway' ); $order->gateway_environment = get_option( 'pmpro_gateway_environment' ); $order->payment_transaction_id = ''; $order->subscription_transaction_id = ''; $order->affiliate_id = ''; $order->affiliate_subid = ''; $order->notes = ''; } } } require_once( dirname( __FILE__ ) . '/admin_header.php' ); ?>
id ) ) { $refund_text = esc_html( sprintf( // translators: %s is the Order Code. __( 'Refund order %s at the payment gateway. This action is permanent. The user and admin will receive an email confirmation after the refund is processed. Are you sure you want to refund this order?', 'paid-memberships-pro' ), str_replace( "'", '', $order->code ) ) ); $refund_nonce_url = wp_nonce_url( add_query_arg( [ 'page' => 'pmpro-orders', 'action' => 'refund_order', 'refund' => $order->id, 'order' => $order->id ], admin_url( 'admin.php' ) ), 'refund_order', 'pmpro_orders_nonce' ); ?>

ID: id ); ?>

%3$s', esc_attr__( 'Refund', 'paid-memberships-pro' ), esc_js( 'javascript:pmpro_askfirst(' . wp_json_encode( $refund_text ) . ', ' . wp_json_encode( $refund_nonce_url ) . '); void(0);' ), esc_html__( 'Refund', 'paid-memberships-pro' ) ); } ?>

code ); } else { ?>

0 ) { echo esc_html( date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $order->getTimestamp() ) ); } else { // set up date vars if ( ! empty( $order->timestamp ) ) { $timestamp = $order->getTimestamp(); } else { $timestamp = current_time( 'timestamp' ); } $year = date( 'Y', $timestamp ); $month = date( 'n', $timestamp ); $day = date( 'j', $timestamp ); $hour = date( 'H', $timestamp ); $minute = date( 'i', $timestamp ); $second = date( 's', $timestamp ); ?> :
0 ) { echo esc_html( $order->user_id ); } else { $user_id = ! empty( $_REQUEST['user'] ) ? intval( $_REQUEST['user'] ) : $order->user_id; ?>
0 ) { echo esc_html( $order->membership_id ); } else { // Get the order's current membership level ID. $membership_id = ! empty( $_REQUEST['membership_id'] ) ? intval( $_REQUEST['membership_id'] ) : $order->membership_id; // Get all membership levels. $levels = pmpro_getAllLevels( true, true ); ?>
has_billing_address() ) { $section_visibility = 'shown'; $section_activated = 'true'; } else { $section_visibility = 'hidden'; $section_activated = 'false'; } ?>
>
0 ) { echo esc_html( $order->billing_name ); } else { ?>
0 ) { echo esc_html( $order->billing_street ); } else { ?>
0 ) { echo esc_html( $order->billing_city ); } else { ?>
0 ) { echo esc_html( $order->billing_state ); } else { ?>
0 ) { echo esc_html( $order->billing_zip ); } else { ?>
0 ) { echo esc_html( $order->billing_country ); } else { ?>
0 ) { echo esc_html( $order->billing_phone ); } else { ?>
0 ) { $order->getDiscountCode(); if ( ! empty( $order->discount_code ) ) { $discount_code_id = $order->discount_code->id; } else { $discount_code_id = 0; } } else { $discount_code_id = 0; } $sqlQuery = "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->pmpro_discount_codes "; $sqlQuery .= "ORDER BY id DESC "; $codes = $wpdb->get_results($sqlQuery, OBJECT); if ( ! empty( $codes ) ) { ?> 0 ) { ?>
0 ) { if( ! empty( $order->discount_code ) ) { echo esc_html( $order->discount_code->code ); } else { esc_html_e( 'N/A', 'paid-memberships-pro' ); } } else { ?>
0 ) { echo esc_html( $order->subtotal ); } else { ?>
0 ) { echo esc_html( $order->tax ); } else { ?>
0 ) { echo esc_html( $order->total ); } else { ?>
0 ) { echo esc_html( $order->payment_type ); } else { ?>

0 ) { echo esc_html( $order->cardtype ); } else { ?>

0 ) { echo esc_html( $order->accountnumber ); } else { ?>

expirationmonth . '/' . $order->expirationyear ); ?>
/
0 ) { echo esc_html( ucwords( $order->status ) ); } else { ?>
0 ) { echo esc_html( $order->gateway ); } else { ?>
0 ) { echo esc_html( $order->gateway_environment ); } else { ?>
0 ) { echo esc_html( $order->payment_transaction_id ); } else { ?>

0 ) { echo esc_html( $order->subscription_transaction_id ); } else { ?> is_renewal() ) { ?>

get_subscription(); if ( ! empty( $subscription ) ) { echo '

' . esc_html__( 'View Subscription', 'paid-memberships-pro') . '

'; } ?>
get_tos_consent_log_entry(); if( !empty( $tospage_id ) || !empty( $consent_entry ) ) { ?>
0 ) { echo esc_html( $order->affiliate_id ); } else { ?>
0 ) { echo esc_html( $order->affiliate_subid ); } else { ?>
0 ) { echo wp_kses_post( $order->notes ); } else { ?>

isset( $_REQUEST['filter'] ) ? trim( sanitize_text_field( $_REQUEST['filter'] ) ) : 'all', 's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '', 'l' => isset( $_REQUEST['l'] ) ? sanitize_text_field( $_REQUEST['l'] ) : false, 'start-month' => isset( $_REQUEST['start-month'] ) ? intval( $_REQUEST['start-month'] ) : '1', 'start-day' => isset( $_REQUEST['start-day'] ) ? intval( $_REQUEST['start-day'] ) : '1', 'start-year' => isset( $_REQUEST['start-year'] ) ? intval( $_REQUEST['start-year'] ) : date( 'Y', $now ), 'end-month' => isset( $_REQUEST['end-month'] ) ? intval( $_REQUEST['end-month'] ) : date( 'n', $now ), 'end-day' => isset( $_REQUEST['end-day'] ) ? intval( $_REQUEST['end-day'] ) : date( 'j', $now ), 'end-year' => isset( $_REQUEST['end-year'] ) ? intval( $_REQUEST['end-year'] ) : date( 'Y', $now ), 'predefined-date' => isset( $_REQUEST['predefined-date'] ) ? sanitize_text_field( $_REQUEST['predefined-date'] ) : 'This Month', 'discount-code' => isset( $_REQUEST['discount-code'] ) ? intval( $_REQUEST['discount-code'] ) : false, 'status' => isset( $_REQUEST['status'] ) ? sanitize_text_field( $_REQUEST['status'] ) : '', ); $export_url = add_query_arg( $url_params, $export_url ); ?>

prepare_items(); $orders_list_table->search_box( __( 'Search Orders', 'paid-memberships-pro' ), 'paid-memberships-pro' ); $orders_list_table->display(); ?>