File: /var/www/dinamo-shop/wp-content/themes/dinamo-shop/woocommerce/myaccount/orders.php
<?php
/**
* Orders
*
* Shows orders on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/orders.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.7.0
*/
defined( 'ABSPATH' ) || exit;
$customer_id = get_current_user_id();
$slug = $current_page->post_name;
$orders_url = $slug . '/' . get_option( 'woocommerce_myaccount_orders_endpoint');
do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<?php if ( $has_orders ) : ?>
<section class="section">
<div class="container">
<h1 class="h2"><?php _e( 'Moje narudžbe', 'dinamo_shop' ); ?></h1>
<div class="popup-error-message">
<img class="error-img" src="<?= get_template_directory_uri() ?>/assets/img/error.svg" alt="">
<p>Za ovu narudžbu nije moguće pogledati detalje</p>
<img class="close-popup-error-message" src="<?= get_template_directory_uri() ?>/assets/img/close.svg" alt="">
</div>
<table class="table-orders">
<thead>
<tr>
<th><?php _e( 'Vrijeme', 'dinamo_shop' ); ?></th>
<th><?php _e( 'Broj narudžbe', 'dinamo_shop' ); ?></th>
<th><?php _e( 'Ukupno', 'dinamo_shop' ); ?></th>
<th><?php _e( 'Status', 'dinamo_shop' ); ?></th>
<th><?php _e( 'Akcije', 'dinamo_shop' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$page = $current_page;
$ppp = 10;
$orders = get_orders_query( $customer_id, $page, $ppp );
$total_pages = ceil( $customer_orders->total / $ppp );
?>
<?php foreach( $orders as $customer_order ) : ?>
<?php
$order = wc_get_order( $customer_order );
$date = $order->get_date_created();
$date = new DateTime( $date );
$date = $date->format( 'd.m.Y. H:i' ) . 'h';
$all_date_info = getDate(strtotime($date));
if ($all_date_info['year'] < 2023) {
$order_date_class = "old";
}
?>
<tr>
<td><?php echo $date; ?></td>
<td><a href="<?php echo $order->get_view_order_url(); ?>" class="link order-number <?= $order_date_class ?>"><?php _e( 'Narudžba', 'dinamo_shop' ); ?> #<?php echo $order->get_order_number(); ?> </a></td>
<td><?php echo $order->get_formatted_order_total(); ?></td>
<td><?php echo wc_get_order_status_name( $order->get_status() ); ?></td>
<td><a href="<?php echo $order->get_view_order_url(); ?>" class="link <?= $order_date_class ?>"><?php _e('Pogledaj narudžbu', 'dinamo_shop' ); ?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>
<?php do_action( 'woocommerce_before_account_orders_pagination' ); ?>
<?php if ( 1 < $total_pages ) : ?>
<div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination pagination">
<?php if ( 1 !== $current_page ) : ?>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'orders', 1 ) ); ?>" class="first">
<svg class="icon icon-arrow"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-arrow"></use></svg>
<svg class="icon icon-arrow"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-arrow"></use></svg>
<span></span>
</a>
<a class="prev" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>">
<svg class="icon icon-arrow"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-arrow"></use></svg>
<span></span>
</a>
<?php endif; ?>
<?php
for( $i = 1; $i <= $customer_orders->max_num_pages; $i++ ){
if( $i <= $total_pages ) {
if( ( $current_page + 2 ) >= $i && ( $current_page - 2 ) <= $i ) { ?>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $i ) ); ?>" class="<?php echo ( $i == $current_page ) ? "active" : ""; ?>"><?php echo $i; ?></a>
<?php }
}
} ?>
<?php if ( $total_pages > $current_page ) : ?>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>" class="next">
<span></span>
<svg class="icon icon-arrow"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-arrow"></use></svg>
</a>
<?php if( $current_page != $total_pages ) : ?>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $total_pages ) ); ?>" class="last">
<span></span>
<svg class="icon icon-arrow"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-arrow"></use></svg>
<svg class="icon icon-arrow"><use xlink:href="<?php echo THEMEROOT; ?>/assets/icons/icons.svg#icon-arrow"></use></svg>
</a>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php else : ?>
<div class="empty-state-outter">
<div class="empty-state">
<div class="empty-icon">
<img src="<?= THEMEROOT ?>/assets/img/shopping-bag.png" />
</div>
<h2><?= __('Nema novih narudžbi', 'dinamo-shop'); ?></h2>
<p><?= __('U ovom trenutku nema narudžbi. Pregledaj ponudu klikom na gumb niže i napravi novu narudžbu.', 'dinamo-shop'); ?></p>
<a href="<?= get_home_url(); ?>" class="btn btn-primary" ><?= __('Idi na naslovnu', 'tokic_theme'); ?></a>
</div>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?>