The following will displayed shipping total based on a percentage. There is 2 ways:
1) First way with a custom function.
In the function.php file of your active child theme (or active theme):
function wc_display_cart_shipping_total( $percentage = 100 )
{
$cart = WC()->cart;
$total = __( 'Free!', 'woocommerce' );
if ( 0 < $cart->get_shipping_total() ) {
if ( $cart->display_prices_including_tax() ) {
$total = wc_price( ( $cart->shipping_total + $cart->shipping_tax_total ) * $percentage / 100 );
if ( $cart->shipping_tax_total > 0 && ! wc_prices_include_tax() ) {
$total .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
}
} else {
$total = wc_price( $cart->shipping_total * $percentage / 100 );
if ( $cart->shipping_tax_total > 0 && wc_prices_include_tax() ) {
$total .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
}
}
return $totals;
}
Usage:
<?php echo wc_display_cart_shipping_total(50); ?>
2) Second way with a filter hook.
In the function.php file of your active child theme (or active theme):
add_filter( 'woocommerce_cart_shipping_total', 'woocommerce_cart_shipping_total_filter_callback', 11, 2 );
function woocommerce_cart_shipping_total_filter_callback( $total, $cart )
{
// HERE set the percentage
$percentage = 50;
if ( 0 < $cart->get_shipping_total() ) {
if ( $cart->display_prices_including_tax() ) {
$total = wc_price( ( $cart->shipping_total + $cart->shipping_tax_total ) * $percentage / 100 );
if ( $cart->shipping_tax_total > 0 && ! wc_prices_include_tax() ) {
$total .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
}
} else {
$total = wc_price( $cart->shipping_total * $percentage / 100 );
if ( $cart->shipping_tax_total > 0 && wc_prices_include_tax() ) {
$total .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
}
}
return $totals;
}
Usage:
<?php echo WC()->cart->get_cart_shipping_total(); ?>