Ejemplo n.º 1
0
    ?>
            <h1 class="shop-car right no-margin rel">
              <a href="<?php 
    echo get_page_link($page->ID);
    ?>
" title="Seu carrinho de pedidos" class="rel">
                <span class="icon-carshop icon-icon_carrinho  left"></span>
                <span class="icon-chevron-down icon-icon_down_2 left secondar"></span>
                <span class="qtd-cart bg-primary abs"><?php 
    $cart->get_total_items_cart();
    ?>
</span>
              </a>
              <div id="item-list-user">
                <?php 
    echo $cart->list_items_cart();
    ?>
              </div>
            </h1>
            <?php 
}
?>
          </div>
        </div>
      </div>
    </header>

    <!-- menu principal -->
    <nav id="main-menu" class="small-16 left rel">
      <div class="row rel">
        
Ejemplo n.º 2
0
function update_items_cart()
{
    $user_id = $_GET['user_id'];
    $item_id = (int) $_GET['item_id'];
    $total_item = (int) $_GET['total_item'];
    $user = get_user_by('id', $user_id);
    if ($user) {
        $user_cart = get_user_meta($user_id, 'user_cart', true);
        $total_cart = 0;
        if ($total_item > 0) {
            $user_cart[$item_id] = $total_item;
            update_user_meta($user_id, 'user_cart', $user_cart);
            foreach ($user_cart as $key => $value) {
                $total_cart += $value;
            }
        } else {
            unset($user_cart[$item_id]);
            update_user_meta($user_id, 'user_cart', $user_cart);
            foreach ($user_cart as $key => $value) {
                $total_cart += $value;
            }
        }
        $cart = new PlanDD_Cart($item_id, $user_id);
        $json = array("total" => $total_cart, "list" => $cart->list_items_cart());
        print json_encode($json);
    }
    exit;
}