Y
Y
Yan Aleksandrov2020-01-13 14:18:22
WooCommerce
Yan Aleksandrov, 2020-01-13 14:18:22

How to get shipping method data?

Good afternoon. You need to get the data of delivery methods on the checkout page (there is no order yet). So far I get this:
WC()->shipping->packages[0]['rates']
But it outputs:

[flat_rate:64] => WC_Shipping_Rate Object
        (
            [data:protected] => Array
                (
                    [id] => flat_rate:64
                    [method_id] => flat_rate
                    [instance_id] => 64
                    [label] => Москва по городу: Платная доставка при заказе менее 2000р
                    [cost] => 200
                    [taxes] => Array
                        (
                        )

                )

            [meta_data:protected] => Array
                (
                    [Позиции] => Товар
                )

        )

You need to get everything that is data:protected.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question