“WC PHP Dapatkan metode pengiriman” Kode Jawaban

WC PHP Dapatkan metode pengiriman

function prefix_get_available_shipping_methods(){

        if ( ! class_exists( 'WC_Shipping_Zones' ) ) {
            return array();
        }

        $zones = WC_Shipping_Zones::get_zones();

        if ( ! is_array( $zones ) ) {
            return array();
        }

        $shipping_methods = array_column( $zones, 'shipping_methods' );

        $flatten = array_merge( ...$shipping_methods );

        $normalized_shipping_methods = array();

        foreach ( $flatten as $key => $class ) {
            $normalized_shipping_methods[ $class->id ] = $class->method_title;
        }

        return $normalized_shipping_methods;

    }
Weary Wildebeest

WC PHP Fungsi Pengiriman Gratis

function get_free_shipping_minimum($zone_name = 'England') {
    if ( ! isset( $zone_name ) ) return null;

    $result = null;
    $zone = null;

    $zones = WC_Shipping_Zones::get_zones();
    foreach ( $zones as $z ) {
        if ( $z['zone_name'] == $zone_name ) {
            $zone = $z;
        }
    }

    if ( $zone ) {
        $shipping_methods_nl = $zone['shipping_methods'];
        $free_shipping_method = null;
        foreach ( $shipping_methods_nl as $method ) {
            if ( $method->id == 'free_shipping' ) {
                $free_shipping_method = $method;
                break;
            }
        }

        if ( $free_shipping_method ) {
            $result = $free_shipping_method->min_amount;
        }
    }

    return $result;
}
Weary Wildebeest

Jawaban yang mirip dengan “WC PHP Dapatkan metode pengiriman”

Pertanyaan yang mirip dengan “WC PHP Dapatkan metode pengiriman”

Lebih banyak jawaban terkait untuk “WC PHP Dapatkan metode pengiriman” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya