Skip to content

Instantly share code, notes, and snippets.

@elmarputz
Created October 28, 2016 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmarputz/2161ab2dfac71d7d9a59af6bbc2b472e to your computer and use it in GitHub Desktop.
Save elmarputz/2161ab2dfac71d7d9a59af6bbc2b472e to your computer and use it in GitHub Desktop.
mbi booklist
<table class="table">
<thead>
<tr>
<th>
Title
</th>
<th>
Author
</th>
<th>
Price
</th>
<th>
<span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($books as $book):
$inCart = ShoppingCart::contains($book->getId());
?>
<tr>
<td><strong>
<?php echo Util::escape($book->getTitle()); ?>
</strong>
</td>
<td>
<?php echo Util::escape($book->getAuthor()); ?>
</td>
<td>
<?php echo Util::escape($book->getPrice()); ?>
</td>
<td class="add-remove">
<?php if ($inCart): ?>
<form method="post" action="<?php echo Util::action('removeFromCart', array('bookId' => $book->getId())); ?>">
<input type="submit" role="button" class="btn btn-default btn-xs btn-info" value="-" />
</form>
<?php else: ?>
<form method="post" action="<?php echo Util::action('addToCart', array('bookId' => $book->getId())); ?>">
<input type="submit" role="button" class="btn btn-default btn-xs btn-success" value="+" />
</form>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment