You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have this error: Argument 1 passed to yii2mod\cart\Cart::add() must be an instance of yii2mod\cart\models\CartItemInterface
is in this method: public function add(CartItemInterface $element, $save = true): self
I follow the doc and configured the extension in correct way:
'cart' => [
'class' => 'yii2mod\cart\Cart',
// you can change default storage class as following:
'storageClass' => [
'class' => 'yii2mod\cart\storage\DatabaseStorage',
// you can also override some properties
'deleteIfEmpty' => true
]
],
Then in my controller, just this simple code:
public function actionCart()
{
$cart = \Yii::$app->cart;
$cart->add(2);
}
I tried to:
Remove configuration in main.php and is not working because configuration are missing, so mean is correctly configurate
implement CartItemInterface in controller
implement add() method in model and call from controller
I try to pass in method integer, array and string
Where I am wrong?
Thank you
The text was updated successfully, but these errors were encountered:
Hello,
I have this error:
Argument 1 passed to yii2mod\cart\Cart::add() must be an instance of yii2mod\cart\models\CartItemInterface
is in this method:
public function add(CartItemInterface $element, $save = true): self
I follow the doc and configured the extension in correct way:
Then in my controller, just this simple code:
I tried to:
Where I am wrong?
Thank you
The text was updated successfully, but these errors were encountered: