WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_AJAX::add_order_shipping() public WC 1.0

Add order shipping cost via ajax.

{} Это метод класса: WC_AJAX{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$result = WC_AJAX::add_order_shipping();

Код WC_AJAX::add_order_shipping() WC 4.7.0

<?php
public static function add_order_shipping() {
	check_ajax_referer( 'order-item', 'security' );

	if ( ! current_user_can( 'edit_shop_orders' ) ) {
		wp_die( -1 );
	}

	$response = array();

	try {
		$order_id = isset( $_POST['order_id'] ) ? absint( $_POST['order_id'] ) : 0;
		$order    = wc_get_order( $order_id );

		if ( ! $order ) {
			throw new Exception( __( 'Invalid order', 'woocommerce' ) );
		}

		$order_taxes      = $order->get_taxes();
		$shipping_methods = WC()->shipping() ? WC()->shipping()->load_shipping_methods() : array();

		// Add new shipping.
		$item = new WC_Order_Item_Shipping();
		$item->set_shipping_rate( new WC_Shipping_Rate() );
		$item->set_order_id( $order_id );
		$item_id = $item->save();

		ob_start();
		include __DIR__ . '/admin/meta-boxes/views/html-order-shipping.php';
		$response['html'] = ob_get_clean();
	} catch ( Exception $e ) {
		wp_send_json_error( array( 'error' => $e->getMessage() ) );
	}

	// wp_send_json_success must be outside the try block not to break phpunit tests.
	wp_send_json_success( $response );
}