Wishlist
List products in wishlist
<?php foreach (kart()->wishlist()->lines() as $line) {
/** @var \Bnomei\Kart\CartLine $line */
/** @var ProductPage $product */
$product = $line->product(); ?>
<li>
<a href="<?= $product->url() ?>"><?= $product->title() ?></a>
<div>
<form method="POST" onclick="this.disabled=true;this.form.submit();" action="<?= $product->now() ?>">
<button type="submit">⊼</button>
</form>
<form method="POST" action="<?= $product->forget() ?>">
<button type="submit" onclick="this.disabled=true;this.form.submit();">⊗</button>
</form>
</div>
</li>
<?php } ?>
Add product to wishlist
<form method="POST" action="<?= $product->wish() ?>">
<button type="submit" onclick="this.disabled=true;this.form.submit();">Add to wishlist</button>
</form>
Remove product from wishlist
<form method="POST" action="<?= $product->forget() ?>">
<button type="submit" onclick="this.disabled=true;this.form.submit();">Remove from wishlist</button>
</form>
Toggle product in wishlist
<?php
/** @var ProductPage $page */
$product ??= $page;
if (kart()->wishlist()->has($product) === false) { ?>
<form method="POST" action="<?= $product->wish() ?>">
<button type="submit" onclick="this.disabled=true;this.form.submit();">Add to wishlist</button>
</form>
<?php } else { ?>
<form method="POST" action="<?= $product->forget() ?>">
<button type="submit" onclick="this.disabled=true;this.form.submit();">Remove from wishlist</button>
</form>
<?php }
Move product between cart and wishlist
<form method="POST" action="<?= $product->later() ?>">
<button onclick="this.disabled=true;this.form.submit();" type="submit">Save for later</button>
</form>
<form method="POST" onclick="this.disabled=true;this.form.submit();" action="<?= $product->now() ?>">
<button type="submit">Move to cart now</button>
</form>
Merging of guest and customer wishlist
When an anonymous user logs into their account, the cart and wishlist from their anonymous session will be merged with the data saved on their account. On logout, the cart and wishlist of the current session will be cleared.