Upsell/cross sell improvements

This commit is contained in:
Mike Jolley 2011-09-19 15:57:17 +01:00
parent d536897e69
commit 72e2b5219b
6 changed files with 57 additions and 395 deletions

View File

@ -137,6 +137,7 @@ div.multi_select_products_wrapper{float:left;width:49%;padding:0;}
div.multi_select_products_wrapper-alt{float:right;} div.multi_select_products_wrapper-alt{float:right;}
.multi_select_products,div.multi_select_countries{border:1px solid #ececec;height:200px;overflow:auto;width:100%;float:left;} .multi_select_products,div.multi_select_countries{border:1px solid #ececec;height:200px;overflow:auto;width:100%;float:left;}
.multi_select_products{background:#fff;} .multi_select_products{background:#fff;}
.multi_select_products.loading{background:#ffffff url(../images/ajax-loader.gif) no-repeat center;}
.multi_select_products li{padding:7px 9px;line-height:2em;border-bottom:1px dotted #ececec;} .multi_select_products li{padding:7px 9px;line-height:2em;border-bottom:1px dotted #ececec;}
.multi_select_countries li{padding:3px 9px;margin:0;line-height:2em;border-bottom:1px dotted #ececec;} .multi_select_countries li{padding:3px 9px;margin:0;line-height:2em;border-bottom:1px dotted #ececec;}
.multi_select_countries li label{display:block;} .multi_select_countries li label{display:block;}

View File

@ -715,6 +715,9 @@ div.multi_select_products_wrapper-alt {
.multi_select_products { .multi_select_products {
background: #fff; background: #fff;
} }
.multi_select_products.loading {
background: #fff url(../images/ajax-loader.gif) no-repeat center;
}
.multi_select_products li { .multi_select_products li {
padding: 7px 9px; padding: 7px 9px;
line-height: 2em; line-height: 2em;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -1,5 +1,10 @@
jQuery( function($){ jQuery( function($){
// Prevent enter submitting post form
jQuery("form#post").bind("keypress", function(e) {
if (e.keyCode == 34 || e.keyCode == 13) return false;
});
// TABS // TABS
jQuery('ul.tabs').show(); jQuery('ul.tabs').show();
jQuery('div.panel-wrap').each(function(){ jQuery('div.panel-wrap').each(function(){
@ -268,7 +273,7 @@ jQuery( function($){
if (product_type!='variable') enable_variation = 'style="display:none;"'; else enable_variation = ''; if (product_type!='variable') enable_variation = 'style="display:none;"'; else enable_variation = '';
// Add custom attribute row // Add custom attribute row
jQuery('table.woocommerce_attributes tbody').append('<tr><td class="center"><button type="button" class="button move_up">&uarr;</button><button type="button" class="move_down button">&darr;</button><input type="hidden" name="attribute_position[' + size + ']" class="attribute_position" value="' + size + '" /></td><td><input type="text" name="attribute_names[' + size + ']" /><input type="hidden" name="attribute_is_taxonomy[' + size + ']" value="0" /></td><td><input type="text" name="attribute_values[' + size + ']" /></td><td class="center"><input type="checkbox" checked="checked" name="attribute_visibility[' + size + ']" value="1" /></td><td class="center enable_variation" ' + enable_variation + '><input type="checkbox" name="attribute_variation[' + size + ']" value="1" /></td><td class="center"><button type="button" class="remove_row button">&times;</button></td></tr>'); jQuery('table.woocommerce_attributes tbody').append('<tr><td><input type="text" name="attribute_names[' + size + ']" /><input type="hidden" name="attribute_is_taxonomy[' + size + ']" value="0" /><input type="hidden" name="attribute_position[' + size + ']" class="attribute_position" value="' + size + '" /></td><td><input type="text" name="attribute_values[' + size + ']" /></td><td class="center"><input type="checkbox" checked="checked" name="attribute_visibility[' + size + ']" value="1" /></td><td class="center enable_variation" ' + enable_variation + '><input type="checkbox" name="attribute_variation[' + size + ']" value="1" /></td><td class="center"><button type="button" class="remove_row button">&times;</button></td></tr>');
} else { } else {
@ -303,19 +308,29 @@ jQuery( function($){
return false; return false;
}); });
jQuery('button.move_up').live('click', function(){ // Attribute ordering
var row = jQuery(this).parent().parent(); jQuery('table.woocommerce_attributes tbody').sortable({
var prev_row = jQuery(row).prev('tr'); items:'tr',
jQuery(row).after(prev_row); cursor:'move',
row_indexes(); axis:'y',
scrollSensitivity:40,
helper:function(e,ui){
ui.children().each(function(){
jQuery(this).width(jQuery(this).width());
}); });
jQuery('button.move_down').live('click', function(){ return ui;
var row = jQuery(this).parent().parent(); },
var next_row = jQuery(row).next('tr'); start:function(event,ui){
jQuery(row).before(next_row); ui.item.css('background-color','#f6f6f6');
},
stop:function(event,ui){
ui.item.removeAttr('style');
row_indexes(); row_indexes();
}
}); });
// Cross sells/Up sells // Cross sells/Up sells
jQuery('.multi_select_products button').live('click', function(){ jQuery('.multi_select_products button').live('click', function(){
var wrapper = jQuery(this).parent().parent().parent().parent(); var wrapper = jQuery(this).parent().parent().parent().parent();
@ -333,29 +348,43 @@ jQuery( function($){
} }
}); });
var xhr;
jQuery('.multi_select_products #product_search').bind('keyup click', function(){ jQuery('.multi_select_products #product_search').bind('keyup click', function(){
jQuery('.multi_select_products_source').addClass('loading');
jQuery('.multi_select_products_source li:not(.product_search)').remove(); jQuery('.multi_select_products_source li:not(.product_search)').remove();
var search = encodeURI( jQuery(this).val() ); if (xhr) xhr.abort();
var search = jQuery(this).val();
var input = this; var input = this;
var name = jQuery(this).attr('rel'); var name = jQuery(this).attr('rel');
if (search.length<3) return; if (search.length<3) {
jQuery('.multi_select_products_source').removeClass('loading');
return;
}
var data = { var data = {
name: name, name: name,
search: search, search: encodeURI(search),
action: 'woocommerce_upsell_crosssell_search_products', action: 'woocommerce_upsell_crosssell_search_products',
security: woocommerce_writepanel_params.upsell_crosssell_search_products_nonce security: woocommerce_writepanel_params.upsell_crosssell_search_products_nonce
}; };
jQuery.post( woocommerce_writepanel_params.ajax_url, data, function( response ) { xhr = jQuery.ajax({
url: woocommerce_writepanel_params.ajax_url,
data: data,
type: 'POST',
success: function( response ) {
jQuery('.multi_select_products_source').removeClass('loading');
jQuery('.multi_select_products_source li:not(.product_search)').remove(); jQuery('.multi_select_products_source li:not(.product_search)').remove();
jQuery(input).parent().parent().append( response ); jQuery(input).parent().parent().append( response );
} ); }
});
}); });

File diff suppressed because one or more lines are too long

View File

@ -255,7 +255,7 @@ function woocommerce_upsell_crosssell_search_products() {
$args = array( $args = array(
'post_type' => 'product', 'post_type' => 'product',
'post_status' => 'publish', 'post_status' => 'publish',
'posts_per_page' => 20, 'posts_per_page' => 15,
'post__in' => array(0, $search) 'post__in' => array(0, $search)
); );
@ -264,7 +264,7 @@ function woocommerce_upsell_crosssell_search_products() {
$args = array( $args = array(
'post_type' => 'product', 'post_type' => 'product',
'post_status' => 'publish', 'post_status' => 'publish',
'posts_per_page' => 20, 'posts_per_page' => 15,
's' => $search 's' => $search
); );