craftcms / digital-products

Sell digital products with Craft Commerce.
https://plugins.craftcms.com/digital-products
MIT License
18 stars 9 forks source link

A license without a linked order results in an error #100

Open berrytimmermans opened 5 months ago

berrytimmermans commented 5 months ago

Description

When one of the licenses is not linked to an order because it was, for instance, manually created, the query below in the example results in: Invalid Argument – yii\base\InvalidArgumentException - Invalid numeric value.

{% set licenses = craft.digitalProducts
        .licenses
        .owner(currentUser)
        .with(['product', 'order'])
        .all()
%}

Steps to reproduce

1.Use the example in the template: Displaying the licensed product for the currently logged-in Craft User. 2.Add a license via the control panel, so that no order is linked.

Additional info

Craft Commerce 4.6.2 Digital Products 3.2.3 Freeform 5.3.5 Link Vault 4.0.4 Mollie for Craft Commerce 4.2.0 Redactor 3.1.0 Redactor Anchors 1.5.0

linear[bot] commented 5 months ago

PT-1835 A license without a linked order results in an error

lukeholder commented 5 months ago

@berrytimmermans could you post the full stack trace please - I will then take a look into it. Thanks

berrytimmermans commented 4 months ago

Thanks @lukeholder for your response, here's the stack trace.

yii\base\InvalidArgumentException: Invalid numeric value:  in /var/www/html/vendor/craftcms/cms/src/helpers/Db.php:599
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/helpers/Db.php(850): craft\helpers\Db::parseParam('elements.id', Array, '=', false, 'integer')
#1 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1464): craft\helpers\Db::parseNumericParam('elements.id', Array)
#2 /var/www/html/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#3 /var/www/html/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\commerce\elements\db\OrderQuery))
#4 /var/www/html/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#5 /var/www/html/vendor/craftcms/cms/src/db/Query.php(252): yii\db\Query->all(NULL)
#6 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1632): craft\db\Query->all(NULL)
#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3038): craft\elements\db\ElementQuery->all()
#8 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2916): craft\services\Elements->_eagerLoadElementsInternal('craft\\digitalpr...', Array, Array)
#9 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(3247): craft\services\Elements->eagerLoadElements('craft\\digitalpr...', Array, Array)
#10 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1589): craft\elements\db\ElementQuery->_createElements(Array)
#11 /var/www/html/vendor/yiisoft/yii2/db/Query.php(251): craft\elements\db\ElementQuery->populate(Array)
#12 /var/www/html/vendor/craftcms/cms/src/db/Query.php(252): yii\db\Query->all(NULL)
#13 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1632): craft\db\Query->all(NULL)
#14 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1635): craft\elements\db\ElementQuery->all()
#15 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(142): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\digitalproducts\elements\db\LicenseQuery), 'all', Array, 'method', false, false, false, 5)
#16 /var/www/html/storage/runtime/compiled_templates/9b/9b3e352ded4922edfa62f6b5b2e047ad.php(42): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\digitalproducts\elements\db\LicenseQuery), 'all', Array, 'method', false, false, false, 5)
#17 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_c5fa357502bd87af03b8671c316d0acf->doDisplay(Array, Array)
#18 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#19 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
#20 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
#21 /var/www/html/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render(Array)
#22 /var/www/html/vendor/craftcms/cms/src/web/View.php(488): Twig\Environment->render('shop/account/er...', Array)
#23 /var/www/html/vendor/craftcms/cms/src/web/View.php(541): craft\web\View->renderTemplate('shop/account/er...', Array)
#24 /var/www/html/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(57): craft\web\View->renderPageTemplate('shop/account/er...', Array, 'site')
#25 /var/www/html/vendor/yiisoft/yii2/web/Response.php(1109): craft\web\TemplateResponseFormatter->format(Object(craft\web\Response))
#26 /var/www/html/vendor/craftcms/cms/src/web/Response.php(338): yii\web\Response->prepare()
#27 /var/www/html/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#28 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#29 /var/www/html/public_html/index.php(12): yii\base\Application->run()
#30 {main}