Update weights/dimensions for variations if they differ. Closes #1629.

This commit is contained in:
Mike Jolley 2012-11-16 13:50:15 +00:00
parent 51bf586fd7
commit 2d0909d28b
5 changed files with 36 additions and 5 deletions

View File

@ -10,10 +10,18 @@ jQuery(document).ready(function($) {
$(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' ) )
$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;
} )
@ -278,16 +286,36 @@ jQuery(document).ready(function($) {
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' ) )
$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 ) {
$sku.text( variation.sku );
} else {
$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();

File diff suppressed because one or more lines are too long

View File

@ -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>' : '',
'availability_html' => $availability_html,
'sku' => $variation->get_sku(),
'weight' => $variation->get_weight() . ' ' . esc_attr( get_option('woocommerce_weight_unit' ) ),
'dimensions' => $variation->get_dimensions(),
'min_qty' => 1,
'max_qty' => $this->backorders_allowed() ? '' : $variation->stock,
'backorders_allowed' => $this->backorders_allowed(),

View File

@ -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 - 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 - 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 - email-order-items.php change get_downloadable_file_url() to get_downloadable_file_urls() to support multiple files.

View File

@ -26,7 +26,7 @@ if ( empty( $attributes ) && ( ! $product->enable_dimensions_display() || ( ! $p
<tr class="<?php if ( $alt == 1 ) echo 'alt'; ?>">
<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>
<?php endif; ?>
@ -35,7 +35,7 @@ if ( empty( $attributes ) && ( ! $product->enable_dimensions_display() || ( ! $p
<tr class="<?php if ( $alt == 1 ) echo 'alt'; ?>">
<th><?php _e( 'Dimensions', 'woocommerce' ) ?></th>
<td><?php echo $product->get_dimensions(); ?></td>
<td class="product_dimensions"><?php echo $product->get_dimensions(); ?></td>
</tr>
<?php endif; ?>