Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Admin/Override...
File: OrderRefund.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WC Admin Order Refund
[2] Fix | Delete
*
[3] Fix | Delete
* WC Admin Order Refund class that adds some functionality on top of general WooCommerce WC_Order_Refund.
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
namespace Automattic\WooCommerce\Admin\Overrides;
[7] Fix | Delete
[8] Fix | Delete
defined( 'ABSPATH' ) || exit;
[9] Fix | Delete
[10] Fix | Delete
use Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore as CustomersDataStore;
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* WC_Order_Refund subclass.
[14] Fix | Delete
*/
[15] Fix | Delete
class OrderRefund extends \WC_Order_Refund {
[16] Fix | Delete
/**
[17] Fix | Delete
* Order traits.
[18] Fix | Delete
*/
[19] Fix | Delete
use OrderTraits;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Caches the customer ID.
[23] Fix | Delete
*
[24] Fix | Delete
* @var int
[25] Fix | Delete
*/
[26] Fix | Delete
public $customer_id = null;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Add filter(s) required to hook this class to substitute WC_Order_Refund.
[30] Fix | Delete
*/
[31] Fix | Delete
public static function add_filters() {
[32] Fix | Delete
add_filter( 'woocommerce_order_class', array( __CLASS__, 'order_class_name' ), 10, 3 );
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Filter function to swap class WC_Order_Refund for this one in cases when it's suitable.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $classname Name of the class to be created.
[39] Fix | Delete
* @param string $order_type Type of order object to be created.
[40] Fix | Delete
* @param number $order_id Order id to create.
[41] Fix | Delete
*
[42] Fix | Delete
* @return string
[43] Fix | Delete
*/
[44] Fix | Delete
public static function order_class_name( $classname, $order_type, $order_id ) {
[45] Fix | Delete
// @todo - Only substitute class when necessary (during sync).
[46] Fix | Delete
if ( 'WC_Order_Refund' === $classname ) {
[47] Fix | Delete
return '\Automattic\WooCommerce\Admin\Overrides\OrderRefund';
[48] Fix | Delete
} else {
[49] Fix | Delete
return $classname;
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Get the customer ID of the parent order used for reports in the customer lookup table.
[55] Fix | Delete
*
[56] Fix | Delete
* @return int|bool Customer ID of parent order, or false if parent order not found.
[57] Fix | Delete
*/
[58] Fix | Delete
public function get_report_customer_id() {
[59] Fix | Delete
if ( is_null( $this->customer_id ) ) {
[60] Fix | Delete
$parent_order = \wc_get_order( $this->get_parent_id() );
[61] Fix | Delete
[62] Fix | Delete
if ( ! $parent_order ) {
[63] Fix | Delete
$this->customer_id = false;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$this->customer_id = CustomersDataStore::get_or_create_customer_from_order( $parent_order );
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
return $this->customer_id;
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Returns null since refunds should not be counted towards returning customer counts.
[74] Fix | Delete
*
[75] Fix | Delete
* @return null
[76] Fix | Delete
*/
[77] Fix | Delete
public function is_returning_customer() {
[78] Fix | Delete
return null;
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function