Хочу сделать корзину с помощью данного модуля https://github.com/omnilight/yii2-shopping-cart
Добавил в модель
Код: Выделить всё
use CartPositionTrait;
public function getPrice()
{
return $this->product_cost;
}
public function getId()
{
return $this->product_id;
}
Код: Выделить всё
public function actionAddToCart($id)
{
$cart = new ShoppingCart();
$model = Product::findOne($id);
if ($model) {
$cart->put($model, 1);
return $this->redirect(['cart-view']);
}
throw new NotFoundHttpException();
}
В описании указана эта инструкция. но как ее прикрутить к виду?
Код: Выделить всё
\Yii::$app->cart->put($cartPosition, 1);