From f7766f3136b1996e5f1cf6db8559019e927e5aa2 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Thu, 21 Apr 2016 16:25:01 -0400 Subject: [PATCH] No longer autoselect submitted value variation selection: --- functions.php | 9 ++++++++- woocommerce/single-product/add-to-cart/variable.php | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 429a06d..22f7ebe 100644 --- a/functions.php +++ b/functions.php @@ -167,7 +167,14 @@ remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_single_ remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_single_price', 40 ); add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_single_price', 10 ); - +//addfilter('woocommercevariationpricehtml', 'myfunction', $product, 2); +// +//function myfunction($price, $product) { +// +//$price = getpostmeta( $product->variationid, 'regular_price'); +//// perform calculation on $price. +//return $price; +//} //remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); //add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 ); diff --git a/woocommerce/single-product/add-to-cart/variable.php b/woocommerce/single-product/add-to-cart/variable.php index 30d3f6e..8d57d1b 100644 --- a/woocommerce/single-product/add-to-cart/variable.php +++ b/woocommerce/single-product/add-to-cart/variable.php @@ -38,7 +38,8 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?> foreach ( $attributes as $attribute_name => $options ) : ob_start(); ?> - get_variation_default_attribute( $attribute_name ); + get_variation_default_attribute( $attribute_name ); + $selected = $product->get_variation_default_attribute( $attribute_name ); wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) ); echo end( $attribute_keys ) === $attribute_name ? apply_filters( 'woocommerce_reset_variations_link', '' . __( 'Clear', 'woocommerce' ) . '' ) : ''; ?> -- 2.17.1