Skip to content

Instantly share code, notes, and snippets.

@fernandoacosta
Last active January 27, 2019 12:59
Embed
What would you like to do?
Prazo de entrega por faixa de dias na tabela de frete offline
<?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