-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-catalog-noajax.php
206 lines (165 loc) · 6.92 KB
/
template-catalog-noajax.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php if (ocart_catalog_version() == 1) { ?>
<div id="helpers">
<div class="wrap">
<div class="ajax-search">
<div class="ajax-search-relative">
<input type="text" name="productSearch" id="productSearch" value="" placeholder="<?php _e('Search for a Product','ocart'); ?>" />
<ul class="ajax-search-results">
<!-- ajax search results appear here -->
</ul>
</div>
</div>
<!-- switch to grid -->
<?php if (ocart_get_option('show_gridbtn')) { ?>
<a id="switchToGrid" href="<?php echo home_url(); ?>#grid"><?php _e('Switch to Grid View','ocart'); ?></a>
<?php } ?>
<!-- done -->
</div>
</div>
<div id="catalog">
<div class="wrap">
<div class="catalogWrapper">
<?php
$sort = ocart_get_option('sort_products');
if ($sort == 1) {
$args = array( 'post_type' => 'product', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', get_query_var( 'taxonomy' ) => get_query_var( 'term' ) );
} else {
$args = array( 'post_type' => 'product', 'numberposts' => -1, get_query_var( 'taxonomy' ) => get_query_var( 'term' ) );
}
$posts = get_posts( $args );
?>
<?php if (count($posts) > 0) { ?>
<ul class="prods">
<?php foreach ($posts as $post): setup_postdata($post); ?>
<li id="item-<?php the_ID(); ?>" rel="<?php the_permalink(); ?>">
<?php if (!ocart_get_option('disable_cart')) { ?>
<?php ocart_product('tag'); ?>
<?php } ?>
<?php ocart_product('catalog_image'); ?>
<div class="label">
<div class="label-content">
<span class="title"><?php ocart_product('title'); ?></span>
<?php if (ocart_get_option('disable_cart') && ocart_get_option('disable_prices')) { } else { ?>
<div class="price"><?php ocart_product('price'); ?></div>
<?php } ?>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
<div class="nextItem"></div>
<div class="prevItem"></div>
<div class="nextproduct"></div>
<div class="prevproduct"></div>
<script type="text/javascript">
// init carousel
jQuery('.prods').carouFredSel({
width: 977,
height: 277,
scroll: 1,
align: "left",
auto: false,
direction: "right",
prev: {
button: '.prevItem',
onBefore: function(){
jQuery('.prods li').removeClass('viewport');
jQuery('.prevproduct').stop().animate({left: 0});
jQuery('.prods').trigger("currentVisible", function( items ) {
items.addClass( 'viewport' );
var next_item_id = jQuery('.prods li.viewport:last').next().attr('id').replace(/[^0-9]/g, '');
jQuery('.nextproduct').load('<?php echo get_template_directory_uri(); ?>/ajax/getimage.php?id=' + next_item_id, function(){
jQuery('.prevproduct').hide().stop().animate({left: '-200px'});
});
});
},
onAfter: function(){
jQuery('.prods li').removeClass('viewport');
jQuery('.prods').trigger("currentVisible", function( items ) {
items.addClass( 'viewport' );
var $img = jQuery('.prods li.viewport:first').last(),
$prev = $img.prev();
if (0==$prev.length) {
$prev = $img.siblings().last();
}
var prev_item_id = $prev.attr('id').replace(/[^0-9]/g, '');
jQuery('.prevproduct').load('<?php echo get_template_directory_uri(); ?>/ajax/getimage.php?id=' + prev_item_id, function(){
jQuery('.prevproduct').show();
});
});
}
},
next: {
button: '.nextItem',
onBefore: function(){
jQuery('.prods li').removeClass('viewport');
jQuery('.nextproduct').stop().animate({right: 0});
jQuery('.prods').trigger("currentVisible", function( items ) {
items.addClass( 'viewport' );
var prev_item_id = jQuery('.prods li.viewport:first').attr('id').replace(/[^0-9]/g, '');
jQuery('.prevproduct').load('<?php echo get_template_directory_uri(); ?>/ajax/getimage.php?id=' + prev_item_id, function(){
jQuery('.nextproduct').hide().stop().animate({right: '-200px'});
});
});
},
onAfter: function(){
jQuery('.prods li').removeClass('viewport');
jQuery('.prods').trigger("currentVisible", function( items ) {
items.addClass( 'viewport' );
var next_item_id = jQuery('.prods li.viewport:last').next().attr('id').replace(/[^0-9]/g, '');
jQuery('.nextproduct').load('<?php echo get_template_directory_uri(); ?>/ajax/getimage.php?id=' + next_item_id, function(){
jQuery('.nextproduct').show();
});
});
}
}
});
// change next/prev product
if (jQuery('.prods li').size() >= 7 ) {
jQuery('.prods').trigger("currentVisible", function( items ) {
items.addClass( 'viewport' );
var next_item_id = jQuery('.prods li.viewport:last').next().attr('id').replace(/[^0-9]/g, '');
jQuery('.nextproduct').load('<?php echo get_template_directory_uri(); ?>/ajax/getimage.php?id=' + next_item_id);
var last_item_id = jQuery('.prods li:last').attr('id').replace(/[^0-9]/g, '');
jQuery('.prevproduct').load('<?php echo get_template_directory_uri(); ?>/ajax/getimage.php?id=' + last_item_id);
});
}
</script>
<?php } ?>
</div>
</div>
</div>
<?php } else { ?>
<div id="helpers">
<div class="wrap">
<div class="ajax-search">
<div class="ajax-search-relative">
<input type="text" name="productSearch" id="productSearch" value="" placeholder="<?php _e('Search for a Product','ocart'); ?>" />
<ul class="ajax-search-results">
<!-- ajax search results appear here -->
</ul>
</div>
</div>
<!-- switch to grid -->
<?php if (ocart_get_option('show_sliderbtn')) { ?>
<a id="switchToSlider" href="<?php echo home_url(); ?>#slider"><?php _e('Switch to Slider View','ocart'); ?></a>
<?php } ?>
<!-- done -->
</div>
</div>
<div id="index">
<div class="wrap">
<!-- categories, options -->
<div class="filter">
<?php ocart_show_grid_filters() ?>
</div>
<div class="catalog">
<?php $posts = get_posts( array( 'post_type' => 'product', 'numberposts' => -1, get_query_var( 'taxonomy' ) => get_query_var( 'term' ) ) ); ?>
<div class="catalog_title"><ins id=""><?php if (get_query_var('taxonomy')) { $current_tax = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); echo $current_tax->name; } ?></ins><span><?php if (count($posts) == 1) { printf(__('<span class="totalprod"><span id="products_count">%s</span> Product Found</span>','ocart'), count($posts)); } else { printf(__('<span class="totalprod"><span id="products_count">%s</span> Products Found</span>','ocart'), count($posts)); } ?></span></div>
<ul class="catalog_list" <?php if (get_query_var('taxonomy')) { ?>rel="<?php echo get_query_var( 'taxonomy' ).'-'.get_query_var( 'term' ); ?>"<?php } ?>>
<!-- data -->
</ul><div class="clear"></div>
</div><div class="clear"></div>
</div>
</div>
<?php } ?>