You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
60 lines
1.6 KiB
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
if (is_product()) {
|
|
|
|
include_module('shop');
|
|
include_component('shop', 'single-product');
|
|
|
|
$context = Timber::get_context();
|
|
$post = Timber::get_post();
|
|
$context['post'] = $post;
|
|
|
|
$context['wc_breadcrumbs'] = array();
|
|
|
|
if (function_exists('woocommerce_breadcrumb')) {
|
|
$args = array(
|
|
'delimiter' => '',
|
|
'wrap_before' => '',
|
|
'wrap_after' => '',
|
|
'before' => '',
|
|
'after' => '',
|
|
'home' => _x('Home', 'breadcrumb', 'woocommerce'),
|
|
);
|
|
|
|
$breadcrumbs = new WC_Breadcrumb();
|
|
$breadcrumbs->generate();
|
|
|
|
$formatted_breadcrumbs = array();
|
|
foreach ($breadcrumbs->get_breadcrumb() as $crumb) {
|
|
$formatted_breadcrumbs[] = array(
|
|
'text' => $crumb[0],
|
|
'url' => $crumb[1]
|
|
);
|
|
}
|
|
|
|
$context['wc_breadcrumbs'] = $formatted_breadcrumbs;
|
|
}
|
|
|
|
$product_id = get_the_ID();
|
|
$product = wc_get_product($product_id);
|
|
|
|
$context['product'] = $product;
|
|
|
|
$context['related_products'] = array();
|
|
$related_products_ids = wc_get_related_products($product_id, 5);
|
|
|
|
if ($related_products_ids) {
|
|
foreach ($related_products_ids as $related_id) {
|
|
$related_product = wc_get_product($related_id);
|
|
if ($related_product) {
|
|
$context['related_products'][] = $related_product;
|
|
}
|
|
}
|
|
}
|
|
|
|
Timber::render('modules/shop/components/single-product/component-template.twig', $context);
|
|
} |