| @@ 114-128 (lines=15) @@ | ||
| 111 | * |
|
| 112 | * @param int|object|WC_Order $order Order to init. |
|
| 113 | */ |
|
| 114 | protected function init( $order ) { |
|
| 115 | if ( is_numeric( $order ) ) { |
|
| 116 | $this->id = absint( $order ); |
|
| 117 | $this->post = get_post( $order ); |
|
| 118 | $this->get_order( $this->id ); |
|
| 119 | } elseif ( $order instanceof WC_Order ) { |
|
| 120 | $this->id = absint( $order->id ); |
|
| 121 | $this->post = $order->post; |
|
| 122 | $this->get_order( $this->id ); |
|
| 123 | } elseif ( isset( $order->ID ) ) { |
|
| 124 | $this->id = absint( $order->ID ); |
|
| 125 | $this->post = $order; |
|
| 126 | $this->get_order( $this->id ); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Remove all line items (products, coupons, shipping, taxes) from the order. |
|
| @@ 33-47 (lines=15) @@ | ||
| 30 | * @param string|int|object|WC_Order_Refund $refund Refund to init |
|
| 31 | * @uses WP_POST |
|
| 32 | */ |
|
| 33 | protected function init( $refund ) { |
|
| 34 | if ( is_numeric( $refund ) ) { |
|
| 35 | $this->id = absint( $refund ); |
|
| 36 | $this->post = get_post( $refund ); |
|
| 37 | $this->get_refund( $this->id ); |
|
| 38 | } elseif ( $refund instanceof WC_Order_Refund ) { |
|
| 39 | $this->id = absint( $refund->id ); |
|
| 40 | $this->post = $refund->post; |
|
| 41 | $this->get_refund( $this->id ); |
|
| 42 | } elseif ( isset( $refund->ID ) ) { |
|
| 43 | $this->id = absint( $refund->ID ); |
|
| 44 | $this->post = $refund; |
|
| 45 | $this->get_refund( $this->id ); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Gets an refund from the database. |
|