adding woocommerce template files to the theme
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 27 Sep 2016 17:25:30 +0000 (13:25 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 27 Sep 2016 17:25:30 +0000 (13:25 -0400)
parts/shop-sidebar.php [new file with mode: 0644]
woocommerce.php [new file with mode: 0644]

diff --git a/parts/shop-sidebar.php b/parts/shop-sidebar.php
new file mode 100644 (file)
index 0000000..ae24747
--- /dev/null
@@ -0,0 +1,76 @@
+<div id="side-divide" class="medium-3 columns show-for-medium">
+</div>
+<div>
+    <?php echo get_template_part("parts/cats-and-products"); ?>
+</div>    
+
+
+<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
diff --git a/woocommerce.php b/woocommerce.php
new file mode 100644 (file)
index 0000000..c7e6b2f
--- /dev/null
@@ -0,0 +1,159 @@
+<!doctype html>
+<html class="no-js" lang="en">
+    <?php include "parts/header-meta.php"; ?>
+        
+    <body>
+        <div class="off-canvas-wrapper">
+            <div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
+                <div class="off-canvas-content" data-off-canvas-content>
+                    <?php
+                    include "sections/header.php"; 
+                    include "sections/off-canvas.php"; 
+                    include "sections/top-bar.php"; 
+                    ?>
+                    <main class="page-inside">
+                        <div id="woo-quick-display" class="small-12 medium-9 columns medium-centered">
+                            <div id="woo-quick-cart-icon" class="small-3 columns left">
+                                <div class="woo-quick-cart-image">
+                                    <a href="<?php echo get_permalink(99);?>">
+                                        <img src="<?php echo get_template_directory_uri(); ?>/assets/shopping-cart.png">
+                                    </a>
+                                    <a href="<?php echo get_permalink(99);?>"><h3>view cart</h3></a>
+                                </div>
+
+                            </div>
+                            <div id="woo-quick-cart-totals" class="small-5 columns">
+                                <p><?php echo $woocommerce->cart->get_cart_total(); ?>
+                                    for
+                                    <?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 
+                                            'woothemes'), $woocommerce->cart->cart_contents_count);?>
+                                </p>
+                            </div>
+                            <div id="woo-quick-checkout" class="small-4 columns right">
+                                <?php
+                                    if (is_user_logged_in()) { 
+                                        echo '<a href="'. get_permalink(101) . '?customer-logout=true" class="button login_toggle">log out</a>';
+                                    }
+                                    elseif (!is_user_logged_in()) {
+                                        echo '<a href="'. get_permalink(101) . '" class="button login_toggle">log in</a>';
+                                    }
+                                ?>
+                                <a href="<?php echo get_permalink(100); ?>" class="button">checkout</a>
+                            </div>
+                        </div>
+                        <div id="content-wrapper" class="row woocommerce-wrapper">                            
+                        <?php if (is_shop()) { ?>
+                            <div class="small-12 medium-7 columns left main woo-tags">
+                            <?php
+                                    /**
+                                     * woocommerce_before_main_content hook
+                                     *
+                                     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
+                                     * @hooked woocommerce_breadcrumb - 20
+                                     */
+                                    do_action( 'woocommerce_before_main_content' );
+                            ?>
+                        <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
+                        <?php endif; ?>
+                        <?php woocommerce_content();?>
+                        <?php do_action( 'woocommerce_archive_description' ); ?>
+                            <?php
+                                    /**
+                                     * woocommerce_after_main_content hook
+                                     *
+                                     * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
+                                     */
+                                    do_action( 'woocommerce_after_main_content' );
+                            ?>
+                            </div><!-- .main .woo-tags -->
+                        <?php } else if (is_product_tag() || is_product_category()) { ?>
+                            <div class="small-12 medium-7 columns left main woo-tags">
+                            <?php
+                                    /**
+                                     * woocommerce_before_main_content hook
+                                     *
+                                     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
+                                     * @hooked woocommerce_breadcrumb - 20
+                                     */
+                                    do_action( 'woocommerce_before_main_content' );
+                            ?>
+                        <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
+                            <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
+                        <?php endif; ?>
+                        <?php do_action( 'woocommerce_archive_description' ); ?>
+                        <?php if ( have_posts() ) : ?>
+                            <?php
+                                /**
+                                 * woocommerce_before_shop_loop hook
+                                 *
+                                 * @hooked woocommerce_result_count - 20
+                                 * @hooked woocommerce_catalog_ordering - 30
+                                 */
+                                do_action( 'woocommerce_before_shop_loop' );
+                            ?>
+                            <?php woocommerce_product_loop_start(); ?>
+                                <?php woocommerce_product_subcategories(); ?>
+                                <?php while ( have_posts() ) : the_post(); ?>
+                                    <?php wc_get_template_part( 'content', 'product' ); ?>
+                                <?php endwhile; // end of the loop. ?>
+                            <?php woocommerce_product_loop_end(); ?>
+                            <?php
+                                /**
+                                 * woocommerce_after_shop_loop hook
+                                 *
+                                 * @hooked woocommerce_pagination - 10
+                                 */
+                                do_action( 'woocommerce_after_shop_loop' );
+                            ?>
+                        <?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
+                            <?php wc_get_template( 'loop/no-products-found.php' ); ?>
+                        <?php endif; ?>
+                                <?php
+                                        /**
+                                         * woocommerce_after_main_content hook
+                                         *
+                                         * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
+                                         */
+                                        do_action( 'woocommerce_after_main_content' );
+                                ?>
+                                </div><!-- .main .woo-tags -->
+                            <?php } else if (is_product()) { ?>
+                                <div class="small-12 medium-7 columns left main woo-single-product">
+                                    <?php
+                                            /**
+                                             * woocommerce_before_main_content hook
+                                             *
+                                             * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
+                                             * @hooked woocommerce_breadcrumb - 20
+                                             */
+                                            do_action( 'woocommerce_before_main_content' );
+                                    ?>
+                                            <?php while ( have_posts() ) : the_post(); ?>
+                                                    <?php wc_get_template_part( 'content', 'single-product' ); ?>
+                                            <?php endwhile; // end of the loop. ?>
+                                    <?php
+                                            /**
+                                             * woocommerce_after_main_content hook
+                                             *
+                                             * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
+                                             */
+                                            do_action( 'woocommerce_after_main_content' );
+                                    ?>
+                                </div><!-- main woo-single-product -->
+                            <?php } ?>
+                                <div id="woo-sidebar" class="small-12 medium-5 columns">
+                                    <?php get_sidebar(); ?>    
+                                </div>
+                            </div><!-- .row .content -->
+                        </main>
+                        <?php
+                        include "sections/footer.php"; 
+                        include "sections/copyright.php";  
+                        ?>
+                    <div class="js-off-canvas-exit"></div>
+                </div><!--/.off-canvas-content-->
+            </div><!--End of inner-wrap-->
+        </div><!--End of off-canvas-->
+        <?php wp_footer();?>
+    </body>
+</html>
\ No newline at end of file