Added woocommerce template partials
authorLaury GvR <laury@gaslightmedia.com>
Wed, 22 Feb 2017 20:27:44 +0000 (15:27 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 22 Feb 2017 20:27:44 +0000 (15:27 -0500)
parts/shop-cats-and-products.php [new file with mode: 0644]
parts/shop-sidebar.php [new file with mode: 0644]

diff --git a/parts/shop-cats-and-products.php b/parts/shop-cats-and-products.php
new file mode 100644 (file)
index 0000000..3c8e0d8
--- /dev/null
@@ -0,0 +1,63 @@
+
+
+<?php $args = array(
+         'orderby'    => 'title',
+         'order'      => 'ASC',
+         'hide_empty' => false,
+         'exclude'    => '18'
+       
+    );
+    $product_categories = get_terms( 'product_cat', $args );
+    $count = count($product_categories);
+    if ( $count > 0 ){
+        foreach ( $product_categories as $product_category ) {
+            $args = array(
+                'posts_per_page' => -1,
+                'tax_query' => array(
+                    'relation' => 'AND',
+                    array(
+                        'taxonomy' => 'product_cat',
+                        'field' => 'slug',
+                        'terms' => $product_category->slug
+                    )
+                ),
+                'post_type' => 'product',
+                'post_status' => 'publish',
+                'orderby' => 'menu_order',
+                'order' => 'ASC',
+                'meta_query' => array(
+                    array(
+                        'key'       => '_visibility',
+                        'value'     => 'hidden',
+                        'compare'   => '!=',
+                    )
+                )
+            );
+            $products = new WP_Query( $args );
+            if ($products->have_posts()) { ?>
+                        <div class="category-container">
+                            <?php 
+                            echo '<div class="category-title">';
+                            echo '<a href="' . get_term_link( $product_category ) . '">' . $product_category->name . '</a>';
+                            echo '</div>';
+                            echo "<ul class='category-products'>";
+
+                            while ( $products->have_posts() ) {
+
+                                $products->the_post();
+                                ?>
+                                    <li class="product">
+                                        <a href="<?php the_permalink(); ?>">
+                                            <?php the_title(); ?>
+                                        </a>
+                                    </li>
+                                <?php
+                            }
+                            if (!$products->have_posts()) {
+                                echo "TBD";
+                            }
+                            echo "</ul>";?>
+                        </div>
+            <?php } ?>
+        <?php } ?>
+    <?php } ?>
\ No newline at end of file
diff --git a/parts/shop-sidebar.php b/parts/shop-sidebar.php
new file mode 100644 (file)
index 0000000..099429f
--- /dev/null
@@ -0,0 +1,49 @@
+<?php 
+    global $woocommerce;
+?> 
+<div class="shop-sidebar">
+    <div class="page_item page_item_has_children">
+        <a href="<?php echo get_permalink( woocommerce_get_page_id( 'shop' ) ); ?>">
+            Categories
+        </a>
+    </div>
+    <div class="categories">
+        <?php echo get_template_part("parts/shop-cats-and-products"); ?>
+    </div>
+    <div class="page_item page_item_has_children">
+        <a href="<?php echo $woocommerce->cart->get_cart_url(); ?>">
+            Cart
+        </a>
+    </div>
+    <div class="page_item page_item_has_children">
+        <a href="<?php echo $woocommerce->cart->get_checkout_url(); ?>">
+            Checkout
+        </a>
+    </div>
+    <?php 
+        $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
+        if ( $myaccount_page_id ) { 
+            $myaccount_page_url = get_permalink( $myaccount_page_id );
+    ?>
+    <div class="page_item page_item_has_children">
+        <a href="<?php echo $myaccount_page_url ?>">
+            My Account
+        </a>
+    </div>
+    <?php } ?>
+</div>
+
+<script>
+jQuery(document).ready(function($) {
+var url = window.location.href;
+    // 'current' class style to sidebar item that matches the current url
+      $('.shop-sidebar .category-container a').each(function() {
+        if ($(this).prop('href') === url) {
+            $(this).closest(".category-container").addClass('current');
+        }
+        if($(this).attr("class") === "current"){
+            $(this).parent().parent().addClass("current");
+        }
+    });
+});
+</script>
\ No newline at end of file