| 1 |
<?php |
| 2 |
/** |
| 3 |
* Layout: Main layout. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/orderable/layouts/main.php |
| 6 |
* |
| 7 |
* HOWEVER, on occasion Orderable will need to update template files and you |
| 8 |
* (the theme developer) will need to copy the new files to your theme to |
| 9 |
* maintain compatibility. We try to do this as little as possible, but it does |
| 10 |
* happen. When this occurs the version of the template file will be bumped and |
| 11 |
* the readme will list any important changes. |
| 12 |
* |
| 13 |
* @package Orderable/Templates |
| 14 |
* |
| 15 |
* @var array $products Array of products, sorted by category. |
| 16 |
* @var array $args Array of shortcode args. |
| 17 |
*/ |
| 18 |
|
| 19 |
defined( 'ABSPATH' ) || exit; |
| 20 |
|
| 21 |
$original_products = $products; |
| 22 |
?> |
| 23 |
|
| 24 |
<div class="orderable-main <?php echo esc_attr( apply_filters( 'orderable_main_class', '', $args ) ); ?>"> |
| 25 |
<?php do_action( 'orderable_main_before_sections', $args, $original_products ); ?> |
| 26 |
|
| 27 |
<div class="orderable-main__sections"> |
| 28 |
<?php foreach ( $products as $product_group ) { ?> |
| 29 |
<?php |
| 30 |
$category = $product_group['category']; |
| 31 |
$products = $product_group['products']; |
| 32 |
$has_child_categories = ! empty( $category['children'] ); |
| 33 |
?> |
| 34 |
|
| 35 |
<?php if ( empty( $product_group['products'] ) && ! $has_child_categories ) { |
| 36 |
continue; |
| 37 |
} ?> |
| 38 |
|
| 39 |
<div id="category-<?php echo esc_attr( ! empty( $category['slug'] ) ? urldecode( $category['slug'] ) : 'uncategorized' ); ?>" class="orderable-main__group"> |
| 40 |
<?php do_action( 'orderable_main_before_products', $args, $product_group['category'], $product_group['products'] ); ?> |
| 41 |
|
| 42 |
<?php if ( $has_child_categories ) { |
| 43 |
foreach ( $product_group['category']['children'] as $child_category_group ) { |
| 44 |
$category = $child_category_group['category']; |
| 45 |
$products = $child_category_group['products']; |
| 46 |
|
| 47 |
if ( empty( $products ) ) { |
| 48 |
continue; |
| 49 |
} |
| 50 |
|
| 51 |
do_action( 'orderable_main_before_products_category_children', $args, $category, $products ); |
| 52 |
|
| 53 |
include Orderable_Helpers::get_template_path( 'products-list.php', 'layouts' ); |
| 54 |
|
| 55 |
do_action( 'orderable_main_after_products_category_children', $args, $category, $products ); |
| 56 |
} |
| 57 |
} else { |
| 58 |
include Orderable_Helpers::get_template_path( 'products-list.php', 'layouts' ); |
| 59 |
} ?> |
| 60 |
|
| 61 |
<?php do_action( 'orderable_main_after_products', $args, $product_group['category'], $product_group['products'] ); ?> |
| 62 |
</div> |
| 63 |
<?php } ?> |
| 64 |
</div> |
| 65 |
|
| 66 |
<?php do_action( 'orderable_main_after_sections', $args, $original_products ); ?> |
| 67 |
</div> |
| 68 |
|