-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwoocommerce.php
30 lines (23 loc) · 955 Bytes
/
woocommerce.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
<?php
if ( ! class_exists( 'Timber' ) ){
echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
return;
}
$context = Timber::get_context();
$context['sidebar'] = Timber::get_widgets( 'shop-sidebar' );
if ( is_singular( 'product' ) ) {
$context['post'] = Timber::get_post();
$product = wc_get_product( $context['post']->ID );
$context['product'] = $product;
Timber::render( 'woocommerce/single-product.twig', $context );
} else {
$posts = Timber::get_posts();
$context['products'] = $posts;
if ( is_product_category() ) {
$queried_object = get_queried_object();
$term_id = $queried_object->term_id;
$context['category'] = get_term( $term_id, 'product_cat' );
$context['title'] = single_term_title( '', false );
}
Timber::render( 'woocommerce/archive.twig', $context );
}