more json fixes #2268

This commit is contained in:
Mike Jolley 2013-01-22 16:48:28 +00:00
parent a3e5748369
commit 1cb13fe740
5 changed files with 28 additions and 27 deletions

View File

@ -76,7 +76,7 @@ function woocommerce_order_downloads_meta_box() {
if ( $products ) foreach ( $products as $product ) {
$product_object = get_product( $product->ID );
$product_name = woocommerce_get_formatted_product_name( $product );
$product_name = woocommerce_get_formatted_product_name( $product_object );
echo '<option value="' . esc_attr( $product->ID ) . '">' . esc_html( $product_name ) . '</option>';

View File

@ -349,7 +349,7 @@ function woocommerce_admin_scripts() {
wp_register_script( 'jquery-tiptip', $woocommerce->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
wp_register_script( 'woocommerce_writepanel', $woocommerce->plugin_url() . '/assets/js/admin/write-panels'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker'), $woocommerce->version );
wp_register_script( 'woocommerce_writepanel', $woocommerce->plugin_url() . '/assets/js/admin/write-panels'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable'), $woocommerce->version );
wp_register_script( 'ajax-chosen', $woocommerce->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'chosen'), $woocommerce->version );

View File

@ -4,14 +4,14 @@
* Modified - products have no children (non hierarchical)
*/
jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','move');
jQuery("table.widefat tbody").sortable({
items: 'tr:not(.inline-edit-row)',
cursor: 'move',
axis: 'y',
containment: 'table.widefat',
scrollSensitivity: 40,
helper: function(e, ui) {
helper: function(e, ui) {
ui.children().each(function() { jQuery(this).width(jQuery(this).width()); });
return ui;
},
@ -20,32 +20,31 @@ jQuery("table.widefat tbody").sortable({
ui.item.children('td,th').css('border-bottom-width','0');
ui.item.css( 'outline', '1px solid #dfdfdf' );
},
stop: function(event, ui) {
stop: function(event, ui) {
ui.item.removeAttr('style');
ui.item.children('td,th').css('border-bottom-width','1px');
},
update: function(event, ui) {
update: function(event, ui) {
jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','default');
jQuery("table.widefat tbody").sortable('disable');
var postid = ui.item.find('.check-column input').val(); // this post id
var postparent = ui.item.find('.post_parent').html(); // post parent
var prevpostid = ui.item.prev().find('.check-column input').val();
var nextpostid = ui.item.next().find('.check-column input').val();
// show spinner
ui.item.find('.check-column input').hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />');
// go do the sorting stuff via ajax
jQuery.post( ajaxurl, { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function(response){
var changes = jQuery.parseJSON(response);
jQuery.each(changes, function(key,value) { jQuery('#inline_'+key+' .menu_order').html(value); });
jQuery.post( ajaxurl, { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function(response){
jQuery.each(response, function(key,value) { jQuery('#inline_'+key+' .menu_order').html(value); });
ui.item.find('.check-column input').show().siblings('img').remove();
jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','move');
jQuery("table.widefat tbody").sortable('enable');
});
// fix cell colors
jQuery( 'table.widefat tbody tr' ).each(function(){
var i = jQuery('table.widefat tbody tr').index(this);

View File

@ -350,19 +350,21 @@ jQuery( function($){
$.post( woocommerce_writepanel_params.ajax_url, data, function( response ) {
result = jQuery.parseJSON( response );
if ( response ) {
$items.each( function() {
var $row = $(this);
var item_id = $row.find('input.order_item_id').val();
$items.each( function() {
var $row = $(this);
var item_id = $row.find('input.order_item_id').val();
$row.find('input.line_tax').val( result['item_taxes'][ item_id ]['line_tax'] ).change();
$row.find('input.line_subtotal_tax').val( result['item_taxes'][ item_id ]['line_subtotal_tax'] ).change();
$('#tax_rows').empty().append( result['tax_row_html'] );
} );
$row.find('input.line_tax').val( response['item_taxes'][ item_id ]['line_tax'] ).change();
$row.find('input.line_subtotal_tax').val( response['item_taxes'][ item_id ]['line_subtotal_tax'] ).change();
$('#tax_rows').empty().append( response['tax_row_html'] );
} );
$('#_order_tax').val( result['item_tax'] ).change();
$('#_order_shipping_tax').val( result['shipping_tax'] ).change();
$('#_order_tax').val( response['item_tax'] ).change();
$('#_order_shipping_tax').val( response['shipping_tax'] ).change();
}
$('.woocommerce_order_items_wrapper').unblock();
});
@ -791,7 +793,7 @@ jQuery( function($){
type: 'POST',
success: function( response ) {
var info = response;
if (info) {
$('input#_shipping_first_name').val( info.shipping_first_name );
$('input#_shipping_last_name').val( info.shipping_last_name );

File diff suppressed because one or more lines are too long