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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-order-refund.php
woocommerce / includes Last commit date
abstracts 11 months ago admin 10 months ago blocks 1 year ago cli 11 months ago customizer 11 months ago data-stores 11 months ago emails 11 months ago export 1 year ago gateways 11 months ago import 11 months ago integrations 2 years ago interfaces 1 year ago legacy 1 year ago libraries 1 year ago log-handlers 1 year ago payment-tokens 5 years ago product-usage 1 year ago queue 4 years ago react-admin 11 months ago rest-api 10 months ago shipping 1 year ago shortcodes 11 months ago theme-support 2 years ago tracks 1 year ago traits 5 years ago walkers 5 years ago wccom-site 1 year ago widgets 1 year ago class-wc-ajax.php 11 months ago class-wc-auth.php 1 year ago class-wc-autoloader.php 1 year ago class-wc-background-emailer.php 5 years ago class-wc-background-updater.php 5 years ago class-wc-brands-brand-settings-manager.php 1 year ago class-wc-brands-coupons.php 1 year ago class-wc-brands.php 10 months ago class-wc-breadcrumb.php 5 years ago class-wc-cache-helper.php 1 year ago class-wc-cart-fees.php 2 years ago class-wc-cart-session.php 11 months ago class-wc-cart-totals.php 10 months ago class-wc-cart.php 11 months ago class-wc-checkout.php 1 year ago class-wc-cli.php 1 year ago class-wc-comments.php 11 months ago class-wc-countries.php 1 year ago class-wc-coupon.php 11 months ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 1 year ago class-wc-customer.php 11 months ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 3 years ago class-wc-datetime.php 4 years ago class-wc-deprecated-action-hooks.php 2 years ago class-wc-deprecated-filter-hooks.php 3 years ago class-wc-discounts.php 11 months ago class-wc-download-handler.php 1 year ago class-wc-emails.php 11 months ago class-wc-embed.php 1 year ago class-wc-form-handler.php 11 months ago class-wc-frontend-scripts.php 1 year ago class-wc-geo-ip.php 11 months ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 1 year ago class-wc-https.php 2 years ago class-wc-install.php 11 months ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 2 years ago class-wc-logger.php 1 year ago class-wc-meta-data.php 4 years ago class-wc-order-factory.php 2 years ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 1 year ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 1 year ago class-wc-order-item-shipping.php 1 year ago class-wc-order-item-tax.php 4 years ago class-wc-order-item.php 1 year ago class-wc-order-query.php 4 years ago class-wc-order-refund.php 1 year ago class-wc-order.php 11 months ago class-wc-payment-gateways.php 11 months ago class-wc-payment-tokens.php 3 years ago class-wc-post-data.php 1 year ago class-wc-post-types.php 1 year ago class-wc-privacy-background-process.php 1 year ago class-wc-privacy-erasers.php 1 year ago class-wc-privacy-exporters.php 4 years ago class-wc-privacy.php 11 months ago class-wc-product-attribute.php 4 years ago class-wc-product-download.php 2 years ago class-wc-product-external.php 1 year ago class-wc-product-factory.php 1 year ago class-wc-product-grouped.php 1 year ago class-wc-product-query.php 1 year ago class-wc-product-simple.php 1 year ago class-wc-product-variable.php 1 year ago class-wc-product-variation.php 1 year ago class-wc-query.php 1 year ago class-wc-rate-limiter.php 4 years ago class-wc-regenerate-images-request.php 3 years ago class-wc-regenerate-images.php 1 year ago class-wc-register-wp-admin-settings.php 4 years ago class-wc-rest-authentication.php 1 year ago class-wc-rest-exception.php 5 years ago class-wc-session-handler.php 10 months ago class-wc-shipping-rate.php 11 months ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 5 years ago class-wc-shipping.php 1 year ago class-wc-shortcodes.php 1 year ago class-wc-structured-data.php 1 year ago class-wc-tax.php 2 years ago class-wc-template-loader.php 11 months ago class-wc-tracker.php 11 months ago class-wc-validation.php 2 years ago class-wc-webhook.php 1 year ago class-woocommerce.php 5 months ago wc-account-functions.php 11 months ago wc-attribute-functions.php 1 year ago wc-brands-functions.php 1 year ago wc-cart-functions.php 11 months ago wc-conditional-functions.php 11 months ago wc-core-functions.php 11 months ago wc-coupon-functions.php 1 year ago wc-deprecated-functions.php 1 year ago wc-formatting-functions.php 11 months ago wc-notice-functions.php 11 months ago wc-order-functions.php 11 months ago wc-order-item-functions.php 3 years ago wc-order-step-logger-functions.php 1 year ago wc-page-functions.php 1 year ago wc-product-functions.php 11 months ago wc-rest-functions.php 11 months ago wc-stock-functions.php 1 year ago wc-template-functions.php 11 months ago wc-template-hooks.php 1 year ago wc-term-functions.php 11 months ago wc-update-functions.php 11 months ago wc-user-functions.php 11 months ago wc-webhook-functions.php 1 year ago wc-widget-functions.php 5 years ago
class-wc-order-refund.php
259 lines
1 <?php
2 /**
3 * Order refund. Refunds are based on orders (essentially negative orders) and
4 * contain much of the same data.
5 *
6 * @version 3.0.0
7 * @package WooCommerce\Classes
8 */
9
10 use Automattic\WooCommerce\Enums\OrderStatus;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Order refund class.
16 */
17 class WC_Order_Refund extends WC_Abstract_Order {
18
19 /**
20 * Which data store to load.
21 *
22 * @var string
23 */
24 protected $data_store_name = 'order-refund';
25
26 /**
27 * This is the name of this object type.
28 *
29 * @var string
30 */
31 protected $object_type = 'order_refund';
32
33 /**
34 * Stores product data.
35 *
36 * @var array
37 */
38 protected $extra_data = array(
39 'amount' => '',
40 'reason' => '',
41 'refunded_by' => 0,
42 'refunded_payment' => false,
43 );
44
45 /**
46 * List of properties that were earlier managed by data store. However, since DataStore is a not a stored entity in itself, they used to store data in metadata of the data object.
47 * With custom tables, some of these are moved from metadata to their own columns, but existing code will still try to add them to metadata. This array is used to keep track of such properties.
48 *
49 * Only reason to add a property here is that you are moving properties from DataStore instance to data object. Otherwise, if you are adding a new property, consider adding it to $data array instead.
50 *
51 * @var array
52 */
53 protected $legacy_datastore_props = array(
54 '_refund_amount',
55 '_refund_reason',
56 '_refunded_by',
57 '_refunded_payment',
58 );
59
60
61 /**
62 * Get internal type (post type.)
63 *
64 * @return string
65 */
66 public function get_type() {
67 return 'shop_order_refund';
68 }
69
70 /**
71 * Get status - always completed for refunds.
72 *
73 * @param string $context What the value is for. Valid values are view and edit.
74 * @return string
75 */
76 public function get_status( $context = 'view' ) {
77 return OrderStatus::COMPLETED;
78 }
79
80 /**
81 * Get a title for the new post type.
82 */
83 public function get_post_title() {
84 // @codingStandardsIgnoreStart
85 return sprintf( __( 'Refund &ndash; %s', 'woocommerce' ), (new DateTime('now'))->format( _x( 'M d, Y @ h:i A', 'Order date parsed by DateTime::format', 'woocommerce' ) ) );
86 // @codingStandardsIgnoreEnd
87 }
88
89 /**
90 * Get refunded amount.
91 *
92 * @param string $context What the value is for. Valid values are view and edit.
93 * @return int|float
94 */
95 public function get_amount( $context = 'view' ) {
96 return $this->get_prop( 'amount', $context );
97 }
98
99 /**
100 * Get refund reason.
101 *
102 * @since 2.2
103 * @param string $context What the value is for. Valid values are view and edit.
104 * @return string
105 */
106 public function get_reason( $context = 'view' ) {
107 return $this->get_prop( 'reason', $context );
108 }
109
110 /**
111 * Get ID of user who did the refund.
112 *
113 * @since 3.0
114 * @param string $context What the value is for. Valid values are view and edit.
115 * @return int
116 */
117 public function get_refunded_by( $context = 'view' ) {
118 return $this->get_prop( 'refunded_by', $context );
119 }
120
121 /**
122 * Return if the payment was refunded via API.
123 *
124 * @since 3.3
125 * @param string $context What the value is for. Valid values are view and edit.
126 * @return bool
127 */
128 public function get_refunded_payment( $context = 'view' ) {
129 return $this->get_prop( 'refunded_payment', $context );
130 }
131
132 /**
133 * Get formatted refunded amount.
134 *
135 * @since 2.4
136 * @return string
137 */
138 public function get_formatted_refund_amount() {
139 return apply_filters( 'woocommerce_formatted_refund_amount', wc_price( $this->get_amount(), array( 'currency' => $this->get_currency() ) ), $this );
140 }
141
142 /**
143 * Set refunded amount.
144 *
145 * @param string $value Value to set.
146 * @throws WC_Data_Exception Exception if the amount is invalid.
147 */
148 public function set_amount( $value ) {
149 $this->set_prop( 'amount', wc_format_decimal( $value ) );
150 }
151
152 /**
153 * Set refund reason.
154 *
155 * @param string $value Value to set.
156 * @throws WC_Data_Exception Exception if the amount is invalid.
157 */
158 public function set_reason( $value ) {
159 $this->set_prop( 'reason', $value );
160 }
161
162 /**
163 * Set refunded by.
164 *
165 * @param int $value Value to set.
166 * @throws WC_Data_Exception Exception if the amount is invalid.
167 */
168 public function set_refunded_by( $value ) {
169 $this->set_prop( 'refunded_by', absint( $value ) );
170 }
171
172 /**
173 * Set if the payment was refunded via API.
174 *
175 * @since 3.3
176 * @param bool $value Value to set.
177 */
178 public function set_refunded_payment( $value ) {
179 $this->set_prop( 'refunded_payment', (bool) $value );
180 }
181
182 /**
183 * Magic __get method for backwards compatibility.
184 *
185 * @param string $key Value to get.
186 * @return mixed
187 */
188 public function __get( $key ) {
189 wc_doing_it_wrong( $key, 'Refund properties should not be accessed directly.', '3.0' );
190 /**
191 * Maps legacy vars to new getters.
192 */
193 if ( 'reason' === $key ) {
194 return $this->get_reason();
195 } elseif ( 'refund_amount' === $key ) {
196 return $this->get_amount();
197 }
198 return parent::__get( $key );
199 }
200
201 /**
202 * Gets an refund from the database.
203 *
204 * @deprecated 3.0
205 * @param int $id (default: 0).
206 * @return bool
207 */
208 public function get_refund( $id = 0 ) {
209 wc_deprecated_function( 'get_refund', '3.0', 'read' );
210
211 if ( ! $id ) {
212 return false;
213 }
214
215 $result = wc_get_order( $id );
216
217 if ( $result ) {
218 $this->populate( $result );
219 return true;
220 }
221
222 return false;
223 }
224
225 /**
226 * Get refund amount.
227 *
228 * @deprecated 3.0
229 * @return int|float
230 */
231 public function get_refund_amount() {
232 wc_deprecated_function( 'get_refund_amount', '3.0', 'get_amount' );
233 return $this->get_amount();
234 }
235
236 /**
237 * Get refund reason.
238 *
239 * @deprecated 3.0
240 * @return string
241 */
242 public function get_refund_reason() {
243 wc_deprecated_function( 'get_refund_reason', '3.0', 'get_reason' );
244 return $this->get_reason();
245 }
246
247 /**
248 * Indicates if the current order has an associated Cost of Goods Sold value.
249 * For refunds the cost will be sum of the cost of the refunded items.
250 *
251 * @since 9.9.0
252 *
253 * @return bool True if this order has an associated Cost of Goods Sold value.
254 */
255 public function has_cogs() {
256 return true;
257 }
258 }
259