Adding the base woocommerce template
authorLaury GvR <laury@gaslightmedia.com>
Thu, 24 Aug 2017 16:30:57 +0000 (12:30 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 24 Aug 2017 16:30:57 +0000 (12:30 -0400)
woocommerce.php [new file with mode: 0644]

diff --git a/woocommerce.php b/woocommerce.php
new file mode 100644 (file)
index 0000000..5d66d88
--- /dev/null
@@ -0,0 +1,235 @@
+<?php get_header(); ?>
+<div id="header-image" class="product_featured_image">
+        <?php echo glm_get_header();?>
+    </div>
+<div id="breadcrumbs" class="row">
+    <?php get_template_part('parts/bread-crumbs'); ?>
+</div>
+<main class="page-inside woocommerce">
+
+    <div id="content-wrapper" class='side-shadow woocommerce-wrapper'>
+        <div class="row">
+            <?php if ( ! is_product_tag() && ! is_product_category()) { ?>
+            <div class="side_bar large-3 columns show-for-large-up">
+                <?php get_sidebar(); ?>
+            </div>
+            <?php } ?>
+            <?php if (is_shop()) { ?>
+                <div class="small-12 large-9 columns 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
+                         */
+                        function wc_category_title_archive_products(){
+
+                            $product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
+
+                            if ( $product_cats && ! is_wp_error ( $product_cats ) ){
+
+                                $single_cat = array_shift( $product_cats ); ?>
+
+                                <small class="product_category_title_item"><?php echo $single_cat->name; ?></small>
+
+                      <?php
+                            }
+                        }
+                        add_action( 'woocommerce_after_shop_loop_item_title', 'wc_category_title_archive_products', 5 );
+                            do_action( 'woocommerce_before_main_content' );
+                            add_filter( 'loop_shop_columns', 'tm_product_columns', 5);
+                                function tm_product_columns($columns) {
+                                    if ( is_product_category() || is_product_tag() ) {
+                                        $columns = 3;
+                                        return $columns;
+                                    }
+                                } ?>
+                           <?php 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>
+            <?php } if (is_product_tag() || is_product_category()) { ?>
+                <div class="small-12 large-12 columns 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
+                     */
+                    function wc_category_title_archive_products(){
+
+                    $product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
+
+                    if ( $product_cats && ! is_wp_error ( $product_cats ) ){
+
+                        $single_cat = array_shift( $product_cats );
+
+                        // Set name to the default first picked category (however WC decides that)
+                        $primaryCatName = $single_cat->name;
+
+                        // Try to get the Primary Category based on how Yoast SEO has set it in the postmeta table
+                        global $wpdb;
+                        $sqlGetPrimary = "SELECT meta_value
+                                FROM $wpdb->postmeta
+                                WHERE
+                                    (meta_key = '_yoast_wpseo_primary_product_cat' AND post_id = %d);
+                        ";
+                        $primaryCatID = $wpdb->get_var(
+                            $wpdb->prepare(
+                                $sqlGetPrimary,
+                                get_the_id()
+                            )
+                        );
+                        $term = get_term_by( 'id', $primaryCatID, 'product_cat' );
+
+                        // Use the primary category instead if it's valid
+                        if( $term->name ) {
+                            $primaryCatName = $term->name;
+                        }
+                    ?>
+
+                    <small class="product_category_title_item"><?php echo $primaryCatName; ?></small>
+
+                    <?php }
+                    }
+                    add_action( 'woocommerce_after_shop_loop_item_title', 'wc_category_title_archive_products', 5 );
+                    do_action( 'woocommerce_before_main_content' );
+                    add_filter( 'loop_shop_columns', 'tm_product_columns', 5);
+                    function tm_product_columns($columns) {
+                        if ( is_product_category() || is_product_tag() ) {
+                            $columns = 3;
+                            return $columns;
+                        }
+                    }
+                    ?>
+
+               <?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>
+            <?php } else if (is_product()) { ?>
+                <div class="small-12 large-9 columns main woo-single-product">
+                    <?php
+                        if(function_exists('pf_show_link')){echo pf_show_link();}
+                    ?>
+                    <?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>
+            <?php } ?>
+        </div>
+    </div>
+    <div id="wooImageHoverContainer">
+        <img>
+    </div>
+<?php get_footer(); ?>
+<script>
+
+$(document).ready(function () {
+    $("#tab-html5_video p").remove();
+    var mainImage = $(".attachment-shop_single.size-shop_single.wp-post-image");
+    var thumbImage =  $(".attachment-shop_thumbnail.size-shop_thumbnail");
+    $(".attachment-shop_thumbnail").parent().css("text-align","center");
+    $(".woocommerce-placeholder").parent().css("text-align","center");
+    $(thumbImage).mouseover(function(){
+        $(mainImage).attr("srcset", $(this).attr("src"));
+    });
+
+    // Thumbnail undisplay
+    $(thumbImage).mouseout(function(){
+        $(mainImage).attr("srcset", $(mainImage).attr("src"));
+    });
+
+});
+</script>