?
Solved

Overwrite Wordpress Function

Posted on 2014-09-10
5
Medium Priority
?
333 Views
Last Modified: 2014-09-25
I want to overwrite / replace a Wordpress, WooCommerce function.

This is what I have:
class WC_Meta_Box_Order_Items {

	/**
	 * Output the metabox
	 */
	public static function output( $post ) {
		global $thepostid, $theorder;

		if ( ! is_object( $theorder ) ) {
			$theorder = wc_get_order( $thepostid );
		}

		$order = $theorder;
		$data  = get_post_meta( $post->ID );

		include( 'views/html-order-items.php' );
	}
}

Open in new window


I want to replace:       public static function output( $post ) {
with:       public static function myPersonalOutput( $post ) {
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
5 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40315416
Where is this class defined?
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 664 total points
ID: 40315581
Jason can give you more of the details.  The theory is that you would extend the WC_Meta_Box_Order_Items class and add your own output() method.
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 668 total points
ID: 40315978
The theory is that you would extend the WC_Meta_Box_Order_Items class and add your own output() method.

Uh, maybe.  Depends on where that function lives...if it's part of the WooCommerce core package and you simply extend it, the changes will get blown away when WooCommerce updates (which they do a few times a year).  This is one of those questions where there is an actual "WordPress" way to do it but I need more information to give an actual, correct answer.

What I'm thinking is the output() function should be hook-able but not everything is....
0
 
LVL 18

Assisted Solution

by:Hube02
Hube02 earned 668 total points
ID: 40316754
More information is definitely needed, are you trying to change the template used for displaying the order, that's built into WooCommerce? If you need to change or add meta values then get_post_meta is hookable. There may also be hooks in WooCommerce that you can use to do what you need. Like others have commented, without knowing why you want to replace the class it's hard to find a solution that works within WP without hacks that will cause problems when you update WP or WC.
0
 
LVL 7

Author Comment

by:rgranlund
ID: 40317296
Ultimately what I am trying to do is to "hook" in from outside of WooCommerce through a custom-functions.php and replace this line:
include( 'views/html-order-items.php' );

with:
includes('MY_DIRECTORY/views/html-order-items.php');
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 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