Skip to content

Voucher does not redeem any amounts and custom line items doesn't work #136

@gopeter

Description

@gopeter

Describe the bug

It seems that there are some incompatibilities between Craft Commerce 5.1 and the Gift Voucher plugin. Adding the voucher to a cart doesn't redeem an amount (it's always 0).

Additionally, I can't add a custom line item (added since Commerce 5.1) once a voucher is applied to the cart:

{
    "name": "Invalid Configuration",
    "message": "Cannot get a purchasable for a custom line item",
    "code": 0,
    "exception": "yii\\base\\InvalidConfigException",
    "file": "/var/www/html/vendor/craftcms/commerce/src/models/LineItem.php",
    "line": 820,
    "trace": [
        {
            "file": "/var/www/html/vendor/verbb/gift-voucher/src/services/Codes.php",
            "line": 245,
            "function": "getPurchasable",
            "class": "craft\\commerce\\models\\LineItem",
            "type": "->"
        },
        {
            "function": "handleValidateLineItem",
            "class": "verbb\\giftvoucher\\services\\Codes",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Event.php",
            "line": 312,
            "function": "call_user_func"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Component.php",
            "line": 650,
            "function": "trigger",
            "class": "yii\\base\\Event",
            "type": "::"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Model.php",
            "line": 386,
            "function": "trigger",
            "class": "yii\\base\\Component",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Model.php",
            "line": 351,
            "function": "beforeValidate",
            "class": "yii\\base\\Model",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/craftcms/commerce/src/elements/traits/OrderValidatorsTrait.php",
            "line": 133,
            "function": "validate",
            "class": "yii\\base\\Model",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/validators/InlineValidator.php",
            "line": 77,
            "function": "validateLineItems",
            "class": "craft\\commerce\\elements\\Order",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/validators/Validator.php",
            "line": 260,
            "function": "validateAttribute",
            "class": "yii\\validators\\InlineValidator",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Model.php",
            "line": 368,
            "function": "validateAttributes",
            "class": "yii\\validators\\Validator",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/craftcms/cms/src/base/Element.php",
            "line": 2666,
            "function": "validate",
            "class": "yii\\base\\Model",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/craftcms/commerce/src/controllers/OrdersController.php",
            "line": 454,
            "function": "validate",
            "class": "craft\\base\\Element",
            "type": "->"
        },
        {
            "function": "actionRefresh",
            "class": "craft\\commerce\\controllers\\OrdersController",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/InlineAction.php",
            "line": 57,
            "function": "call_user_func_array"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Controller.php",
            "line": 178,
            "function": "runWithParams",
            "class": "yii\\base\\InlineAction",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Module.php",
            "line": 552,
            "function": "runAction",
            "class": "yii\\base\\Controller",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
            "line": 350,
            "function": "runAction",
            "class": "yii\\base\\Module",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
            "line": 649,
            "function": "runAction",
            "class": "craft\\web\\Application",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
            "line": 312,
            "function": "_processActionRequest",
            "class": "craft\\web\\Application",
            "type": "->"
        },
        {
            "file": "/var/www/html/vendor/yiisoft/yii2/base/Application.php",
            "line": 384,
            "function": "handleRequest",
            "class": "craft\\web\\Application",
            "type": "->"
        },
        {
            "file": "/var/www/html/web/index.php",
            "line": 14,
            "function": "run",
            "class": "yii\\base\\Application",
            "type": "->"
        }
    ]
}

Steps to reproduce

  1. Add the voucher to the cart
  2. Add a product to the cart
  3. Go to the backend and open the cart
  4. Click on "add a custom line item"
  5. A network error occurs

Craft CMS version

Craft Pro 5.4.4

Plugin version

4.0.3

Multi-site?

Yes

Additional context

Craft Commerce 5.1.1

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