Improved variations panel, bulk edit, and added tax classes for variations. Closes #779.

This commit is contained in:
Mike Jolley 2012-04-11 18:56:54 +01:00
parent 9d42f4f733
commit afd727bb24
6 changed files with 369 additions and 201 deletions

View File

@ -57,7 +57,20 @@ function variable_product_type_options() {
<p class="toolbar"> <p class="toolbar">
<a href="#" class="close_all"><?php _e('Close all', 'woocommerce'); ?></a><a href="#" class="expand_all"><?php _e('Expand all', 'woocommerce'); ?></a> <a href="#" class="close_all"><?php _e('Close all', 'woocommerce'); ?></a><a href="#" class="expand_all"><?php _e('Expand all', 'woocommerce'); ?></a>
<strong><?php _e('Bulk edit:', 'woocommerce'); ?></strong> <a class="button set set_all_prices" href="#"><?php _e('Prices', 'woocommerce'); ?></a> <a class="button set set_all_sale_prices" href="#"><?php _e('Sale prices', 'woocommerce'); ?></a> <a class="button set set_all_stock" href="#"><?php _e('Stock', 'woocommerce'); ?></a> <a class="button toggle toggle_downloadable" href="#"><?php _e('Downloadable', 'woocommerce'); ?></a> <a class="button toggle toggle_virtual" href="#"><?php _e('Virtual', 'woocommerce'); ?></a> <a class="button toggle toggle_enabled" href="#"><?php _e('Enabled', 'woocommerce'); ?></a> <a class="button set set_all_paths" href="#"><?php _e('File paths', 'woocommerce'); ?></a> <a class="button set set_all_limits" href="#"><?php _e('Download limits', 'woocommerce'); ?></a> <a href="#" class="button delete_variations"><?php _e('Delete all', 'woocommerce'); ?></a> <strong><?php _e('Bulk edit:', 'woocommerce'); ?></strong>
<select id="field_to_edit">
<option value="variable_price"><?php _e('Prices', 'woocommerce'); ?></option>
<option value="variable_sale_price"><?php _e('Sale prices', 'woocommerce'); ?></option>
<option value="variable_stock"><?php _e('Stock', 'woocommerce'); ?></option>
<option value="variable_weight"><?php _e('Weight', 'woocommerce'); ?></option>
<option value="variable_length"><?php _e('Length', 'woocommerce'); ?></option>
<option value="variable_width"><?php _e('Width', 'woocommerce'); ?></option>
<option value="variable_height"><?php _e('Height', 'woocommerce'); ?></option>
<option value="variable_file_path"><?php _e('File Path', 'woocommerce'); ?></option>
<option value="variable_download_limit"><?php _e('Download limit', 'woocommerce'); ?></option>
</select>
<a class="button bulk_edit plus"><?php _e('Edit', 'woocommerce'); ?></a>
<a class="button toggle toggle_downloadable" href="#"><?php _e('Downloadable', 'woocommerce'); ?></a> <a class="button toggle toggle_virtual" href="#"><?php _e('Virtual', 'woocommerce'); ?></a> <a class="button toggle toggle_enabled" href="#"><?php _e('Enabled', 'woocommerce'); ?></a> <a href="#" class="button delete_variations"><?php _e('Delete all', 'woocommerce'); ?></a>
</p> </p>
<div class="woocommerce_variations wc-metaboxes"> <div class="woocommerce_variations wc-metaboxes">
@ -86,7 +99,15 @@ function variable_product_type_options() {
if (!$image) $image = woocommerce_placeholder_img_src(); if (!$image) $image = woocommerce_placeholder_img_src();
$classes = get_the_terms( $variation->ID, 'product_shipping_class' ); $classes = get_the_terms( $variation->ID, 'product_shipping_class' );
if ($classes && !is_wp_error($classes)) $current_shipping_class = current($classes)->term_id; else $current_shipping_class = ''; if ( $classes && ! is_wp_error( $classes ) ) $current_shipping_class = current($classes)->term_id; else $current_shipping_class = '';
$tax_classes = array_filter(array_map('trim', explode("\n", get_option('woocommerce_tax_classes'))));
$tax_class_options = array();
$parent_tax_class = get_post_meta( $post->ID, '_tax_class', true );
$tax_class_options['parent'] =__('Same as parent', 'woocommerce');
$tax_class_options[''] = __('Standard', 'woocommerce');
if ($tax_classes) foreach ( $tax_classes as $class )
$tax_class_options[sanitize_title($class)] = $class;
?> ?>
<div class="woocommerce_variation wc-metabox closed"> <div class="woocommerce_variation wc-metabox closed">
<h3> <h3>
@ -128,28 +149,47 @@ function variable_product_type_options() {
<table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content"> <table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content">
<tbody> <tbody>
<tr> <tr>
<td class="upload_image" rowspan="2"><a href="#" class="upload_image_button <?php if ($image_id>0) echo 'remove'; ?>" rel="<?php echo $variation->ID; ?>"><img src="<?php echo $image ?>" width="60px" height="60px" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo $image_id; ?>" /><span class="overlay"></span></a></td> <td class="sku" colspan="2">
<?php if( get_option('woocommerce_enable_sku', true) !== 'no' ) : ?>
<td><label><?php _e('SKU:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woocommerce'); ?>" 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; ?>" /></td> <label><?php _e('SKU', 'woocommerce'); ?>: <a class="tips" data-tip="<?php _e('Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woocommerce'); ?>" 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; ?>" />
<?php else : ?>
<input type="hidden" name="variable_sku[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['_sku'][0])) echo $variation_data['_sku'][0]; ?>" />
<?php endif; ?>
</td>
<td class="data" rowspan="2">
<table cellspacing="0" cellpadding="0">
<tr>
<td><label><?php _e('Stock Qty:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a quantity to enable stock management for this variation, or leave blank to use the variable product stock options.', 'woocommerce'); ?>" 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('Stock Qty:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a quantity to enable stock management for this variation, or leave blank to use the variable product stock options.', 'woocommerce'); ?>" 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>&nbsp;</td>
</tr>
<tr>
<td><label><?php _e('Price:', 'woocommerce'); ?></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>
<td><label><?php _e('Weight', 'woocommerce').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" data-tip="<?php _e('Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce'); ?>" 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('Sale Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['_sale_price'][0])) echo $variation_data['_sale_price'][0]; ?>" /></td>
</tr>
<td class="dimensions_field"> <?php if( get_option('woocommerce_enable_weight', true) !== 'no' || get_option('woocommerce_enable_dimensions', true) !== 'no' ) : ?>
<tr>
<?php if( get_option('woocommerce_enable_weight', true) !== 'no' ) : ?>
<td class="hide_if_variation_virtual"><label><?php _e('Weight', 'woocommerce').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" data-tip="<?php _e('Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce'); ?>" 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>
<?php else : ?>
<td>&nbsp;</td>
<?php endif; ?>
<?php if( get_option('woocommerce_enable_dimensions', true) !== 'no' ) : ?>
<td class="dimensions_field hide_if_variation_virtual">
<label for"product_length"><?php echo __('Dimensions (L&times;W&times;H)', 'woocommerce'); ?></label> <label for"product_length"><?php echo __('Dimensions (L&times;W&times;H)', 'woocommerce'); ?></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 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" 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'; ?>" /> <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>
<?php else : ?>
<td><label><?php _e('Price:', 'woocommerce'); ?></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> <td>&nbsp;</td>
<?php endif; ?>
<td><label><?php _e('Sale Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['_sale_price'][0])) echo $variation_data['_sale_price'][0]; ?>" /></td>
</tr> </tr>
<tr> <?php endif; ?>
<tr>
<td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php <td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php
$args = array( $args = array(
'taxonomy' => 'product_shipping_class', 'taxonomy' => 'product_shipping_class',
@ -161,19 +201,20 @@ function variable_product_type_options() {
); );
wp_dropdown_categories( $args ); wp_dropdown_categories( $args );
?></td> ?></td>
<td><label><?php _e('Tax class:', 'woocommerce'); ?></label> <select name="variable_tax_class[<?php echo $loop; ?>]"><?php
<td><label><?php _e('Downloadable', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if access is given to a downloadable file upon purchase of a product.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[<?php echo $loop; ?>]" <?php if (isset($variation_data['_downloadable'][0])) checked($variation_data['_downloadable'][0], 'yes'); ?> /></td> foreach ( $tax_class_options as $key => $tax_class ) {
echo '<option value="' . $key . '" ';
<td><label><?php _e('Virtual', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if a product is not shipped or there is no shipping cost.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="checkbox" class="checkbox" name="variable_is_virtual[<?php echo $loop; ?>]" <?php if (isset($variation_data['_virtual'][0])) checked($variation_data['_virtual'][0], 'yes'); ?> /></td> if ( isset( $variation_data['_tax_class'][0] ) ) selected($key, $variation_data['_tax_class'][0]);
echo '>' . $tax_class . '</option>';
<td><label><?php _e('Enabled', 'woocommerce'); ?></label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked($variation->post_status, 'publish'); ?> /></td> }
?></select></td>
</tr>
<tr>
<td> <td>
<div class="show_if_variation_downloadable file_path_field"> <div class="show_if_variation_downloadable file_path_field">
<label><?php _e('File path:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a File Path to make this variation a downloadable product, or leave blank.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" class="file_path" name="variable_file_path[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['_file_path'][0])) echo $variation_data['_file_path'][0]; ?>" placeholder="<?php _e('File path/URL', 'woocommerce'); ?>" /> <input type="button" class="upload_file_button button" value="<?php _e('&uarr;', 'woocommerce'); ?>" title="<?php _e('Upload', 'woocommerce'); ?>" /> <label><?php _e('File path:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a File Path to make this variation a downloadable product, or leave blank.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" class="file_path" name="variable_file_path[<?php echo $loop; ?>]" value="<?php if (isset($variation_data['_file_path'][0])) echo $variation_data['_file_path'][0]; ?>" placeholder="<?php _e('File path/URL', 'woocommerce'); ?>" /> <input type="button" class="upload_file_button button" value="<?php _e('&uarr;', 'woocommerce'); ?>" title="<?php _e('Upload', 'woocommerce'); ?>" />
</div> </div>
</td> </td>
<td> <td>
<div class="show_if_variation_downloadable"> <div class="show_if_variation_downloadable">
<label><?php _e('Download Limit:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Leave blank for unlimited re-downloads.', 'woocommerce'); ?>" 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', 'woocommerce'); ?>" /> <label><?php _e('Download Limit:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Leave blank for unlimited re-downloads.', 'woocommerce'); ?>" 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', 'woocommerce'); ?>" />
@ -181,6 +222,25 @@ function variable_product_type_options() {
</td> </td>
</tr> </tr>
<?php do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data ); ?> <?php do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data ); ?>
</table>
</td>
</tr>
<tr>
<td class="upload_image">
<a href="#" class="upload_image_button <?php if ($image_id>0) echo 'remove'; ?>" rel="<?php echo $variation->ID; ?>"><img src="<?php echo $image ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo $image_id; ?>" /><span class="overlay"></span></a>
</td>
<td class="options">
<label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked($variation->post_status, 'publish'); ?> /> <?php _e('Enabled', 'woocommerce'); ?></label>
<label><input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[<?php echo $loop; ?>]" <?php if (isset($variation_data['_downloadable'][0])) checked($variation_data['_downloadable'][0], 'yes'); ?> /> <?php _e('Downloadable', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if access is given to a downloadable file upon purchase of a product.', 'woocommerce'); ?>" href="#">[?]</a></label>
<label><input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[<?php echo $loop; ?>]" <?php if (isset($variation_data['_virtual'][0])) checked($variation_data['_virtual'][0], 'yes'); ?> /> <?php _e('Virtual', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if a product is not shipped or there is no shipping cost.', 'woocommerce'); ?>" href="#">[?]</a></label>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -297,54 +357,89 @@ function variable_product_type_options() {
endforeach; endforeach;
?><input type="hidden" name="variable_post_id[' + loop + ']" value="' + variation_id + '" /><input type="hidden" class="variation_menu_order" name="variation_menu_order[' + loop + ']" value="' + loop + '" /></h3>\ ?><input type="hidden" name="variable_post_id[' + loop + ']" value="' + variation_id + '" /><input type="hidden" class="variation_menu_order" name="variation_menu_order[' + loop + ']" value="' + loop + '" /></h3>\
<table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content">\ <table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content">\
<tbody>\ <tbody> \
<tr>\ <tr>\
<td class="upload_image" rowspan="2"><a href="#" class="upload_image_button" rel="' + variation_id + '"><img src="<?php echo woocommerce_placeholder_img_src(); ?>" width="60px" height="60px" /><input type="hidden" name="upload_image_id[' + loop + ']" class="upload_image_id" /><span class="overlay"></span></a></td>\ <td class="sku" colspan="2">\
\ <?php if( get_option('woocommerce_enable_sku', true) !== 'no' ) : ?>\
<td><label><?php _e('SKU:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woocommerce'); ?>" 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; ?>" /></td>\ <label><?php _e('SKU', 'woocommerce'); ?>: <a class="tips" data-tip="<?php _e('Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woocommerce'); ?>" 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; ?>" />\
<td><label><?php _e('Stock Qty:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a quantity to enable stock management for this variation, or leave blank to use the variable product stock options.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_stock[' + loop + ']" /></td>\ <?php else : ?>\
\ <input type="hidden" name="variable_sku[' + loop + ']" />\
<td><label><?php _e('Weight', 'woocommerce').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" data-tip="<?php _e('Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce'); ?>" 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>\ <?php endif; ?>\
\
<td class="dimensions_field">\
<label for"product_length"><?php echo __('Dimensions (L&times;W&times;H)', 'woocommerce'); ?></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>\
\ <td class="data" rowspan="2">\
<table cellspacing="0">\
<tr>\
<td><label><?php _e('Stock Qty:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a quantity to enable stock management for this variation, or leave blank to use the variable product stock options.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_stock[' + loop + ']" /></td>\
<td>&nbsp;</td>\
</tr>\
<tr>\
<td><label><?php _e('Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_price[' + loop + ']" /></td>\ <td><label><?php _e('Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_price[' + loop + ']" /></td>\
\
<td><label><?php _e('Sale Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_sale_price[' + loop + ']" /></td>\ <td><label><?php _e('Sale Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_sale_price[' + loop + ']" /></td>\
</tr>\ </tr>\
<?php if( get_option('woocommerce_enable_weight', true) !== 'no' || get_option('woocommerce_enable_dimensions', true) !== 'no' ) : ?>\
<tr>\
<?php if( get_option('woocommerce_enable_weight', true) !== 'no' ) : ?>\
<td class="hide_if_variation_virtual"><label><?php _e('Weight', 'woocommerce').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" data-tip="<?php _e('Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce'); ?>" 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>\
<?php else : ?>\
<td>&nbsp;</td>\
<?php endif; ?>\
<?php if( get_option('woocommerce_enable_dimensions', true) !== 'no' ) : ?>\
<td class="dimensions_field hide_if_variation_virtual">\
<label for"product_length"><?php echo __('Dimensions (L&times;W&times;H)', 'woocommerce'); ?></label>\
<input id="product_length" class="input-text" size="6" type="text" name="variable_length[' + loop + ']" 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[' + loop + ']" 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[' + loop + ']" placeholder="<?php if ($value = get_post_meta($post->ID, '_height', true)) echo $value; else echo '0'; ?>" />\
</td>\
<?php else : ?>\
<td>&nbsp;</td>\
<?php endif; ?>\
</tr>\
<?php endif; ?>\
<tr>\ <tr>\
<td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php <td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php
$args = array( $args = array(
'taxonomy' => 'product_shipping_class', 'taxonomy' => 'product_shipping_class',
'hide_empty' => 0, 'hide_empty' => 0,
'show_option_all' => __('Same as parent', 'woocommerce'), 'show_option_all' => __('Same as parent', 'woocommerce'),
'name' => "variable_shipping_class[]", 'name' => 'variable_shipping_class[]',
'id' => '', 'id' => '',
'echo' => 0 'echo' => 0
); );
echo addslashes(str_replace('[]', "[' + loop + ']", str_replace("\n", '', wp_dropdown_categories( $args )))); echo addslashes(str_replace('[]', "[' + loop + ']", str_replace("\n", '', wp_dropdown_categories( $args ))));
?></td>\ ?></td>\
<td><label><?php _e('Downloadable', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if access is given to a downloadable file upon purchase of a product.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[' + loop + ']" /></td>\ <td><label><?php _e('Tax class:', 'woocommerce'); ?></label> <select name="variable_tax_class[' + loop + ']"><?php
\ foreach ( $tax_class_options as $key => $tax_class ) {
<td><label><?php _e('Virtual', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if a product is not shipped or there is no shipping cost.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="checkbox" class="checkbox" name="variable_is_virtual[' + loop + ']" /></td>\ echo '<option value="' . $key . '" ';
\ if ( isset( $variation_data['_tax_class'][0] ) ) echo addslashes(selected($key, $variation_data['_tax_class'][0], false));
<td><label><?php _e('Enabled', 'woocommerce'); ?></label><input type="checkbox" class="checkbox" checked="checked" name="variable_enabled[' + loop + ']" /></td>\ echo '>' . $tax_class . '</option>';
\ }
?></select></td>\
</tr>\
<tr>\
<td>\ <td>\
<div class="show_if_variation_downloadable file_path_field" style="display:none;"><label><?php _e('File path:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a File Path to make this variation a downloadable product, or leave blank.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" class="file_path" name="variable_file_path[' + loop + ']" placeholder="<?php _e('File path/URL', 'woocommerce'); ?>" /> <input type="button" class="upload_file_button button" value="<?php _e('&uarr;', 'woocommerce'); ?>" title="<?php _e('Upload', 'woocommerce'); ?>" /></div>\ <div class="show_if_variation_downloadable file_path_field"><label><?php _e('File path:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enter a File Path to make this variation a downloadable product, or leave blank.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" class="file_path" name="variable_file_path[' + loop + ']" placeholder="<?php _e('File path/URL', 'woocommerce'); ?>" /> <input type="button" class="upload_file_button button" value="<?php _e('&uarr;', 'woocommerce'); ?>" title="<?php _e('Upload', 'woocommerce'); ?>" /></div>\
</td>\ </td>\
\
<td>\ <td>\
<div class="show_if_variation_downloadable" style="display:none;"><label><?php _e('Download Limit:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Leave blank for unlimited re-downloads.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_download_limit[' + loop + ']" placeholder="<?php _e('Unlimited', 'woocommerce'); ?>" /></div>\ <div class="show_if_variation_downloadable"><label><?php _e('Download Limit:', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Leave blank for unlimited re-downloads.', 'woocommerce'); ?>" href="#">[?]</a></label><input type="text" size="5" name="variable_download_limit[' + loop + ']" placeholder="<?php _e('Unlimited', 'woocommerce'); ?>" /></div>\
</td>\
</tr>\
<?php do_action( 'woocommerce_product_after_variable_attributes_js' ); ?>\
</table>\
</td>\
</tr>\
<tr>\
<td class="upload_image"><a href="#" class="upload_image_button" rel="' + variation_id + '"><img src="<?php echo $image ?>" /><input type="hidden" name="upload_image_id[' + loop + ']" class="upload_image_id" /><span class="overlay"></span></a></td>\
<td class="options">\
\
<label><input type="checkbox" class="checkbox" name="variable_enabled[' + loop + ']" checked="checked" /> <?php _e('Enabled', 'woocommerce'); ?></label>\
\
<label><input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[' + loop + ']" /> <?php _e('Downloadable', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if access is given to a downloadable file upon purchase of a product.', 'woocommerce'); ?>" href="#">[?]</a></label>\
\
<label><input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[' + loop + ']" /> <?php _e('Virtual', 'woocommerce'); ?> <a class="tips" data-tip="<?php _e('Enable this option if a product is not shipped or there is no shipping cost.', 'woocommerce'); ?>" href="#">[?]</a></label>\
\
</td>\ </td>\
</tr>\ </tr>\
<?php do_action( 'woocommerce_product_after_variable_attributes_js' ); ?> \
</tbody>\ </tbody>\
</table>\ </table>\
</div>'); </div>');
@ -354,6 +449,9 @@ function variable_product_type_options() {
'fadeIn' : 50, 'fadeIn' : 50,
'fadeOut' : 50 'fadeOut' : 50
}); });
jQuery('input.variable_is_downloadable, input.variable_is_virtual').change();
jQuery('.woocommerce_variations').unblock(); jQuery('.woocommerce_variations').unblock();
}); });
@ -473,27 +571,17 @@ function variable_product_type_options() {
return false; return false;
}); });
jQuery('a.set_all_prices').click(function(){ jQuery('a.bulk_edit').click(function() {
var value = prompt("<?php _e('Enter a price', 'woocommerce'); ?>"); var field_to_edit = jQuery('select#field_to_edit').val();
jQuery('input[name^="variable_price"]').val( value ); var value = prompt("<?php _e('Enter a value', 'woocommerce'); ?>");
return false; jQuery('input[name^="' + field_to_edit + '"]').val( value );
});
jQuery('a.set_all_sale_prices').click(function(){
var value = prompt("<?php _e('Enter a price', 'woocommerce'); ?>");
jQuery('input[name^="variable_sale_price"]').val( value );
return false;
});
jQuery('a.set_all_stock').click(function(){
var value = prompt("<?php _e('Enter stock quantity', 'woocommerce'); ?>");
jQuery('input[name^="variable_stock"]').val( value );
return false; return false;
}); });
jQuery('a.toggle_virtual').click(function(){ jQuery('a.toggle_virtual').click(function(){
var checkbox = jQuery('input[name^="variable_is_virtual"]'); var checkbox = jQuery('input[name^="variable_is_virtual"]');
checkbox.attr('checked', !checkbox.attr('checked')); checkbox.attr('checked', !checkbox.attr('checked'));
jQuery('input.variable_is_virtual').change();
return false; return false;
}); });
@ -510,29 +598,27 @@ function variable_product_type_options() {
return false; return false;
}); });
jQuery('a.set_all_paths').click(function(){
var value = prompt("<?php _e('Enter a file path/URL', 'woocommerce'); ?>");
jQuery('input[name^="variable_file_path"]').val( value );
return false;
});
jQuery('a.set_all_limits').click(function(){
var value = prompt("<?php _e('Enter a download limit', 'woocommerce'); ?>");
jQuery('input[name^="variable_download_limit"]').val( value );
return false;
});
jQuery('#variable_product_options').on('change', 'input.variable_is_downloadable', function(){ jQuery('#variable_product_options').on('change', 'input.variable_is_downloadable', function(){
jQuery(this).parent().parent().find('.show_if_variation_downloadable').hide(); jQuery(this).closest('.woocommerce_variation').find('.show_if_variation_downloadable').hide();
if (jQuery(this).is(':checked')) { if (jQuery(this).is(':checked')) {
jQuery(this).parent().parent().find('.show_if_variation_downloadable').show(); jQuery(this).closest('.woocommerce_variation').find('.show_if_variation_downloadable').show();
} }
}); });
jQuery('input.variable_is_downloadable').change(); jQuery('#variable_product_options').on('change', 'input.variable_is_virtual', function(){
jQuery(this).closest('.woocommerce_variation').find('.hide_if_variation_virtual').show();
if (jQuery(this).is(':checked')) {
jQuery(this).closest('.woocommerce_variation').find('.hide_if_variation_virtual').hide();
}
});
jQuery('input.variable_is_downloadable, input.variable_is_virtual').change();
// Ordering // Ordering
$('.woocommerce_variations').sortable({ $('.woocommerce_variations').sortable({
@ -646,16 +732,23 @@ function process_product_meta_variable( $post_id ) {
$variable_height = $_POST['variable_height']; $variable_height = $_POST['variable_height'];
$variable_stock = $_POST['variable_stock']; $variable_stock = $_POST['variable_stock'];
$variable_price = $_POST['variable_price']; $variable_price = $_POST['variable_price'];
$variable_sale_price= $_POST['variable_sale_price']; $variable_sale_price = $_POST['variable_sale_price'];
$upload_image_id = $_POST['upload_image_id']; $upload_image_id = $_POST['upload_image_id'];
if (isset($_POST['variable_enabled'])) $variable_enabled = $_POST['variable_enabled'];
if (isset($_POST['variable_is_virtual'])) $variable_is_virtual = $_POST['variable_is_virtual'];
if (isset($_POST['variable_is_downloadable'])) $variable_is_downloadable = $_POST['variable_is_downloadable'];
$variable_file_path = $_POST['variable_file_path']; $variable_file_path = $_POST['variable_file_path'];
$variable_download_limit = $_POST['variable_download_limit']; $variable_download_limit = $_POST['variable_download_limit'];
$variable_shipping_class = $_POST['variable_shipping_class']; $variable_shipping_class = $_POST['variable_shipping_class'];
$variable_tax_class = $_POST['variable_tax_class'];
$variable_menu_order = $_POST['variation_menu_order']; $variable_menu_order = $_POST['variation_menu_order'];
if (isset($_POST['variable_enabled']))
$variable_enabled = $_POST['variable_enabled'];
if (isset($_POST['variable_is_virtual']))
$variable_is_virtual = $_POST['variable_is_virtual'];
if (isset($_POST['variable_is_downloadable']))
$variable_is_downloadable = $_POST['variable_is_downloadable'];
$attributes = (array) maybe_unserialize( get_post_meta($post_id, '_product_attributes', true) ); $attributes = (array) maybe_unserialize( get_post_meta($post_id, '_product_attributes', true) );
for ( $i=0; $i <= max( array_keys( $_POST['variable_post_id'] ) ); $i++ ) : for ( $i=0; $i <= max( array_keys( $_POST['variable_post_id'] ) ); $i++ ) :
@ -713,6 +806,11 @@ function process_product_meta_variable( $post_id ) {
update_post_meta( $variation_id, '_virtual', $is_virtual ); update_post_meta( $variation_id, '_virtual', $is_virtual );
update_post_meta( $variation_id, '_downloadable', $is_downloadable ); update_post_meta( $variation_id, '_downloadable', $is_downloadable );
if ( $variable_tax_class[$i] !== 'parent' )
update_post_meta( $variation_id, '_tax_class', $variable_tax_class[$i] );
else
delete_post_meta( $variation_id, '_tax_class' );
if ($is_downloadable=='yes') : if ($is_downloadable=='yes') :
update_post_meta( $variation_id, '_download_limit', $variable_download_limit[$i] ); update_post_meta( $variation_id, '_download_limit', $variable_download_limit[$i] );
update_post_meta( $variation_id, '_file_path', $variable_file_path[$i] ); update_post_meta( $variation_id, '_file_path', $variable_file_path[$i] );

File diff suppressed because one or more lines are too long

View File

@ -1519,6 +1519,17 @@ img.help_tip {
background: #ececec; background: #ececec;
border: 1px solid #ececec; border: 1px solid #ececec;
margin: 9px 0 !important; margin: 9px 0 !important;
-moz-border-radius-topleft: 3px;
-moz-border-radius-topright: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
&.closed {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
h3 { h3 {
margin: 0 !important; margin: 0 !important;
padding: 6px !important; padding: 6px !important;
@ -1575,8 +1586,8 @@ img.help_tip {
padding: 4px; padding: 4px;
color: #555; color: #555;
} }
select { select, .chzn-container {
width: 100%; width: 100% !important;
} }
input.short { input.short {
width: 200px; width: 200px;
@ -1643,8 +1654,10 @@ img.help_tip {
} }
} }
.woocommerce_variation { .woocommerce_variation {
table td { table {
width: 16.66%; background: #f5f5f5;
padding: 6px;
td {
input { input {
min-width: inherit !important; min-width: inherit !important;
} }
@ -1657,13 +1670,61 @@ img.help_tip {
margin-right: 0; margin-right: 0;
} }
} }
&.options {
width: 150px;
label {
margin-bottom: 6px;
}
}
&.data {
padding: 0 0 0 12px;
table {
width: 100%;
padding: 0 12px 0 12px;
background: #fff;
border: 1px solid #dfdfdf;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
border-radius: 3px;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
td {
width: 50%;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
}
table:before {
content: "";
display: block;
position: absolute;
top: 33px;
left: 0;
margin: 0 0 0 -1px;
border: 7px solid #dfdfdf;
border-color: transparent transparent transparent #dfdfdf;
}
table:after {
content: "";
display: block;
position: absolute;
top: 34px;
left: 0;
margin: 0 0 0 -1px;
border: 6px solid #f5f5f5;
border-color: transparent transparent transparent #f5f5f5;
}
}
&.upload_image { &.upload_image {
width: 1%;
white-space: nowrap; white-space: nowrap;
width: 75px;
img { img {
float: none; float: none;
margin-right: 6px; width: 73px;
vertical-align: middle; border: 1px solid #dfdfdf;
} }
.button { .button {
margin: 0; margin: 0;
@ -1677,8 +1738,8 @@ img.help_tip {
position: relative; position: relative;
.overlay { .overlay {
display: none; display: none;
width: 60px; width: 75px;
height: 60px; height: 75px;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
@ -1711,6 +1772,7 @@ img.help_tip {
} }
} }
} }
}
} }
/* Tooltips */ /* Tooltips */

View File

@ -22,6 +22,7 @@ class WC_Product_Variation extends WC_Product {
var $variation_has_stock; var $variation_has_stock;
var $variation_has_sku; var $variation_has_sku;
var $variation_shipping_class; var $variation_shipping_class;
var $variation_has_tax_class;
/** /**
* Loads all product data from custom fields * Loads all product data from custom fields
@ -136,6 +137,11 @@ class WC_Product_Variation extends WC_Product {
$this->virtual = 'no'; $this->virtual = 'no';
} }
if ( isset( $product_custom_fields['_tax_class'][0] ) ) {
$this->variation_has_tax_class = true;
$this->tax_class = $product_custom_fields['_tax_class'][0];
}
$this->total_stock = $this->stock; $this->total_stock = $this->stock;
} }

View File

@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, affiliate
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
Requires at least: 3.3 Requires at least: 3.3
Tested up to: 3.3 Tested up to: 3.3
Stable tag: 1.5.3 Stable tag: 1.5.4
WooCommerce is a powerful, extendable eCommerce plugin that helps you sell anything. Beautifully. WooCommerce is a powerful, extendable eCommerce plugin that helps you sell anything. Beautifully.
@ -143,12 +143,14 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog == == Changelog ==
= 1.5.4 = = 1.5.4 - 12/04/2012 =
* Feature - Allow attributes to be added from the edit product page * Feature - Allow attributes to be added from the edit product page
* Feature - Allow external products to be a part of a grouped product. Button titles will be respected when displayed. * Feature - Allow external products to be a part of a grouped product. Button titles will be respected when displayed.
* Feature - Added woocommerce_get_dimension/woocommerce_get_weight helpers for normalisation. Thanks Andy Zhang * Feature - Added woocommerce_get_dimension/woocommerce_get_weight helpers for normalisation. Thanks Andy Zhang
* Feature - Pass page_style to paypal standard if defined * Feature - Pass page_style to paypal standard if defined
* Feature - Option to hide shipping costs until an address is entered on the cart/checkout * Feature - Option to hide shipping costs until an address is entered on the cart/checkout
* Feature - Tax class selection for variations
* Tweak - Redesigned variation panels and variation bulk edit to make them easier to use and expand.
* Tweak - Show multiple success messages/error messages if added, rather than one or the other * Tweak - Show multiple success messages/error messages if added, rather than one or the other
* Tweak - Adding an item to an order now uses the ajax style product finder * Tweak - Adding an item to an order now uses the ajax style product finder
* Tweak - Updated chosen to latest release * Tweak - Updated chosen to latest release

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce * Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/ * Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully. * Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 1.5.3 * Version: 1.5.4
* Author: WooThemes * Author: WooThemes
* Author URI: http://woothemes.com * Author URI: http://woothemes.com
* Requires at least: 3.3 * Requires at least: 3.3
@ -32,7 +32,7 @@ class Woocommerce {
/** Version ***************************************************************/ /** Version ***************************************************************/
var $version = '1.5.3'; var $version = '1.5.4';
/** URLS ******************************************************************/ /** URLS ******************************************************************/