Solved

Wordpress WooCommerce Core Functions

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Amazon Redshift 2 24
What is the best PDF generator to use? 1 23
wordpress display sub menu only when click 12 18
Help Extract Specific in SQL 8 16
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

930 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

13 Experts available now in Live!

Get 1:1 Help Now