Override Plugin function in Theme file

Question

I am trying to override Dokan plugin to display more data in wp-admin list table column, the new output is:

function get_refund_reason(){
    global $wpdb;
    $reason = $wpdb->get_row("SELECT * FROM  wp_dokan_rma_request WHERE  `order_id` ='". $this->data['order_id'] ."'");
    return $this->data['refund_reason'] . " - ".  $reason->details;

Here is the existing code dokan-pro/includes/Refund/Refund.php

namespace WeDevsDokanProRefund;
    
use WP_Error;
use WeDevsDokanAbstractsDokanModel;

class Refund extends DokanModel {
    protected $data = [];

    public function __construct( $data = [] ) {
        $defaults = [
            'id'              => 0,
            'order_id'        => 0,
            'seller_id'       => 0,
            'refund_amount'   => 0,
            'refund_reason'   => '',
            'item_qtys'       => null,
            'item_totals'     => null,
            'item_tax_totals' => null,
            'restock_items'   => null,
            'date'            => current_time( 'mysql' ),
            'status'          => 0,
            'method'          => 'false',
        ];

        $data = wp_parse_args( $data, $defaults );

        $this->set_data( $data );
    }

    protected function set_data( $data ) {
        $data = wp_unslash( $data );

        $this->set_id( $data['id'] )
            ->set_order_id( $data['order_id'] )
            ->set_seller_id( $data['seller_id'] )
            ->set_refund_amount( $data['refund_amount'] )
            ->set_refund_reason( $data['refund_reason'] )
            ->set_item_qtys( $data['item_qtys'] )
            ->set_item_totals( $data['item_totals'] )
            ->set_item_tax_totals( $data['item_tax_totals'] )
            ->set_restock_items( $data['restock_items'] )
            ->set_date( $data['date'] )
            ->set_status( $data['status'] )
            ->set_method( $data['method'] );
    }

    public function get_refund_reason() {
        return $this->data['refund_reason'];
    }
}

Please advice

0
Tayssir Ch 4 months 0 Answers 16 views 0

Leave an answer