Removing the parent functions from executing

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.

Read More

My questions are…..

  1. what extra code do I add to the child theme funtion.php file?

and

  1. 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;   
  }

Related posts

1 comment

  1. You will need to write something like this in the child theme function.php to overwrite any code in Avada/includes/woo-config.php

        add_action('init','remove_avada_product_stock'); 
        function remove_avada_product_stock() {
          global $avada_woocommerce;
          remove_action( 'woocommerce_single_product_summary',  array(     $avada_woocommerce, 'avada_woocommerce_stock_html' ) , 10 ); /* To remove stock quantity in avada */
          /*you can also write other hooks and filters here */
        }
    

Comments are closed.