forked from unimatrix/web
Build Dune shop catalogue and repair shared menu publication
This commit is contained in:
parent
2cc164d06b
commit
4382bae93b
2 changed files with 14 additions and 5 deletions
|
|
@ -11,23 +11,30 @@ final class DuneShopController extends Sceleton {
|
|||
$sashes=count(array_filter($rows,fn($r)=>$r['kind']==='sash'));$ranks=count(array_filter($rows,fn($r)=>$r['kind']==='rank'));
|
||||
$base=fn($route)=>Html::encode(\yii\helpers\Url::to([$route]));
|
||||
$out='<section class="dune-store-welcome"><div><small>THE DUNEREALMS EMPORIUM</small><h1>Carry a piece of the realms.</h1><p>Ceremonial sashes, personal keepsakes and ways to support the community.</p><a class="dune-store-button" href="'.$base('catalog/all-products').'">Browse the collection</a></div><img src="https://www.dunerealms.com/assets/nav-shop-v1.webp" alt=""></section>';
|
||||
$tiles=[['Ceremonial sashes',$sashes.' designs · made to order','catalog/all-products','nav-clan-v2.webp','sash'],['Donor ranks',$ranks.' ways to support the realms','catalog/all-products','nav-account-v2.webp','rank'],['Sale',count($saleIds)?'Explore current offers':'No sales active right now','catalog/sales','nav-exchange-v2.webp','']];
|
||||
$tiles=[['Sale',count($saleIds)?'Explore current offers':'No sales active right now','catalog/sales','nav-exchange-v2.webp',''],['Ceremonial sashes',$sashes.' designs · made to order','catalog/all-products','nav-clan-v2.webp','sash'],['Donor ranks',$ranks.' ways to support the realms','catalog/all-products','nav-account-v2.webp','rank']];
|
||||
$out.='<nav class="dune-store-categories" aria-label="Shop collections">';
|
||||
foreach($tiles as [$title,$text,$route,$icon,$kind]){
|
||||
$category=$kind?Yii::$app->db->createCommand('SELECT c.categories_id FROM categories c JOIN categories_description d ON d.categories_id=c.categories_id WHERE d.language_id=1 AND d.categories_name=:name LIMIT 1',[':name'=>$kind==='sash'?'Ceremonial Sashes':'Donor Ranks'])->queryScalar():null;
|
||||
$url=$category?\yii\helpers\Url::to(['catalog/index','cPath'=>$category]):\yii\helpers\Url::to([$route]);
|
||||
$out.='<a href="'.Html::encode($url).'"><img src="https://www.dunerealms.com/assets/'.$icon.'" alt=""><div><h2>'.Html::encode($title).'</h2><p>'.Html::encode($text).'</p></div><span aria-hidden="true">↗</span></a>';
|
||||
$out.='<a class="'.($title==='Sale'?'dune-store-category--sale':'').'" href="'.Html::encode($url).'"><img src="https://www.dunerealms.com/assets/'.$icon.'" alt=""><div><h2>'.Html::encode($title).'</h2><p>'.Html::encode($text).'</p></div><span aria-hidden="true">'.($title==='Sale'?'SALE':'↗').'</span></a>';
|
||||
}
|
||||
$out.='</nav>';
|
||||
foreach([['New arrivals','Recently added to the collection',array_slice($rows,0,6),'catalog/products-new'],['Featured','Selected pieces from the realms',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$featuredIds))),'catalog/featured-products'],['Sale','Current offers from the emporium',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$saleIds))),'catalog/sales']] as [$title,$sub,$items,$route]){
|
||||
$out.='<section class="dune-store-section"><header><div><h2>'.$title.'</h2><p>'.$sub.'</p></div><a href="'.$base($route).'">View all ↗</a></header>';
|
||||
foreach([['Sale','Current offers from the emporium',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$saleIds))),'catalog/sales'],['Featured','Selected pieces from the realms',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$featuredIds))),'catalog/featured-products'],['New arrivals','Recently added to the collection',array_slice($rows,0,6),'catalog/products-new']] as [$title,$sub,$items,$route]){
|
||||
$out.='<section class="dune-store-section'.($title==='Sale'?' dune-store-section--sale':'').'"><header><div><h2>'.($title==='Sale'?'<span class="dune-store-sale-label">SALE</span> ':'').$title.'</h2><p>'.$sub.'</p></div><a href="'.$base($route).'">View all ↗</a></header>';
|
||||
if(!$items)$out.='<div class="dune-store-empty">'.($title==='Sale'?'There are no active sale offers.':'Featured products have not been selected yet.').'</div>';
|
||||
else{
|
||||
$out.='<div class="dune-store-products">';
|
||||
foreach(array_slice($items,0,6) as $p){
|
||||
$url=Html::encode(\yii\helpers\Url::to(['catalog/product','products_id'=>$p['products_id']]));
|
||||
$image=Html::encode(\common\classes\Images::getImageUrl($p['products_id'],'Small',1));
|
||||
$price=Yii::$container->get('currencies')->display_price(\common\helpers\Product::get_products_price($p['products_id'],1,$p['products_price']),\common\helpers\Tax::get_tax_rate($p['products_tax_class_id']));
|
||||
$currencies=Yii::$container->get('currencies');$tax=\common\helpers\Tax::get_tax_rate($p['products_tax_class_id']);
|
||||
$normal=\common\helpers\Product::get_products_price($p['products_id'],1,$p['products_price']);
|
||||
$special=\common\helpers\Product::get_products_special_price($p['products_id'],1);
|
||||
$price=$currencies->display_price($normal,$tax);
|
||||
if($special!==false&&$special!==null&&(float)$special>=0&&(float)$special<(float)$normal){
|
||||
$saving=(int)round((1-(float)$special/(float)$normal)*100);
|
||||
$price='<del>'.$price.'</del><strong>'.$currencies->display_price($special,$tax).'</strong><span class="dune-store-saving">Save '.$saving.'%</span>';
|
||||
}
|
||||
$out.='<article><a class="dune-store-product-art" href="'.$url.'"><img loading="lazy" src="'.$image.'" alt="'.Html::encode($p['products_name']).'"></a><small>'.($p['kind']==='sash'?'MADE TO ORDER':'CATALOGUE PREVIEW').'</small><h3><a href="'.$url.'">'.Html::encode($p['products_name']).'</a></h3><div class="dune-store-price">'.$price.'</div><a class="dune-store-button" href="'.$url.'">View details</a></article>';
|
||||
}
|
||||
$out.='</div>';
|
||||
|
|
|
|||
|
|
@ -30,3 +30,5 @@ html,body{height:auto!important;min-height:0!important}.main-content{min-height:
|
|||
@media(min-width:1500px){.dune-store-products{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(max-width:900px){.dune-store-categories{grid-template-columns:1fr}.dune-store-products{grid-template-columns:repeat(2,minmax(0,1fr))}.dune-store-welcome{padding:28px}.dune-store-welcome>img{width:110px;height:110px}}@media(max-width:550px){.dune-store-welcome{padding:24px;gap:12px}.dune-store-welcome>img{display:none}.dune-store-products{grid-template-columns:1fr}.dune-store-section{padding:18px}.dune-store-section>header{align-items:flex-start}.dune-store-product-art{height:210px}.dune-store-product-art img{height:200px!important}.header-middle>.block{flex-wrap:wrap!important;justify-content:center!important}.header-middle .w-search{flex-basis:100%!important}}
|
||||
/* Catalogue navigation, filtering and pagination share the framed dev-alpha system. */
|
||||
#box-110903{padding:0!important;background:transparent!important}#box-110904{padding:20px!important;border:1px solid #6b7048!important;border-radius:12px!important;background:linear-gradient(145deg,#1a3b2b,#10291f)!important;box-sizing:border-box!important}#box-110904 h2,#box-110904 h3,#box-110904 .title,.leftCategories .title{color:#e5ce8e!important;font-size:16px!important;font-weight:600!important}.leftCategories ul{list-style:none!important;padding:0!important}.leftCategories a,.w-categories a,.w-menu-simple a{display:block;padding:10px 12px!important;border-radius:7px;color:#d5dfca!important;font-size:13px!important;text-decoration:none!important}.leftCategories a:hover,.w-categories a:hover,.w-menu-simple a:hover{background:#2c4c34!important;color:#f3dd9d!important}.w-catalog-sorting,.w-catalog-items-on-page,.w-catalog-listing-look,.w-catalog-compare-button{padding:10px 12px!important;background:#112b20!important;border:1px solid #4f6544!important;border-radius:8px!important;color:#bfcfb5!important;font-size:12px!important;box-sizing:border-box!important}.w-catalog-sorting select,.w-catalog-items-on-page select{padding:8px 10px!important;border:1px solid #8b7b4b!important;border-radius:7px!important;min-height:36px!important;background:#0b2119!important;color:#eadbb2!important}.w-catalog-counts-items{padding:12px 0!important;font-size:12px!important;color:#aabfa4!important}.w-catalog-paging a,.w-catalog-paging span{border-color:#687146!important;border-radius:6px!important;color:#dfca90!important;background:#163223!important}.w-catalog-paging .active,.w-catalog-paging .current{background:#355237!important;border-color:#bea058!important;color:#fff0c4!important}.w-catalog-listing-look a{color:#e1cb8e!important}.products-listing .item-nav,.products-listing .compare label{color:#bfccb3!important;background:#10291f!important}.products-listing .view-button{min-width:85px!important}.products-listing .instock,.products-listing .in-stock{color:#b6d6ad!important;font-size:12px!important}.w-catalog-b2b-add-button{display:none!important}.w-catalog-title h1{color:#eed99e!important;padding:4px 0!important}.main-content .filter-box,.main-content .filters{border:1px solid #4b6241!important;border-radius:9px!important;padding:14px!important;background:#102b20!important;color:#d3dec7!important}.main-content input[type=checkbox]{accent-color:#b59a53!important}.products-listing .item{transition:border-color .15s,box-shadow .15s}.products-listing .item:hover{border-color:#c5a75c!important;box-shadow:0 10px 28px #0004!important}
|
||||
/* Active promotions get a restrained commercial sale treatment. */
|
||||
.dune-store-category--sale{background:linear-gradient(125deg,#542e2a,#292d21)!important;border-color:#b08855!important}.dune-store-category--sale>span{font-size:10px!important;letter-spacing:.1em!important;background:#a24636;border:1px solid #ce8f63;border-radius:5px;padding:6px 8px;color:#fff0cb!important}.dune-store-section--sale{background:linear-gradient(120deg,#38281f,#172e21 65%)!important;border-color:#b08a53!important;border-top:3px solid #b77949!important;box-shadow:0 8px 24px #0003}.dune-store-section--sale>header{border-color:#805b40!important}.dune-store-sale-label{display:inline-block;vertical-align:middle;font-size:10px;line-height:1.2;letter-spacing:.1em;background:#a54737;color:#fff1cf;padding:6px 9px;border:1px solid #d48b60;border-radius:5px;margin-right:8px}.dune-store-section--sale article{border-color:#8c7147!important;background:linear-gradient(145deg,#302f20,#10271b)!important}.dune-store-price del{display:block;color:#a9b3a1;font-size:13px;font-weight:400;margin-bottom:5px}.dune-store-price strong{display:block;color:#f3d28a!important}.dune-store-saving{display:inline-block;font-size:10px;font-weight:600;letter-spacing:.025em;background:#8f3d2e;color:#ffe6b3;border:1px solid #bd7850;border-radius:4px;padding:4px 7px;margin-top:8px}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff