Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wc php get shipping methods

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;

    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wc #php #shipping #methods
ADD COMMENT
Topic
Name
4+5 =