Update weights/dimensions for variations if they differ. Closes #1629.
This commit is contained in:
parent
51bf586fd7
commit
2d0909d28b
|
@ -10,10 +10,18 @@ jQuery(document).ready(function($) {
|
||||||
|
|
||||||
$(this).closest('form.variations_form').find('.variations select').val('').change();
|
$(this).closest('form.variations_form').find('.variations select').val('').change();
|
||||||
|
|
||||||
var $sku = $(this).closest('.product').find('.sku');
|
var $sku = $(this).closest('.product').find('.sku');
|
||||||
|
var $weight = $(this).closest('.product').find('.product_weight');
|
||||||
|
var $dimensions = $(this).closest('.product').find('.product_dimensions');
|
||||||
|
|
||||||
if ( $sku.attr( 'data-o_sku' ) )
|
if ( $sku.attr( 'data-o_sku' ) )
|
||||||
$sku.text( $sku.attr( 'data-o_sku' ) );
|
$sku.text( $sku.attr( 'data-o_sku' ) );
|
||||||
|
|
||||||
|
if ( $weight.attr( 'data-o_weight' ) )
|
||||||
|
$weight.text( $weight.attr( 'data-o_weight' ) );
|
||||||
|
|
||||||
|
if ( $dimensions.attr( 'data-o_dimensions' ) )
|
||||||
|
$dimensions.text( $dimensions.attr( 'data-o_dimensions' ) );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} )
|
} )
|
||||||
|
@ -278,16 +286,36 @@ jQuery(document).ready(function($) {
|
||||||
|
|
||||||
var $single_variation_wrap = $variation_form.find('.single_variation_wrap');
|
var $single_variation_wrap = $variation_form.find('.single_variation_wrap');
|
||||||
|
|
||||||
var $sku = $product.find('.product_meta').find('.sku');
|
var $sku = $product.find('.product_meta').find('.sku');
|
||||||
|
var $weight = $product.find('.product_weight');
|
||||||
|
var $dimensions = $product.find('.product_dimensions');
|
||||||
|
|
||||||
if ( ! $sku.attr( 'data-o_sku' ) )
|
if ( ! $sku.attr( 'data-o_sku' ) )
|
||||||
$sku.attr( 'data-o_sku', $sku.text() );
|
$sku.attr( 'data-o_sku', $sku.text() );
|
||||||
|
|
||||||
|
if ( ! $weight.attr( 'data-o_weight' ) )
|
||||||
|
$weight.attr( 'data-o_weight', $weight.text() );
|
||||||
|
|
||||||
|
if ( ! $dimensions.attr( 'data-o_dimensions' ) )
|
||||||
|
$dimensions.attr( 'data-o_dimensions', $dimensions.text() );
|
||||||
|
|
||||||
if ( variation.sku ) {
|
if ( variation.sku ) {
|
||||||
$sku.text( variation.sku );
|
$sku.text( variation.sku );
|
||||||
} else {
|
} else {
|
||||||
$sku.text( $sku.attr( 'data-o_sku' ) );
|
$sku.text( $sku.attr( 'data-o_sku' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( variation.weight ) {
|
||||||
|
$weight.text( variation.weight );
|
||||||
|
} else {
|
||||||
|
$weight.text( $weight.attr( 'data-o_weight' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( variation.dimensions ) {
|
||||||
|
$dimensions.text( variation.dimensions );
|
||||||
|
} else {
|
||||||
|
$dimensions.text( $dimensions.attr( 'data-o_dimensions' ) );
|
||||||
|
}
|
||||||
|
|
||||||
$single_variation_wrap.find('.quantity').show();
|
$single_variation_wrap.find('.quantity').show();
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1520,6 +1520,8 @@ class WC_Product {
|
||||||
'price_html' => $this->min_variation_price != $this->max_variation_price ? '<span class="price">' . $variation->get_price_html() . '</span>' : '',
|
'price_html' => $this->min_variation_price != $this->max_variation_price ? '<span class="price">' . $variation->get_price_html() . '</span>' : '',
|
||||||
'availability_html' => $availability_html,
|
'availability_html' => $availability_html,
|
||||||
'sku' => $variation->get_sku(),
|
'sku' => $variation->get_sku(),
|
||||||
|
'weight' => $variation->get_weight() . ' ' . esc_attr( get_option('woocommerce_weight_unit' ) ),
|
||||||
|
'dimensions' => $variation->get_dimensions(),
|
||||||
'min_qty' => 1,
|
'min_qty' => 1,
|
||||||
'max_qty' => $this->backorders_allowed() ? '' : $variation->stock,
|
'max_qty' => $this->backorders_allowed() ? '' : $variation->stock,
|
||||||
'backorders_allowed' => $this->backorders_allowed(),
|
'backorders_allowed' => $this->backorders_allowed(),
|
||||||
|
|
|
@ -180,6 +180,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
||||||
* Feature - New shop page/category archive display settings, and the ability to change display per-category.
|
* Feature - New shop page/category archive display settings, and the ability to change display per-category.
|
||||||
* Feature - Allow shipping tax classes to be defined independent of items. https://github.com/woothemes/woocommerce/issues/1625
|
* Feature - Allow shipping tax classes to be defined independent of items. https://github.com/woothemes/woocommerce/issues/1625
|
||||||
* Feature - Redone order item storage making them easier (and faster) to access for reporting, and querying purchases. Huge performance gains for reports. Order items are no longer serialised - they are stored in there own table with meta. Existing data can be be updated on upgrade.
|
* Feature - Redone order item storage making them easier (and faster) to access for reporting, and querying purchases. Huge performance gains for reports. Order items are no longer serialised - they are stored in there own table with meta. Existing data can be be updated on upgrade.
|
||||||
|
* Feature - Update weights/dimensions for variations if they differ.
|
||||||
|
|
||||||
* Templating - Revised pagination, sorting areas (sorting is now above products, numbered pagination below) and added a result count.
|
* Templating - Revised pagination, sorting areas (sorting is now above products, numbered pagination below) and added a result count.
|
||||||
* Templating - email-order-items.php change get_downloadable_file_url() to get_downloadable_file_urls() to support multiple files.
|
* Templating - email-order-items.php change get_downloadable_file_url() to get_downloadable_file_urls() to support multiple files.
|
||||||
|
|
|
@ -26,7 +26,7 @@ if ( empty( $attributes ) && ( ! $product->enable_dimensions_display() || ( ! $p
|
||||||
|
|
||||||
<tr class="<?php if ( $alt == 1 ) echo 'alt'; ?>">
|
<tr class="<?php if ( $alt == 1 ) echo 'alt'; ?>">
|
||||||
<th><?php _e( 'Weight', 'woocommerce' ) ?></th>
|
<th><?php _e( 'Weight', 'woocommerce' ) ?></th>
|
||||||
<td><?php echo $product->get_weight() . ' ' . esc_attr( get_option('woocommerce_weight_unit') ); ?></td>
|
<td class="product_weight"><?php echo $product->get_weight() . ' ' . esc_attr( get_option('woocommerce_weight_unit') ); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -35,7 +35,7 @@ if ( empty( $attributes ) && ( ! $product->enable_dimensions_display() || ( ! $p
|
||||||
|
|
||||||
<tr class="<?php if ( $alt == 1 ) echo 'alt'; ?>">
|
<tr class="<?php if ( $alt == 1 ) echo 'alt'; ?>">
|
||||||
<th><?php _e( 'Dimensions', 'woocommerce' ) ?></th>
|
<th><?php _e( 'Dimensions', 'woocommerce' ) ?></th>
|
||||||
<td><?php echo $product->get_dimensions(); ?></td>
|
<td class="product_dimensions"><?php echo $product->get_dimensions(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
Loading…
Reference in New Issue