woocommerce_shipping_method_add_rate_args
Add a shipping rate. If taxes are not set they will be calculated based on cost.
Использование
add_filter( 'woocommerce_shipping_method_add_rate_args', 'wp_kama_woocommerce_shipping_method_add_rate_args_filter', 10, 2 ); /** * Function for `woocommerce_shipping_method_add_rate_args` filter-hook. * * @param array $args Arguments . * @param $that * * @return array */ function wp_kama_woocommerce_shipping_method_add_rate_args_filter( $args, $that ){ // filter... return $args; }
- $args(массив)
- Arguments .
По умолчанию: array()) - $that
- -
Где вызывается хук
woocommerce_shipping_method_add_rate_args
woocommerce/includes/abstracts/abstract-wc-shipping-method.php 290-306
$args = apply_filters( 'woocommerce_shipping_method_add_rate_args', wp_parse_args( $args, array( 'id' => $this->get_rate_id(), // ID for the rate. If not passed, this id:instance default will be used. 'label' => '', // Label for the rate. 'cost' => '0', // Amount or array of costs (per item shipping). 'taxes' => '', // Pass taxes, or leave empty to have it calculated for you, or 'false' to disable calculations. 'calc_tax' => 'per_order', // Calc tax per_order or per_item. Per item needs an array of costs. 'meta_data' => array(), // Array of misc meta data to store along with this rate - key value pairs. 'package' => false, // Package array this rate was generated for @since 2.6.0. 'price_decimals' => wc_get_price_decimals(), ) ), $this );