Каждый второй магазин на miniShop2 просит «ну ту корзину, которая у вас уже была». Ядро компонента ради чужой вёрстки не правим: обновление придёт ночью и сотрёт героизм. Свои чанки на msCart и msOrder, на «спасибо» — msGetOrder. Ниже каркас, который уже жил на живых сайтах. Это не закон вселенной. Это чтобы не начинать с пустого файла в два часа ночи.
Вызовы на странице оформления:
[ [!msCart?
&tpl=`
Чанк tpl.msCartCustom — строки, плюс/минус, картинка, опции, пустое состояние. Классы под себя переименуете, svg можете выкинуть, логику количества лучше не. Сломаете плюс/минус — будете отлаживать корзину в два часа ночи, и это уже не смешно.
`
]]
[ [!msOrder?
&tpl=`tpl.msOrderCustom`
]]
[ [!msGetOrder]] tpl.msCartCustom<div id="msCart">
{if $products | length == 0}
<div class="alert alert-warning">
{'ms2_cart_is_empty' | lexicon}
</div>
{else}
<div class="table-responsive">
<div class="table table-striped table--cart">
{foreach $products as $product}
{var $image}
{if $product.thumb?}
<img src="{$product.thumb}" alt="{$product.pagetitle}" title="{$product.pagetitle}"/>
{else}
<img src="{'assets_url' | option}components/minishop2/img/web/ms2_small.png"
srcset="{'assets_url' | option}components/minishop2/img/web/ms2_small@2x.png 2x"
alt="{$product.pagetitle}" title="{$product.pagetitle}"/>
{/if}
{/var}
<div id="{$product.key}" class="cart-row">
<div class="ms-image img-mobile">
{if $product.id?}
<a href="{$product.id | url}">{$image}</a>
{else}
{$image}
{/if}
</div>
<div class="cart-row-inner">
<div class="ms-title">
<div class="d-flex title-cart">
<div class="ms-image mw-100 pr-3 image-desc">
{if $product.id?}
<a href="{$product.id | url}">{$image}</a>
{else}
{$image}
{/if}
</div>
<div >
{if $product.id?}
<a class="ms-cart-title_link" href="{$product.id | url}">{$product.pagetitle}</a>
{else}
{$product.name}
{/if}
{if $product.options?}
<div class="options-cart">
{foreach $product.options as $key => $option}
{if $key in ['modification','modifications','msal']}{continue}{/if}
{set $caption = $product[$key ~ '.caption']}
{set $caption = $caption ? $caption : ('ms2_product_' ~ $key) | lexicon}
{if $option is array}
{$caption} - {$option | join : '; '} <br>
{else}
{$caption} - {$option} <br>
{/if}
{/foreach}
</div>
{/if}
</div>
</div>
</div>
<div class="ms-count">
<p class="ms-count-head">Кол-во:</p>
<form method="post" class="ms2_form form-count js-count">
<input type="hidden" name="key" value="{$product.key}"/>
<span class="count_btn minus" data-ms2-count="minus">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dash" viewBox="0 0 16 16"><path d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z"></path></svg>
</span>
<div class="form-group">
<div class="input-group input-group-sm">
<input type="text" name="count" value="{$product.count}" class="form-control form-control--count"/>
[ [-
<div class="input-group-append">
<span class="input-group-text">{'ms2_frontend_count_unit' | lexicon}</span>
</div>]]
</div>
<button class="btn btn-sm" type="submit" name="ms2_action" value="cart/change">↻</button>
</div>
<span class="plus count_btn" data-ms2-count="plus">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16"><path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path></svg>
</span>
</form>
</div>
[ [-
<div class="ms-weight">
<span class="text-nowrap">{$product.weight} {'ms2_frontend_weight_unit' | lexicon}</span>
</div>]]
<div class="ms-price">
<p class="mob-title">Цена:</p>
<span class="mr-2 text-nowrap">{$product.price} {'ms2_frontend_currency' | lexicon}</span>
{if $product.old_price?}
<span class="old_price text-nowrap">{$product.old_price} {'ms2_frontend_currency' | lexicon}</span>
{/if}
</div>
<div class="ms-cost">
<p class="mob-title">Стоимость:</p>
<span class="mr-2 text-nowrap"><span class="ms2_cost">{$product.cost}</span> {'ms2_frontend_currency' | lexicon}</span>
</div>
<div class="ms-remove">
<form method="post" class="ms2_form text-md-right">
<input type="hidden" name="key" value="{$product.key}">
<button class="btn btn-sm btn-danger" type="submit" name="ms2_action" value="cart/remove">×</button>
</form>
</div>
</div>
</div>
{/foreach}
</div>
<div class="ms-footer">
<div class="total"><strong>{'ms2_cart_total' | lexicon}:</strong> </div>
[ [-
<div class="total">{'ms2_cart_total' | lexicon}:</div>
<div class="total_count">
<span class="ms2_total_count">{$total.count}</span>
{'ms2_frontend_count_unit' | lexicon}
</div>
<div class="total_weight text-nowrap" colspan="2">
<span class="ms2_total_weight">{$total.weight}</span>
{'ms2_frontend_weight_unit' | lexicon}
</div>
]]
<div class="total_cost text-nowrap" colspan="2">
<span class="ms2_total_cost">{$total.cost}</span>
{'ms2_frontend_currency' | lexicon}
</div>
</div>
</div>
[ [-
<form method="post" class="ms2_form">
<button type="submit" name="ms2_action" value="cart/clean" class="btn btn-danger">
{'ms2_cart_clean' | lexicon}
</button>
</form>]]
{/if}
</div>
tpl.msOrderCustom
<form class="ms2_form" id="msOrder" method="post" style="margin-bottom:50px">
<div class="row row--fields">
<div class="col-12 col-md-6">
<h4>Чтобы завершить <strong>оформление заказа</strong></h4>
<p>Пользователю необходимо пройти следующие шаги:</p>
<strong class="order-head">1. Данные получателя</strong>
<div class="order-list">
{foreach ['email','receiver','phone'] as $field}
<div class="form-group row input-parent ">
<div class="col-md-8">
<input type="text" id="{$field}" placeholder="{('ms2_frontend_' ~ $field) | lexicon}"
name="{$field}" value="{$form[$field]}"
class="form-control{($field in list $errors) ? ' error' : ''}">
</div>
</div>
{/foreach}
</div>
</div>
</div>
<div class="row ">
<div class="col-12 col-md-6 row--fields" id="deliveries">
<strong class="order-head">2. Варианты доставки:</strong>
<div class="form-group row">
<div class="col-12 delivery-wrap-order">
{foreach $deliveries as $delivery index=$index}
{var $checked = !($order.delivery in keys $deliveries) && $index == 0 || $delivery.id == $order.delivery}
<div class="checkbox">
[ [-
<label class="col-form-label delivery input-parent">
<input type="radio" name="delivery" value="{$delivery.id}" id="delivery_{$delivery.id}"
data-payments="{$delivery.payments | json_encode}"
{$checked ? 'checked' : ''}>
{if $delivery.logo?}
<img src="{$delivery.logo}" alt="{$delivery.name}" title="{$delivery.name}"/>
{else}
{$delivery.name}
{/if}
{if $delivery.description?}
<p class="small">
{$delivery.description}
</p>
{/if}
</label>
]]
<label class="cart_aside-check">
<input type="radio" name="delivery" value="{$delivery.id}" id="delivery_{$delivery.id}"
data-payments="{$delivery.payments | json_encode}"
{$checked ? 'checked' : ''}>
<span></span>
<div class="delivery-block-order">
{$delivery.name}
{if $delivery.description?}
<p class="small">
{$delivery.description}
</p>
{/if}
</div>
</label>
</div>
{/foreach}
</div>
</div>
</div>
<div class="col-12 col-md-6 row--fields" id="payments">
<strong class="order-head">3. Способы оплаты:</strong>
<div class="form-group row">
<div class="col-12 delivery-wrap-order payment-wrap-order">
{foreach $payments as $payment index=$index}
{var $checked = !($order.payment in keys $payments) && $index == 0 || $payment.id == $order.payment}
<div class="checkbox">
<label class="payment input-parent">
<input type="radio" name="payment" value="{$payment.id}" id="payment_{$payment.id}"
{$payment.id == $order.payment ? 'checked' : ''}>
{if $payment.logo?}
<img src="{$payment.logo}" alt="{$payment.name}" title="{$payment.name}"/>
{else}
{$payment.name}
{/if}
{if $payment.description?}
<p class="small">
{$payment.description}
</p>
{/if}
</label>
[ [-
<label class="col-form-label payment input-parent">
<input type="radio" name="payment" value="{$payment.id}" id="payment_{$payment.id}"{$checked ? 'checked' : ''}>
{if $payment.logo?}
<img src="{$payment.logo}" alt="{$payment.name}" title="{$payment.name}" class="mw-100"/>
{else}
{$payment.name}
{/if}
{if $payment.description?}
<p class="small">{$payment.description}</p>
{/if}
</label>]]
</div>
{/foreach}
</div>
</div>
</div>
<div class="col-12 col-md-6 row--fields">
<strong class="order-head">4. Адрес доставки:</strong>
<div class="order-list order-list--address">
{foreach ['index','region','city', 'street', 'building'] as $field}
<div class="form-group row input-parent form-group-{$field}">
<div class="col-md-8">
<input type="text" id="{$field}" placeholder="{('ms2_frontend_' ~ $field) | lexicon}"
name="{$field}" value="{$form[$field]}"
class="form-control{($field in list $errors) ? ' error' : ''}">
</div>
</div>
{/foreach}
</div>
</div>
</div>
[ [-
<button type="button" name="ms2_action" value="order/clean" class="btn btn-danger ms2_link">
{'ms2_frontend_order_cancel' | lexicon}
</button>
]]
<div class="form-group row input-parent row--fields">
<strong class="col-md-4 col-form-label order-head" for="comment">
5. {'ms2_frontend_comment' | lexicon} <span class="required-star">*</span>
</strong>
<div class="col-md-8 order-list">
<textarea name="comment" id="comment" placeholder="{'ms2_frontend_comment' | lexicon}"
class="form-control{('comment' in list $errors) ? ' error' : ''}">{$form.comment}</textarea>
</div>
</div>
<div class="d-flex flex-column flex-md-row align-items-center justify-content-center justify-content-md-end mb-5 order-bottom-wrapper">
<div class="footer-order">
<h4 class="mb-md-0">{'ms2_frontend_order_cost' | lexicon}:</h4>
<strong> <span id="ms2_order_cost">{$order.cost ?: 0}</span> {'ms2_frontend_currency' | lexicon}</strong>
</div>
<button type="submit" name="ms2_action" value="order/submit" class="btn card_btn" style="border:none">
{'ms2_frontend_order_submit' | lexicon}
</button>
</div>
</form>
css.cart-row-inner{
position: relative;
display: flex;
justify-content: space-between;
width: 100%;
align-items: center;
}
.cart-row{
display: flex;
padding:20px 0;
border-top: 1px solid #d6d6d6;
}
.cart-row:last-child{
border-bottom: 1px solid #d6d6d6;
}
.ms-title{
width: 30%;
}
.title-cart{
display: flex;
gap:10px;
}
.ms-cart-title_link{
color:inherit;
font-weight: bold;
margin-bottom: 10px;
display: block;
}
.ms-price{
display: flex;
flex-direction:column;
gap:10px;
}
.ms-count{
display: flex;
gap:10px;
align-items: center;
}
.table .ms-count-head{
flex: 0 0 auto;
margin-bottom: 0;
}
.form-control--count{
width: 100%;
border: none;
background: transparent;
text-align: center;
}
.btn-cart-count{
cursor:pointer;
}
.form-count{
display: flex;
align-items: center;
padding:10px;
border-radius:15px;
border:1px solid #d6d6d6;
}
#msCart .old_price{
color:#c5c5c5;
}
.ms-footer{
display: flex;
justify-content: flex-end;
gap: 10px;
margin: 20px 0;
}
.options-cart{
font-size: 12px;
}
.ms-remove{
width: 20px;
}
.ms-remove .btn{
cursor:pointer;
border: none;
background: #fff;
box-shadow: 0px 0px 67px -9px rgba(0, 0, 0, 0.2);
color: #646161;
}
#msOrder input{
-webkit-text-fill-color: inherit;
}
.table--cart{
display: flex;
flex-direction: column;
gap: 20px;
}
.order-list{
display: flex;
justify-content: space-between;
flex-wrap:wrap;
}
.order-list--address{
row-gap:15px;
}
.row--fields{
margin-bottom: 20px;
}
.delivery-block-order{
display: flex;
flex-direction:column;
}
.delivery-wrap-order{
display: flex;
justify-content: space-between;
}
.order-list .form-group{
width: 32%;
}
.order-list .form-control{
width: 100%;
padding:20px 20px;
border-radius:15px;
border:1px solid #d6d6d6;
}
.order-head{
display: block;
margin-bottom: 20px;
}
.order-list--address .form-group{
width: 33%;
}
.order-btn{
border:none;
cursor:pointer;
width: 30%;
margin-bottom: 0;
}
.payment-wrap-order{
justify-content: flex-start;
gap:20px;
}
.order-bottom-wrapper{
display: flex;
justify-content: space-between;
}
/* .order-list--address .form-group-building,.order-list--address .form-group-entrance,.order-list--address .form-group-floor,.order-list--address .form-group-room{
width: 16.2222%;
} */
.order-list--address{
justify-content: flex-start;
gap:5px;
}
.footer-order{
display: flex;
gap:10px;
align-items: center;
}
#msOrder .cart_aside-check span{
background-color: #9e9e9e;
}
#msOrder .cart_aside-check input:checked + span{
background-color: #6DB654;
}
.img-mobile,.mob-title{
display: none;
}
.order-list--full{
width: 100%;
}
.full-w{
width: 100%;
}
.d-none{
display: none;
}
@media(max-width:992px){
.cart-row-inner{
align-items: flex-start;
}
#msCart .mob-title{
display: block;
margin-bottom: 0;
}
.ms-cost{
display: flex;
flex-direction:column;
gap:10px;
}
.cart-row-inner{
flex-wrap:wrap;
gap:20px;
}
#msCart .ms-title{
width: 100%;
}
#msCart .ms-price{
width: 30%;
}
.cart-row{
gap:20px;
}
.img-mobile{
display: flex;
align-items: center;
}
.order-list--address{
gap:0.5%;
row-gap: 15px;
}
.ms-count{
flex-direction:column;
}
.image-desc{
display: none;
}
}
@media(max-width:769px){
.order-list .form-group,.order-btn{
width: 100%;
}
.order-list{
gap:10px;
}
#msCart .ms-count{
width: 100%;
align-items: flex-start;
}
.delivery-wrap-order,.payment-wrap-order{
flex-wrap:wrap;
gap:10px;
}
.order-bottom-wrapper{
flex-wrap:wrap;
gap:10px;
}
}
@media(max-width:427px){
#msCart .ms-price{
width: 100%;
}
.ms-remove{
position: absolute;
top:0;
right: 10px;
}
}
Комментарии
Комментарии (0)