Now will display price if all variations have the same price
authorLaury GvR <laury@gaslightmedia.com>
Tue, 5 Apr 2016 18:31:44 +0000 (14:31 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 5 Apr 2016 18:31:44 +0000 (14:31 -0400)
functions.php
woocommerce/single-product/price.php [deleted file]

index f2e4d1e..6a456e2 100644 (file)
@@ -95,11 +95,6 @@ function glm_get_header() {
     echo '</div>';
 }
 
-function get_product_category_by_id($cat_id) 
-{
-$category = get_term_by('id', $cat_id, 'product_cat', 'OBJECT');
-return $category; 
-}
 add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
 
 function display_price_in_variation_option_name( $term ) {
@@ -136,12 +131,9 @@ remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_pr
 add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 30 );
 add_filter ( 'woocommerce_product_thumbnails_columns', 'prod_thumb_cols' );
 
-remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
-add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 );
+//remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
+//add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 );
 
-function prod_thumb_cols() {
-    return 4; // .last class applied to every 4th thumbnail
-}
 // Change number or products per row to 3
 add_filter('loop_shop_columns', 'loop_columns',999);
 function loop_columns() {
@@ -158,17 +150,13 @@ function woocommerce_support() {
 // WooCommerce number of products shown
 add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );
 
-// // The code below is useful when you want the image to resize to
-//    if (has_post_thumbnail()) {
-//            $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(), "full");
-//            echo '<img src="'.$image_data[0].'" style="no-repeat;max-height:400px;">';
-//    } else {
-//            echo '<img src="'.get_template_directory_uri().'/assets/default-header.gif" style="max-height:400px;">';
-//    }
-//    echo '<div class="row">';
-//    echo '<div class="small-12 columns">';
-//    echo '</div>';
-//    echo '</div>';
+// Display Price For Variable Product With Same Variations Prices
+add_filter('woocommerce_available_variation', function ($value, $object = null, $variation = null) {
+    if ($value['price_html'] == '') {
+        $value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
+    }
+    return $value;
+}, 10, 3);
 
 add_action('wp_enqueue_scripts', 'glm_site_scripts');
 
diff --git a/woocommerce/single-product/price.php b/woocommerce/single-product/price.php
deleted file mode 100644 (file)
index 17409c2..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * Single Product Price, including microdata for SEO
- *
- * This template can be overridden by copying it to yourtheme/woocommerce/single-product/price.php.
- *
- * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
- * will need to copy the new files to your theme to maintain compatibility. We try to do this.
- * as little as possible, but it does happen. When this occurs the version of the template file will.
- * be bumped and the readme will list any important changes.
- *
- * @see     http://docs.woothemes.com/document/template-structure/
- * @author  WooThemes
- * @package WooCommerce/Templates
- * @version 2.4.9
- */
-
-if ( ! defined( 'ABSPATH' ) ) {
-       exit; // Exit if accessed directly
-}
-
-global $product;
-
-?>
-<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
-
-       <?php if( $product->is_type( 'simple' ) ){ ?><p class="price"><?php echo $product->get_price_html(); ?></p><?php } ?>
-
-       <meta itemprop="price" content="<?php echo esc_attr( $product->get_price() ); ?>" />
-       <meta itemprop="priceCurrency" content="<?php echo esc_attr( get_woocommerce_currency() ); ?>" />
-       <link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />
-
-</div>