Mache den Lizenzartikel zur Produktseite und leite die Seite aus dem Angebot ab
CI Feature / test (push) Failing after 3m16s
CI Feature / test (push) Failing after 3m16s
Die Produktseite ist die Seite des Artikels (/shop/{id}), den die Option als einzige
Position verkauft, oder die Paketseite. Sie wird nicht mehr einem Programm zugeordnet.
Ein Kauf braucht genau eine Position und einen Preis, sonst lässt er sich nicht aktivieren.
Module und Programme werden dadurch nicht öffentlich (Karten und /programme unverändert).
Tests: Die Tests, die eine Programmseite als Produktseite voraussetzten, prüfen jetzt die
Artikelseite; die Zuordnung „eigene Paketseite oder Programmseite“ entfällt (ADR-52).
Ein Altbestandstest sichert die Programmseite für Angebote mit mehreren Positionen.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1950dc377b
commit
08f7d0c63d
22 files changed
+544
-275
No files matched your search
@@ -31,8 +31,13 @@ public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
||||
|
||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
$key = app(ProductOptions::class)->groupKey($offer);
|
||||
$page = $offer->composition;
|
||||
$listed = $offer->standalone_bundle || ($page !== null && $catalog->shownVersion($page) !== null);
|
||||
$listed = match (true) {
|
||||
$key === null => false,
|
||||
$key[0] === 'c' => $page !== null && $catalog->shownVersion($page) !== null,
|
||||
default => true,
|
||||
};
|
||||
$result = $listed ? $cart->add($offer) : Cart::UNAVAILABLE;
|
||||
$back = $this->productPage($offer);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
@@ -37,6 +39,28 @@ public function package(Bundle $bundle, ProductOptions $products, Cart $cart): V
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktseite eines Lizenzartikels: Titel und Beschreibung aus der Redaktion des Artikels (sonst aus seinem Inhalt),
|
||||
* der Aufbau des verkauften Inhalts und darunter die kaufbaren Lizenzoptionen. Ohne kaufbare Option gibt es sie nicht.
|
||||
*/
|
||||
public function article(LicenseArticle $article, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
abort_unless(Shop::enabled() && $article->archived_at === null, 404);
|
||||
$options = $products->forArticle($article);
|
||||
abort_if($options === [], 404);
|
||||
|
||||
return view('public.article', [
|
||||
'article' => $article,
|
||||
'title' => $products->articleTitle($article),
|
||||
'profile' => app(EditorialProfileReader::class)->read($article, 'detail'),
|
||||
'goal' => $products->articleGoal($article),
|
||||
'nodes' => $products->articleStructure($article),
|
||||
'options' => $options,
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
$version = $catalog->shownVersion($composition);
|
||||
@@ -47,6 +71,7 @@ public function program(Composition $composition, PublicCatalogReader $catalog,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
|
||||
'articles' => Shop::enabled() ? $products->articlesOf($composition) : [],
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
@@ -47,6 +49,29 @@ public function index(Request $request, ProductOptions $products, PublicCatalogR
|
||||
];
|
||||
}
|
||||
|
||||
// Lizenzartikel mit kaufbarer Option: Titel und Kurztext aus der Redaktion des Artikels (sonst seines Inhalts).
|
||||
$articleSummaries = $products->articleSummaries();
|
||||
|
||||
foreach (LicenseArticle::query()->whereIn('id', array_keys($articleSummaries))->whereNull('archived_at')->orderBy('code')->get() as $article) {
|
||||
$profile = app(EditorialProfileReader::class)->read($article, 'kachel');
|
||||
$title = $products->articleTitle($article);
|
||||
$teaser = (string) ($profile->value('teaser') ?: $profile->value('summary'));
|
||||
$haystack = mb_strtolower($title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $articleSummaries[$article->id];
|
||||
$cards[] = [
|
||||
'url' => route('shop.article', $article),
|
||||
'title' => $title,
|
||||
'teaser' => $teaser,
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
Reference in new issue
Block a user