# Wishlist

Source: https://kart.bnomei.com/docs/content/wishlist
Updated: 2025-08-08T14:03:16+00:00
Summary: Wishlist management with Kart in Kirby CMS: list products, add, remove, toggle items, save for later or move to cart, and merge guest/customer wishlists.

## List products in wishlist

Code (php):  
```
<?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" action="<?= $product->now() ?>">
                <button type="submit" onclick="this.disabled=true;this.form.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

Code (php):  
```
<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

Code (plaintext):  
```
<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

Code (php):  
```
<?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

Code (plaintext):  
```
<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.