| @@ 214-223 (lines=10) @@ | ||
| 211 | * @deprecated 2.6.0 Logic moved to constructor |
|
| 212 | * @param int|object|WC_Order $order Order to init. |
|
| 213 | */ |
|
| 214 | protected function init( $order ) { |
|
| 215 | _deprecated_function( 'init', '2.6', 'Logic moved to constructor' ); |
|
| 216 | if ( is_numeric( $order ) ) { |
|
| 217 | $this->read( $order ); |
|
| 218 | } elseif ( $order instanceof WC_Order ) { |
|
| 219 | $this->read( absint( $order->get_id() ) ); |
|
| 220 | } elseif ( isset( $order->ID ) ) { |
|
| 221 | $this->read( absint( $order->ID ) ); |
|
| 222 | } |
|
| 223 | } |
|
| 224 | ||
| 225 | /** |
|
| 226 | * Gets an order from the database. |
|
| @@ 105-113 (lines=9) @@ | ||
| 102 | * |
|
| 103 | * @param int|object|WC_Order $order Order to init. |
|
| 104 | */ |
|
| 105 | public function __construct( $order = 0 ) { |
|
| 106 | if ( is_numeric( $order ) ) { |
|
| 107 | $this->read( $order ); |
|
| 108 | } elseif ( $order instanceof WC_Order ) { |
|
| 109 | $this->read( absint( $order->get_id() ) ); |
|
| 110 | } elseif ( ! empty( $order->ID ) ) { |
|
| 111 | $this->read( absint( $order->ID ) ); |
|
| 112 | } |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Change data to JSON format. |
|
| @@ 33-42 (lines=10) @@ | ||
| 30 | * Get the refund if ID is passed, otherwise the refund is new and empty. |
|
| 31 | * @param int|object|WC_Order_Refund $refund Refund to init. |
|
| 32 | */ |
|
| 33 | public function __construct( $refund = 0 ) { |
|
| 34 | if ( is_numeric( $refund ) ) { |
|
| 35 | $this->read( $refund ); |
|
| 36 | } elseif ( $order instanceof WC_Order_Refund ) { |
|
| 37 | $this->read( $refund->get_id() ); |
|
| 38 | } elseif ( ! empty( $refund->ID ) ) { |
|
| 39 | $this->read( absint( $refund->ID ) ); |
|
| 40 | } |
|
| 41 | $this->set_order_type( 'refund' ); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Read from the database. |
|