Solved

Wordpress WooCommerce Core Functions

Posted on 2014-04-29
2
494 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now