Gib Paketen eine eigene Produktseite und ergänze Tests zu Nutzerkreis und Verkaufsstart
Ein eigenständig vermarktetes Paket (offers.standalone_bundle) erhält /pakete/{id}
mit seinem tatsächlichen Umfang, Shop-Kachel und Suche. Die Angebotsmaske kennt
Nutzerkreis und Anzahl Trainer. Zwei Bestandstests (CartTest, Vergleich der
Rechte und Erwerbsarten) legen die Vergleichsangebote jetzt als Einzellizenz an,
weil der Nutzerkreis zum identischen Umfang gehört; ihre Aussagen bleiben.
Eine Rechnungs- oder Stripe-Bestellung lässt sich nicht mit der Testzahlung bestätigen.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0154182f3b
commit
1ce2e1e51f
21 files changed
+997
-31
No files matched your search
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
@@ -31,9 +32,8 @@ public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
$page = $offer->composition;
|
||||
$result = $page !== null && $catalog->shownVersion($page) !== null
|
||||
? $cart->add($offer)
|
||||
: Cart::UNAVAILABLE;
|
||||
$listed = $offer->standalone_bundle || ($page !== null && $catalog->shownVersion($page) !== null);
|
||||
$result = $listed ? $cart->add($offer) : Cart::UNAVAILABLE;
|
||||
$back = $this->productPage($offer);
|
||||
|
||||
return match ($result) {
|
||||
@@ -81,8 +81,8 @@ public function accept(Offer $offer, Cart $cart): RedirectResponse
|
||||
|
||||
private function productPage(Offer $offer): RedirectResponse
|
||||
{
|
||||
return $offer->composition_id !== null
|
||||
? redirect()->route('public.program', $offer->composition_id)
|
||||
: redirect()->route('cart');
|
||||
$url = app(ProductOptions::class)->pageUrl($offer);
|
||||
|
||||
return $url !== null ? redirect()->to($url) : redirect()->route('cart');
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
@@ -17,6 +18,25 @@ public function index(PublicCatalogReader $catalog): View
|
||||
return view('public.programs', ['programs' => $catalog->publicPrograms()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eigene Produktseite eines Pakets, das für sich vermarktet wird: Sie zeigt den tatsächlichen Umfang des Pakets
|
||||
* (die enthaltenen Artikel) und darunter die kaufbaren Lizenzoptionen. Ohne kaufbare Option gibt es sie nicht.
|
||||
*/
|
||||
public function package(Bundle $bundle, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
abort_unless(Shop::enabled(), 404);
|
||||
$options = $products->forBundle($bundle);
|
||||
abort_if($options === [], 404);
|
||||
|
||||
return view('public.package', [
|
||||
'bundle' => $bundle,
|
||||
'contents' => $products->bundleContents($options),
|
||||
'options' => $options,
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
$version = $catalog->shownVersion($composition);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
@@ -37,7 +38,7 @@ public function index(Request $request, ProductOptions $products, PublicCatalogR
|
||||
|
||||
$summary = $summaries[$composition->id];
|
||||
$cards[] = [
|
||||
'composition' => $composition,
|
||||
'url' => route('public.program', $composition),
|
||||
'title' => $title,
|
||||
'teaser' => (string) ($composition->teaser ?: $composition->summary),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
@@ -45,6 +46,26 @@ public function index(Request $request, ProductOptions $products, PublicCatalogR
|
||||
];
|
||||
}
|
||||
|
||||
// Pakete mit eigener Produktseite: gelistet mit Name und enthaltenen Artikeln.
|
||||
foreach (Bundle::query()->whereIn('id', array_keys($products->bundleSummaries()))->orderBy('name')->get() as $bundle) {
|
||||
$options = $products->forBundle($bundle);
|
||||
$contents = $products->bundleContents($options);
|
||||
$names = implode(', ', array_column($contents, 'title'));
|
||||
|
||||
if ($term !== '' && ! str_contains(mb_strtolower($bundle->name.' '.$names), mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $products->bundleSummaries()[$bundle->id];
|
||||
$cards[] = [
|
||||
'url' => route('public.package', $bundle),
|
||||
'title' => (string) $bundle->name,
|
||||
'teaser' => 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : ''),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
return view('shop.index', ['cards' => $cards, 'term' => $term]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user