• Resolved Kasp

    (@kasp)


    Hi,

    The Flat Rate, Local Pickup and Free Shipping methods are missing from the dropdowns when we are trying to add them to a shipping zone.

    We’ve been running our site for 4 months. When we have first set up woocommerce they were working correctly. Now for some reason they are gone. Please see this image:

    The list is empty.

    We are also using custom shipping methods, which were working correctly with these default ones. Normally our custom shipping methods don’t support shipping zones, but if I set them to support shipping zones they appear in this dropdown, the default shipping methods don’t appear there anymore in any case.

    Is there anything I can do to find out why they are missing? Engineer-level suggestions are welcome. It may be that we’re just missing a setting, but I think it’s some plugins that don’t play well with each other.

    Thank you for any tips.

    WP: 4.9.8
    WooCommerce: 3.4.4

    Plugins:

    WPML Multilingual CMS by OnTheGoSystems – 4.0.5
    Advanced Custom Fields Multilingual by OnTheGoSystems – 0.8
    BackWPup by Inpsyde GmbH – 3.6.0
    Contact Form 7 by Takayuki Miyoshi – 5.0.3
    Customer Chat for Facebook by Sam Carlton – 1.0.3.2
    Duplicator by Snap Creek – 1.2.40
    Google Tag Manager for WordPress by Thomas Geiger – 1.8.1
    EU Cookie Law by Alex Moss, Marco Milesi, Peadig, Shane Jones – 3.0.5
    Facebook for WooCommerce by Facebook – 1.9.5 – Not tested with the active version of WooCommerce
    Facebook Widget by Milap Patel – 4.2.2
    Hide Admin Bar by Shelby DeNike – 0.3.9.3
    IgniteUp by Ceylon Systems – 3.3
    Invisible reCaptcha by Mihai Chelaru – 1.2.1
    WPBakery Page Builder by Michael M – WPBakery.com – 5.4.7
    Woocommerce Products Price Bulk Edit by Mostafa Qanbari – 2.0 – Not tested with the active version of WooCommerce
    Multiple POS System by Rohit Sharma – 1.0.0
    Nasa Core by NasaTheme – 1.2.10
    Ninja Tables by WPManageNinja – 2.3.4
    OneSignal Push Notifications by OneSignal – 1.16.7
    Product Watermark for WooCommerce by BeRocket – 1.2
    Slider Revolution by ThemePunch – 5.4.7.2
    Skill Bars by Themepoints – 1.1
    Smartie Estimated Shipping by Miroslav Kaspar – 1.0.0 – Not tested with the active version of WooCommerce
    Smartie Shipping by Miroslav Kaspar – 1.0.0 – Not tested with the active version of WooCommerce
    TinyMCE Advanced by Andrew Ozz – 4.8.0
    WC Custom Thank You by Nicola Mustone – 1.2.1
    WooCommerce Product Feed by WebAppick – 2.2.19
    WooCommerce GoPay woo by woo – 1.1 – Not tested with the active version of WooCommerce
    WooCommerce Notification by Andy Ha (villatheme.com) – 1.2.1.4.2 – Not tested with the active version of WooCommerce
    WooCommerce international phone input by Alex Masliychuk (alex91ckua) – 1.4.5 – Not tested with the active version of WooCommerce
    Woo Product Slider and Carousel with category by WP Online Support – 1.2.1 – Not tested with the active version of WooCommerce
    Woocomerce Checkout Validate by Pixeltoweb ([email protected]) – 1.0.0
    WooCommerce PayPal Checkout Gateway by WooCommerce – 1.6.2
    WooCommerce Stripe Gateway by WooCommerce – 4.1.8
    WooCommerce Gateways Country Limiter by OnTheGoSystems – 1.4 – Not tested with the active version of WooCommerce
    WooCommerce Google Analytics Integration by WooCommerce – 1.4.4 – Not tested with the active version of WooCommerce
    WooCommerce Sales MIS Report by Infosoft Consultant – 3.4
    WooCommerce Multilingual by OnTheGoSystems – 4.3.4
    WooCommerce PDF Invoices & Packing Slips by Ewout Fernhout – 2.1.10
    Woocommerce Payment Gateway Per Product by Dreamfox Media – 2.5.2 – Not tested with the active version of WooCommerce
    WooCommerce by Automattic – 3.4.4
    WooDiscuz – WooCommerce Comments by gVectors Team (A. Chakhoyan, G. Zakaryan, H. Martirosyan) – 2.2.1 – Not tested with the active version of WooCommerce
    Yoast SEO by Team Yoast – 8.0
    WP Attachment Export by Peter Harlacher – 0.3.3
    WP Instagram Widget by Scott Evans – 2.0.3
    WP Konami Code by Yslo – 1.0.2
    WP Mail SMTP by WPForms – 1.3.3
    WP Product Feed Manager by Michel Jongbloed – 1.9.4
    WPML CMS Nav by OnTheGoSystems – 1.4.23
    WPML Media by OnTheGoSystems – 2.3.5
    WPML Sticky Links by OnTheGoSystems – 1.4.4
    WPML String Translation by OnTheGoSystems – 2.8.5
    WPML Translation Management by OnTheGoSystems – 2.6.5
    YITH WooCommerce Brands Add-on by Yithemes – 1.2.2
    YITH WooCommerce Compare by YITHEMES – 2.3.1
    YITH WooCommerce Featured Video by YITHEMES – 1.1.17 – Not tested with the active version of WooCommerce
    YITH WooCommerce Product Bundles by YITHEMES – 1.1.7
    YITH WooCommerce Wishlist by YITHEMES – 2.2.3

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Kasp

    (@kasp)

    It seems like this part, which generates the dropdown items:

    foreach ( WC()->shipping->load_shipping_methods() as $method ) {
        if ( ! $method->supports( 'shipping-zones' ) ) {
          continue;
        }
        echo '<option data-description="' . esc_attr( wp_kses_post( wpautop( $method->get_method_description() ) ) ) . '" value="' . esc_attr( $method->id ) . '">' . esc_attr( $method->get_method_title() ) . '</li>';
    }

    …does only get the custom shipping methods from WC()->shipping->load_shipping_methods(), no Flat Rate, Free Shipping or Local Pickup is in the returned array.

    Thread Starter Kasp

    (@kasp)

    It seems like there’s a problem with WC::load_shipping_methods(), because it expects a $package = array() argument and then there’s a condition:

    if ( ! empty( $package ) ) {
        // ...
    } else {
        $this->shipping_methods = array();
    }

    Because WC()->shipping->load_shipping_methods() is called without argument, the default shipping methods get always erased from the array within the else block.

    Location: WC::load_shipping_methods() in /wp-content/plugins/woocommerce/includes/class-wc-shipping.php at 152

    Thread Starter Kasp

    (@kasp)

    Hm nope, the default shipping methods are hardcoded in WC::get_shipping_method_class_names() and this one is called AFTER the above.

    In WC::get_shipping_method_class_names() the $shipping_methods array contains the default shipping methods before the return. But it seems like in WC::load_shipping_methods() the return value of WC::get_shipping_method_class_names() does not contain the default shipping methods anymore, just our custom ones.

    So perhaps the default shipping methods are lost somewhere in: apply_filters( 'woocommerce_shipping_methods', $shipping_methods )

    • This reply was modified 6 years, 3 months ago by Kasp.
    Thread Starter Kasp

    (@kasp)

    Okay, the woocommerce_shipping_methods hook is what we are using to load our custom shipping methods. I thought maybe we are simply somehow overriding the default shipping methods with our custom ones.

    I went to our custom shipping methods plugin’s code and checked what’s there:

    function add_custom_shipping_methods($methods) {
        return SmartieShipping::gI()->allShippingMethods();
    }
     
    add_filter( 'woocommerce_shipping_methods', 'add_custom_shipping_methods' );

    I realized the $methods argument contains an array of default shipping methods loaded before this hook and any custom shipping methods are supposed to be attached to this array.

    Perhaps someone somewhen changed this to return just our custom shipping methods from allShippingMethods().

    Changing the return line to the following made the default shipping methods available again:
    return array_merge($methods, SmartieShipping::gI()->allShippingMethods());

    This problem is now resolved.

    Thread Starter Kasp

    (@kasp)

    PS: The missing image from the first post: https://pasteall.org/pic/show.php?id=097f257a85f091df99bd93082802b97f

    • This reply was modified 6 years, 3 months ago by Kasp.
    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    @kasp,

    Glad to hear you’ve figured this out. I’ll go ahead and mark this as resolved. If you have any further questions, feel free to start a new thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Flat Rate, Free Shipping and Local Pickup missing’ is closed to new replies.