We help IT Professionals succeed at work.
Get Started

Woo Commerce Override Actions Functions

1,020 Views
Last Modified: 2014-05-02
I have a Wordpress Installation and am using Woo Commerce.  I want to change / Override one of the WooCommerce Public Functions.

add_action( 'woocommerce-product-addons_end', array( $this, 'totals' ), 10 );	
do_action( 'woocommerce-product-addons_end', $post_id );

public function totals( $post_id ) {

		global $product;

		if ( ! isset( $product ) || $product->id != $post_id )
			$the_product = get_product( $post_id );
		else
			$the_product = $product;

		echo '<div id="product-addons-total" data-type="' . $the_product->product_type . '" data-price="' . ( is_object( $the_product ) ? $the_product->get_price() : '' ) . '"></div>';
	}

Open in new window

BUT I'm not sure how to write it.  This is what I have so far but it shows both my action and the original.

add_action( 'woocommerce-product-addons_end', 'add_custom_price');
do_action( 'woocommerce-product-addons_end', 'add_custom_price');

function add_custom_price( $post_id ) {

		global $product;

			$the_product = $product;

		echo '<div id="CUSTOM-ID" data-type="' . $the_product->product_type . '" data-price="MY CUSTOM PRICE"></div>';
	}

Open in new window


Help?
Comment
Watch Question
Top Expert 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE