Поддержка WooCommerce Метод доставки не отображается в заказе

  • Доброго времени.

    Прошу помощи. Возникла необходимость добавить свой метод доставки. Сделал заготовку плагина для метода «Ракета», но при оформлении заказа его нет. В админке вижу его, в зону добавил, а на фронте нет.
    В тех примерах что нашел (по сути их всего 3, остальное копипаст):

    https://code.tutsplus.com/ru/tutorials/create-a-custom-shipping-method-for-woocommerce—cms-26098

    https://misha.agency/woocommerce/sozdanie-plagina-dostavki.html#WC_Shipping_Method

    https://www.tychesoftwares.com/creating-a-new-shipping-method-and-exploring-the-shipping-method-api-of-woocommerce/

    об этой проблеме ни слова, вроде как должен появиться при оформлении. Скриншоты тут:
    https://cloud.mail.ru/public/xmpP/NgcaBEDaK
    https://cloud.mail.ru/public/obv8/EiaDDsFmz
    https://cloud.mail.ru/public/CxS7/dUcN8VLBG

    Что я сделал не так, чего не хватает? Подскажите пожалуйста. Код плагина ниже, функция is_available($package) для простоты всегда возвращает true. Аналогично calculate_shipping всегда возвращает 100. Параметры сайта: WP 5.9.3, тема Storefront, WC — 5.7.2. На тестовом сайте с последней версией WC результат такой же.

    <?php
    
    /**
     * Plugin Name: Rocket Delivery
     * Description: Custom Shipping Method for WooCommerce
     * Version: 1.0.0
     * Author: IronSoft
     * License: Free
     */
    
    if ( ! defined( 'WPINC' ) ) {
        die;
    }
    
    // Check if WooCommerce is active
    if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
        die;
    }
    
        function rocket_shipping_method() {
            if ( ! class_exists( 'Rocket_Shipping_Method' ) ) {
                class Rocket_Shipping_Method extends WC_Shipping_Method {
                   
                    public function __construct() {
                        $this->id                 = 'rocket_delivery';
                        $this->method_title       = 'Доставка "Ракета"';
                        $this->method_description = 'Доставка курьером компании "Ракета"';
                        $this->supports              = array(
                            'shipping-zones',
                            'instance-settings',
                            'settings',
                            'instance-settings-modal',
                        );
                        $this->init();
                        $this->enabled = isset( $this->settings['enabled'] ) ? $this->settings['enabled'] : 'yes';
                        $this->title = isset( $this->settings['title'] ) ? $this->settings['title'] : 'Доставка "Ракета"';
                    }
    
                    // инициализирует настройки плагина
                    function init() {
                        // Load the settings API
                       $this->init_form_fields();
                       $this->init_settings();
    
                        // Save settings in admin if you have any defined
                        add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
                    }
    
                    public function is_available( $package ) {
                          return true;
                    }
    
                    // определяет поля настройки для метода
                     
                    function init_form_fields() {
    
                        $this->form_fields = array(
    
                            'enabled' => array(
                                'title' => 'Включить',
                                'type' => 'checkbox',
                                'description' => 'Включить метод доставки.',
                                'default' => 'yes'
                            ),
    
                            'title' => array(
                                'title' => 'Заголовок',
                                'type' => 'text',
                                'description' => 'Заголовок для отображения',
                                'default' => 'Доставка "Ракета"',
                            ),
    
                        );
                    }
    
                    // This function is used to calculate the shipping cost. 
                    public function calculate_shipping( $package = array()) {
    
                        $this->add_rate( array(
                            'id'    => $this->id . $this->instance_id,
                            'label' => $this->title,
                            'cost'  => 100,
                        ) );
                    }
                } 
            }
        }
    
        add_action( 'woocommerce_shipping_init', 'rocket_shipping_method' );
    
        function add_rocket_shipping_method( $methods ) {
            $methods['rocket_delivery'] = 'Rocket_Shipping_Method';
            //var_dump($methods);
            return $methods;
        }
    
        add_filter( 'woocommerce_shipping_methods', 'add_rocket_shipping_method' );
    
  • Тема «Метод доставки не отображается в заказе» закрыта для новых ответов.