archive-product.php 7.57 KB
Newer Older
imac's avatar
imac committed
1 2 3 4 5 6 7 8 9 10 11 12
<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.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.
 *
imac's avatar
imac committed
13 14 15
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @author      WooThemes
 * @package     WooCommerce/Templates
imac's avatar
imac committed
16 17 18 19 20 21 22
 * @version     2.0.0
 */
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}
$current_page = 'catalogue';
get_header();
23
$product;
imac's avatar
imac committed
24 25 26 27
$cate = get_queried_object();
$cateID = $cate->term_id;

//SubCats
imac's avatar
imac committed
28
$child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' => the_category_ID(), 'exclude' => $cateID, 'orderby' => 'title', 'order' => 'ASC'));
imac's avatar
imac committed
29 30 31 32 33
?>

<div class="container clearfix" id="catalogue" data-page = "<?php echo $cateID; ?>">
    <div class="container-bg abs-full"></div>
    <?php get_sidebar() ?>
imac's avatar
imac committed
34 35 36 37 38
    <div class="header mobile-nav display--only-mobile blue-bg fixed">
        <div class="nav-wrapper blue-bg">
            <ul></ul>
        </div>
    </div>
imac's avatar
imac committed
39 40 41 42 43 44 45 46 47 48 49 50 51
    <div class="right-container">
        <div class="left-panel fixed-full position--after-menu ">
            <div class="filter-wrapper">
                <div class="filter-btn fixed position--after-menu">
                    <div class="btn-container"><span class="abs-center font-small">Filtres</span></div>
                </div>
                <div class="filter-content">
                    <div class="filter-list fixed position--after-menu">
                        <div class="top-header">
                            <span>Filtres</span>
                            <span class="close-btn"></span>
                        </div>

52 53 54 55 56 57 58 59
                        <?php
                        $attributes = array('Univers' => 'pa_univers', 'Matiére' => 'pa_matiere', 'Format' => 'pa_format', 'Couleurs' => 'pa_couleur');
                        foreach ($attributes as $key => $value) :
                            ?>
                            <div class="filter-bloc">
                                <div class="header">
                                    <p><span><?php echo $key ?></span></p>
                                </div>
imac's avatar
imac committed
60

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
                                <?php
                                $terms = get_terms($value);

                                if (!empty($terms) && !is_wp_error($terms)):
                                    ?>
                                    <div class="bloc-content">
                                        <ul <?php if ($value == 'pa_couleur') echo 'class = "list-color-filter clearfix"'; ?>>
                                            <?php
                                            foreach ($terms as $term) :
                                                if ($value == 'pa_couleur'):
                                                    $color = get_field('couleurs', 'pa_couleur_' . $term->term_id);

                                                    if (isset($color) && strlen($color) > 0):
                                                        ?>
                                                        <li data-color = "<?php echo $color; ?>" class="<?php echo $term->name; ?>"></li>
                                                        <?php
                                                    endif;
                                                else :
                                                    ?>
                                                    <li><?php echo $term->name; ?></li>
                                                <?php
                                                endif;
                                            endforeach;
                                            if ($value == 'pa_couleur'):
                                                ?>

                                                <li class="reinit">Tout déselectionner</li>
                                            <?php endif; ?>
                                        </ul>

                                    </div>
                                <?php endif; ?>
imac's avatar
imac committed
93
                            </div>
94 95 96 97
                        <?php endforeach; ?>



imac's avatar
imac committed
98
                        <div class="center filter-btn-list">
99
                            <div class="btn pink-btn rounded" id="search-btn">Rechercher</div>
imac's avatar
imac committed
100 101 102 103 104 105 106 107 108
                            <span class = "reinit-all">Effacer les filtres</span>
                        </div>
                    </div>
                </div>
            </div>
            <?php
            foreach ($child_category as $key => $value) :
                ?>
                <div class="cover-wrapper abs-full transition" data-cat = "#cat<?php echo $value->term_id ?>" style = "background-image: url('<?php echo nap_category_image($value->term_id) ?>')">
109 110 111
                    <div class="cover-desc-wrapper">
                        <p><?php echo $value->description; ?></p>
                    </div>
imac's avatar
imac committed
112 113 114 115 116 117 118 119 120 121
                </div>   
                <?php
            endforeach;
            ?>
        </div>
        <div class="right-panel right">
            <div class="panel panel-content list-animation">
                <?php foreach ($child_category as $key => $value) : ?>
                    <section id = "cat<?php echo $value->term_id ?>">
                        <h2 class="crete small-title"><?php echo $value->name ?></h2>
imac's avatar
imac committed
122 123 124 125 126
                        <div class="cover-mobile display--only-mobile animated fadeInUp" style = "background-image: url('<?php echo nap_category_image($value->term_id) ?>')">
                            <div class="cover-desc-wrapper">
                                <p><?php echo $value->description; ?></p>
                            </div>
                        </div>
imac's avatar
imac committed
127 128
                        <div class="product-list">
                            <?php
129
                            $args = array('post_type' => 'product', 'stock' => 1, 'posts_per_page' => -1, 'product_cat' => $value->name, 'orderby' => 'title' , 'order' => 'ASC');
imac's avatar
imac committed
130 131
                            $naps_posts = new WP_Query($args);
                            $options = array();
132

imac's avatar
imac committed
133 134
                            while ($naps_posts->have_posts()) : $naps_posts->the_post();
                                $id = get_the_ID();
135 136

                                $options['size'] = (get_field('produit_affichage', $id)) ? get_field('produit_affichage', $id) : 'small';
imac's avatar
imac committed
137
                                $args = array(
138
                                    'post_type' => array('product', 'product_variation'),
imac's avatar
imac committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
                                    'post_status' => array('private', 'publish'),
                                    'numberposts' => -1,
                                    'orderby' => 'menu_order',
                                    'order' => 'asc',
                                    'post_parent' => $id
                                );
                                ?>

                                <?php echo nap_get_item($id, $args, $current_page, $options); ?>


                                <?php
                            endwhile;
                            wp_reset_query();
                            ?>
                        </div> 
                    </section>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
</div>
<?php get_footer(); ?>