golden hour
/home/godaofbq/hyperbarichelp.com/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1
⬆️ Go Up
Upload
File/Folder
Size
Actions
.htaccess
420 B
Del
OK
AI
-
Del
OK
AbstractCartRoute.php
9.54 KB
Del
OK
AbstractRoute.php
9.77 KB
Del
OK
AbstractTermsRoute.php
5.08 KB
Del
OK
Agentic
-
Del
OK
Batch.php
3.77 KB
Del
OK
Cart.php
1.34 KB
Del
OK
CartAddItem.php
4.65 KB
Del
OK
CartApplyCoupon.php
2.07 KB
Del
OK
CartCoupons.php
3.89 KB
Del
OK
CartCouponsByCode.php
2.66 KB
Del
OK
CartExtensions.php
1.93 KB
Del
OK
CartItems.php
3.82 KB
Del
OK
CartItemsByKey.php
4.07 KB
Del
OK
CartRemoveCoupon.php
2.51 KB
Del
OK
CartRemoveItem.php
2.58 KB
Del
OK
CartSelectShippingRate.php
3.6 KB
Del
OK
CartUpdateCustomer.php
9.94 KB
Del
OK
CartUpdateItem.php
2.53 KB
Del
OK
Checkout.php
37.65 KB
Del
OK
CheckoutOrder.php
8.1 KB
Del
OK
Order.php
2.24 KB
Del
OK
Patterns.php
2.86 KB
Del
OK
ProductAttributeTerms.php
3.67 KB
Del
OK
ProductAttributes.php
1.59 KB
Del
OK
ProductAttributesById.php
2 KB
Del
OK
ProductBrands.php
1.36 KB
Del
OK
ProductBrandsById.php
2.39 KB
Del
OK
ProductCategories.php
1.35 KB
Del
OK
ProductCategoriesById.php
1.98 KB
Del
OK
ProductCollectionData.php
9.22 KB
Del
OK
ProductReviews.php
6.84 KB
Del
OK
ProductTags.php
1.24 KB
Del
OK
Products.php
15.17 KB
Del
OK
ProductsById.php
2.58 KB
Del
OK
ProductsBySlug.php
3.4 KB
Del
OK
ShopperListItems.php
7.91 KB
Del
OK
ShopperListItemsByKey.php
2.5 KB
Del
OK
ShopperLists.php
1.79 KB
Del
OK
ShopperListsBySlug.php
2.18 KB
Del
OK
ShopperListsNonceCheck.php
3.44 KB
Del
OK
Edit: CheckoutOrder.php
<?php namespace Automattic\WooCommerce\StoreApi\Routes\V1; use Automattic\WooCommerce\StoreApi\Payments\PaymentResult; use Automattic\WooCommerce\StoreApi\Exceptions\InvalidStockLevelsInCartException; use Automattic\WooCommerce\StoreApi\Exceptions\RouteException; use Automattic\WooCommerce\StoreApi\Utilities\OrderAuthorizationTrait; use Automattic\WooCommerce\StoreApi\Utilities\CheckoutTrait; /** * CheckoutOrder class. */ class CheckoutOrder extends AbstractCartRoute { use OrderAuthorizationTrait; use CheckoutTrait; /** * The route identifier. * * @var string */ const IDENTIFIER = 'checkout-order'; /** * The routes schema. * * @var string */ const SCHEMA_TYPE = 'checkout-order'; /** * Holds the current order being processed. * * @var \WC_Order */ private $order = null; /** * Get the path of this REST route. * * @return string */ public function get_path() { return self::get_path_regex(); } /** * Get the path of this rest route. * * @return string */ public static function get_path_regex() { return '/checkout/(?P<id>[\d]+)'; } /** * Get method arguments for this REST route. * * @return array An array of endpoints. */ public function get_args() { return [ [ 'methods' => \WP_REST_Server::CREATABLE, 'callback' => [ $this, 'get_response' ], 'permission_callback' => [ $this, 'is_authorized' ], 'args' => array_merge( [ 'payment_data' => [ 'description' => __( 'Data to pass through to the payment method when processing payment.', 'woocommerce' ), 'type' => 'array', 'items' => [ 'type' => 'object', 'properties' => [ 'key' => [ 'type' => 'string', ], 'value' => [ 'type' => [ 'string', 'boolean' ], ], ], ], ], ], $this->schema->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ) ), ], 'schema' => [ $this->schema, 'get_public_item_schema' ], 'allow_batch' => [ 'v1' => true ], ]; } /** * Process an order. * * 1. Process Request * 2. Process Customer * 3. Validate Order * 4. Process Payment * * @throws RouteException On error. * @throws InvalidStockLevelsInCartException On error. * * @param \WP_REST_Request $request Request object. * * @return \WP_REST_Response */ protected function get_route_post_response( \WP_REST_Request $request ) { $order_id = absint( $request['id'] ); $this->order = wc_get_order( $order_id ); if ( ! $this->order instanceof \WC_Order || ! $this->order->needs_payment() ) { return new \WP_Error( 'invalid_order_update_status', __( 'This order cannot be paid for.', 'woocommerce' ) ); } /** * Process request data. * * The order address is validated before anything is persisted, so a rejected request * cannot mutate the existing order or the customer record. */ $this->update_billing_address( $request ); $this->update_order_from_request( $request ); /** * Process customer data. * * Update order with customer details, and sign up a user account as necessary. */ $this->process_customer( $request ); /** * Validate order. * * This logic ensures the order is valid before payment is attempted. */ $this->order_controller->validate_existing_order_before_payment( $this->order ); /** * Fires before an order is processed by the Checkout Block/Store API. * * This hook informs extensions that $order has completed processing and is ready for payment. * * This is similar to existing core hook woocommerce_checkout_order_processed. We're using a new action: * - To keep the interface focused (only pass $order, not passing request data). * - This also explicitly indicates these orders are from checkout block/StoreAPI. * * @since 7.2.0 * * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3238 * @example See docs/examples/checkout-order-processed.md * @param \WC_Order $order Order object. */ do_action( 'woocommerce_store_api_checkout_order_processed', $this->order ); /** * Process the payment and return the results. */ $payment_result = new PaymentResult(); if ( $this->order->needs_payment() ) { $this->process_payment( $request, $payment_result ); } else { $this->process_without_payment( $request, $payment_result ); } return $this->prepare_item_for_response( (object) [ 'order' => wc_get_order( $this->order ), 'payment_result' => $payment_result, ], $request ); } /** * Since this endpoint only operates on existing orders, we don't need to do updates based on * the cart data. * * @param \WP_REST_Request $request Request object. */ protected function cart_updated( \WP_REST_Request $request ) {} /** * Applies the billing and shipping address from the request to the order and customer. * * The address is set on the order and validated before anything is persisted, so a rejected * request cannot mutate the order or the customer. wc()->customer is saved on shutdown (see * WooCommerce::initialize_cart()), so its address fields are only set once validation passes. * * @throws RouteException When the order address fails validation. * * @param \WP_REST_Request $request Full details about the request. */ private function update_billing_address( \WP_REST_Request $request ) { $customer = wc()->customer; // Billing address is a required field. $billing = $request['billing_address']; // If shipping address (optional field) was not provided, set it to the given billing address (required field). $shipping = $request['shipping_address'] ?? $billing; $this->order->set_billing_address( $billing ); $this->order->set_shipping_address( $shipping ); $this->order_controller->validate_existing_order_before_update( $this->order ); // Update customer object with validated order addresses. foreach ( $billing as $key => $value ) { if ( is_callable( [ $customer, "set_billing_$key" ] ) ) { $customer->{"set_billing_$key"}( $value ); } } foreach ( $shipping as $key => $value ) { if ( is_callable( [ $customer, "set_shipping_$key" ] ) ) { $customer->{"set_shipping_$key"}( $value ); } } /** * Fires when the Checkout Block/Store API updates a customer from the API request data. * * @since 8.2.0 * * @param \WC_Customer $customer Customer object. * @param \WP_REST_Request $request Full details about the request. */ do_action( 'woocommerce_store_api_checkout_update_customer_from_request', $customer, $request ); $customer->save(); $this->order->save(); $this->order->calculate_totals(); } /** * Gets the chosen payment method from the request. * * @throws RouteException On error. * @param \WP_REST_Request $request Request object. * @return \WC_Payment_Gateway|null */ private function get_request_payment_method( \WP_REST_Request $request ) { $request_payment_method = wc_clean( wp_unslash( $request['payment_method'] ?? '' ) ); if ( empty( $request_payment_method ) ) { if ( $this->order->needs_payment() ) { throw new RouteException( 'woocommerce_rest_checkout_missing_payment_method', __( 'No payment method provided.', 'woocommerce' ), 400 ); } return null; } $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); if ( ! isset( $available_gateways[ $request_payment_method ] ) ) { throw new RouteException( 'woocommerce_rest_checkout_payment_method_disabled', sprintf( // Translators: %s Payment method ID. __( 'The %s payment gateway is not available.', 'woocommerce' ), esc_html( $request_payment_method ) ), 400 ); } return $available_gateways[ $request_payment_method ]; } /** * Updates the order with user details (e.g. address). * * @throws RouteException API error object with error details. * @param \WP_REST_Request $request Request object. */ private function process_customer( \WP_REST_Request $request ) { $this->order_controller->sync_customer_data_with_order( $this->order ); } }
Save