Stock system changes + write panel improvements

This commit is contained in:
Mike Jolley 2011-08-21 14:28:54 +01:00
parent 69c65c8b32
commit 23cbdbdbc4
9 changed files with 241 additions and 122 deletions

View File

@ -26,7 +26,7 @@ function woocommerce_content_right_now() {
$outofstock = array(); $outofstock = array();
$lowinstock = array(); $lowinstock = array();
$args = array( $args = array(
'post_type' => 'product', 'post_type' => array('product', 'product_variation'),
'post_status' => 'publish', 'post_status' => 'publish',
'ignore_sticky_posts' => 1, 'ignore_sticky_posts' => 1,
'posts_per_page' => -1 'posts_per_page' => -1
@ -34,20 +34,27 @@ function woocommerce_content_right_now() {
$my_query = new WP_Query($args); $my_query = new WP_Query($args);
if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();
$_product = &new woocommerce_product( $my_query->post->ID ); if ($my_query->post->post_type == 'product_variation') :
$parent = $my_query->post->post_parent;
$_product = &new woocommerce_product_variation( $my_query->post->ID );
else :
$parent = $my_query->post->ID;
$_product = &new woocommerce_product( $my_query->post->ID );
endif;
if (!$_product->managing_stock()) continue; if (!$_product->managing_stock()) continue;
$thisitem = '<tr class="first"> $thisitem = '<tr class="first">
<td class="first b"><a href="post.php?post='.$my_query->post->ID.'&action=edit">'.$_product->stock.'</a></td> <td class="first b"><a href="post.php?post='.$parent.'&action=edit">'.$_product->stock.'</a></td>
<td class="t"><a href="post.php?post='.$my_query->post->ID.'&action=edit">'.$my_query->post->post_title.'</a></td> <td class="t"><a href="post.php?post='.$parent.'&action=edit">'.$my_query->post->post_title.'</a></td>
</tr>'; </tr>';
if ($_product->stock<=$nostockamount) : if ($_product->total_stock<=$nostockamount) :
$outofstock[] = $thisitem; $outofstock[] = $thisitem;
continue; continue;
endif; endif;
if ($_product->stock<=$lowstockamount) $lowinstock[] = $thisitem; if ($_product->total_stock<=$lowstockamount) $lowinstock[] = $thisitem;
endwhile; endif; endwhile; endif;
wp_reset_query(); wp_reset_query();

View File

@ -77,12 +77,18 @@ function variable_product_type_options() {
<tbody> <tbody>
<tr> <tr>
<td class="upload_image"><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 if (isset($variation_data['_thumbnail_id'][0])) echo $variation_data['_thumbnail_id'][0]; ?>" /><input type="button" rel="<?php echo $variation->ID; ?>" class="upload_image_button button" value="<?php _e('Product Image', 'woothemes'); ?>" /></td> <td class="upload_image"><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 if (isset($variation_data['_thumbnail_id'][0])) echo $variation_data['_thumbnail_id'][0]; ?>" /><input type="button" rel="<?php echo $variation->ID; ?>" class="upload_image_button button" value="<?php _e('Product Image', 'woothemes'); ?>" /></td>
<td><label><?php _e('SKU:', 'woothemes'); ?></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]; ?>" /></td>
<td><label><?php _e('Weight', 'woothemes').' ('.get_option('woocommerce_weight_unit').'):'; ?></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]; ?>" /></td> <td><label><?php _e('SKU:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Leave blank to use the variable product\'s 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]; ?>" /></td>
<td><label><?php _e('Stock Qty:', 'woothemes'); ?></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('Price:', 'woothemes'); ?></label><input type="text" size="5" name="variable_price[<?php echo $loop; ?>]" placeholder="<?php _e('e.g. 29.99', 'woothemes'); ?>" value="<?php if (isset($variation_data['price'][0])) echo $variation_data['price'][0]; ?>" /></td> <td><label><?php _e('Weight', 'woothemes').' ('.get_option('woocommerce_weight_unit').'):'; ?> <a class="tips" tip="<?php _e('Leave blank to use the variable product\'s 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]; ?>" /></td>
<td><label><?php _e('Sale Price:', 'woothemes'); ?></label><input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" placeholder="<?php _e('e.g. 29.99', 'woothemes'); ?>" value="<?php if (isset($variation_data['sale_price'][0])) echo $variation_data['sale_price'][0]; ?>" /></td>
<td><label><?php _e('Enabled', 'woothemes'); ?></label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked($variation->post_status, 'publish'); ?> /></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\'s 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('Price:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Leave blank to use the variable product\'s price.', 'woothemes'); ?>" href="#">[?]</a></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:', 'woothemes'); ?> <a class="tips" tip="<?php _e('Leave blank to use the variable product\'s sale price.', 'woothemes'); ?>" href="#">[?]</a></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><label><?php _e('Enabled', 'woothemes'); ?> <a class="tips" tip="<?php _e('If you don\'t enable this variation the user will be informed that it is not available.', 'woothemes'); ?>" href="#">[?]</a></label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked($variation->post_status, 'publish'); ?> /></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -115,6 +121,18 @@ function variable_product_write_panel_js() {
?> ?>
jQuery(function(){ jQuery(function(){
<?php if (!$attributes || (is_array($attributes) && sizeof($attributes)==0)) : ?>
jQuery('button.link_all_variations, button.add_variation').live('click', function(){
alert('<?php _e('You must add some attributes via the "Product Data" panel and save before adding a new variation.', 'woothemes'); ?>');
return false;
});
<?php else : ?>
jQuery('button.add_variation').live('click', function(){ jQuery('button.add_variation').live('click', function(){
jQuery('.woocommerce_variations').block({ message: null, overlayCSS: { background: '#fff url(<?php echo woocommerce::plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } }); jQuery('.woocommerce_variations').block({ message: null, overlayCSS: { background: '#fff url(<?php echo woocommerce::plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
@ -175,7 +193,7 @@ function variable_product_write_panel_js() {
return false; return false;
}); });
jQuery('button.link_all_variations').live('click', function(){ jQuery('button.link_all_variations').live('click', function(){
var answer = confirm('<?php _e('Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes.', 'woothemes'); ?>'); var answer = confirm('<?php _e('Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes.', 'woothemes'); ?>');
if (answer){ if (answer){
@ -235,6 +253,8 @@ function variable_product_write_panel_js() {
return false; return false;
}); });
<?php endif; ?>
var current_field_wrapper; var current_field_wrapper;
window.send_to_editor_default = window.send_to_editor; window.send_to_editor_default = window.send_to_editor;

View File

@ -27,7 +27,7 @@ function woocommerce_product_data_box() {
<ul class="product_data_tabs tabs" style="display:none;"> <ul class="product_data_tabs tabs" style="display:none;">
<li class="active"><a href="#general_product_data"><?php _e('General', 'woothemes'); ?></a></li> <li class="active"><a href="#general_product_data"><?php _e('General', 'woothemes'); ?></a></li>
<li class="pricing_tab"><a href="#pricing_product_data"><?php _e('Pricing', 'woothemes'); ?></a></li> <li class="tax_tab"><a href="#tax_product_data"><?php _e('Tax', 'woothemes'); ?></a></li>
<?php if (get_option('woocommerce_manage_stock')=='yes') : ?><li class="inventory_tab"><a href="#inventory_product_data"><?php _e('Inventory', 'woothemes'); ?></a></li><?php endif; ?> <?php if (get_option('woocommerce_manage_stock')=='yes') : ?><li class="inventory_tab"><a href="#inventory_product_data"><?php _e('Inventory', 'woothemes'); ?></a></li><?php endif; ?>
<li><a href="#woocommerce_attributes"><?php _e('Attributes', 'woothemes'); ?></a></li> <li><a href="#woocommerce_attributes"><?php _e('Attributes', 'woothemes'); ?></a></li>
<li><a href="#upsell_product_data" title="<?php _e('Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woothemes'); ?>"><?php _e('Up-sells', 'woothemes'); ?></a></li> <li><a href="#upsell_product_data" title="<?php _e('Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woothemes'); ?>"><?php _e('Up-sells', 'woothemes'); ?></a></li>
@ -37,97 +37,96 @@ function woocommerce_product_data_box() {
</ul> </ul>
<div id="general_product_data" class="panel woocommerce_options_panel"><?php <div id="general_product_data" class="panel woocommerce_options_panel"><?php
// Product Type echo '<div class="options_group grouping">';
if ($terms = wp_get_object_terms( $thepostid, 'product_type' )) $product_type = current($terms)->slug; else $product_type = 'simple';
woocommerce_wp_select( array( 'id' => 'product-type', 'label' => __('Product Type', 'woothemes'), 'value' => $product_type, 'options' => apply_filters('product_type_selector', array( // List Grouped products
'simple' => __('Simple', 'woothemes') $post_parents = array();
), $product_type) ) ); $post_parents[''] = __('Choose a grouped product&hellip;', 'woothemes');
$posts_in = array_unique((array) get_objects_in_term( get_term_by( 'slug', 'grouped', 'product_type' )->term_id, 'product_type' ));
if (sizeof($posts_in)>0) :
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'asc',
'post_parent' => 0,
'include' => $posts_in,
);
$grouped_products = get_posts($args);
$loop = 0;
if ($grouped_products) : foreach ($grouped_products as $product) :
if ($product->ID==$post->ID) continue;
$post_parents[$product->ID] = $product->post_title;
endforeach; endif;
endif;
woocommerce_wp_select( array( 'id' => 'parent_id', 'label' => __('Grouping', 'woothemes'), 'value' => $post->post_parent, 'options' => $post_parents ) );
// Ordering
woocommerce_wp_text_input( array( 'id' => 'menu_order', 'label' => _x('Sort Order', 'ordering', 'woothemes'), 'value' => $post->menu_order ) );
// List Grouped products echo '</div>';
$post_parents = array();
$post_parents[''] = __('Choose a grouped product&hellip;', 'woothemes'); echo '<div class="options_group">';
$posts_in = array_unique((array) get_objects_in_term( get_term_by( 'slug', 'grouped', 'product_type' )->term_id, 'product_type' )); // SKU
if (sizeof($posts_in)>0) : if( get_option('woocommerce_enable_sku', true) !== 'no' ) :
$args = array( woocommerce_wp_text_input( array( 'id' => 'sku', 'label' => __('SKU', 'woothemes'), 'placeholder' => $post->ID ) );
'post_type' => 'product', else:
'post_status' => 'publish', echo '<input type="hidden" name="sku" value="'.get_post_meta($thepostid, 'sku', true).'" />';
'numberposts' => -1, endif;
'orderby' => 'title',
'order' => 'asc', echo '</div>';
'post_parent' => 0,
'include' => $posts_in, echo '<div class="options_group pricing">';
);
$grouped_products = get_posts($args); // Price
$loop = 0; woocommerce_wp_text_input( array( 'id' => 'regular_price', 'label' => __('Regular Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):', 'placeholder' => '0.00' ) );
if ($grouped_products) : foreach ($grouped_products as $product) :
// Special Price
woocommerce_wp_text_input( array( 'id' => 'sale_price', 'label' => __('Sale Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):', 'placeholder' => '0.00' ) );
// Special Price date range
$field = array( 'id' => 'sale_price_dates', 'label' => __('Sale Price Dates', 'woothemes') );
$sale_price_dates_from = get_post_meta($thepostid, 'sale_price_dates_from', true);
$sale_price_dates_to = get_post_meta($thepostid, 'sale_price_dates_to', true);
echo ' <p class="form-field">
<label for="'.$field['id'].'_from">'.$field['label'].':</label>
<input type="text" class="short date-pick" name="'.$field['id'].'_from" id="'.$field['id'].'_from" value="';
if ($sale_price_dates_from) echo date('Y-m-d', $sale_price_dates_from);
echo '" placeholder="' . __('From&hellip;', 'woothemes') . '" maxlength="10" />
<input type="text" class="short date-pick" name="'.$field['id'].'_to" id="'.$field['id'].'_to" value="';
if ($sale_price_dates_to) echo date('Y-m-d', $sale_price_dates_to);
echo '" placeholder="' . __('To&hellip;', 'woothemes') . '" maxlength="10" />
<span class="description">' . __('Date format', 'woothemes') . ': <code>YYYY-MM-DD</code></span>
</p>';
if ($product->ID==$post->ID) continue; echo '</div>';
$post_parents[$product->ID] = $product->post_title;
endforeach; endif; echo '<div class="options_group">';
endif;
woocommerce_wp_select( array( 'id' => 'parent_id', 'label' => __('Parent post', 'woothemes'), 'value' => $post->post_parent, 'options' => $post_parents ) ); // Weight
if( get_option('woocommerce_enable_weight', true) !== 'no' ) :
woocommerce_wp_text_input( array( 'id' => 'weight', 'label' => __('Weight', 'woothemes') . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00' ) );
else:
echo '<input type="hidden" name="weight" value="'.get_post_meta($thepostid, 'weight', true).'" />';
endif;
// Ordering echo '</div>';
woocommerce_wp_text_input( array( 'id' => 'menu_order', 'label' => _x('Post Order', 'ordering', 'woothemes'), 'value' => $post->menu_order ) );
// SKU
if( get_option('woocommerce_enable_sku', true) !== 'no' ) :
woocommerce_wp_text_input( array( 'id' => 'sku', 'label' => __('SKU', 'woothemes'), 'description' => __('Leave blank to use product ID', 'woothemes') ) );
else:
echo '<input type="hidden" name="sku" value="'.get_post_meta($thepostid, 'sku', true).'" />';
endif;
// Weight
if( get_option('woocommerce_enable_weight', true) !== 'no' ) :
woocommerce_wp_text_input( array( 'id' => 'weight', 'label' => __('Weight', 'woothemes') . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00' ) );
else:
echo '<input type="hidden" name="weight" value="'.get_post_meta($thepostid, 'weight', true).'" />';
endif;
// Featured
woocommerce_wp_checkbox( array( 'id' => 'featured', 'label' => __('Featured?', 'woothemes') ) );
// Visibility
woocommerce_wp_select( array( 'id' => 'visibility', 'label' => __('Visibility', 'woothemes'), 'options' => array(
'visible' => __('Catalog &amp; Search', 'woothemes'),
'catalog' => __('Catalog', 'woothemes'),
'search' => __('Search', 'woothemes'),
'hidden' => __('Hidden', 'woothemes')
) ) );
?> ?>
</div> </div>
<div id="pricing_product_data" class="panel woocommerce_options_panel"> <div id="tax_product_data" class="panel woocommerce_options_panel">
<?php <?php
// Price
woocommerce_wp_text_input( array( 'id' => 'regular_price', 'label' => __('Regular Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):', 'placeholder' => '0.00' ) );
// Special Price
woocommerce_wp_text_input( array( 'id' => 'sale_price', 'label' => __('Sale Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):', 'placeholder' => '0.00' ) );
// Special Price date range
$field = array( 'id' => 'sale_price_dates', 'label' => __('Sale Price Dates', 'woothemes') );
$sale_price_dates_from = get_post_meta($thepostid, 'sale_price_dates_from', true);
$sale_price_dates_to = get_post_meta($thepostid, 'sale_price_dates_to', true);
echo ' <p class="form-field">
<label for="'.$field['id'].'_from">'.$field['label'].':</label>
<input type="text" class="short date-pick" name="'.$field['id'].'_from" id="'.$field['id'].'_from" value="';
if ($sale_price_dates_from) echo date('Y-m-d', $sale_price_dates_from);
echo '" placeholder="' . __('From&hellip;', 'woothemes') . '" maxlength="10" />
<input type="text" class="short date-pick" name="'.$field['id'].'_to" id="'.$field['id'].'_to" value="';
if ($sale_price_dates_to) echo date('Y-m-d', $sale_price_dates_to);
echo '" placeholder="' . __('To&hellip;', 'woothemes') . '" maxlength="10" />
<span class="description">' . __('Date format', 'woothemes') . ': <code>YYYY-MM-DD</code></span>
</p>';
// Tax // Tax
woocommerce_wp_select( array( 'id' => 'tax_status', 'label' => __('Tax Status', 'woothemes'), 'options' => array( woocommerce_wp_select( array( 'id' => 'tax_status', 'label' => __('Tax Status', 'woothemes'), 'options' => array(
'taxable' => __('Taxable', 'woothemes'), 'taxable' => __('Taxable', 'woothemes'),
@ -152,7 +151,7 @@ function woocommerce_product_data_box() {
<?php <?php
// manage stock // manage stock
woocommerce_wp_checkbox( array( 'id' => 'manage_stock', 'label' => __('Manage stock??', 'woothemes') ) ); woocommerce_wp_checkbox( array( 'id' => 'manage_stock', 'label' => __('Manage stock?', 'woothemes') ) );
// Stock status // Stock status
woocommerce_wp_select( array( 'id' => 'stock_status', 'label' => __('Stock status', 'woothemes'), 'options' => array( woocommerce_wp_select( array( 'id' => 'stock_status', 'label' => __('Stock status', 'woothemes'), 'options' => array(
@ -300,7 +299,7 @@ function woocommerce_product_data_box() {
<li class="product_search"><input type="search" rel="upsell_ids" name="product_search" id="product_search" placeholder="<?php _e('Search for product', 'woothemes'); ?>" /><div class="clear"></div></li> <li class="product_search"><input type="search" rel="upsell_ids" name="product_search" id="product_search" placeholder="<?php _e('Search for product', 'woothemes'); ?>" /><div class="clear"></div></li>
</ul> </ul>
</div> </div>
<div class="multi_select_products_wrapper"><h4><?php _e('Up-Sells', 'woothemes'); ?></h4><ul class="multi_select_products multi_select_products_target"> <div class="multi_select_products_wrapper multi_select_products_wrapper-alt"><h4><?php _e('Up-Sells', 'woothemes'); ?></h4><ul class="multi_select_products multi_select_products_target">
<?php <?php
$upsell_ids = get_post_meta($thepostid, 'upsell_ids', true); $upsell_ids = get_post_meta($thepostid, 'upsell_ids', true);
if (!$upsell_ids) $upsell_ids = array(0); if (!$upsell_ids) $upsell_ids = array(0);
@ -317,7 +316,7 @@ function woocommerce_product_data_box() {
<li class="product_search"><input type="search" rel="crosssell_ids" name="product_search" id="product_search" placeholder="<?php _e('Search for product', 'woothemes'); ?>" /><div class="clear"></div></li> <li class="product_search"><input type="search" rel="crosssell_ids" name="product_search" id="product_search" placeholder="<?php _e('Search for product', 'woothemes'); ?>" /><div class="clear"></div></li>
</ul> </ul>
</div> </div>
<div class="multi_select_products_wrapper"><h4><?php _e('Cross-Sells', 'woothemes'); ?></h4><ul class="multi_select_products multi_select_products_target"> <div class="multi_select_products_wrapper multi_select_products_wrapper-alt"><h4><?php _e('Cross-Sells', 'woothemes'); ?></h4><ul class="multi_select_products multi_select_products_target">
<?php <?php
$crosssell_ids = get_post_meta($thepostid, 'crosssell_ids', true); $crosssell_ids = get_post_meta($thepostid, 'crosssell_ids', true);
if (!$crosssell_ids) $crosssell_ids = array(0); if (!$crosssell_ids) $crosssell_ids = array(0);
@ -517,7 +516,7 @@ function woocommerce_process_product_meta( $post_id, $post ) {
update_post_meta( $post_id, 'manage_stock', 'yes' ); update_post_meta( $post_id, 'manage_stock', 'yes' );
update_post_meta( $post_id, 'backorders', stripslashes( $_POST['backorders'] ) ); update_post_meta( $post_id, 'backorders', stripslashes( $_POST['backorders'] ) );
if ($_POST['backorders']=='no' && $_POST['stock']<1) : if ($product_type!=='variable' && $_POST['backorders']=='no' && $_POST['stock']<1) :
update_post_meta( $post_id, 'stock_status', 'outofstock' ); update_post_meta( $post_id, 'stock_status', 'outofstock' );
endif; endif;
@ -587,4 +586,37 @@ function woocommerce_product_selection_list_remove( $posts_to_display, $name ) {
?><li rel="<?php echo $related_post->ID; ?>"><button type="button" name="Remove" class="button remove" title="Remove">X</button><strong><?php echo $related_post->post_title; ?></strong> &ndash; #<?php echo $related_post->ID; ?> <?php if (isset($SKU) && $SKU) echo 'SKU: '.$SKU; ?><input type="hidden" name="<?php echo $name; ?>[]" value="<?php echo $related_post->ID; ?>" /></li><?php ?><li rel="<?php echo $related_post->ID; ?>"><button type="button" name="Remove" class="button remove" title="Remove">X</button><strong><?php echo $related_post->post_title; ?></strong> &ndash; #<?php echo $related_post->ID; ?> <?php if (isset($SKU) && $SKU) echo 'SKU: '.$SKU; ?><input type="hidden" name="<?php echo $name; ?>[]" value="<?php echo $related_post->ID; ?>" /></li><?php
endforeach; endif; endforeach; endif;
}
/**
* Procuct type panel
**/
function woocommerce_product_type_box() {
global $post, $thepostid;
$thepostid = $post->ID;
echo '<div class="woocommerce_options_panel">';
// Product Type
if ($terms = wp_get_object_terms( $thepostid, 'product_type' )) $product_type = current($terms)->slug; else $product_type = 'simple';
woocommerce_wp_select( array( 'id' => 'product-type', 'label' => __('Product Type', 'woothemes'), 'value' => $product_type, 'options' => apply_filters('product_type_selector', array(
'simple' => __('Simple', 'woothemes')
), $product_type) ) );
// Visibility
woocommerce_wp_select( array( 'id' => 'visibility', 'label' => __('Visibility', 'woothemes'), 'options' => array(
'visible' => __('Catalog &amp; Search', 'woothemes'),
'catalog' => __('Catalog', 'woothemes'),
'search' => __('Search', 'woothemes'),
'hidden' => __('Hidden', 'woothemes')
) ) );
// Featured
woocommerce_wp_checkbox( array( 'id' => 'featured', 'label' => __('Featured?', 'woothemes') ) );
echo '</div>';
} }

View File

@ -22,6 +22,7 @@ require_once('writepanel-coupon_data.php');
add_action( 'add_meta_boxes', 'woocommerce_meta_boxes' ); add_action( 'add_meta_boxes', 'woocommerce_meta_boxes' );
function woocommerce_meta_boxes() { function woocommerce_meta_boxes() {
add_meta_box( 'woocommerce-product-type', __('Product Type &amp; Visibility', 'woothemes'), 'woocommerce_product_type_box', 'product', 'normal', 'high' );
add_meta_box( 'woocommerce-product-data', __('Product Data', 'woothemes'), 'woocommerce_product_data_box', 'product', 'normal', 'high' ); add_meta_box( 'woocommerce-product-data', __('Product Data', 'woothemes'), 'woocommerce_product_data_box', 'product', 'normal', 'high' );
add_meta_box( 'woocommerce-product-type-options', __('Product Type Options', 'woothemes'), 'woocommerce_product_type_options_box', 'product', 'normal', 'high' ); add_meta_box( 'woocommerce-product-type-options', __('Product Type Options', 'woothemes'), 'woocommerce_product_type_options_box', 'product', 'normal', 'high' );

View File

@ -344,6 +344,9 @@ table.wp-list-table .column-featured, table.wp-list-table .column-sellable, tabl
#dashboard_right_now .complete { #dashboard_right_now .complete {
color: green; color: green;
} }
#dashboard_right_now .t, #dashboard_right_now .t a {
white-space: normal;
}
#woocommmerce_dashboard_sales h3 a { #woocommmerce_dashboard_sales h3 a {
float: right; float: right;
margin-left: 8px; margin-left: 8px;
@ -524,7 +527,10 @@ p.taxrow label input {
border-color: #e1e1e1; border-color: #e1e1e1;
color: #333; color: #333;
} }
#woocommerce-product-data .inside, #woocommerce-product-type-options .inside, #woocommerce-order-data .inside { #woocommerce-product-data .inside,
#woocommerce-product-type-options .inside,
#woocommerce-order-data .inside,
#woocommerce-product-type .inside {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
@ -532,7 +538,7 @@ p.taxrow label input {
padding: 9px 9px 9px 9px; padding: 9px 9px 9px 9px;
color: #555; color: #555;
} }
.woocommerce_page_settings .woocommerce_options_panel, .panel { .woocommerce_page_settings .woocommerce_options_panel, .panel, #woocommerce-product-type .woocommerce_options_panel {
padding: 0; padding: 0;
} }
#woocommerce-product-type-options .panel, #woocommerce-product-specs .inside { #woocommerce-product-type-options .panel, #woocommerce-product-specs .inside {
@ -544,7 +550,7 @@ p.taxrow label input {
zoom: 1; zoom: 1;
margin: 0 0 9px; margin: 0 0 9px;
font-size: 12px; font-size: 12px;
padding: 7px 9px; padding: 5px 9px;
line-height: 24px; line-height: 24px;
} }
.woocommerce_options_panel label { .woocommerce_options_panel label {
@ -591,6 +597,10 @@ p.taxrow label input {
.woocommerce_options_panel .short { .woocommerce_options_panel .short {
width: 20%; width: 20%;
} }
.woocommerce_options_panel .options_group {
border-top: 1px solid white;
border-bottom: 1px solid #DFDFDF;
}
#woocommerce_attributes { #woocommerce_attributes {
padding: 12px; padding: 12px;
} }
@ -642,10 +652,16 @@ button.add_variation,
button.link_all_variations { button.link_all_variations {
float: right; float: right;
} }
#upsell_product_data, #crosssell_product_data {
padding: 0 9px 9px;
}
div.multi_select_products_wrapper { div.multi_select_products_wrapper {
float: left; float: left;
width: 45%; width: 49%;
padding: 0 9px 9px; padding: 0;
}
div.multi_select_products_wrapper-alt {
float: right;
} }
.multi_select_products, div.multi_select_countries { .multi_select_products, div.multi_select_countries {
border: 1px solid #ececec; border: 1px solid #ececec;
@ -654,6 +670,9 @@ div.multi_select_products_wrapper {
width: 100%; width: 100%;
float: left; float: left;
} }
.multi_select_products {
background: #fff;
}
.multi_select_products li { .multi_select_products li {
padding: 7px 9px; padding: 7px 9px;
line-height: 2em; line-height: 2em;
@ -694,7 +713,6 @@ div.multi_select_products_wrapper {
cursor: default; cursor: default;
} }
#woocommerce-product-data input.dp-applied { #woocommerce-product-data input.dp-applied {
width: 140px;
float: left; float: left;
} }
#grouped_product_options, #virtual_product_options, #simple_product_options { #grouped_product_options, #virtual_product_options, #simple_product_options {
@ -760,6 +778,9 @@ div.multi_select_products_wrapper {
/* Tooltips */ /* Tooltips */
.tips { .tips {
cursor: help; cursor: help;
text-decoration: none;
}
img.tips {
padding: 5px 0 0 0; padding: 5px 0 0 0;
} }
#easyTooltip { #easyTooltip {
@ -773,6 +794,7 @@ div.multi_select_products_wrapper {
-o-border-radius: 4px; -o-border-radius: 4px;
-khtml-border-radius: 4px; -khtml-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
max-width: 300px;
} }
/* Datepicker */ /* Datepicker */
table.jCalendar { table.jCalendar {

View File

@ -372,6 +372,9 @@ table.wp-list-table .column-featured, table.wp-list-table .column-sellable, tabl
#dashboard_right_now .complete { #dashboard_right_now .complete {
color: green; color: green;
} }
#dashboard_right_now .t, #dashboard_right_now .t a {
white-space: normal;
}
#woocommmerce_dashboard_sales { #woocommmerce_dashboard_sales {
h3 a { h3 a {
@ -579,7 +582,7 @@ p.taxrow label {
color: #333; color: #333;
} }
#woocommerce-product-data .inside, #woocommerce-product-type-options .inside, #woocommerce-order-data .inside { #woocommerce-product-data .inside, #woocommerce-product-type-options .inside, #woocommerce-order-data .inside, #woocommerce-product-type .inside {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
@ -587,7 +590,7 @@ p.taxrow label {
padding: 9px 9px 9px 9px; padding: 9px 9px 9px 9px;
color: #555; color: #555;
} }
.woocommerce_page_settings .woocommerce_options_panel, .panel { .woocommerce_page_settings .woocommerce_options_panel, .panel, #woocommerce-product-type .woocommerce_options_panel {
padding: 0; padding: 0;
} }
#woocommerce-product-type-options .panel, #woocommerce-product-specs .inside { #woocommerce-product-type-options .panel, #woocommerce-product-specs .inside {
@ -599,7 +602,7 @@ p.taxrow label {
zoom: 1; zoom: 1;
margin: 0 0 9px; margin: 0 0 9px;
font-size: 12px; font-size: 12px;
padding: 7px 9px; padding: 5px 9px;
line-height: 24px; line-height: 24px;
} }
.woocommerce_options_panel label { .woocommerce_options_panel label {
@ -646,6 +649,10 @@ p.taxrow label {
.woocommerce_options_panel .short { .woocommerce_options_panel .short {
width: 20%; width: 20%;
} }
.woocommerce_options_panel .options_group {
border-top: 1px solid white;
border-bottom: 1px solid #DFDFDF;
}
#woocommerce_attributes { #woocommerce_attributes {
padding: 12px; padding: 12px;
@ -695,10 +702,16 @@ table.woocommerce_attributes .center {
float: right; float: right;
} }
#upsell_product_data, #crosssell_product_data {
padding: 0 9px 9px;
}
div.multi_select_products_wrapper { div.multi_select_products_wrapper {
float: left; float: left;
width: 45%; width: 49%;
padding: 0 9px 9px; padding: 0;
}
div.multi_select_products_wrapper-alt {
float: right;
} }
.multi_select_products, div.multi_select_countries { .multi_select_products, div.multi_select_countries {
border: 1px solid #ececec; border: 1px solid #ececec;
@ -707,6 +720,9 @@ div.multi_select_products_wrapper {
width: 100%; width: 100%;
float: left; float: left;
} }
.multi_select_products {
background: #fff;
}
.multi_select_products li { .multi_select_products li {
padding: 7px 9px; padding: 7px 9px;
line-height: 2em; line-height: 2em;
@ -748,7 +764,6 @@ div.multi_select_products_wrapper {
cursor: default; cursor: default;
} }
#woocommerce-product-data input.dp-applied { #woocommerce-product-data input.dp-applied {
width: 140px;
float: left; float: left;
} }
@ -820,6 +835,9 @@ div.multi_select_products_wrapper {
/* Tooltips */ /* Tooltips */
.tips { .tips {
cursor: help; cursor: help;
text-decoration: none;
}
img.tips {
padding: 5px 0 0 0; padding: 5px 0 0 0;
} }
#easyTooltip { #easyTooltip {
@ -833,6 +851,7 @@ div.multi_select_products_wrapper {
-o-border-radius:4px; -o-border-radius:4px;
-khtml-border-radius:4px; -khtml-border-radius:4px;
border-radius:4px; border-radius:4px;
max-width: 300px;
} }
/* Datepicker */ /* Datepicker */

View File

@ -170,20 +170,20 @@ jQuery( function($){
// Show option // Show option
if (select_val=='variable') { if (select_val=='variable') {
jQuery('.inventory_tab, .pricing_tab').show(); jQuery('.stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing').show();
jQuery('.menu_order_field, .parent_id_field').val('').hide(); jQuery('.options_group.grouping').val('').hide();
} else if (select_val=='simple') { } else if (select_val=='simple') {
jQuery('.inventory_tab, .pricing_tab').show(); jQuery('.stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing').show();
jQuery('.menu_order_field, .parent_id_field').show(); jQuery('.options_group.grouping').show();
} else if (select_val=='grouped') { } else if (select_val=='grouped') {
jQuery('.inventory_tab, .pricing_tab').hide(); jQuery('.stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing').hide();
jQuery('.menu_order_field, .parent_id_field').val('').hide(); jQuery('.options_group.grouping').val('').hide();
} else if (select_val=='downloadable') { } else if (select_val=='downloadable') {
jQuery('.inventory_tab, .pricing_tab').show(); jQuery('.stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing').show();
jQuery('.menu_order_field, .parent_id_field').show(); jQuery('.options_group.grouping').show();
} else if (select_val=='virtual') { } else if (select_val=='virtual') {
jQuery('.inventory_tab, .pricing_tab').show(); jQuery('.stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing').show();
jQuery('.menu_order_field, .parent_id_field').show(); jQuery('.options_group.grouping').show();
} }
$('body').trigger('woocommerce-product-type-change', select_val, $(this) ); $('body').trigger('woocommerce-product-type-change', select_val, $(this) );

View File

@ -31,6 +31,7 @@ class woocommerce_product {
var $upsell_ids; var $upsell_ids;
var $crosssell_ids; var $crosssell_ids;
var $product_type; var $product_type;
var $total_stock;
/** /**
@ -85,6 +86,18 @@ class woocommerce_product {
$this->get_children(); $this->get_children();
// total_stock
$this->total_stock = $this->stock;
if (sizeof($this->children)>0) foreach ($this->children as $child) :
if (isset($child->product->variation_has_stock)) :
if ($child->product->variation_has_stock) :
$this->total_stock += $child->product->stock;
endif;
else :
$this->total_stock += $child->product->stock;
endif;
endforeach;
if ($product_custom_fields) : if ($product_custom_fields) :
$this->exists = true; $this->exists = true;
else : else :
@ -233,7 +246,7 @@ class woocommerce_product {
function is_in_stock() { function is_in_stock() {
if ($this->managing_stock()) : if ($this->managing_stock()) :
if (!$this->backorders_allowed()) : if (!$this->backorders_allowed()) :
if ($this->stock==0 || $this->stock<0) : if ($this->total_stock==0 || $this->total_stock<0) :
return false; return false;
else : else :
if ($this->stock_status=='instock') return true; if ($this->stock_status=='instock') return true;
@ -288,7 +301,7 @@ class woocommerce_product {
endif; endif;
else : else :
if ($this->is_in_stock()) : if ($this->is_in_stock()) :
if ($this->stock > 0) : if ($this->total_stock > 0) :
$availability = __('In stock', 'woothemes'); $availability = __('In stock', 'woothemes');
if ($this->backorders_allowed()) : if ($this->backorders_allowed()) :

View File

@ -86,6 +86,8 @@ class woocommerce_product_variation extends woocommerce_product {
else : else :
$this->exists = false; $this->exists = false;
endif; endif;
$this->variation_has_sku = $this->variation_has_stock = $this->variation_has_weight = $this->variation_has_price = $this->variation_has_sale_price = false;
/* Override parent data with variation */ /* Override parent data with variation */
if (isset($product_custom_fields['sku'][0]) && !empty($product_custom_fields['sku'][0])) : if (isset($product_custom_fields['sku'][0]) && !empty($product_custom_fields['sku'][0])) :
@ -95,6 +97,7 @@ class woocommerce_product_variation extends woocommerce_product {
if (isset($product_custom_fields['stock'][0]) && $product_custom_fields['stock'][0]!=='') : if (isset($product_custom_fields['stock'][0]) && $product_custom_fields['stock'][0]!=='') :
$this->variation_has_stock = true; $this->variation_has_stock = true;
$this->manage_stock = 'yes';
$this->stock = $product_custom_fields['stock'][0]; $this->stock = $product_custom_fields['stock'][0];
endif; endif;
@ -114,6 +117,8 @@ class woocommerce_product_variation extends woocommerce_product {
$this->sale_price = $product_custom_fields['sale_price'][0]; $this->sale_price = $product_custom_fields['sale_price'][0];
if ($this->sale_price < $this->price) $this->price = $this->sale_price; if ($this->sale_price < $this->price) $this->price = $this->sale_price;
endif; endif;
$this->total_stock = $this->stock;
} }
/** Get the product's post data */ /** Get the product's post data */