This is a Developer level doc. We are unable to provide support for customizations under our Support Policy. See guide on adding PHP code without editing files.
API Version: 2
With API v2 of CoCart, the totals are not formatted automatically as per users feedback but for some, they wanted to keep it the same as before.
So use this snippet and the totals will be formatted like version 1.
<?php add_filter( 'cocart_cart', 'cocart_totals_html' ); function cocart_totals_html( $cart ) { $decimals = wc_get_price_decimals(); foreach( $cart['totals'] as $total => $value ) { $value = substr_replace( $value, '', intval( '-' . $decimals ) ); $cart['totals'][$total] = html_entity_decode( strip_tags( wc_price( $value ) ) ); } return $cart; }
Was this helpful to you?
Did you like the article/guide or would you like to give some feedback? Click on one of the buttons and let us know your opinion!