I have this shopkeeper running in Wordpress. And I want to change the colon to parentheses but it gets weird , I don't want spaces between it just like this " (€5,50).
I've been trying to fix this problem for almost a day.
really hope to see any answers.
here is the html : gyazo.com/f05c00f01d2522aa962d90f5c0fcc5ea
method function :
function wc_cart_totals_shipping_method_label( $method ) {
$label = $method->label;
if ( $method->cost > 0 ) {
if ( WC()->cart->tax_display_cart == 'excl' ) {
$label .= ': ' . wc_price( $method->cost );
if ( $method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax ) {
$label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
} else {
$label .= '(' . wc_price( $method->cost + $method->get_shipping_tax() ).')';
if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) {
$label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
}
}
} elseif ( $method->id !== 'free_shipping' ) {
$label .= ' (' . __( 'Free', 'woocommerce' ) . ')';
}
return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );
}
code where I print :
<select name="shipping_method[<?php echo $index; ?>]" data-index="<?php echo $index; ?>" id="shipping_method_<?php echo $index; ?>" class="shipping_method">
<?php foreach ( $available_methods as $method ) : ?>
<option value="<?php echo esc_attr( $method->id ); ?>" <?php selected( $method->id, $chosen_method ); ?>><?php echo wp_kses_post( wc_cart_totals_shipping_method_label( $method ) ); ?></option>
<?php endforeach; ?>
</select>
Before the result try to add this:
$label = '(€'.preg_replace("/\([\s]+?/", "", str_replace(array('€', ' '), '', $label));
First use str_replace to remove html entities, seconds use a regex to remove all whitespaces after the ( and finally append at the start of the string "(€"