Skip to content

Adding a product with "Multi Select" option to cart doesn't work #163

@TalkMarc

Description

@TalkMarc

When adding an item to a cart that has a mandatory option of type "Multi Select" in it's assigned option group, the following exception is thrown:

Error:
Call to a member function getOptionValue() on array

  at /srv/sylius/src/Traits/OrderItemCustomerOptionCapableTrait.php:113
  at Tests\Brille24\SyliusCustomerOptionsPlugin\Application\src\Entity\Order\OrderItem->equals(object(OrderItem))
     (/srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Controller/OrderItemController.php:258)
  at Sylius\Bundle\OrderBundle\Controller\OrderItemController->Sylius\Bundle\OrderBundle\Controller\{closure}(object(OrderItem), 2)
  at array_filter(array(object(OrderItem), object(OrderItem), object(OrderItem)), object(Closure), 1)
     (/srv/sylius/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php:371)
  at Doctrine\Common\Collections\ArrayCollection->filter(object(Closure))
     (/srv/sylius/vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php:230)
  at Doctrine\Common\Collections\AbstractLazyCollection->filter(object(Closure))
     (/srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Controller/OrderItemController.php:258)
  at Sylius\Bundle\OrderBundle\Controller\OrderItemController->resolveAddedOrderItem(object(Order), object(OrderItem))
     (/srv/sylius/vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Controller/OrderItemController.php:90)
  at Sylius\Bundle\OrderBundle\Controller\OrderItemController->addAction(object(Request))
     (/srv/sylius/vendor/symfony/http-kernel/HttpKernel.php:163)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (/srv/sylius/vendor/symfony/http-kernel/HttpKernel.php:75)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (/srv/sylius/vendor/symfony/http-kernel/Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:27) 

The OrderItemCustomerOptionCapableTrait.php doesn't seem to expect a single option to have an array of OrderItemOptions instead of just a OrderItemOption as is the case in the other option types:

Screenshot of debugger output

I encountered this while working on #146

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions