SaveCheckoutCart.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Webkul\BagistoApi\Models;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GraphQl\Mutation;
  5. use Webkul\BagistoApi\Dto\CartData;
  6. use Webkul\BagistoApi\Dto\SaveCheckoutCartInput;
  7. use Webkul\BagistoApi\State\SaveCheckoutCartProcessor;
  8. /**
  9. * SaveCheckoutCart - GraphQL API Resource for persisting checkout selections.
  10. *
  11. * Single mutation that saves shipping method, coupon code and payment method in
  12. * one call and returns the full cart. Any input field equal to "-1" is left
  13. * untouched. The cart is resolved from the Authorization: Bearer token.
  14. */
  15. #[ApiResource(
  16. routePrefix: '/api/shop',
  17. shortName: 'SaveCheckoutCart',
  18. uriTemplate: '/save-checkout-carts',
  19. operations: [],
  20. graphQlOperations: [
  21. new Mutation(
  22. name: 'create',
  23. input: SaveCheckoutCartInput::class,
  24. output: CartData::class,
  25. processor: SaveCheckoutCartProcessor::class,
  26. denormalizationContext: [
  27. 'allow_extra_attributes' => true,
  28. 'groups' => ['mutation'],
  29. ],
  30. normalizationContext: [
  31. 'groups' => ['mutation'],
  32. ],
  33. description: 'Save shipping method, coupon code and payment method for the cart and return the full cart. Pass "-1" for any field to leave it unchanged.',
  34. ),
  35. ]
  36. )]
  37. class SaveCheckoutCart {}