No longer autoselect submitted value variation selection:
authorLaury GvR <laury@gaslightmedia.com>
Thu, 21 Apr 2016 20:25:01 +0000 (16:25 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 21 Apr 2016 20:25:01 +0000 (16:25 -0400)
functions.php
woocommerce/single-product/add-to-cart/variable.php

index 429a06d..22f7ebe 100644 (file)
@@ -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 );
 
index 30d3f6e..8d57d1b 100644 (file)
@@ -38,7 +38,8 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
                 foreach ( $attributes as $attribute_name => $options ) : ob_start(); ?>
                     <tr>
                         <td class="value">
-                            <?php $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name ); 
+                            <?php // $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->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', '<a class="reset_variations" href="#">' . __( 'Clear', 'woocommerce' ) . '</a>' ) : '';
                             ?>