403Webshell
Server IP : 104.171.130.249  /  Your IP : 216.73.216.146
Web Server : nginx/1.25.5
System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/themes/matreshka/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wp-content/themes/matreshka//page-history.php
<?php
/*
Template Name: История покупок
*/

get_header();

// Check if user is logged in
if ( ! is_user_logged_in() ) {
	wp_redirect( wc_get_page_permalink( 'myaccount' ) );
	exit;
}

$current_user = wp_get_current_user();
?>

<!-- bread-crumb -->
<section class="bread-crumb d-none d-md-flex mt-4">
	<div class="container">
		<p class="montserrat-medium">
			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="text-decoration-none text-dark">Главная</a>
			<span class="dot">●</span>
			<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="text-decoration-none text-dark">Профиль</a>
			<span class="dot">●</span>
			<span class="bread-crumb-product">История покупок</span>
		</p>
										</div>
									</section>

<!-- navigation -->
<section>
	<div class="container navigation mt-3">
		<div class="history-nav d-flex w-100">
            <a href="javascript:history.back()" class="ms-2 d-block d-md-none">
				<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowLeft.svg' ); ?>" alt="arrow left icon">
			</a>
			<h2 class="history-title montserrat-semibold mx-auto mx-md-0">История покупок</h2>
		</div>
	</div>
</section>

<!-- history -->
<section>
	<div class="container ">
		<div class="container-history">
			<?php
			$status_labels = [
				'completed'  => [ 'Выполнен', 'text-success' ],
				'processing' => [ 'В обработке', 'text-primary' ],
				'on-hold'    => [ 'На удержании', 'text-warning' ],
				'pending'    => [ 'Ожидает оплаты', 'text-warning' ],
				'cancelled'  => [ 'Отменён', 'text-danger' ],
				'refunded'   => [ 'Возврат', 'text-danger' ],
				'failed'     => [ 'Ошибка', 'text-danger' ],
			];
			$months_ru = array(
				'January' => 'января', 'February' => 'февраля', 'March' => 'марта',
				'April' => 'апреля', 'May' => 'мая', 'June' => 'июня',
				'July' => 'июля', 'August' => 'августа', 'September' => 'сентября',
				'October' => 'октября', 'November' => 'ноября', 'December' => 'декабря'
			);
			$days_ru = array(
				'Monday' => 'понедельник', 'Tuesday' => 'вторник', 'Wednesday' => 'среда',
				'Thursday' => 'четверг', 'Friday' => 'пятница', 'Saturday' => 'суббота', 'Sunday' => 'воскресенье'
			);

			// Get customer orders
			$customer_orders = wc_get_orders( array(
				'customer' => $current_user->ID,
				'limit'    => -1,
				'orderby'  => 'date',
				'order'    => 'DESC',
				'status'   => array( 'completed', 'processing', 'on-hold', 'pending', 'cancelled', 'refunded', 'failed' ),
			) );

			if ( $customer_orders ) :
				foreach ( $customer_orders as $order ) :
					$order_id = $order->get_id();
					$order_date = $order->get_date_created();
					$order_total = $order->get_total();
					$order_items = $order->get_items();

					// Collect product images (up to 4 items, including placeholders).
					$preview_images = array();
					$items_text = array();

					foreach ( $order_items as $item ) {
						$product = $item->get_product();
						$items_text[] = $item->get_name();

						if ( count( $preview_images ) < 4 ) {
							$preview_images[] = matreshka_get_history_product_image_html( $product, $item->get_name(), 'thumbnail' );
						}
					}

					// Get real cashback data from order meta
					$bonuses_earned = (int) $order->get_meta( '_matreshka_cashback_awarded' );

					$order_status = $order->get_status();
					$status_info = $status_labels[ $order_status ] ?? [ ucfirst( $order_status ), 'text-secondary' ];

					// Format date — Russian month names
					$date_formatted = $order_date->date_i18n( 'd F' );
					$time_formatted = $order_date->date_i18n( 'H:i' );
					$day_name = $order_date->date_i18n( 'l' );

					foreach ( $months_ru as $en => $ru ) {
						$date_formatted = str_replace( $en, $ru, $date_formatted );
					}
					foreach ( $days_ru as $en => $ru ) {
						$day_name = str_replace( $en, $ru, $day_name );
					}

					$items_preview = implode( ', ', array_slice( $items_text, 0, 3 ) );
					$modal_id = 'history-order-modal-' . $order_id;
					$price_args = array( 'currency' => $order->get_currency() );
					$order_totals = $order->get_order_item_totals();
					$coupon_items = $order->get_items( 'coupon' );
					$shipping_type = $order->get_meta( '_matreshka_shipping_type' ) ?: 'delivery';
					$courier_comment = $order->get_meta( '_matreshka_courier_comment' ) ?: $order->get_customer_note();
					$packing_preferences = array_filter( array(
						$order->get_meta( '_matreshka_less_bags' ) === 'yes' ? 'Меньше пакетов' : '',
						$order->get_meta( '_matreshka_vegs_in_bags' ) === 'yes' ? 'Овощи в пакетах' : '',
					) );
					?>
					<article class="history-item history-item--interactive" role="button" tabindex="0" data-history-order-modal="<?php echo esc_attr( $modal_id ); ?>" aria-controls="<?php echo esc_attr( $modal_id ); ?>" aria-expanded="false" aria-label="Открыть детали заказа №<?php echo esc_attr( $order->get_order_number() ); ?>">
						<?php if ( ! empty( $preview_images ) ) :
							$img_count = count( array_slice( $preview_images, 0, 4 ) );
						?>
							<div class="history-item-img history-item-img--<?php echo esc_attr( $img_count ); ?> me-3" style="min-width: 91px;">
								<?php foreach ( array_slice( $preview_images, 0, 4 ) as $image_html ) : ?>
									<?php echo $image_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
								<?php endforeach; ?>
							</div>
						<?php endif; ?>

						<div class="history-item-title">
							<p class="montserrat-semibold">
								Покупка <?php echo esc_html( $date_formatted ); ?>
								<span class="montserrat-regular text-dark-opacity">
									<?php echo esc_html( $time_formatted ); ?>, <?php echo esc_html( $day_name ); ?>
								</span>
								<br/>
								<span class="montserrat-medium <?php echo esc_attr( $status_info[1] ); ?>" style="font-size: 13px;">
									<?php echo esc_html( $status_info[0] ); ?>
								</span>
							</p>
							<?php if ( ! empty( $items_preview ) ) : ?>
								<p class="text-dark-opacity montserrat-medium d-md-block d-none">
									<?php echo esc_html( $items_preview ); ?>
								</p>
							<?php endif; ?>
						</div>

						<div class="history-item-price ms-auto text-end">
							<p class="montserrat-semibold"><?php echo wc_price( $order_total ); ?></p>
							<?php if ( $bonuses_earned > 0 ) : ?>
								<span class="montserrat-semibold" style="font-size: 13px; color: var(--success, #528A4D);">+<?php echo esc_html( $bonuses_earned ); ?> бонусов</span>
								<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/Subtractred.svg' ); ?>" alt="bonus icon" class="ms-1">
							<?php endif; ?>
						</div>
					</article>

					<div class="history-order-modal" id="<?php echo esc_attr( $modal_id ); ?>" aria-hidden="true" hidden>
						<div class="history-order-modal__overlay" data-history-order-modal-close></div>
						<section class="history-order-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="<?php echo esc_attr( $modal_id ); ?>-title" tabindex="-1">
							<header class="history-order-modal__header">
								<div>
									<p class="history-order-modal__eyebrow montserrat-medium">Чек заказа # <?php echo esc_html( $order->get_order_number() ); ?></p>
									<h3 id="<?php echo esc_attr( $modal_id ); ?>-title" class="montserrat-semibold">Покупка <?php echo esc_html( $date_formatted ); ?></h3>
								</div>
								<button type="button" class="history-order-modal__close" data-history-order-modal-close aria-label="Закрыть детали заказа">&times;</button>
							</header>

							<div class="history-order-modal__body">
								<div class="history-order-modal__meta montserrat-medium">
									<span><span class="material-icons-outlined">schedule</span><?php echo esc_html( $time_formatted . ', ' . $day_name ); ?></span>
									<span class="<?php echo esc_attr( $status_info[1] ); ?>"><span class="material-icons-outlined">info</span><?php echo esc_html( $status_info[0] ); ?></span>
								</div>

								<section class="history-receipt-section">
									<h4 class="montserrat-semibold">Товары</h4>
									<div class="history-receipt-items">
										<?php foreach ( $order_items as $item ) :
											$product = $item->get_product();
											$image_html = matreshka_get_history_product_image_html( $product, $item->get_name(), 'woocommerce_thumbnail' );
											$quantity = $item->get_quantity();
											$line_total = (float) $item->get_total();
											$unit_price = $quantity ? $line_total / $quantity : $line_total;
											?>
											<article class="history-receipt-item">
												<?php echo $image_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
												<div class="history-receipt-item__info">
													<p class="montserrat-medium"><?php echo esc_html( $item->get_name() ); ?></p>
													<span class="montserrat-regular"><?php echo esc_html( $quantity ); ?> шт. × <?php echo wp_kses_post( wc_price( $unit_price, $price_args ) ); ?></span>
												</div>
												<strong class="montserrat-semibold"><?php echo wp_kses_post( wc_price( $line_total, $price_args ) ); ?></strong>
											</article>
											<?php endforeach; ?>
										</div>
									</section>

								<section class="history-receipt-section">
									<h4 class="montserrat-semibold">Расчёт</h4>
									<div class="history-receipt-totals montserrat-regular">
										<?php foreach ( $order_totals as $total_key => $total ) :
											$total_classes = array();
											if ( 'order_total' === $total_key ) {
												$total_classes[] = 'history-receipt-totals__total';
												$total_classes[] = 'montserrat-semibold';
											}
											if ( false !== strpos( $total_key, 'discount' ) || false !== strpos( $total_key, 'coupon' ) ) {
												$total_classes[] = 'history-receipt-totals__discount';
											}
											?>
											<div<?php echo $total_classes ? ' class="' . esc_attr( implode( ' ', $total_classes ) ) . '"' : ''; ?>><span><?php echo wp_kses_post( $total['label'] ); ?></span><span><?php echo wp_kses_post( $total['value'] ); ?></span></div>
										<?php endforeach; ?>
										</div>
									</section>

								<section class="history-receipt-section">
									<h4 class="montserrat-semibold"><?php echo $shipping_type === 'pickup' ? 'Самовывоз' : 'Доставка'; ?></h4>
									<div class="history-receipt-details montserrat-regular">
										<?php if ( $shipping_type === 'pickup' ) : ?>
											<?php $store_name = $order->get_meta( '_matreshka_pickup_store_name' ); $store_address = $order->get_meta( '_matreshka_pickup_store_address' ); $store_phone = $order->get_meta( '_matreshka_pickup_store_phone' ); $store_hours = $order->get_meta( '_matreshka_pickup_store_hours' ); ?>
											<?php if ( $store_name ) : ?><p><span class="material-icons-outlined">storefront</span><strong><?php echo esc_html( $store_name ); ?></strong></p><?php endif; ?>
											<?php if ( $store_address ) : ?><p><span class="material-icons-outlined">location_on</span><?php echo esc_html( $store_address ); ?></p><?php endif; ?>
											<?php if ( $store_hours ) : ?><p><span class="material-icons-outlined">schedule</span><?php echo esc_html( $store_hours ); ?></p><?php endif; ?>
											<?php if ( $store_phone ) : ?><p><span class="material-icons-outlined">phone</span><a href="tel:<?php echo esc_attr( $store_phone ); ?>"><?php echo esc_html( $store_phone ); ?></a></p><?php endif; ?>
										<?php else : ?>
											<?php $address_parts = array_filter( array( $order->get_billing_address_1() ?: $order->get_shipping_address_1(), $order->get_meta( '_matreshka_entrance' ) ? 'Подъезд: ' . $order->get_meta( '_matreshka_entrance' ) : '', $order->get_meta( '_matreshka_floor' ) ? 'Этаж: ' . $order->get_meta( '_matreshka_floor' ) : '', $order->get_meta( '_matreshka_apartment' ) ? 'Кв.: ' . $order->get_meta( '_matreshka_apartment' ) : '', $order->get_meta( '_matreshka_intercom' ) ? 'Домофон: ' . $order->get_meta( '_matreshka_intercom' ) : '' ) ); ?>
											<?php if ( $address_parts ) : ?><p><span class="material-icons-outlined">location_on</span><?php echo esc_html( implode( ' · ', $address_parts ) ); ?></p><?php endif; ?>
											<?php if ( $order->get_meta( '_matreshka_leave_at_door' ) === 'yes' ) : ?><p><span class="material-icons-outlined">door_front</span>Оставить у двери</p><?php endif; ?>
										<?php endif; ?>
										<?php if ( $order->get_billing_phone() ) : ?><p><span class="material-icons-outlined">phone</span><a href="tel:<?php echo esc_attr( $order->get_billing_phone() ); ?>"><?php echo esc_html( $order->get_billing_phone() ); ?></a></p><?php endif; ?>
									</div>
								</section>

								<section class="history-receipt-section">
									<h4 class="montserrat-semibold">Детали заказа</h4>
									<div class="history-receipt-details montserrat-regular">
										<?php if ( $order->get_payment_method_title() ) : ?><p><span class="material-icons-outlined">payments</span>Оплата: <?php echo esc_html( $order->get_payment_method_title() ); ?></p><?php endif; ?>
										<?php if ( $courier_comment ) : ?><p><span class="material-icons-outlined">chat_bubble_outline</span><?php echo esc_html( $courier_comment ); ?></p><?php endif; ?>
									</div>
								</section>
							</div>
						</section>
					</div>
				<?php endforeach; ?>
			<?php else : ?>
				<div class="text-center py-5">
                    <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/notfount.png' ); ?>" alt="No orders" class="mb-3">
					<p class="montserrat-medium">У вас пока нет заказов</p>
				</div>
			<?php endif; ?>
		</div>
	</div>
</section>

<?php
get_footer();

Youez - 2016 - github.com/yon3zu
LinuXploit