Woocommerce sidebar experimentation
authorLaury GvR <laury@gaslightmedia.com>
Tue, 6 Sep 2016 20:59:04 +0000 (16:59 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 6 Sep 2016 20:59:04 +0000 (16:59 -0400)
parts/shop-sidebar.php [new file with mode: 0644]
scss/plugins/_woocommerce.scss
sidebar.php
woocommerce.php

diff --git a/parts/shop-sidebar.php b/parts/shop-sidebar.php
new file mode 100644 (file)
index 0000000..e2922ea
--- /dev/null
@@ -0,0 +1,70 @@
+                
+                <div class="sidebar shop-sidebar">
+<!--                    <h1>Test</h1>-->
+                    <?php
+//
+                        $taxonomy     = 'product_cat';
+                        $orderby      = 'name';  
+                        $show_count   = 0;      // 1 for yes, 0 for no
+                        $pad_counts   = 0;      // 1 for yes, 0 for no
+                        $hierarchical = 1;      // 1 for yes, 0 for no  
+                        $title        = '';  
+                        $empty        = 0;
+
+                        $args = array(
+                               'taxonomy'     => $taxonomy,
+                               'orderby'      => $orderby,
+                               'show_count'   => $show_count,
+                               'pad_counts'   => $pad_counts,
+                               'hierarchical' => $hierarchical,
+                               'title_li'     => $title,
+                               'hide_empty'   => $empty
+                        );
+                       $all_categories = get_categories( $args );
+                       foreach ($all_categories as $cat) {
+                          if($cat->category_parent == 0) {
+                              $category_id = $cat->term_id;       
+                              echo '<br /><a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a>';
+
+                              $args2 = array(
+                                      'taxonomy'     => $taxonomy,
+                                      'child_of'     => 0,
+                                      'parent'       => $category_id,
+                                      'orderby'      => $orderby,
+                                      'show_count'   => $show_count,
+                                      'pad_counts'   => $pad_counts,
+                                      'hierarchical' => $hierarchical,
+                                      'title_li'     => $title,
+                                      'hide_empty'   => $empty
+                              );
+                              $sub_cats = get_categories( $args2 );
+                              if($sub_cats) {
+                                  foreach($sub_cats as $sub_category) {
+                                      echo  $sub_category->name ;
+                                  }   
+                              }
+                          }       
+                      }
+                      ?>
+                    
+                    <a href="<?php echo esc_url( get_permalink( woocommerce_get_page_id( 'shop' ) ) ); ?>">
+                        <h1>Products</h1>
+                    </a>
+<!-- Adding parent_id="0" to the shortcode attributes below places it back the way it was, just showing top-level cats -->
+                    <?php echo do_shortcode('[product_categories number="" hierarchical="1" orderby="name" order="asc" columns="1" hide_empty="0" ids=""]'); ?>
+                </div>
+
+<script>
+jQuery(document).ready(function($) {
+var url = window.location.href;
+    // 'current' class style to sidebar item that matches the current url
+      $('.shop-sidebar ul.products li a').each(function() {
+        if ($(this).prop('href') === url) {
+            $(this).addClass('current');
+        }
+        if($(this).attr("class") === "current"){
+            $(this).parent("li").addClass("current");
+        }
+    });
+});
+</script>
\ No newline at end of file
index 169eeb6..3f6ee46 100644 (file)
@@ -1,8 +1,5 @@
 
 /* WooCommerce */
-#woo-quick-display {
-  max-width: 75rem;
-}
 #woo-quick-display {
     background-color: white;
     border-radius: 3px;
@@ -11,6 +8,7 @@
     font-size: 16px;
     height: 70px;
     margin-top: 20px;
+    margin-bottom: 10px;
     > div {
         text-align: center;
     }
@@ -19,7 +17,7 @@
         display: inline;
         margin-left: 15px;
         margin-top: 12px;
-        padding: 2px 8px;
+        padding: 5px 11px;
         float: right;
         margin: 12px 0 0 18px;
         background-color: $maroon;
@@ -856,4 +854,7 @@ h3#ship-to-different-address {
 .woocommerce-wrapper .button:hover {
     color: white;
 }
+#woo-sidebar {
+    margin-top: 30px;
+}
 /* End WooCommerce */ 
\ No newline at end of file
index 8466d5e..348a38a 100644 (file)
@@ -1,6 +1,7 @@
                         <div class="row">
                             <div id="side-divide" class="medium-3 columns show-for-medium">
                             </div>
+                            <?php echo do_shortcode('[product_categories number="" orderby="name" order="asc" columns="2" hide_empty="0" parent="0" ids=""]'); ?>   
                             <div class="small-12 medium-9 columns sidebar text-center medium-text-left">
                                 <div id="event-list">
                                     <h2>Event Dates:</h2>
index 0c5c2de..b1ce8b5 100644 (file)
@@ -43,7 +43,7 @@
                         </div>
                         <div id="content-wrapper" class="row woocommerce-wrapper">                            
                         <?php if (is_shop()) { ?>
-                            <div class="small-12 medium-9 columns medium-centered main woo-tags">
+                            <div class="small-12 medium-7 columns left main woo-tags">
                             <?php
                                     /**
                                      * woocommerce_before_main_content hook
@@ -67,7 +67,7 @@
                             ?>
                             </div><!-- .main .woo-tags -->
                         <?php } else if (is_product_tag() || is_product_category()) { ?>
-                            <div class="small-12 medium-9 columns medium-centered main woo-tags">
+                            <div class="small-12 medium-7 columns left main woo-tags">
                             <?php
                                     /**
                                      * woocommerce_before_main_content hook
                                 ?>
                                 </div><!-- .main .woo-tags -->
                             <?php } else if (is_product()) { ?>
-                                <div class="small-12 medium-9 columns medium-centered main woo-single-product">
+                                <div class="small-12 medium-7 columns left main woo-single-product">
                                     <?php
                                             /**
                                              * woocommerce_before_main_content hook
                                     ?>
                                 </div><!-- main woo-single-product -->
                             <?php } ?>
+                                <div id="woo-sidebar" class="small-12 medium-5 columns right">
+                                    <?php include 'parts/shop-sidebar.php';?>    
+                                </div>
                             </div><!-- .row .content -->
                         </main>
                         <?php