Last active
June 20, 2017 13:09
-
-
Save asecondwill/0727eda5dd6c548ac680 to your computer and use it in GitHub Desktop.
and the php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$context = Timber::get_context(); | |
$context['cats'] = Timber::get_terms('product_cat');; | |
if (is_singular('product')) { | |
$context['post'] = Timber::get_post(); | |
$product = get_product( $context['post']->ID ); | |
$context['product'] = $product; | |
add_action( 'mc_attributes', function($product){ | |
$product->list_attributes(); | |
}); | |
add_action( 'mc_reviews', function($product){ | |
return wc_get_template('single-product-reviews.php'); | |
}); | |
Timber::render('woo/single-product.twig', $context); | |
}else{ | |
$posts = Timber::get_posts(); | |
$products = []; | |
foreach ($posts as $post) { | |
$p= []; | |
$p['post'] = $post; | |
$p['product'] = get_product( $post->ID ); | |
$products[] = $p; | |
} | |
$context['products'] = $products; | |
Timber::render('woo/products.twig', $context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment