I needed to make changes to the cart hooks ( ‘You Have %d Item In Your List’, ‘Avada’ ) in the Avada/includes/woo-config.php.
To avoid my changes getting removed, if the theme is updated, I copied the code, with my changes, (see below) into my child theme function.php file.
My questions are…..
- what extra code do I add to the child theme funtion.php file?
and
- where do I place it to stop the action from the Avada woo-config.php file from functioning now that I have it in my child function.php file.
The copied code below is what I now have in my child theme funtion.php file.
It has the changes I need but does not work due to the unaltered code in the woo-config.php being used by wordpress first.
/* cart hooks */
add_action( 'woocommerce_before_cart_table', 'avada_woocommerce_before_cart_table', 20 );
function avada_woocommerce_before_cart_table( $args ) {
global $woocommerce;
$html = '<div class="woocommerce-content-box full-width clearfix">';
if ( $woocommerce->cart->cart_contents_count == 1 ) {
$html .= '<h2>' . sprintf( __( 'You Have %d Item In Your List', 'Avada' ), $woocommerce->cart->cart_contents_count ) . '</h2>';
} else {
$html .= '<h2>' . sprintf( __( 'You Have %d Items In Your List', 'Avada' ), $woocommerce->cart->cart_contents_count ) . '</h2>';
}
echo $html;
}
You will need to write something like this in the child theme function.php to overwrite any code in Avada/includes/woo-config.php