Prazo de entrega por faixa de dias na tabela de frete offline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wc_table_shipping_rate', 'wcts_delivery_time_range', 10, 2 ); | |
function wcts_delivery_time_range( $rate, $raw ) { | |
$percentage = 60; | |
$value = intval( ( $percentage / 100 ) * $raw['delivery_time'] ); | |
$value = 0 >= $value ? 1 : $value; | |
if ( $value !== $rate['label'] ) { | |
$rate['label'] = str_replace( '{initial_days}', $value, $rate['label'] ); | |
} | |
return $rate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment