Solved

Wordpress WooCommerce Core Functions

Posted on 2014-04-29
2
535 Views
Last Modified: 2014-05-06
I would like to edit a WooCommerce Core Function but am not 100% How to accomplish:

WooCommerce Function:
public function get_price_html( $price = '' ) {

if ( $this->get_price() > 0 ) {
				$price .= wc_price( $display_price ) . $this->get_price_suffix();

				$price = apply_filters( 'woocommerce_price_html', $price, $this );

			}
}

Open in new window


My Function:
add_filter('woocommerce_price_html', 'renderQuote', 10, 2);
function renderQuote()	{

	if(isset($_POST['get_quote'])) { // Handle the form.)
		$new_price = $price + 10;
		echo 'New Price'. $new_price;
	
	}
}

Open in new window


What I want to do is add 10 to the price.

Please let me know if you need more information.
0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Expert Comment

by:Rartemass
ID: 40031135
Quick question: Why do you want the core function to hard code a price increase instead of changing the list price for the product?
0
 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 40031656
You have two problems here:
- a filter must return something
- you have no parameters in your filter function, but in filter two parameters are defined
Change your function from:
add_filter('woocommerce_price_html', 'renderQuote', 10, 2);
function renderQuote()	{

	if(isset($_POST['get_quote'])) { // Handle the form.)
		$new_price = $price + 10;
		echo 'New Price'. $new_price;
	
	}
}

Open in new window

To:
add_filter( 'woocommerce_price_html', 'renderQuote', 10, 2 );
function renderQuote( $price, $product ) {

	if(isset($_POST['get_quote'])) { // Handle the form.)
		$new_price = $price + 10;
		//echo 'New Price'. $new_price;

		// a filter must return something
		return $new_price;
	}

}

Open in new window

0

Featured Post

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
The viewer will learn how to dynamically set the form action using jQuery.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question