@@ -40,6 +40,11 @@ class OrderItemsWithCustomOptionsTest extends WebapiAbstract
4040 */
4141 private DataFixtureStorage $ fixtures ;
4242
43+ /**
44+ * Set up test dependencies
45+ *
46+ * @return void
47+ */
4348 protected function setUp (): void
4449 {
4550 parent ::setUp ();
@@ -52,6 +57,8 @@ protected function setUp(): void
5257
5358 /**
5459 * Test creating order with products having all custom option types and retrieving via REST API
60+ *
61+ * @return void
5562 */
5663 #[DataFixture(
5764 ProductFixture::class,
@@ -291,6 +298,11 @@ public function testCreateTwoProductsWithAllCustomOptionsAndRetrieveOrderItems()
291298 }
292299 }
293300
301+ /**
302+ * Create a guest cart via REST API
303+ *
304+ * @return string Cart ID
305+ */
294306 private function createGuestCart (): string
295307 {
296308 $ serviceInfo = [
@@ -303,6 +315,15 @@ private function createGuestCart(): string
303315 return (string )$ this ->_webApiCall ($ serviceInfo );
304316 }
305317
318+ /**
319+ * Prepare custom options data for a product by SKU
320+ *
321+ * This method loads the product and prepares custom option values for all option types
322+ * including field, area, drop_down, radio, checkbox, multiple, date, date_time, and time
323+ *
324+ * @param string $sku Product SKU
325+ * @return array Array of custom options with option_id and option_value
326+ */
306327 private function prepareCustomOptionsForProductBySku (string $ sku ): array
307328 {
308329 $ objectManager = Bootstrap::getObjectManager ();
@@ -338,6 +359,14 @@ private function prepareCustomOptionsForProductBySku(string $sku): array
338359 return $ customOptions ;
339360 }
340361
362+ /**
363+ * Get the first option value ID from a custom option
364+ *
365+ * Used for drop_down and radio button options where only one value can be selected
366+ *
367+ * @param \Magento\Catalog\Api\Data\ProductCustomOptionInterface $option Product custom option
368+ * @return string|null Option type ID or null if no values exist
369+ */
341370 private function getFirstOptionValue (\Magento \Catalog \Api \Data \ProductCustomOptionInterface $ option ): ?string
342371 {
343372 $ values = $ option ->getValues ();
@@ -349,6 +378,14 @@ private function getFirstOptionValue(\Magento\Catalog\Api\Data\ProductCustomOpti
349378 return (string )$ firstValue ->getOptionTypeId ();
350379 }
351380
381+ /**
382+ * Get all option value IDs from a custom option as comma-separated string
383+ *
384+ * Used for checkbox and multiple select options where multiple values can be selected
385+ *
386+ * @param \Magento\Catalog\Api\Data\ProductCustomOptionInterface $option Product custom option
387+ * @return string|null Comma-separated option type IDs or null if no values exist
388+ */
352389 private function getAllOptionValues (\Magento \Catalog \Api \Data \ProductCustomOptionInterface $ option ): ?string
353390 {
354391 $ values = $ option ->getValues ();
@@ -364,6 +401,14 @@ private function getAllOptionValues(\Magento\Catalog\Api\Data\ProductCustomOptio
364401 return implode (', ' , $ valueIds );
365402 }
366403
404+ /**
405+ * Add a product to cart with custom options via REST API
406+ *
407+ * @param string $cartId Guest cart ID
408+ * @param ProductInterface $product Product to add
409+ * @param array $customOptions Array of custom options with option_id and option_value
410+ * @return array Response containing the added cart item
411+ */
367412 private function addProductToCart (string $ cartId , ProductInterface $ product , array $ customOptions ): array
368413 {
369414 $ serviceInfo = [
@@ -389,6 +434,12 @@ private function addProductToCart(string $cartId, ProductInterface $product, arr
389434 return $ this ->_webApiCall ($ serviceInfo , $ requestData );
390435 }
391436
437+ /**
438+ * Set shipping information for the cart via REST API
439+ *
440+ * @param string $cartId Guest cart ID
441+ * @return array Response containing payment methods and totals
442+ */
392443 private function setShippingInformation (string $ cartId ): array
393444 {
394445 $ serviceInfo = [
@@ -424,6 +475,12 @@ private function setShippingInformation(string $cartId): array
424475 return $ this ->_webApiCall ($ serviceInfo , $ requestData );
425476 }
426477
478+ /**
479+ * Place order for the cart via REST API
480+ *
481+ * @param string $cartId Guest cart ID
482+ * @return int Order ID
483+ */
427484 private function placeOrder (string $ cartId ): int
428485 {
429486 $ serviceInfo = [
@@ -442,6 +499,12 @@ private function placeOrder(string $cartId): int
442499 return (int )$ this ->_webApiCall ($ serviceInfo , $ requestData );
443500 }
444501
502+ /**
503+ * Get order details via REST API
504+ *
505+ * @param int $orderId Order ID
506+ * @return array Order data including entity_id, items, and other order details
507+ */
445508 private function getOrder (int $ orderId ): array
446509 {
447510 $ serviceInfo = [
@@ -454,6 +517,16 @@ private function getOrder(int $orderId): array
454517 return $ this ->_webApiCall ($ serviceInfo );
455518 }
456519
520+ /**
521+ * Get order items by order ID via REST API
522+ *
523+ * This method retrieves order items from the sales_order_item table
524+ * using the /V1/orders/items endpoint with order_id filter.
525+ * Equivalent to querying: SELECT * FROM sales_order_item WHERE order_id = ?
526+ *
527+ * @param int $orderId Order entity ID
528+ * @return array Array containing items, search_criteria, and total_count
529+ */
457530 private function getOrderItemsByOrderId (int $ orderId ): array
458531 {
459532 $ searchCriteria = [
0 commit comments