Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom event #76

Open
ChristopherDosin opened this issue Mar 9, 2023 · 1 comment
Open

Custom event #76

ChristopherDosin opened this issue Mar 9, 2023 · 1 comment

Comments

@ChristopherDosin
Copy link
Contributor

ChristopherDosin commented Mar 9, 2023

We use plugins for customized products. In this case, for example. These are stored separately in the shopping cart and therefore need a changed UUID. In the current version of your plugin, the following position is called in the CartSubscriber and causes a failed UUID check on these positions.

private function checkProductSerial(LineItem $lineItem, Context $context): void
{
if ($lineItem->getType() !== LineItem::PRODUCT_LINE_ITEM_TYPE) {
return;
}

$this->esdCartService->checkProductsWithSerialKey([$lineItem->getId()], $context);
}

We have now solved the customer's problem by excluding these products from the check by performing a UUID check ourselves and catching the exception.

private function checkProductSerial(LineItem $lineItem, Context $context): void
{
if ($lineItem->getType() !== LineItem::PRODUCT_LINE_ITEM_TYPE) {
return;
}

try {
Uuid::fromHexToBytes($lineItem->getId());
} catch (\Exception $e) {
return;
}

$this->esdCartService->checkProductsWithSerialKey([$lineItem->getId()], $context);
}

It would also be conceivable to install an event for which you can register to prevent the examination. Could you please consider something like this for your next plugin version?

@ottschoNaud
Copy link

ottschoNaud commented Mar 9, 2023

I found another part in the code which needs the same condition, the EsdCartService. The final solution needs to be implemented before any call of the checkProductsWithSerialKey function.

public function isCanCheckoutOrder(Cart $cart, Context $context): bool
    {
        $lineItemIds = [];

        try {
            foreach ($cart->getLineItems() as $lineItem) {
                try {
                    Uuid::fromHexToBytes($lineItem->getId());
                } catch (\Exception $e) {
                    continue;
                }

                $lineItemIds[] = $lineItem->getId();
            }

            $this->checkProductsWithSerialKey($lineItemIds, $context);

            return true;
        } catch (ProductNotEnoughSerialException $exception) {
            return false;
        }
    }

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

No branches or pull requests

2 participants