Added a selected_attributes variable, which uses the default attributes but also has a filter applied.
This commit is contained in:
parent
33a7444421
commit
e1e2e2b618
|
@ -352,7 +352,8 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
|
||||||
global $post, $_product, $woocommerce;
|
global $post, $_product, $woocommerce;
|
||||||
|
|
||||||
$attributes = $_product->get_available_attribute_variations();
|
$attributes = $_product->get_available_attribute_variations();
|
||||||
$default_attributes = apply_filters( 'woocommerce_product_default_attributes', (array) maybe_unserialize(get_post_meta( $post->ID, '_default_attributes', true )));
|
$default_attributes = (array) maybe_unserialize(get_post_meta( $post->ID, '_default_attributes', true ));
|
||||||
|
$selected_attributes = apply_filters( 'woocommerce_product_default_attributes', $default_attributes );
|
||||||
|
|
||||||
// Put available variations into an array and put in a Javascript variable (JSON encoded)
|
// Put available variations into an array and put in a Javascript variable (JSON encoded)
|
||||||
$available_variations = array();
|
$available_variations = array();
|
||||||
|
@ -406,7 +407,7 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
|
||||||
<option value=""><?php echo __('Choose an option', 'woothemes') ?>…</option>
|
<option value=""><?php echo __('Choose an option', 'woothemes') ?>…</option>
|
||||||
<?php if(is_array($options)) : ?>
|
<?php if(is_array($options)) : ?>
|
||||||
<?php
|
<?php
|
||||||
$selected_value = (isset($default_attributes[sanitize_title($name)])) ? $default_attributes[sanitize_title($name)] : '';
|
$selected_value = (isset($selected_attributes[sanitize_title($name)])) ? $selected_attributes[sanitize_title($name)] : '';
|
||||||
// Get terms if this is a taxonomy - ordered
|
// Get terms if this is a taxonomy - ordered
|
||||||
if (taxonomy_exists(sanitize_title($name))) :
|
if (taxonomy_exists(sanitize_title($name))) :
|
||||||
$args = array('menu_order' => 'ASC');
|
$args = array('menu_order' => 'ASC');
|
||||||
|
|
Loading…
Reference in New Issue