-
Notifications
You must be signed in to change notification settings - Fork 0
/
taxonomy-product_cat.php
150 lines (107 loc) · 3.53 KB
/
taxonomy-product_cat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php get_header(); ?>
<main>
<?php
// Queried Term
$queried_object = get_queried_object();
global $term_id;
$term_id = $queried_object->term_id;
$term_name = $queried_object->name;
$button_color = "";
if ( $term_id === 4 ) {
$button_color = 'blue-button';
} else if ( $term_id === 3 ) {
$button_color = 'green-button';
} else if ( $term_id === 5 ) {
$button_color = 'orange-button';
}
?>
<section id="section-p-cat-banner">
<?php
// Banner Background
$cat_img = get_field('feat_img', 'product_cat_' . $term_id);
echo '<div class="bg-img desktop" style="background-image:url(\'' . $cat_img['sizes']['panel_bg'] . '\');"></div>';
echo '<div class="bg-img mobile" style="background-image:url(\'' . $cat_img['sizes']['panel_bg_mobile'] . '\');"></div>';
?>
<div class="row">
<div class="col span-12">
<div id="p-cat-banner-content" class="white-text">
<?php
// Category Name Box
echo '<div class="heading-box">';
// "Products" Link
echo '<h6><a href="' . get_bloginfo('url') . '/products/">Products</a></h6>';
// Category Name
echo '<h1>' . $term_name . '</h1>';
echo '</div>';
// Blurb Box
$cat_blurb = get_field('blurb', 'product_cat_' . $term_id);
$show_blurb = get_field('show_blurb_on_landing_page', 'product_cat_' . $term_id);
if ($show_blurb) {
echo '<div class="blurb-box">';
// Overlay
echo '<div class="overlay cat-col-' . $term_id . ' cc-bg"></div>';
// Blurb
echo '<p class="blurb">' . $cat_blurb . '</p>';
echo '</div>';
}
?>
</div>
</div>
</div>
</section>
<?php
// Flexible Content
global $flexible_rows;
$flexible_rows = 'product_cat_' . $term_id;
flexibleContent();
?>
<?php
// Call to action
$cta = get_field('call_to_action', $queried_object);
$cta_section = <<<HTML
<div class="p-cat-cta cat-col-{$term_id} cc-bg">
<div class="row">
<div class="col span-12">
{$cta}
</div>
</div>
</div>
HTML;
if ($cta) {
echo $cta_section;
}
?>
<section id="section-p-cat-content">
<div class="row">
<div class="col span-12">
<?php
// Query Products in Category
$html_out = '';
if( $wp_query->have_posts() ):
$html_out .= '<div id="p-cat-grid">';
while( $wp_query->have_posts() ): $wp_query->the_post();
$product_thumb = get_field('thumb');
$product_thumb_src = $product_thumb['sizes']['medium'];
$product_title = get_the_title();
$product_link = get_the_permalink();
$product_html = <<<HTML
<div class="p-cat-grid__item">
<div class="p-cat-card">
<a class="p-cat-card__image-link" title="{$product_title}" href="{$product_link}"><img class="p-cat-card__image" src="{$product_thumb_src}" alt="{$product_title}" /></a>
<h5 class="p-cat-card__title"><a href="{$product_link}">{$product_title}</a></h5>
<a class="button p-cat-card__button {$button_color}" href="{$product_link}">View Product</a>
</div>
</div>
HTML;
$html_out .= $product_html;
endwhile;
$html_out .= '</div>';
echo $html_out;
endif;
wp_reset_query();
?>
</div>
</div>
</section>
</main>
<?php get_footer(); ?>