Skip to content

CartCommand.php: Fix getTotalCount desc - #3052

Merged
adriendupuis merged 2 commits into
5.0from
fix-cart-total-count-desc
Feb 11, 2026
Merged

adriendupuis merged 2 commits into
5.0from
fix-cart-total-count-desc

Conversation

@adriendupuis

@adriendupuis adriendupuis commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor
Question Answer
JIRA Ticket
Versions 5.0, 4.6
Edition

Fix getTotalCount() description comment.
If the user own 25 carts, the limited result slice contains 20 carts, but getTotalCount() returns 25, not 20

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@github-actions

Copy link
Copy Markdown

Preview of modified files: no change to preview.

@adriendupuis
adriendupuis marked this pull request as ready for review February 10, 2026 09:09
Comment thread code_samples/api/commerce/src/Command/CartCommand.php Outdated
Co-authored-by: Marek Nocoń <mnocon@users.noreply.github.com>
@adriendupuis
adriendupuis requested a review from mnocon February 10, 2026 12:08
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/api/commerce/src/Command/CartCommand.php

docs/commerce/cart/cart_api.md@25:``` php
docs/commerce/cart/cart_api.md@26:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 66) =]]
docs/commerce/cart/cart_api.md@27:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $output->writeln($cart->getName());

docs/commerce/cart/cart_api.md@34:``` php
docs/commerce/cart/cart_api.md@35:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 10, 11) =]]
docs/commerce/cart/cart_api.md@36:// ...
docs/commerce/cart/cart_api.md@37:
docs/commerce/cart/cart_api.md@38:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 49, 57) =]]
docs/commerce/cart/cart_api.md@39:```

001⫶use Ibexa\Contracts\Cart\Value\CartQuery;
002⫶
003⫶// ...
004⫶
005⫶ $cartQuery = new CartQuery();
006⫶ $cartQuery->setOwnerId(14); // carts created by User ID: 14
007⫶ $cartQuery->setLimit(20); // fetch 20 carts
008⫶
009⫶ $cartsList = $this->cartService->findCarts($cartQuery);
010⫶
011⫶ $cartsList->getCarts(); // array of CartInterface objects

code_samples/api/commerce/src/Command/CartCommand.php

docs/commerce/cart/cart_api.md@25:``` php
docs/commerce/cart/cart_api.md@26:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 66) =]]
docs/commerce/cart/cart_api.md@27:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $output->writeln($cart->getName());

docs/commerce/cart/cart_api.md@34:``` php
docs/commerce/cart/cart_api.md@35:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 10, 11) =]]
docs/commerce/cart/cart_api.md@36:// ...
docs/commerce/cart/cart_api.md@37:
docs/commerce/cart/cart_api.md@38:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 49, 57) =]]
docs/commerce/cart/cart_api.md@39:```

001⫶use Ibexa\Contracts\Cart\Value\CartQuery;
002⫶
003⫶// ...
004⫶
005⫶ $cartQuery = new CartQuery();
006⫶ $cartQuery->setOwnerId(14); // carts created by User ID: 14
007⫶ $cartQuery->setLimit(20); // fetch 20 carts
008⫶
009⫶ $cartsList = $this->cartService->findCarts($cartQuery);
010⫶
011⫶ $cartsList->getCarts(); // array of CartInterface objects
012⫶        $cartsList->getTotalCount(); // number of returned carts
012⫶        $cartsList->getTotalCount(); // number of matching carts regardless of the limit

docs/commerce/cart/cart_api.md@45:``` php
docs/commerce/cart/cart_api.md@46:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 8, 9) =]]
docs/commerce/cart/cart_api.md@47:// ...
docs/commerce/cart/cart_api.md@48:
docs/commerce/cart/cart_api.md@49:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 70, 78) =]]
docs/commerce/cart/cart_api.md@50:```

001⫶use Ibexa\Contracts\Cart\Value\CartCreateStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cartCreateStruct = new CartCreateStruct(
006⫶ 'Default cart',
007⫶ $currency // Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface
008⫶ );
009⫶
010⫶ $cart = $this->cartService->createCart($cartCreateStruct);
011⫶
012⫶ $output->writeln($cart->getName()); // prints 'Default cart' to the console

docs/commerce/cart/cart_api.md@58:``` php
docs/commerce/cart/cart_api.md@59:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 9, 10) =]]
docs/commerce/cart/cart_api.md@60:// ...
docs/commerce/cart/cart_api.md@61:
docs/commerce/cart/cart_api.md@62:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 82, 89) =]]
docs/commerce/cart/cart_api.md@63:```

001⫶use Ibexa\Contracts\Cart\Value\CartMetadataUpdateStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cartUpdateMetadataStruct = new CartMetadataUpdateStruct();
006⫶ $cartUpdateMetadataStruct->setName('New name');
007⫶ $cartUpdateMetadataStruct->setCurrency($newCurrency);
008⫶
009⫶ $updatedCart = $this->cartService->updateCartMetadata($cart, $cartUpdateMetadataStruct);
010⫶
011⫶ $output->writeln($updatedCart->getName()); // prints 'New name' to the console

docs/commerce/cart/cart_api.md@82:``` php
docs/commerce/cart/cart_api.md@83:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@84:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 125) =]]
docs/commerce/cart/cart_api.md@85:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $this->cartService->deleteCart($cart);

docs/commerce/cart/cart_api.md@91:``` php
docs/commerce/cart/cart_api.md@92:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@93:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 91, 92) =]]
docs/commerce/cart/cart_api.md@94:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $this->cartService->emptyCart($cart);

docs/commerce/cart/cart_api.md@103:``` php
docs/commerce/cart/cart_api.md@104:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@105:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 94, 95) =]]
docs/commerce/cart/cart_api.md@106:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $violationList = $this->cartService->validateCart($cart); // Symfony\Component\Validator\ConstraintViolationListInterface

docs/commerce/cart/cart_api.md@113:``` php
docs/commerce/cart/cart_api.md@114:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]]
docs/commerce/cart/cart_api.md@115:// ...
docs/commerce/cart/cart_api.md@116:
docs/commerce/cart/cart_api.md@117:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@118:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 99, 106) =]]
docs/commerce/cart/cart_api.md@119:```

001⫶use Ibexa\Contracts\Cart\Value\EntryAddStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
006⫶
007⫶ $entryAddStruct = new EntryAddStruct($product);
008⫶ $entryAddStruct->setQuantity(10);
009⫶
010⫶ $cart = $this->cartService->addEntry($cart, $entryAddStruct);
011⫶
012⫶ $entry = $cart->getEntries()->first();
013⫶ $output->writeln($entry->getProduct()->getName()); // prints product name to the console

docs/commerce/cart/cart_api.md@125:``` php
docs/commerce/cart/cart_api.md@126:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@127:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 112) =]]
docs/commerce/cart/cart_api.md@128:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $entry = $cart->getEntries()->first();
004⫶
005⫶ $cart = $this->cartService->removeEntry($cart, $entry); // updated Cart object

docs/commerce/cart/cart_api.md@135:``` php
docs/commerce/cart/cart_api.md@136:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]]
docs/commerce/cart/cart_api.md@137:// ...
docs/commerce/cart/cart_api.md@138:
docs/commerce/cart/cart_api.md@139:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@140:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 110) =]]
docs/commerce/cart/cart_api.md@141:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 114, 122) =]]
docs/commerce/cart/cart_api.md@142:```

001⫶use Ibexa\Contracts\Cart\Value\EntryUpdateStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
006⫶
007⫶ $entry = $cart->getEntries()->first();
008⫶
009⫶ $entryUpdateStruct = new EntryUpdateStruct(5);
010⫶ $entryUpdateStruct->setQuantity(10);
011⫶
012⫶ $cart = $this->cartService->updateEntry(
013⫶ $cart,
014⫶ $entry,
015⫶ $entryUpdateStruct
016⫶ ); // updated Cart object

docs/commerce/cart/cart_api.md@187:```php
docs/commerce/cart/cart_api.md@188:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 126, 139) =]]
docs/commerce/cart/cart_api.md@189:```

001⫶ // Get the order with items that should be reordered
002⫶ $orderIdentifier = '2e897b31-0d7a-46d3-ba45-4eb65fe02790';
003⫶ $order = $this->orderService->getOrderByIdentifier($orderIdentifier);
004⫶
005⫶ // Get the cart to merge
006⫶ $existingCart = $this->cartResolver->resolveCart();
007⫶
008⫶ $reorderCart = $this
009⫶ ->reorderService
010⫶ ->addToCartFromOrder($order, $this->reorderService->createReorderCart($order));
011⫶
012⫶ // Merge the carts into the target cart and delete the merged carts
013⫶ $reorderCart = $this->cartService->mergeCarts($reorderCart, true, $existingCart);


docs/commerce/cart/cart_api.md@45:``` php
docs/commerce/cart/cart_api.md@46:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 8, 9) =]]
docs/commerce/cart/cart_api.md@47:// ...
docs/commerce/cart/cart_api.md@48:
docs/commerce/cart/cart_api.md@49:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 70, 78) =]]
docs/commerce/cart/cart_api.md@50:```

001⫶use Ibexa\Contracts\Cart\Value\CartCreateStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cartCreateStruct = new CartCreateStruct(
006⫶ 'Default cart',
007⫶ $currency // Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface
008⫶ );
009⫶
010⫶ $cart = $this->cartService->createCart($cartCreateStruct);
011⫶
012⫶ $output->writeln($cart->getName()); // prints 'Default cart' to the console

docs/commerce/cart/cart_api.md@58:``` php
docs/commerce/cart/cart_api.md@59:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 9, 10) =]]
docs/commerce/cart/cart_api.md@60:// ...
docs/commerce/cart/cart_api.md@61:
docs/commerce/cart/cart_api.md@62:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 82, 89) =]]
docs/commerce/cart/cart_api.md@63:```

001⫶use Ibexa\Contracts\Cart\Value\CartMetadataUpdateStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cartUpdateMetadataStruct = new CartMetadataUpdateStruct();
006⫶ $cartUpdateMetadataStruct->setName('New name');
007⫶ $cartUpdateMetadataStruct->setCurrency($newCurrency);
008⫶
009⫶ $updatedCart = $this->cartService->updateCartMetadata($cart, $cartUpdateMetadataStruct);
010⫶
011⫶ $output->writeln($updatedCart->getName()); // prints 'New name' to the console

docs/commerce/cart/cart_api.md@82:``` php
docs/commerce/cart/cart_api.md@83:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@84:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 125) =]]
docs/commerce/cart/cart_api.md@85:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $this->cartService->deleteCart($cart);

docs/commerce/cart/cart_api.md@91:``` php
docs/commerce/cart/cart_api.md@92:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@93:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 91, 92) =]]
docs/commerce/cart/cart_api.md@94:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $this->cartService->emptyCart($cart);

docs/commerce/cart/cart_api.md@103:``` php
docs/commerce/cart/cart_api.md@104:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@105:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 94, 95) =]]
docs/commerce/cart/cart_api.md@106:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $violationList = $this->cartService->validateCart($cart); // Symfony\Component\Validator\ConstraintViolationListInterface

docs/commerce/cart/cart_api.md@113:``` php
docs/commerce/cart/cart_api.md@114:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]]
docs/commerce/cart/cart_api.md@115:// ...
docs/commerce/cart/cart_api.md@116:
docs/commerce/cart/cart_api.md@117:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@118:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 99, 106) =]]
docs/commerce/cart/cart_api.md@119:```

001⫶use Ibexa\Contracts\Cart\Value\EntryAddStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
006⫶
007⫶ $entryAddStruct = new EntryAddStruct($product);
008⫶ $entryAddStruct->setQuantity(10);
009⫶
010⫶ $cart = $this->cartService->addEntry($cart, $entryAddStruct);
011⫶
012⫶ $entry = $cart->getEntries()->first();
013⫶ $output->writeln($entry->getProduct()->getName()); // prints product name to the console

docs/commerce/cart/cart_api.md@125:``` php
docs/commerce/cart/cart_api.md@126:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@127:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 112) =]]
docs/commerce/cart/cart_api.md@128:```

001⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
002⫶
003⫶ $entry = $cart->getEntries()->first();
004⫶
005⫶ $cart = $this->cartService->removeEntry($cart, $entry); // updated Cart object

docs/commerce/cart/cart_api.md@135:``` php
docs/commerce/cart/cart_api.md@136:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]]
docs/commerce/cart/cart_api.md@137:// ...
docs/commerce/cart/cart_api.md@138:
docs/commerce/cart/cart_api.md@139:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
docs/commerce/cart/cart_api.md@140:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 110) =]]
docs/commerce/cart/cart_api.md@141:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 114, 122) =]]
docs/commerce/cart/cart_api.md@142:```

001⫶use Ibexa\Contracts\Cart\Value\EntryUpdateStruct;
002⫶
003⫶// ...
004⫶
005⫶ $cart = $this->cartService->getCart('1844450e-61da-4814-8d82-9301a3df0054');
006⫶
007⫶ $entry = $cart->getEntries()->first();
008⫶
009⫶ $entryUpdateStruct = new EntryUpdateStruct(5);
010⫶ $entryUpdateStruct->setQuantity(10);
011⫶
012⫶ $cart = $this->cartService->updateEntry(
013⫶ $cart,
014⫶ $entry,
015⫶ $entryUpdateStruct
016⫶ ); // updated Cart object

docs/commerce/cart/cart_api.md@187:```php
docs/commerce/cart/cart_api.md@188:[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 126, 139) =]]
docs/commerce/cart/cart_api.md@189:```

001⫶ // Get the order with items that should be reordered
002⫶ $orderIdentifier = '2e897b31-0d7a-46d3-ba45-4eb65fe02790';
003⫶ $order = $this->orderService->getOrderByIdentifier($orderIdentifier);
004⫶
005⫶ // Get the cart to merge
006⫶ $existingCart = $this->cartResolver->resolveCart();
007⫶
008⫶ $reorderCart = $this
009⫶ ->reorderService
010⫶ ->addToCartFromOrder($order, $this->reorderService->createReorderCart($order));
011⫶
012⫶ // Merge the carts into the target cart and delete the merged carts
013⫶ $reorderCart = $this->cartService->mergeCarts($reorderCart, true, $existingCart);

Download colorized diff

@adriendupuis
adriendupuis merged commit 280953b into 5.0 Feb 11, 2026
10 checks passed
@adriendupuis
adriendupuis deleted the fix-cart-total-count-desc branch February 11, 2026 22:46
adriendupuis added a commit that referenced this pull request Feb 11, 2026
---------

Co-authored-by: Marek Nocoń <mnocon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants