@@ -19,6 +19,13 @@ public static function phpBlueprint(): array
1919 {
2020 return [
2121 'name ' => 'stocks ' ,
22+ 'image ' => [
23+ 'back ' => 'var(--color-black) ' ,
24+ 'color ' => 'var(--color-gray-500) ' ,
25+ 'cover ' => true ,
26+ 'icon ' => 'kart-stocks ' ,
27+ 'query ' => false ,
28+ ],
2229 'options ' => [
2330 'preview ' => false ,
2431 'changeSlug ' => false ,
@@ -37,7 +44,11 @@ public static function phpBlueprint(): array
3744 [
3845 'label ' => 'bnomei.kart.products ' ,
3946 'value ' => '{{ page.children.count }} ' ,
40- 'link ' => '{{ site.kart.page("products").panel.url }} ' ,
47+ 'link ' => '{{ site.kart.page("products")?.panel.url }} ' ,
48+ ],
49+ [
50+ 'label ' => 'bnomei.kart.out-of-stock ' ,
51+ 'value ' => '{{ site.kart.page("products")?.outOfStock.count }} ' ,
4152 ],
4253 [
4354 'label ' => 'bnomei.kart.stocks ' ,
@@ -60,10 +71,10 @@ public static function phpBlueprint(): array
6071 'stocks ' => [
6172 'label ' => 'bnomei.kart.stocks ' ,
6273 'type ' => 'pages ' ,
63- 'search ' => true ,
74+ // 'search' => true,
6475 'template ' => 'stock ' , // maps to StockPage model
6576 'sortBy ' => 'timestamp desc ' ,
66- 'text ' => '[{{ page.stockPad(3) }}] {{ page.page.toPage.title }} ' ,
77+ 'text ' => '{{ page.page.toPage.inStock ? "" : "⚠️ " }} [{{ page.stockPad(3) }}] {{ page.page.toPage.title }} ' ,
6778 'info ' => '{{ page.title }} ・ {{ page.timestamp }} ' ,
6879 'limit ' => 1000 ,
6980 ],
@@ -101,8 +112,11 @@ public function stock(?string $id = null, ?string $withHold = null, ?string $var
101112 }
102113 }
103114 $ t += $ c ;
115+ if ($ c > 0 ) {
116+ $ stocks [$ page ->uuid ()->toString ().'|* ' ] = $ c ;
117+ }
104118 if ($ p + $ c > 0 ) {
105- $ stocks [$ page ->uuid ()->toString ().'|* ' ] = $ p + $ c ;
119+ $ stocks [$ page ->uuid ()->toString ().'|= ' ] = $ p + $ c ;
106120 }
107121 }
108122 if ($ t > 0 ) {
@@ -116,7 +130,7 @@ public function stock(?string $id = null, ?string $withHold = null, ?string $var
116130 } else {
117131 // slowish...
118132 $ stocks = $ this ->stockPages ($ id );
119- $ stock = $ stocks ->count () ? $ stocks ->sumField ('stock ' )->toInt () : null ;
133+ $ stock = $ stocks ->count () && ! $ variant ? $ stocks ->sumField ('stock ' )->toInt () : null ;
120134 foreach ($ stocks as $ p ) {
121135 foreach ($ p ->variants ()->toStructure () as $ var ) {
122136 $ v = $ var ->variant ()->split ();
0 commit comments