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">
<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>
<div class="woocommerce_variations wc-metaboxes">
@ -86,7 +99,15 @@ function variable_product_type_options() {
if (!$image) $image = woocommerce_placeholder_img_src();
$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">
<h3>
@ -128,59 +149,98 @@ function variable_product_type_options() {
<table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content">
<tbody>
<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><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>
<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('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 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[<?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 class="sku" colspan="2">
<?php if( get_option('woocommerce_enable_sku', true) !== 'no' ) : ?>
<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><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('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>
<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>&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('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>
<?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>
<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>
<?php else : ?>
<td>&nbsp;</td>
<?php endif; ?>
</tr>
<?php endif; ?>
<tr>
<td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php
$args = array(
'taxonomy' => 'product_shipping_class',
'hide_empty' => 0,
'show_option_all' => __('Same as parent', 'woocommerce'),
'name' => 'variable_shipping_class['.$loop.']',
'id' => '',
'selected' => $current_shipping_class
);
wp_dropdown_categories( $args );
?></td>
<td><label><?php _e('Tax class:', 'woocommerce'); ?></label> <select name="variable_tax_class[<?php echo $loop; ?>]"><?php
foreach ( $tax_class_options as $key => $tax_class ) {
echo '<option value="' . $key . '" ';
if ( isset( $variation_data['_tax_class'][0] ) ) selected($key, $variation_data['_tax_class'][0]);
echo '>' . $tax_class . '</option>';
}
?></select></td>
</tr>
<tr>
<td>
<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'); ?>" />
</div>
</td>
<td>
<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'); ?>" />
</div>
</td>
</tr>
<?php do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data ); ?>
</table>
</td>
</tr>
<tr>
<td class="upload_image">
<td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php
$args = array(
'taxonomy' => 'product_shipping_class',
'hide_empty' => 0,
'show_option_all' => __('Same as parent', 'woocommerce'),
'name' => 'variable_shipping_class['.$loop.']',
'id' => '',
'selected' => $current_shipping_class
);
wp_dropdown_categories( $args );
?></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[<?php echo $loop; ?>]" <?php if (isset($variation_data['_downloadable'][0])) checked($variation_data['_downloadable'][0], 'yes'); ?> /></td>
<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>
<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>
<td>
<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'); ?>" />
</div>
<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>
<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'); ?>" />
</div>
<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>
<?php do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data ); ?>
</tbody>
</table>
</div>
@ -297,54 +357,89 @@ function variable_product_type_options() {
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>\
<table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content">\
<tbody>\
<tbody> \
<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><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>\
\
<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><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>\
\
<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 class="sku" colspan="2">\
<?php if( get_option('woocommerce_enable_sku', true) !== 'no' ) : ?>\
<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; ?>" />\
<?php else : ?>\
<input type="hidden" name="variable_sku[' + loop + ']" />\
<?php endif; ?>\
</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('Sale Price:', 'woocommerce'); ?></label><input type="text" size="5" name="variable_sale_price[' + loop + ']" /></td>\
</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>\
<td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php
$args = array(
'taxonomy' => 'product_shipping_class',
'hide_empty' => 0,
'show_option_all' => __('Same as parent', 'woocommerce'),
'name' => 'variable_shipping_class[]',
'id' => '',
'echo' => 0
);
echo addslashes(str_replace('[]', "[' + loop + ']", str_replace("\n", '', wp_dropdown_categories( $args ))));
?></td>\
<td><label><?php _e('Tax class:', 'woocommerce'); ?></label> <select name="variable_tax_class[' + loop + ']"><?php
foreach ( $tax_class_options as $key => $tax_class ) {
echo '<option value="' . $key . '" ';
if ( isset( $variation_data['_tax_class'][0] ) ) echo addslashes(selected($key, $variation_data['_tax_class'][0], false));
echo '>' . $tax_class . '</option>';
}
?></select></td>\
</tr>\
<tr>\
<td>\
<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>\
<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>\
\
<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>\
</tr>\
<tr>\
<td><label><?php _e('Shipping class:', 'woocommerce'); ?></label> <?php
$args = array(
'taxonomy' => 'product_shipping_class',
'hide_empty' => 0,
'show_option_all' => __('Same as parent', 'woocommerce'),
'name' => "variable_shipping_class[]",
'id' => '',
'echo' => 0
);
echo addslashes(str_replace('[]', "[' + loop + ']", str_replace("\n", '', wp_dropdown_categories( $args ))));
?></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('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>\
\
<td><label><?php _e('Enabled', 'woocommerce'); ?></label><input type="checkbox" class="checkbox" checked="checked" name="variable_enabled[' + loop + ']" /></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>\
</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>\
<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>\
</tr>\
<?php do_action( 'woocommerce_product_after_variable_attributes_js' ); ?> \
</tbody>\
</table>\
</div>');
@ -354,6 +449,9 @@ function variable_product_type_options() {
'fadeIn' : 50,
'fadeOut' : 50
});
jQuery('input.variable_is_downloadable, input.variable_is_virtual').change();
jQuery('.woocommerce_variations').unblock();
});
@ -473,27 +571,17 @@ function variable_product_type_options() {
return false;
});
jQuery('a.set_all_prices').click(function(){
var value = prompt("<?php _e('Enter a price', 'woocommerce'); ?>");
jQuery('input[name^="variable_price"]').val( value );
return false;
});
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 );
jQuery('a.bulk_edit').click(function() {
var field_to_edit = jQuery('select#field_to_edit').val();
var value = prompt("<?php _e('Enter a value', 'woocommerce'); ?>");
jQuery('input[name^="' + field_to_edit + '"]').val( value );
return false;
});
jQuery('a.toggle_virtual').click(function(){
var checkbox = jQuery('input[name^="variable_is_virtual"]');
checkbox.attr('checked', !checkbox.attr('checked'));
jQuery('input.variable_is_virtual').change();
return false;
});
@ -509,30 +597,28 @@ function variable_product_type_options() {
checkbox.attr('checked', !checkbox.attr('checked'));
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(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')) {
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
$('.woocommerce_variations').sortable({
@ -638,24 +724,31 @@ function process_product_meta_variable( $post_id ) {
if (isset($_POST['variable_sku'])) :
$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'];
$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_download_limit = $_POST['variable_download_limit'];
$variable_shipping_class = $_POST['variable_shipping_class'];
$variable_menu_order = $_POST['variation_menu_order'];
$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'];
$upload_image_id = $_POST['upload_image_id'];
$variable_file_path = $_POST['variable_file_path'];
$variable_download_limit = $_POST['variable_download_limit'];
$variable_shipping_class = $_POST['variable_shipping_class'];
$variable_tax_class = $_POST['variable_tax_class'];
$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) );
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, '_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') :
update_post_meta( $variation_id, '_download_limit', $variable_download_limit[$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;
border: 1px solid #ececec;
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 {
margin: 0 !important;
padding: 6px !important;
@ -1575,8 +1586,8 @@ img.help_tip {
padding: 4px;
color: #555;
}
select {
width: 100%;
select, .chzn-container {
width: 100% !important;
}
input.short {
width: 200px;
@ -1643,70 +1654,121 @@ img.help_tip {
}
}
.woocommerce_variation {
table td {
width: 16.66%;
input {
min-width: inherit !important;
}
&.dimensions_field {
table {
background: #f5f5f5;
padding: 6px;
td {
input {
width: 32%;
margin-right: 2%;
min-width: inherit !important;
}
.last {
margin-right: 0;
}
}
&.upload_image {
width: 1%;
white-space: nowrap;
img {
float: none;
margin-right: 6px;
vertical-align: middle;
}
.button {
margin: 0;
padding: 4px 10px;
width: auto;
float: none;
vertical-align: middle;
}
.upload_image_button {
display: block;
position: relative;
.overlay {
display: none;
width: 60px;
height: 60px;
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
opacity:0.5;
background: #eee url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAXklEQVQYGW2OUQrAMAhDFy8+dnKnwiuh2I+aJulDZebDkfSie1b28Q7EXWrfvSm60RQnkQUC8ja7owpmL6d4GdDZ0cNNHyIhZEj4QYCxze6orsluAh8AnR0xKPR07weXJi8JGd3qqwAAAABJRU5ErkJggg==) no-repeat center center;
&.dimensions_field {
input {
width: 32%;
margin-right: 2%;
}
.last {
margin-right: 0;
}
}
.upload_image_button:hover {
.overlay {
&.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_button.remove .overlay {
background: #eee url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWElEQVQYGY2OUQ6AMAxCZdm9jSev65K3YKNm+6EFBlVEHDxJJ3Pi0C72xlBNyTs3jU7wEUTTIB51GCp2CL8HLpHEdaOLb/N2dfuq9NT0zOo/M9q6EaImsd/uViMLVuD4KAAAAABJRU5ErkJggg==) no-repeat center center;
&.upload_image {
white-space: nowrap;
width: 75px;
img {
float: none;
width: 73px;
border: 1px solid #dfdfdf;
}
.button {
margin: 0;
padding: 4px 10px;
width: auto;
float: none;
vertical-align: middle;
}
.upload_image_button {
display: block;
position: relative;
.overlay {
display: none;
width: 75px;
height: 75px;
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
opacity:0.5;
background: #eee url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAXklEQVQYGW2OUQrAMAhDFy8+dnKnwiuh2I+aJulDZebDkfSie1b28Q7EXWrfvSm60RQnkQUC8ja7owpmL6d4GdDZ0cNNHyIhZEj4QYCxze6orsluAh8AnR0xKPR07weXJi8JGd3qqwAAAABJRU5ErkJggg==) no-repeat center center;
}
}
.upload_image_button:hover {
.overlay {
display: block;
}
}
.upload_image_button.remove .overlay {
background: #eee url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWElEQVQYGY2OUQ6AMAxCZdm9jSev65K3YKNm+6EFBlVEHDxJJ3Pi0C72xlBNyTs3jU7wEUTTIB51GCp2CL8HLpHEdaOLb/N2dfuq9NT0zOo/M9q6EaImsd/uViMLVuD4KAAAAABJRU5ErkJggg==) no-repeat center center;
}
}
}
.file_path_field {
position: relative;
padding-right: 40px;
.upload_file_button {
position: absolute;
right: 0;
width: 30px;
padding: 5px 0;
margin: 1px 0 0;
text-align: center;
.file_path_field {
position: relative;
padding-right: 40px;
.upload_file_button {
position: absolute;
right: 0;
width: 30px;
padding: 5px 0;
margin: 1px 0 0;
text-align: center;
}
}
}
}

View File

@ -22,6 +22,7 @@ class WC_Product_Variation extends WC_Product {
var $variation_has_stock;
var $variation_has_sku;
var $variation_shipping_class;
var $variation_has_tax_class;
/**
* Loads all product data from custom fields
@ -136,6 +137,11 @@ class WC_Product_Variation extends WC_Product {
$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;
}

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
Requires at least: 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.
@ -143,12 +143,14 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 1.5.4 =
= 1.5.4 - 12/04/2012 =
* 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 - Added woocommerce_get_dimension/woocommerce_get_weight helpers for normalisation. Thanks Andy Zhang
* 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 - 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 - Adding an item to an order now uses the ajax style product finder
* Tweak - Updated chosen to latest release

View File

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