Refunds: Function logic and AJAX implementation
This commit is contained in:
parent
c2e1258d04
commit
9c5c033fcf
|
@ -406,6 +406,7 @@ function woocommerce_admin_scripts() {
|
|||
'remove_item_notice' => __( 'Are you sure you want to remove the selected items? If you have previously reduced this item\'s stock, or this order was submitted by a customer, you will need to manually restore the item\'s stock.', 'woocommerce' ),
|
||||
'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
|
||||
'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
|
||||
'refund_item_notice' => __( 'Are you sure you want to refund the selected items? The item\'s stock will not be affected.', 'woocommerce' ),
|
||||
'name_label' => __( 'Name', 'woocommerce' ),
|
||||
'remove_label' => __( 'Remove', 'woocommerce' ),
|
||||
'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
|
||||
|
|
|
@ -624,8 +624,32 @@ jQuery( function($){
|
|||
}
|
||||
|
||||
} else if ( action == 'refund' ) {
|
||||
|
||||
var order_id = $('#post_ID').val();
|
||||
|
||||
// @todo refund handling
|
||||
var answer = confirm( woocommerce_writepanel_params.refund_item_notice );
|
||||
|
||||
if ( answer ) {
|
||||
|
||||
$('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
|
||||
|
||||
var data = {
|
||||
order_id: order_id,
|
||||
order_item_ids: item_ids,
|
||||
action: 'woocommerce_refund_order_item',
|
||||
security: woocommerce_writepanel_params.order_item_nonce
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
url: woocommerce_writepanel_params.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
$('table.woocommerce_order_items').unblock();
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
} else if ( action == 'reduce_stock' ) {
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -945,6 +945,30 @@ function woocommerce_ajax_remove_order_item() {
|
|||
|
||||
add_action( 'wp_ajax_woocommerce_remove_order_item', 'woocommerce_ajax_remove_order_item' );
|
||||
|
||||
/**
|
||||
* woocommerce_ajax_refund_order_item function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function woocommerce_ajax_refund_order_item() {
|
||||
global $woocommerce, $wpdb;
|
||||
|
||||
check_ajax_referer( 'order-item', 'security' );
|
||||
|
||||
$order_item_ids = $_POST['order_item_ids'];
|
||||
|
||||
if ( sizeof( $order_item_ids ) > 0 ) {
|
||||
foreach( $order_item_ids as $id ) {
|
||||
woocommerce_refund_order_item( absint( $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_woocommerce_refund_order_item', 'woocommerce_ajax_refund_order_item' );
|
||||
|
||||
/**
|
||||
* woocommerce_ajax_reduce_order_item_stock function.
|
||||
*
|
||||
|
|
|
@ -1795,6 +1795,28 @@ function woocommerce_delete_order_item( $item_id ) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* woocommerce_refund_order_item function.
|
||||
*
|
||||
* @access public
|
||||
* @param int $item_id
|
||||
* @return bool
|
||||
*/
|
||||
function woocommerce_refund_order_item( $item_id ) {
|
||||
global $wpdb;
|
||||
|
||||
$item_id = absint( $item_id );
|
||||
|
||||
if ( ! $item_id )
|
||||
return false;
|
||||
|
||||
// @todo refund handling here
|
||||
|
||||
do_action( 'woocommerce_refund_order_item', $item_id );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* WooCommerce Order Item Meta API - Update term meta
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue