source->address_line1)) { $addr_street = $charge->source->address_line1; } if (empty($addr_zip) && ! empty($charge->source->address_zip)) { $addr_zip = $charge->source->address_zip; } if (empty($addr_city) && ! empty($charge->source->address_city)) { $addr_city = $charge->source->address_city; } if (empty($addr_state) && ! empty($charge->source->address_state)) { $addr_state = $charge->source->address_state; } if (empty($addr_country) && ! empty($charge->source->address_country)) { $addr_country = $charge->source->address_country; } //get address from new API payment data $ipn = ASP_Process_IPN_NG::get_instance(); if (isset($ipn->p_data)) { $addr = $ipn->p_data->get_billing_details(); if ($addr) { if (empty($addr_street) && ! empty($addr->line1)) { $addr_street = $addr->line1; } if (empty($addr_zip) && ! empty($addr->postal_code)) { $addr_zip = $addr->postal_code; } if (empty($addr_city) && ! empty($addr->city)) { $addr_city = $addr->city; } if (empty($addr_state) && ! empty($addr->state)) { $addr_state = $addr->state; } if (empty($addr_country) && ! empty($addr->country)) { $addr_country = $addr->country; } } } if (! empty($addr_country)) { //convert country code to country name $countries = ASP_Utils::get_countries_untranslated(); if (isset($countries[$addr_country])) { $addr_country = $countries[$addr_country]; } } $ipn_data = array( 'payer_email' => $data['stripeEmail'], 'first_name' => $first_name, 'last_name' => $last_name, 'txn_id' => $data['txn_id'], 'address_street' => $addr_street, 'address_city' => $addr_city, 'address_state' => $addr_state, 'address_zip' => $addr_zip, 'address_country' => $addr_country, ); ASP_Debug_Logger::log('Calling swpm_handle_subsc_signup_stand_alone'); $swpm_id = ''; if (SwpmMemberUtils::is_member_logged_in()) { $swpm_id = SwpmMemberUtils::get_logged_in_members_id(); } if (defined('SIMPLE_WP_MEMBERSHIP_PATH')) { if (!function_exists('swpm_handle_subsc_signup_stand_alone')) { require_once(SIMPLE_WP_MEMBERSHIP_PATH . 'ipn/swpm_handle_subsc_ipn.php'); } swpm_handle_subsc_signup_stand_alone($ipn_data, $level_id, $data['txn_id'], $swpm_id); } } public function handle_swpm_account_connection($data, $charge) { if (empty($data['product_id'])) { return; } $order_post_id = $data['order_post_id']; // Check if user is logged in if (!SwpmMemberUtils::is_member_logged_in()) { return; } $member_id = SwpmMemberUtils::get_logged_in_members_id(); if (!is_numeric($member_id)) { return; } // Valid swpm member ID found, let's save it to order meta; update_post_meta($order_post_id, 'asp_product_swpm_member_id', $member_id); ASP_Debug_Logger::log('Connected SWPM member ID ' . $member_id . ' to order ID ' . $order_post_id); } public function show_asp_swpm_purchase_history($atts) { $is_logged_in = SwpmMemberUtils::is_member_logged_in(); $member_id = SwpmMemberUtils::get_logged_in_members_id(); if (empty($is_logged_in) || !is_numeric($member_id)) { return '

' . esc_html__('You need to be logged in to view your purchase history.', 'stripe-payments') . '

'; } $atts = shortcode_atts(array( 'show_downloads' => 0, ), $atts); $show_downloads = boolval($atts['show_downloads']); // Get all order cpt (stripe_order) for this SWPM member by member ID by the 'asp_product_swpm_member_id' post meta. $orders = get_posts(array( 'post_type' => 'stripe_order', 'posts_per_page' => -1, 'field' => 'ids', 'meta_query' => array( array( 'key' => 'asp_product_swpm_member_id', 'value' => $member_id, ), ), )); if (empty($orders)) { return '

' . esc_html__('No purchase history found.', 'stripe-payments') . '

'; } $transactions_data = array(); foreach ($orders as $order) { $product_id = get_post_meta($order->ID, 'asp_product_id', true); if (empty($product_id)) { continue; } // $product_name = get_the_title($product_id); $order_data = get_post_meta($order->ID, 'order_data', true); // Format the date using the saved wp date format string; // $date_format = get_option('date_format') . ' ' . get_option('time_format'); $date_format = get_option('date_format'); $formatted_date = date($date_format, strtotime($order->post_date)); $product_name = isset($order_data['item_name']) ? sanitize_text_field($order_data['item_name']) : '-'; $txn_id = isset($order_data['txn_id']) ? sanitize_text_field($order_data['txn_id']) : '-'; $item_url = isset($order_data['item_url']) ? sanitize_url($order_data['item_url']) : ''; $quantity = isset($order_data['item_quantity']) ? intval($order_data['item_quantity']) : 0; $paid_amount = isset($order_data['paid_amount']) ? $order_data['paid_amount'] : 0; $currency_code = isset($order_data['currency_code']) ? strtoupper($order_data['currency_code']) : 'USD'; // Get the formatted amount with currency symbol $paid_amount = ASP_Utils::formatted_price($paid_amount, $currency_code); $transactions_data[] = array( 'product_name' => $product_name, 'quantity' => $quantity, 'txn_id' => $txn_id, 'item_url' => $item_url, 'purchase_date' => $formatted_date, 'paid_amount' => $paid_amount, ); } $output = ''; ob_start(); ?>
1) { echo ' x' . esc_html($txn['quantity']); } ?>