Search
 
SCRIPT & CODE EXAMPLE
 

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;

    }
Comment

wc php free shipping function

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;
}
Comment

PREVIOUS NEXT
Code Example
Php :: find in associative array php by property value 
Php :: symfony get locale from request in controller 
Php :: cannot be cast automatically to type integer laravel 
Php :: php split 
Php :: PHP - Elegant way of removing values from Associative Arrays based on a key value duplication 
Php :: woocommerce_product_is_on_sale filter 
Php :: check date is in the last 24 hours? 
Php :: PHP sprintf — Return a formatted string 
Php :: phpmailer 
Php :: php obfuscate email 
Php :: php array remove empty values recursive 
Php :: Create fake users on click laravel 
Php :: In QueryRecorder.php line 22: Argument 2 passed to FacadeIgnitionQueryRecorderQueryRecorder::__construct() must be of the type bool, null given, 
Php :: php get parent url from script location 
Php :: php receive request 
Php :: laravel where condition with if 
Php :: how to enable auto refresh on save laravel 
Php :: guzzle download file 
Php :: laravel index method 
Php :: read input from user 
Php :: php for loop stack overflow 
Php :: drupal get route current content type 
Php :: how to use or where in laravel 
Php :: Laravel unique cheque using multiple column 
Php :: wordpress run php code in page 
Php :: php-array-delete-by-value-not-key 
Php :: avatar generator laravel 
Php :: serve https with php local 
Php :: php in html need .htaccess 
Php :: randhex php 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =