Automattic\WooCommerce\Blocks\Shipping

ShippingController::show_local_pickup_details()publicWC 1.0

Inject collection details onto the order received page.

Метод класса: ShippingController{}

Хуков нет.

Возвращает

Строку.

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

$ShippingController = new ShippingController();
$ShippingController->show_local_pickup_details( $return, $order );
$return(строка) (обязательный)
Return value.
$order(\WC_Order) (обязательный)
Order object.

Код ShippingController::show_local_pickup_details() WC 8.7.0

public function show_local_pickup_details( $return, $order ) {
	// Confirm order is valid before proceeding further.
	if ( ! $order instanceof \WC_Order ) {
		return $return;
	}

	$shipping_method_ids = ArrayUtil::select( $order->get_shipping_methods(), 'get_method_id', ArrayUtil::SELECT_BY_OBJECT_METHOD );
	$shipping_method_id  = current( $shipping_method_ids );

	// Ensure order used pickup location method, otherwise bail.
	if ( 'pickup_location' !== $shipping_method_id ) {
		return $return;
	}

	$shipping_method = current( $order->get_shipping_methods() );
	$details         = $shipping_method->get_meta( 'pickup_details' );
	$location        = $shipping_method->get_meta( 'pickup_location' );
	$address         = $shipping_method->get_meta( 'pickup_address' );

	if ( ! $address ) {
		return $return;
	}

	return sprintf(
		// Translators: %s location name.
		__( 'Collection from <strong>%s</strong>:', 'woocommerce' ),
		$location
	) . '<br/><address>' . str_replace( ',', ',<br/>', $address ) . '</address><br/>' . $details;
}