-
Notifications
You must be signed in to change notification settings - Fork 0
/
woocommerce.php
32 lines (27 loc) · 1.03 KB
/
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
31
32
<?php
$context = Timber::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;
// Get related products
$related_limit = wc_get_loop_prop('columns');
$related_ids = wc_get_related_products($context['post']->id, $related_limit);
$context['related_products'] = Timber::get_posts($related_ids);
// Restore the context and loop back to the main query loop.
wp_reset_postdata();
Timber::render("pages/single-product.twig", $context);
} else {
$posts = Timber::get_posts();
$context["products"] = $posts;
$context["title"] = "Shop";
if (is_product_category()) {
$queried_object = get_queried_object();
$term_id = $queried_object->term_id;
$context["category"] = get_term($term_id, "product_cat");
$context["description"] = category_description($term_id);
$context["title"] = single_term_title("", false);
}
Timber::render("archives/products.twig", $context);
}