public function recalcp($id, $qty){
if(!isset($_SESSION['cart'][$id])) return false;
$qtyMinus = $_SESSION['cart'][$id][$qty] === 1;
$sumMinus = $_SESSION['cart'][$id][$qty] * $_SESSION['cart'][$id]['price'];
$_SESSION['cart.qty'] -= $qtyMinus;
$_SESSION['cart.sum'] -= $sumMinus;
unset($_SESSION['cart'][$id]);
}
public function actionDelPr(){
$id = Yii::$app->request->post('id');
$qty = (int)Yii::$app->request->post('qty');
$session =Yii::$app->session;
$cart = new Cart();
$cart->recalcp($id, $qty);
$this->layout = false;
return $this->render('cart-modal', compact('session'));
}
$('#cart .modal-body').on('click', '.del-n', function () {
var id = $(this).data('id'),
qty = $(this).prev('.js-qty').val();
$.ajax({
url: '/cart/del-pr',
data: {id: id, qty: qty},
type: 'POST',
success: function(res){
if(!res) alert('Ошибка!');
showCart(res);
},
error: function(){
alert('Error!');
}
});
});
<div class="spoiler">
<input style="position: absolute;left: -9999px;" class="size" type="radio" id="f<?= $one->id ?>" checked name="<?= $one->id ?>" value="31"/>
<label class="product_size left_size" for="f<?= $one->id ?>"> 31 см</label>
<div class="box">
<div class="product__controls tuuu1">
<div class="product__cart">
<div class="product__price"><span class="money"><span class="money__value"><?= $one->price ?> </span><span class="money__currency money__currency_on-the-right">₽</span></span>
</div>
<div class="product__to-cart">
<input type="text" value="1" class="js-qty" id="qty">
<a href="<?= \yii\helpers\Url::to(['cart/add', 'id' => $one->id]) ?>" data-id="<?= $one->id ?>" type="submit" class="product__button button button_primary-outline add-to-cart">
<span class="button__inc">В корзину</span>
</a>
</div>
</div>
</div>
</div>
<input class="size" type="radio" id="f<?= $one->id ?>" checked name="<?= $one->id ?>" value="31"/>
<label class="product_size left_size" for="f<?= $one->id ?>"> 31 см</label>
<input type="radio" class="size" id="r<?= $one->id ?>" name="<?= $one->id ?>" value="50"/>
<label class="product_size right_size" for="r<?= $one->id ?>"> 50 см</label>
<input type="text" value="1" class="js-qty" id="qty">
<a href="<?= \yii\helpers\Url::to(['cart/add', 'id' => $one->id]) ?>" data-id="<?= $one->id ?>" type="submit" class="product__button button button_primary-outline add-to-cart">
<span class="button__inc">В корзину</span>
</a>
2 крупных сайта поднимать (один из них прямой конкурент спортмастера)
1 сервис - на полной предоплате 16 компаний