Variation taxonomy changes

This commit is contained in:
Mike Jolley 2011-08-24 20:32:33 +01:00
parent 6913726cd5
commit b0f4e4bbba
5 changed files with 52 additions and 16 deletions

View File

@ -39,6 +39,22 @@ function woocommerce_meta_boxes() {
remove_meta_box( 'commentstatusdiv', 'shop_coupon' , 'normal' );
remove_meta_box( 'slugdiv', 'shop_coupon' , 'normal' );
remove_meta_box('pageparentdiv', 'product_variation', 'side');
add_meta_box('product_variation-parent', __('Product', 'woothemes'), 'variations_product_meta_box', 'product_variation', 'side', 'default');
}
/**
* Let variations have a product as the parent
*/
function variations_product_meta_box($post) {
$post_type_object = get_post_type_object($post->post_type);
if ( $post_type_object->hierarchical ) {
$pages = wp_dropdown_pages(array('post_type' => 'product', 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0));
if ( ! empty($pages) ) {
echo $pages;
} // end empty pages check
} // end hierarchical check.
}
/**

View File

@ -473,6 +473,9 @@ div.taxrows .taxrow label.checkbox input {
float: left;
}
/* Write Panels */
#product_variation-parent #parent_id {
width: 100%;
}
#woocommerce-product-data ul.product_data_tabs, .woocommerce ul.tabs {
background: #ececec;
padding: 7px 9px 0;

View File

@ -522,6 +522,9 @@ div.taxrows {
}
/* Write Panels */
#product_variation-parent #parent_id {
width: 100%;
}
#woocommerce-product-data ul.product_data_tabs, .woocommerce ul.tabs {
background: #ececec;
padding: 7px 9px 0;

View File

@ -26,37 +26,51 @@ jQuery(function(){
// Trigger event
jQuery('body').trigger('adding_to_cart');
// Block widget
jQuery('.widget_shopping_cart, .shop_table.cart').block({message: null, overlayCSS: {background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
// Ajax action
jQuery.post( params.ajax_url, data, function(response) {
// Get response
fragments = jQuery.parseJSON( response );
// Block fragments class
if (fragments) {
jQuery.each(fragments, function(key, value) {
jQuery(key).addClass('updating');
});
}
// Block widgets and fragments
jQuery('.widget_shopping_cart, .shop_table.cart, .updating').fadeTo('400', '0.6').block({message: null, overlayCSS: {background: 'transparent url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
// Changes button classes
jQuery(thisbutton).addClass('added');
jQuery(thisbutton).removeClass('loading');
// Cart widget load
jQuery('.widget_shopping_cart:eq(0)').load( window.location + ' .widget_shopping_cart:eq(0) > *', function() {
jQuery('.widget_shopping_cart').unblock();
// Replace fragments
if (fragments) {
jQuery.each(fragments, function(key, value) {
jQuery(key).replaceWith(value);
});
}
// Unblock
jQuery('.widget_shopping_cart, .updating').css('opacity', '1').unblock();
} );
// Cart load
jQuery('.shop_table.cart').load( window.location + ' .shop_table.cart:eq(0) > *', function() {
jQuery("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
jQuery('.shop_table.cart').unblock();
jQuery('.shop_table.cart').css('opacity', '1').unblock();
} );
// Trigger event so themes can refresh other areas
jQuery('body').trigger('added_to_cart');
// Get response
fragments = jQuery.parseJSON( response );
if (fragments) {
jQuery.each(fragments, function(key, value) {
jQuery(key).replaceWith(value);
});
}
});

View File

@ -161,10 +161,10 @@ function woocommerce_post_type() {
'capability_type' => 'post',
'publicly_queryable' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'hierarchical' => true,
'rewrite' => false,
'query_var' => true,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'supports' => array( 'title', 'custom-fields', 'page-attributes', 'thumbnail' ),
'show_in_nav_menus' => false,
'show_in_menu' => 'edit.php?post_type=product'
)