Solved

Wordpress WooCommerce Core Functions

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

785 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