Automattic\WooCommerce\StoreApi\Schemas\V1\Agentic
CheckoutSessionSchema::format_fulfillment_options
Format fulfillment options (shipping methods).
Метод класса: CheckoutSessionSchema{}
Хуков нет.
Возвращает
Массив. Fulfillment options.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->format_fulfillment_options();
Код CheckoutSessionSchema::format_fulfillment_options() CheckoutSessionSchema::format fulfillment options WC 10.5.0
protected function format_fulfillment_options() {
$options = [];
$packages = WC()->shipping()->get_packages();
foreach ( $packages as $package ) {
if ( empty( $package['rates'] ) ) {
continue;
}
foreach ( $package['rates'] as $rate ) {
$options[] = [
'type' => FulfillmentType::SHIPPING,
'id' => $rate->get_id(),
'title' => $rate->get_label(),
'subtitle' => null,
'carrier' => $rate->get_method_id(),
'earliest_delivery_time' => null,
'latest_delivery_time' => null,
'subtotal' => $this->amount_to_cents( $rate->get_cost() ),
'tax' => $this->amount_to_cents( $rate->get_shipping_tax() ),
'total' => $this->amount_to_cents( $rate->get_cost() + $rate->get_shipping_tax() ),
];
}
}
return $options;
}