<?php /* Template Name: فاکتور */ ?>




<div style="display:none;">


<?php
get_header(); 


echo '<meta name="robots" content="noindex, nofollow" />';

defined( 'ABSPATH' ) || exit;
?>

</div>

<style>
.factor-no-error {
	text-align: center;
	padding: 25px;
	font-size: 18px;
}
.factor-no-inner {
	display: table;
	margin: auto;
	background: #cc2c2c;
	color: #fff;
	padding: 25px;
	border-radius: 15px;
}

.factor-no-inner i {
	float: right;
	width: 100%;
	margin-bottom: 20px;
	font-size: 35px;
}
</style>
<?php

if ( class_exists( 'WooCommerce' ) ) {
if ( isset( $_GET['order_id'] ) ) {
    $order_id = intval( $_GET['order_id'] );

    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        $user_id = $current_user->ID;

        $order = wc_get_order( $order_id );

        if ( $order ) {
            $order_user_id = $order->get_user_id();

            if ( $user_id === $order_user_id || current_user_can( 'manage_options' ) ) {
if (
    $order->get_status() === 'completed' || 
    $order->get_status() === 'processing' || 
    $order->get_status() === 'on-hold' || 
    $order->get_status() === 'cancelled'
) {


                    include( locate_template( 'ffile/factor/factor.php' ) );
                } else {
                    echo "<div class='factor-no-error'><div class='factor-no-inner'>";
                    echo '<i class="fi fi-rr-exclamation"></i>';
                    echo 'فاکتوری ساخته نشده است';
                    echo "</div></div>";
                }
            } else {
                wp_redirect( wc_get_page_permalink( 'myaccount' ) );
                exit;
            }
        } else {
            echo "<div class='factor-no-error'><div class='factor-no-inner'>";
                    echo '<i class="fi fi-rr-exclamation"></i>';
            echo 'سفارشی با این شماره یافت نشد';
            echo "</div></div>";
        }
    } else {
        wp_redirect( wc_get_page_permalink( 'myaccount' ) );
        exit;
    }
} else {
    wp_redirect( wc_get_page_permalink( 'myaccount' ) );
                exit;
}}
?>

<div style="display:none;">

<?php get_footer(); ?>
</div>