Added dimensions to individual variationsAdded dimensions to individual variations. Closes #272.

This commit is contained in:
Mike Jolley 2011-11-28 13:13:49 +00:00
parent 912357cc90
commit 895a24696f
5 changed files with 60 additions and 5 deletions

View File

@ -116,9 +116,16 @@ function variable_product_type_options() {
<td><label><?php _e('SKU:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_sku[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['sku'][0])) echo $variation_data['sku'][0]; ?>" placeholder="<?php if ($sku = get_post_meta($post->ID, 'sku', true)) echo $sku; else echo $post->ID; ?>" /></td>
<td><label><?php _e('Stock Qty:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Enter a quantity to manage stock for this variation, or leave blank to use the variable product stock options.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['stock'][0])) echo $variation_data['stock'][0]; ?>" /></td>
<td><label><?php _e('Weight', 'woothemes').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" tip="<?php _e('Enter a weight for this variation or leave blank to use the parent product weight.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['weight'][0])) echo $variation_data['weight'][0]; ?>" placeholder="<?php if ($value = get_post_meta($post->ID, 'weight', true)) echo $value; else echo '0.00'; ?>" /></td>
<td><label><?php _e('Stock Qty:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Enter a quantity to manage stock for this variation, or leave blank to use the variable product stock options.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['stock'][0])) echo $variation_data['stock'][0]; ?>" /></td>
<td class="dimensions_field">
<label for"product_length"><?php echo __('Dimensions (L&times;W&times;H)', 'woothemes'); ?></label>
<input id="product_length" class="input-text" size="6" type="text" name="variable_length[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['length'][0])) echo $variation_data['length'][0]; ?>" placeholder="<?php if ($value = get_post_meta($post->ID, 'length', true)) echo $value; else echo '0'; ?>" />
<input class="input-text" size="6" type="text" name="variable_width[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['width'][0])) echo $variation_data['width'][0]; ?>" placeholder="<?php if ($value = get_post_meta($post->ID, 'width', true)) echo $value; else echo '0'; ?>" />
<input class="input-text last" size="6" type="text" name="variable_height[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['height'][0])) echo $variation_data['height'][0]; ?>" placeholder="<?php if ($value = get_post_meta($post->ID, 'height', true)) echo $value; else echo '0'; ?>" />
</td>
<td><label><?php _e('Price:', 'woothemes'); ?></label><input type="text" size="5" name="variable_price[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['price'][0])) echo $variation_data['price'][0]; ?>" /></td>
@ -144,6 +151,8 @@ function variable_product_type_options() {
<label><?php _e('Download Limit:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Leave blank for unlimited re-downloads.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_download_limit[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['download_limit'][0])) echo $variation_data['download_limit'][0]; ?>" placeholder="<?php _e('Unlimited', 'woothemes'); ?>" />
</div>
</td>
<td>&nbsp;</td>
</tr>
</tbody>
@ -275,9 +284,16 @@ function variable_product_write_panel_js() {
\
<td><label><?php _e('SKU:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_sku[' + loop + ']" placeholder="<?php if ($sku = get_post_meta($post->ID, 'sku', true)) echo $sku; else echo $post->ID; ?>" /></td>\
\
<td><label><?php _e('Stock Qty:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Enter a quantity to manage stock for this variation, or leave blank to use the variable product stock options.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_stock[' + loop + ']" /></td>\
\
<td><label><?php _e('Weight', 'woothemes').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" tip="<?php _e('Enter a weight for this variation or leave blank to use the parent product weight.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_weight[' + loop + ']" placeholder="<?php if ($value = get_post_meta($post->ID, 'weight', true)) echo $value; else echo '0.00'; ?>" /></td>\
\
<td><label><?php _e('Stock Qty:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Enter a quantity to manage stock for this variation, or leave blank to use the variable product stock options.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_stock[' + loop + ']" /></td>\
<td class="dimensions_field">\
<label for"product_length"><?php echo __('Dimensions (L&times;W&times;H)', 'woothemes'); ?></label>\
<input id="product_length" class="input-text" size="6" type="text" name="variable_length[' + loop + ']" placeholder="0" />\
<input class="input-text" size="6" type="text" name="variable_width[' + loop + ']" placeholder="0" />\
<input class="input-text last" size="6" type="text" name="variable_height[' + loop + ']" placeholder="0" />\
</td>\
\
<td><label><?php _e('Price:', 'woothemes'); ?></label><input type="text" size="5" name="variable_price[' + loop + ']" /></td>\
\
@ -297,6 +313,7 @@ function variable_product_write_panel_js() {
<td>\
<div class="show_if_variation_downloadable" style="display:none;"><label><?php _e('Download Limit:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Leave blank for unlimited re-downloads.', 'woothemes'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_download_limit[' + loop + ']" placeholder="<?php _e('Unlimited', 'woothemes'); ?>" /></div>\
</td>\
<td>&nbsp;</td>\
</tr>\
</tbody>\
</table>\
@ -705,6 +722,9 @@ function process_product_meta_variable( $post_id ) {
$variable_post_id = $_POST['variable_post_id'];
$variable_sku = $_POST['variable_sku'];
$variable_weight = $_POST['variable_weight'];
$variable_length = $_POST['variable_length'];
$variable_width = $_POST['variable_width'];
$variable_height = $_POST['variable_height'];
$variable_stock = $_POST['variable_stock'];
$variable_price = $_POST['variable_price'];
$variable_sale_price= $_POST['variable_sale_price'];
@ -764,6 +784,11 @@ function process_product_meta_variable( $post_id ) {
update_post_meta( $variation_id, 'price', $variable_price[$i] );
update_post_meta( $variation_id, 'sale_price', $variable_sale_price[$i] );
update_post_meta( $variation_id, 'weight', $variable_weight[$i] );
update_post_meta( $variation_id, 'length', $variable_length[$i] );
update_post_meta( $variation_id, 'width', $variable_width[$i] );
update_post_meta( $variation_id, 'height', $variable_height[$i] );
update_post_meta( $variation_id, 'stock', $variable_stock[$i] );
update_post_meta( $variation_id, '_thumbnail_id', $upload_image_id[$i] );

View File

@ -170,8 +170,10 @@ div.multi_select_products_wrapper-alt{float:right;}
#variable_product_options p.bulk_edit a.set,#variable_product_options p.default_variation a.set{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat 7px 5px;}
#variable_product_options p.bulk_edit a.toggle,#variable_product_options p.default_variation a.toggle{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWUlEQVQYGY3QAQrAIAgFUB07mrfWu7kc+2JRsiA0fJnE7k5m5tQsEWFS1WGduh3mahpNLx3hOs4WAr2zfU8mRBGxorAJ4wAU+boS1g41x4UbScQdQJ3/fvgDtStDiI0qoDcAAAAASUVORK5CYII=) no-repeat 7px 5px;}
.woocommerce_variation{background:#ececec;border:1px solid #ececec;margin:0 0 8px !important;}.woocommerce_variation p{margin:0 !important;padding:6px !important;}.woocommerce_variation p button{float:right;}
.woocommerce_variation table td{background:#fff;padding:6px 6px;vertical-align:middle;width:20%;}.woocommerce_variation table td label{color:#999;font-size:10px;text-transform:uppercase;text-align:left;display:block;line-height:16px;}
.woocommerce_variation table td{background:#fff;padding:6px 6px;vertical-align:middle;width:16.66%;}.woocommerce_variation table td label{color:#999;font-size:10px;text-transform:uppercase;text-align:left;display:block;line-height:16px;}
.woocommerce_variation table td input{float:left;width:100%;}
.woocommerce_variation table td.dimensions_field input{width:32%;margin-right:2%;}
.woocommerce_variation table td.dimensions_field .last{margin-right:0;}
.woocommerce_variation table td.upload_image{width:1%;white-space:nowrap;}.woocommerce_variation table td.upload_image img{float:none;margin-right:6px;vertical-align:middle;}
.woocommerce_variation table td.upload_image .button{margin:0;padding:4px 10px;width:auto;float:none;vertical-align:middle;}
.woocommerce_variation table td.upload_image .upload_image_button{display:block;position:relative;}.woocommerce_variation table td.upload_image .upload_image_button .overlay{display:none;width:60px;height:60px;position:absolute;top:0;left:0;margin:0;padding:0;opacity:0.5;background:#eeeeee url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAXklEQVQYGW2OUQrAMAhDFy8+dnKnwiuh2I+aJulDZebDkfSie1b28Q7EXWrfvSm60RQnkQUC8ja7owpmL6d4GdDZ0cNNHyIhZEj4QYCxze6orsluAh8AnR0xKPR07weXJi8JGd3qqwAAAABJRU5ErkJggg==) no-repeat center center;}

View File

@ -991,7 +991,7 @@ div.multi_select_products_wrapper-alt {
background: #fff;
padding: 6px 6px;
vertical-align: middle;
width: 20%;
width: 16.66%;
label {
color: #999;
font-size: 10px;
@ -1004,6 +1004,15 @@ div.multi_select_products_wrapper-alt {
float: left;
width: 100%;
}
&.dimensions_field {
input {
width: 32%;
margin-right: 2%;
}
.last {
margin-right: 0;
}
}
&.upload_image {
width: 1%;
white-space: nowrap;

View File

@ -13,6 +13,9 @@ class woocommerce_product_variation extends woocommerce_product {
var $variation_data;
var $variation_id;
var $variation_has_length;
var $variation_has_width;
var $variation_has_height;
var $variation_has_weight;
var $variation_has_price;
var $variation_has_sale_price;
@ -72,7 +75,7 @@ class woocommerce_product_variation extends woocommerce_product {
$this->product_type = 'variable';
$this->variation_has_sku = $this->variation_has_stock = $this->variation_has_weight = $this->variation_has_price = $this->variation_has_sale_price = false;
$this->variation_has_sku = $this->variation_has_stock = $this->variation_has_weight = $this->variation_has_length = $this->variation_has_width = $this->variation_has_height = $this->variation_has_price = $this->variation_has_sale_price = false;
/* Override parent data with variation */
if (isset($product_custom_fields['sku'][0]) && !empty($product_custom_fields['sku'][0])) :
@ -91,6 +94,21 @@ class woocommerce_product_variation extends woocommerce_product {
$this->weight = $product_custom_fields['weight'][0];
endif;
if (isset($product_custom_fields['length'][0]) && $product_custom_fields['length'][0]!=='') :
$this->variation_has_length = true;
$this->length = $product_custom_fields['length'][0];
endif;
if (isset($product_custom_fields['width'][0]) && $product_custom_fields['width'][0]!=='') :
$this->variation_has_width = true;
$this->width = $product_custom_fields['width'][0];
endif;
if (isset($product_custom_fields['height'][0]) && $product_custom_fields['height'][0]!=='') :
$this->variation_has_height = true;
$this->height = $product_custom_fields['height'][0];
endif;
if (isset($product_custom_fields['price'][0]) && $product_custom_fields['price'][0]!=='') :
$this->variation_has_price = true;
$this->price = $product_custom_fields['price'][0];

View File

@ -109,6 +109,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Continue shopping button when directing user to cart after adding a product to the cart
* Refund/Reverse notification in paypal gateway
* Made stock notifications use email template
* Added dimensions to individual variations
= 1.2.4 - 18/11/2011 =
* More sale price logic fixes for variations. Now correctly compares variation's prices.