PATH:
home
/
letacommog
/
supportleta
/
wp-content
/
plugins
/
woocommerce
/
includes
/
api
<?php /** * REST API Order Refunds controller * * Handles requests to the /orders/<order_id>/refunds endpoint. * * @package WooCommerce/API * @since 2.6.0 */ defined( 'ABSPATH' ) || exit; /** * REST API Order Refunds controller class. * * @package WooCommerce/API * @extends WC_REST_Order_Refunds_V2_Controller */ class WC_REST_Order_Refunds_Controller extends WC_REST_Order_Refunds_V2_Controller { /** * Endpoint namespace. * * @var string */ protected $namespace = 'wc/v3'; /** * Prepares one object for create or update operation. * * @since 3.0.0 * @param WP_REST_Request $request Request object. * @param bool $creating If is creating a new object. * @return WP_Error|WC_Data The prepared item, or WP_Error object on failure. */ protected function prepare_object_for_database( $request, $creating = false ) { $order = wc_get_order( (int) $request['order_id'] ); if ( ! $order ) { return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 ); } if ( 0 > $request['amount'] ) { return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 ); } // Create the refund. $refund = wc_create_refund( array( 'order_id' => $order->get_id(), 'amount' => $request['amount'], 'reason' => empty( $request['reason'] ) ? null : $request['reason'], 'line_items' => empty( $request['line_items'] ) ? array() : $request['line_items'], 'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true, 'restock_items' => true, ) ); if ( is_wp_error( $refund ) ) { return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500 ); } if ( ! $refund ) { return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 ); } if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) { foreach ( $request['meta_data'] as $meta ) { $refund->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); } $refund->save_meta_data(); } /** * Filters an object before it is inserted via the REST API. * * The dynamic portion of the hook name, `$this->post_type`, * refers to the object type slug. * * @param WC_Data $coupon Object object. * @param WP_REST_Request $request Request object. * @param bool $creating If is creating a new object. */ return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating ); } }
[+]
..
[-] class-wc-rest-order-refunds-controller.php
[edit]
[-] class-wc-rest-system-status-tools-controller.php
[edit]
[-] class-wc-rest-system-status-controller.php
[edit]
[+]
v2
[-] class-wc-rest-report-sales-controller.php
[edit]
[-] class-wc-rest-product-attribute-terms-controller.php
[edit]
[-] class-wc-rest-customer-downloads-controller.php
[edit]
[-] class-wc-rest-report-customers-totals-controller.php
[edit]
[+]
legacy
[-] class-wc-rest-report-orders-totals-controller.php
[edit]
[-] class-wc-rest-shipping-zone-methods-controller.php
[edit]
[-] class-wc-rest-orders-controller.php
[edit]
[-] class-wc-rest-customers-controller.php
[edit]
[-] class-wc-rest-product-tags-controller.php
[edit]
[+]
v1
[-] class-wc-rest-products-controller.php
[edit]
[-] class-wc-rest-data-continents-controller.php
[edit]
[-] class-wc-rest-payment-gateways-controller.php
[edit]
[-] class-wc-rest-network-orders-controller.php
[edit]
[-] class-wc-rest-tax-classes-controller.php
[edit]
[-] class-wc-rest-shipping-zones-controller.php
[edit]
[-] class-wc-rest-order-notes-controller.php
[edit]
[-] class-wc-rest-product-reviews-controller.php
[edit]
[-] class-wc-rest-report-top-sellers-controller.php
[edit]
[-] class-wc-rest-shipping-zone-locations-controller.php
[edit]
[-] class-wc-rest-data-currencies-controller.php
[edit]
[-] class-wc-rest-data-countries-controller.php
[edit]
[-] class-wc-rest-product-shipping-classes-controller.php
[edit]
[-] class-wc-rest-product-categories-controller.php
[edit]
[-] class-wc-rest-setting-options-controller.php
[edit]
[-] class-wc-rest-shipping-methods-controller.php
[edit]
[-] class-wc-rest-report-coupons-totals-controller.php
[edit]
[-] class-wc-rest-product-attributes-controller.php
[edit]
[-] class-wc-rest-webhooks-controller.php
[edit]
[-] class-wc-rest-data-controller.php
[edit]
[-] class-wc-rest-authentication.php
[edit]
[-] class-wc-rest-reports-controller.php
[edit]
[-] class-wc-rest-exception.php
[edit]
[-] class-wc-rest-report-products-totals-controller.php
[edit]
[-] class-wc-rest-product-variations-controller.php
[edit]
[-] class-wc-rest-report-reviews-totals-controller.php
[edit]
[-] class-wc-rest-coupons-controller.php
[edit]
[-] class-wc-rest-taxes-controller.php
[edit]
[-] class-wc-rest-settings-controller.php
[edit]