Site icon Hip-Hop Website Design and Development

Override the plugin class and performance

hope any person might assist me. I’ve purchased one plugin. However I want to alter the perform of the plugin in my baby template features.php
Right here is the lessons and features of the plugin. I want to alter the perform “get_product_price” with my worth.

class TOP_Woo {
  public perform __construct() {
    ..
    ..
    $this->init_hook();
  }

  public perform init_hook() {
    add_filter( 'woocommerce_product_class', array( $this, 'my_product_class' ), 10, 4 );
  }

  public perform my_product_class( $classname, $product_type, $post_type, $product_id) {
    $classname = 'SUB_WC_Product';
    return $classname;
  }

  public perform load() {
    TOP_Woo::occasion();
  }

  public static perform occasion() {
    if ( ! self::$_instance ) {
      self::$_instance = new self();
    }
    return self::$_instance;
  }
}
add_action( 'plugins_loaded', array( 'TOP_Woo', 'load' ) );


international $woocommerce;
class SUB_WC_Product extends WC_Product_Simple {
  public perform __construct ( $product = 0 ) {
    $this->put up = get_post( $this->id );
  }

  public perform get_product_price( $context = 'view' ) {
    return "XY";
  }
}

Thanks! 🙂