Prevent possible PHP warnings produced by 'woocommerce_ajax_order_items_removed' hook (#37178)
* Remove superfluous check. * Prevent PHP warnings in `woocommerce_ajax_order_items_removed` * Add changelog
This commit is contained in:
parent
6f757f8991
commit
b19ad2f6d7
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: tweak
|
||||||
|
|
||||||
|
Prevent 'woocommerce_ajax_order_items_removed' from generating PHP warnings.
|
|
@ -1315,7 +1315,7 @@ class WC_AJAX {
|
||||||
'city' => isset( $_POST['city'] ) ? wc_strtoupper( wc_clean( wp_unslash( $_POST['city'] ) ) ) : '',
|
'city' => isset( $_POST['city'] ) ? wc_strtoupper( wc_clean( wp_unslash( $_POST['city'] ) ) ) : '',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! is_array( $order_item_ids ) && is_numeric( $order_item_ids ) ) {
|
if ( is_numeric( $order_item_ids ) ) {
|
||||||
$order_item_ids = array( $order_item_ids );
|
$order_item_ids = array( $order_item_ids );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,6 +1332,10 @@ class WC_AJAX {
|
||||||
$item_id = absint( $item_id );
|
$item_id = absint( $item_id );
|
||||||
$item = $order->get_item( $item_id );
|
$item = $order->get_item( $item_id );
|
||||||
|
|
||||||
|
if ( ! $item ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Before deleting the item, adjust any stock values already reduced.
|
// Before deleting the item, adjust any stock values already reduced.
|
||||||
if ( $item->is_type( 'line_item' ) ) {
|
if ( $item->is_type( 'line_item' ) ) {
|
||||||
$changed_stock = wc_maybe_adjust_line_item_product_stock( $item, 0 );
|
$changed_stock = wc_maybe_adjust_line_item_product_stock( $item, 0 );
|
||||||
|
@ -1363,7 +1367,7 @@ class WC_AJAX {
|
||||||
* @param bool|array|WP_Error $changed_store Result of wc_maybe_adjust_line_item_product_stock().
|
* @param bool|array|WP_Error $changed_store Result of wc_maybe_adjust_line_item_product_stock().
|
||||||
* @param bool|WC_Order|WC_Order_Refund $order As returned by wc_get_order().
|
* @param bool|WC_Order|WC_Order_Refund $order As returned by wc_get_order().
|
||||||
*/
|
*/
|
||||||
do_action( 'woocommerce_ajax_order_items_removed', $item_id, $item, $changed_stock, $order );
|
do_action( 'woocommerce_ajax_order_items_removed', $item_id ?? 0, $item ?? false, $changed_stock ?? false, $order );
|
||||||
|
|
||||||
// Get HTML to return.
|
// Get HTML to return.
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
Loading…
Reference in New Issue