LemonStand Forum: Adding a cart to the sidebar - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Adding a cart to the sidebar

#1 User is offline   cdana 

  • Member
  • Group: Members
  • Posts: 10
  • Joined: 07-November 11

Posted 23 January 2012 - 11:52 AM

How would I go about adding a small cart display to my side bar. I follow the instructions verbatim on http://lemonstandapp...docs/cart_page/ to get an idea but I always get undefined items error. Can some one show me a proper working example example? Thanks.
0

#2 User is offline   apepp 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 233
  • Joined: 30-October 11

Posted 13 February 2012 - 09:37 AM

..this is an example mini cart partial:

<div id="mini_cart_id" class="mini_cart">

<?= open_form() ?>


<a href="<?= root_url('/cart') ?>" title="Cart items">CART :
<?= Shop_Cart::get_item_total_num() ?> item(s) | <?= format_currency(Shop_Cart::total_price()) ?></a>

<ul>
<?php $counter = 0; ?>
<?php foreach (Shop_Cart::list_active_items() as $item): ?>

<li>
<a href="<?= root_url($item->product->page_url('/product')) ?>" title="<?= h($item->product->name) ?>">
<?= substr(h($item->product->name),0,32) ?></a>

<a title="REMOVE" onclick="$(this).getForm().sendRequest(
'shop:on_deleteCartItem',
{
extraFields: {
'key': '<?= $item->key ?>'
},
update: {'cart_page_div': 'cart_partial', 'mini_cart_id': 'shop_mini_cart'}
});return false"  href="#">
<img class="cart_delete" alt="REMOVE" src="<?= root_url('/resources/images/cart_delete.gif') ?>" /></a>
</li>

<?php $counter++; if ($counter == 4) break;?>
<? endforeach; ?>
</ul>

</form>


</div>


...then on all the external pages "AJAX" tab (that don't use the "shop:cart" action) you need pretty much this:

function add_to_cart_ext($controller)
{
  $_POST['product_cart_quantity'] = post_array_item('grouped_product_cart_quantity', post('product_id'));
  $controller->exec_action_handler('shop:on_addToCart');
 }


...the "cart" page "AJAX" tab, could do with this too:

function on_removeAllCartItems($controller) {
Shop_Cart::remove_active_items(); }


function add_to_cart_ext($controller)
{
  $_POST['product_cart_quantity'] = post_array_item('grouped_product_cart_quantity', post('product_id'));
  $controller->exec_action_handler('shop:on_addToCart');
 }


...check out the free themes on marketplace as a useful guide too:

http://lemonstandapp...ategory/themes/

This post has been edited by apepp: 13 February 2012 - 09:43 AM

0

Share this topic:


Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users