Automattic\WooCommerce\StoreApi\Schemas\V1\Agentic
CheckoutSessionSchema::format_fulfillment_options_from_order
Format fulfillment options from order.
Method of the class: CheckoutSessionSchema{}
No Hooks.
Returns
Array. Fulfillment options.
Usage
// protected - for code of main (parent) or child class $result = $this->format_fulfillment_options_from_order( $order );
- $order(WC_Order) (required)
- Order object.
CheckoutSessionSchema::format_fulfillment_options_from_order() CheckoutSessionSchema::format fulfillment options from order code WC 10.7.0
protected function format_fulfillment_options_from_order( $order ) {
$options = [];
$shipping_methods = $order->get_shipping_methods();
foreach ( $shipping_methods as $item ) {
$options[] = [
'type' => FulfillmentType::SHIPPING,
'id' => $item->get_method_id() . ':' . $item->get_instance_id(),
'title' => $item->get_name(),
'subtitle' => null,
'carrier' => $item->get_method_id(),
'earliest_delivery_time' => null,
'latest_delivery_time' => null,
'subtotal' => $this->amount_to_cents( $item->get_total() ),
'tax' => $this->amount_to_cents( $item->get_total_tax() ),
'total' => $this->amount_to_cents( $item->get_total() + $item->get_total_tax() ),
];
}
return $options;
}