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 :: many isset posts 
Php :: what does php stand for 
Php :: convert php code to html online 
Php :: php printf percent sign 
Php :: Laravel Eloquent sum of multiplied columns 
Php :: laravel creating_table_name 
Php :: Laravel - Controller get select value from Views 
Php :: Drupal 9 loop term objects to retrieve term data (id, name, uuid) 
Php :: laravel faker car plate br 
Php :: how to convert array into json php 
Php :: PHP soundex — Calculate the soundex key of a string 
Php :: php range from one 
Php :: laravel ffmpeg color filter effects 
Php :: switch php version ubuntu 20.04 site:stackoverflow.com 
Php :: var_dump-type and value of expresion 
Php :: plesk change php version 
Php :: how to print * symbol in c++ 
Php :: Number in English Words (Indian format) php 
Php :: schema key issue laravel 
Php :: get datetime of excel cell in codeigniter 
Php :: how do i implement blockchain payments on laravel website 
Php :: wordpress microformats vs. schema.org 
Php :: Settings pages are created like this: 
Php :: utf8 decode 
Php :: search bar php progress 
Php :: wordpress not recognizing function during plugin activation 
Php :: Comment ajouter un fil d’Ariane personnalisé à l’URL d’accueil dans WooCommerce 
Php :: laravel migration softdelete 
Php :: print select sql result in php 
Php :: undefined variable require_once 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =