WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Woocommerce Tweak Classes With Filters and Hooks (2 posts)

  1. nscdde
    Member
    Posted 11 months ago #

    I'm developing a woocommerce custom extension to a customer requested me with some functionallities.

    I need override some functions inside the class_wc_order.php file, but i don't want edit the file directly, i want do it through an extension or well as function in the theme.

    This is the idea:

    <?php
    require_once(ABSPATH .'wp-content/plugins/woocommerce/classes/class-wc-order.php');

    class WC_Order_Custom extends WC_Order{

    public function __construct( $id = '' ) {
    parent::__construct( $id = '' );
    }

    public function reduce_order_stock(){
    // code goes here
    }

    }

    My intention is, use the reduce_order_stock function that i created instead the original, at the moment to generate the orders, but i'm stucked there, i need figure out it soon.
    How can i do it with filters and actions?

    Thankyou for your help and time.

  2. nscdde
    Member
    Posted 11 months ago #

    Finally i found the answer, i didn't need replace the function, just add another new after the reduce stock function with the hook, reduce_order_stock action.

    By the way, thanks

Reply

You must log in to post.

About this Topic