I got a few shipping methods set inside Woocommerce, as well as the shipping methods created with the plugins (Flexible Shipping plugin in particular).

How can I print the names and IDs of the methods in front end, so I can target those names in the functions?

What I want to achieve: under checkboxes with the front end name of the shipping method, I want to print backend names like so:

Free delivery

Standard Delivery

Local Pickup

Custom Delivery

/* and below */





I hope my explanation is clear enough ;)

I want to use it for excluding some payment gateways when the shipping method is selected - this code works just fine, but I don't know how to get the shipping ids from custom plugins...

// Disable Payment Gateway For Specific Shipping Method
function rd_gateway_disable_shipping_30($available_gateways) {

    global $woocommerce;

    if (!is_admin()) {

        $chosen_methods = WC()->session->get('chosen_shipping_methods');
        $chosen_shipping = $chosen_methods[0];

        // Remove pay on delivery when free shipping selected
        if (    isset($available_gateways['dotpay']) 
            &&  0 === strpos($chosen_shipping, 'flat_rate:3')
        ) {

        if (    isset($available_gateways['cod']) 
            &&  0 === strpos($chosen_shipping, 'flat_rate:4')
        ) {

    return $available_gateways;


add_filter('woocommerce_available_payment_gateways', 'rd_gateway_disable_shipping_30');
  • it can be clearer if you explain what you want to do with theses values ? if it's for debug purposes, you can find them in the HTML code of the checkboxes on the cart page. – mmm Jan 31 '18 at 22:46
  • Oh true, I've just updated my question. – Anda Jan 31 '18 at 22:57
  • 1
    it looks like the codes your are searching for are in the attribute "value" of radio buttons. – mmm Jan 31 '18 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.