From: Laury GvR Date: Tue, 5 Apr 2016 18:31:44 +0000 (-0400) Subject: Now will display price if all variations have the same price X-Git-Tag: v1.0.0^2~45 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=b9a6b7a6470c4e06794e534a5f4c1325169d6fce;p=WP-Themes%2Fjollylama.git Now will display price if all variations have the same price --- diff --git a/functions.php b/functions.php index f2e4d1e..6a456e2 100644 --- a/functions.php +++ b/functions.php @@ -95,11 +95,6 @@ function glm_get_header() { echo ''; } -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 ''; -// } else { -// echo ''; -// } -// echo '
'; -// echo '
'; -// echo '
'; -// echo '
'; +// 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'] = '' . $variation->get_price_html() . ''; + } + 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 index 17409c2..0000000 --- a/woocommerce/single-product/price.php +++ /dev/null @@ -1,33 +0,0 @@ - -
- - is_type( 'simple' ) ){ ?>

get_price_html(); ?>

- - - - - -