Как отключить отправку информации о весе товара в Google for WooCommerce?

Как отключить отправку информации о весе товара в плагине Google for WooCommerce (shipping_weight)? Или отключить отправку информации о весе товара, если он указан 0.

Можно ли удалить часть кода в плагине, чтобы сделать это?
Если я правильно понял, за это отвечает файл
wp-content/plugins/google-listings-and-ads/src/Product/WCProductAdapter.php

Участок
/**
     * Map the shipping information for WooCommerce product.
     *
     * @return $this
     */
    protected function map_wc_product_shipping(): WCProductAdapter {
        $this->add_shipping_country( $this->getTargetCountry() );
 
        if ( ! $this->is_virtual() ) {
            $dimension_unit = apply_filters( 'woocommerce_gla_dimension_unit', get_option( 'woocommerce_dimension_unit' ) );
            $weight_unit    = apply_filters( 'woocommerce_gla_weight_unit', get_option( 'woocommerce_weight_unit' ) );
 
            $this->map_wc_shipping_dimensions( $dimension_unit )
                ->map_wc_shipping_weight( $weight_unit );
        }
 
        // Set the product's shipping class slug as the shipping label.
        $shipping_class = $this->wc_product->get_shipping_class();
        if ( ! empty( $shipping_class ) ) {
            $this->setShippingLabel( $shipping_class );
        }
 
        return $this;
    }


Создал файл с таким кодом, но он не работает

<?php
/**
 * Plugin Name: WooCommerce - Hide product shipping
 */
 
add_filter( 'map_wc_shipping_weight', '__return_false' );
  • Вопрос задан
  • 10 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы