AI
1 year ago
Agentic
4 months ago
AbstractCartRoute.php
4 months ago
AbstractRoute.php
3 months ago
AbstractTermsRoute.php
4 months ago
Batch.php
4 months ago
Cart.php
1 year ago
CartAddItem.php
4 months ago
CartApplyCoupon.php
1 year ago
CartCoupons.php
3 months ago
CartCouponsByCode.php
1 year ago
CartExtensions.php
2 years ago
CartItems.php
2 years ago
CartItemsByKey.php
2 years ago
CartRemoveCoupon.php
1 year ago
CartRemoveItem.php
4 months ago
CartSelectShippingRate.php
5 months ago
CartUpdateCustomer.php
4 months ago
CartUpdateItem.php
4 months ago
Checkout.php
1 month ago
CheckoutOrder.php
1 year ago
Order.php
7 months ago
Patterns.php
1 year ago
ProductAttributeTerms.php
1 month ago
ProductAttributes.php
1 year ago
ProductAttributesById.php
1 year ago
ProductBrands.php
1 year ago
ProductBrandsById.php
1 year ago
ProductCategories.php
1 year ago
ProductCategoriesById.php
1 year ago
ProductCollectionData.php
11 months ago
ProductReviews.php
4 months ago
ProductTags.php
1 year ago
Products.php
3 months ago
ProductsById.php
3 months ago
ProductsBySlug.php
3 months ago
ShopperListItems.php
1 month ago
ShopperListItemsByKey.php
1 month ago
ShopperLists.php
1 month ago
ShopperListsBySlug.php
1 month ago
ShopperListsNonceCheck.php
1 month ago
Cart.php
63 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\StoreApi\Routes\V1; |
| 3 | |
| 4 | /** |
| 5 | * Cart class. |
| 6 | */ |
| 7 | class Cart extends AbstractCartRoute { |
| 8 | /** |
| 9 | * The route identifier. |
| 10 | * |
| 11 | * @var string |
| 12 | */ |
| 13 | const IDENTIFIER = 'cart'; |
| 14 | |
| 15 | /** |
| 16 | * Get the path of this REST route. |
| 17 | * |
| 18 | * @return string |
| 19 | */ |
| 20 | public function get_path() { |
| 21 | return self::get_path_regex(); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Get the path of this rest route. |
| 26 | * |
| 27 | * @return string |
| 28 | */ |
| 29 | public static function get_path_regex() { |
| 30 | return '/cart'; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Get method arguments for this REST route. |
| 35 | * |
| 36 | * @return array An array of endpoints. |
| 37 | */ |
| 38 | public function get_args() { |
| 39 | return [ |
| 40 | [ |
| 41 | 'methods' => \WP_REST_Server::READABLE, |
| 42 | 'callback' => [ $this, 'get_response' ], |
| 43 | 'permission_callback' => '__return_true', |
| 44 | 'args' => [ |
| 45 | 'context' => $this->get_context_param( [ 'default' => 'view' ] ), |
| 46 | ], |
| 47 | ], |
| 48 | 'schema' => [ $this->schema, 'get_public_item_schema' ], |
| 49 | 'allow_batch' => [ 'v1' => true ], |
| 50 | ]; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Handle the request and return a valid response for this endpoint. |
| 55 | * |
| 56 | * @param \WP_REST_Request $request Request object. |
| 57 | * @return \WP_REST_Response |
| 58 | */ |
| 59 | protected function get_route_response( \WP_REST_Request $request ) { |
| 60 | return rest_ensure_response( $this->schema->get_item_response( $this->cart_controller->get_cart_for_response() ) ); |
| 61 | } |
| 62 | } |
| 63 |