Can I override a PHP Function that is called in another file/plugin?

First of, I have read “Override default php function” and namespaces doesn’t fulfil my need. I have also looked into PHP.net’s override_function() but that can’t help me with my problem either.

I am using a WordPress plugin called Jigoshop as an eCommerce solution but in some cases I cannot remove the actions I need to apply my own structure to a ‘single product’ page. I do not want to edit the plugin files themselves as a plugin update may negate and remove my previous changes. Essentially, I want to control the output through my /themes/mytheme/functions.php file.

Read More

Has anyone come across this before whereby the original function is contained in a file I do not want to edit for that same ‘updating’ reason?

Thanks

EDIT (2012-11-21):
I have a custom function in my functions.php file like so:

function prepare_jigoshop_wrappers() {
    remove_action('jigoshop_before_main_content', 'jigoshop_breadcrumb', 20);
    add_action('jigoshop_before_main_content', 'custom_jigoshop_breadcrumb', 10);
}
add_action('wp_head', 'prepare_jigoshop_wrappers');

This essentially allows me to apply my own structure & configuration. For other default functions, it is a little more difficult. For example, the ‘quantity selector’, ‘Add to Cart’ button and ‘stock availability’ all are contained within a function called jigoshop_template_single_summary in the jigoshop_template_actions.php file calling the likes of _title, _price, _excerpt, _meta, _sharing & _add_to_cart.

The order these are displayed, I cannot seem to change. Therefore, I want to essentially redefine function jigoshop_template_single_summary() {...}

Related posts

Leave a Reply

2 comments

  1. I don’t know this plugin very well but probably this is what you Need Theming with Jigoshop

    Override some functions in php(also in common..) is never a good idea. If the plugin doesn’t provide a way to hook into it’s functionality is sometimes better to use an alternative plugin or rewrite the core code..