public function getCartContents($withoutCache = false)
 {
     if ($withoutCache === false) {
         $action = null;
     } else {
         $action = 'rebuild';
     }
     return uc_cart_get_contents(uc_cart_get_id(), $action);
 }
<?php

$items = uc_cart_get_contents();
?>
<div class="dropdown-menu">
  <?php 
if (empty($items)) {
    ?>
    <strong><?php 
    print t('Your shopping cart is empty.');
    ?>
</strong>
  <?php 
} else {
    ?>
  
    <strong><?php 
    print t('Recently added item(s)');
    ?>
</strong>
    <ul class="list-unstyled">
      <?php 
    foreach ($items as $item) {
        ?>
        <li>
          <?php 
        $image = _get_node_field($item, 'uc_product_image');
        ?>
          <?php 
        if (isset($image[0])) {
            ?>
</span>
			<span id ='order-subtotal'><?php 
echo $subtotal;
?>
</span>
			</div>
			<fieldset class="form-wrapper" id="selected-photos-pane">
				<legend><span class="fieldset-legend"><?php 
print t('Selected photos');
?>
</span></legend>
			</fieldset>
			<div class = 'thumbnails'>
    		  <?php 
$i = 0;
foreach (uc_cart_get_contents($cid) as $index => $product) {
    $photo = $product->uc_product_image['und'][0];
    $nid = $product->nid;
    $i++;
    ?>
    		 	<div id = "thumb-<?php 
    echo $nid;
    ?>
" class="image-thumbnail">
      		      <div id="<?php 
    echo $nid;
    ?>
" class="remove-cart-item" >x</div>  
    		      <?php 
    echo theme("image_formatter", array('item' => $photo, 'image_style' => 'search_thumbnail'));
    ?>
Exemple #4
0
/**
 * Override or insert variables into the node templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("node" in this case.)
 */
function motores_preprocess_node(&$vars, $hook)
{
    global $user;
    //print_r($vars['node']);exit;
    switch ($vars['node']->type) {
        case 'page':
        case 'accesorio':
        case 'talleres':
        case 'tarifa':
        case 'product':
            break;
        default:
            if ($vars['page']) {
                // este es un anuncio
                $vars['anuncio'] = 1;
                // small scrollable
                foreach ($vars['field_imagenes'] as $i) {
                    $vars['small_scrollable'][] = theme('imagecache', 'slideshow_small', $i['filepath']);
                }
                drupal_add_js(path_to_theme() . '/js/scrollable.min.js', 'theme');
                // JS engine
                drupal_add_js(path_to_theme() . '/js/anuncio_engine.js', 'theme');
            }
            // if this node is being previewed
            if ($vars['view']->name == 'anuncio_preview') {
                // las fotos
                foreach ($vars['field_imagenes'] as $img) {
                    $vars['imagenes'] .= theme('imagecache', 'preview_thumb', $img['filepath']);
                }
                // link a donde vas despues
                $cart = uc_cart_get_contents();
                // si el anuncio no es gratis, a pagar se ha dicho.
                if ($cart[0]->model != 1 && $cart[0]->model != 4) {
                    $vars['next'] = 'cart/checkout';
                    $vars['query'] = 'anuncio=' . $vars['node']->nid;
                } else {
                    $vars['next'] = 'anuncio/procesar/' . $vars['node']->nid;
                }
            }
            break;
    }
    // If this node is being searched
    if ($vars['view']->name == 'busqueda') {
        $vars['search_image'] = l(theme('imagecache', 'search_result', $vars['field_imagenes'][0]['filepath']), 'node/' . $vars['nid'], array('html' => true));
        // averiguar si el anuncio lleva badge en los resultados de busqueda
        $author = user_load($vars['node']->uid);
        if (motores_anuncio_is_cuenta_agencia($author)) {
            $vars['classes'] .= ' badge-agencia';
            $vars['agencia'] = 1;
            foreach ($author->roles as $rol) {
                if ($rol != 'authenticated user') {
                    $vars['agencia_tipo'] = $rol;
                }
            }
        } elseif ($vars['node']->field_tipo_anunio[0]['safe']['nid'] == '64') {
            $vars['classes'] .= ' badge-premium';
            $vars['agencia'] = 1;
            $vars['agencia_tipo'] = $vars['node']->field_tipo_anunio[0]['safe']['title'];
        }
    }
}
/**
 * Handle requests to update a cart item.
 *
 * @param $nid
 *   Node id of the cart item.
 * @param $data
 *   Array of extra information about the item.
 * @param $qty
 *   The quantity of this item in the cart.
 * @param $cid
 *   The cart id. Defaults to NULL, which indicates that the current user's cart
 *   should be retrieved with uc_cart_get_id().
 */
function hook_update_cart_item($nid, $data = array(), $qty, $cid = NULL)
{
    if (!$nid) {
        return NULL;
    }
    $cid = !(is_null($cid) || empty($cid)) ? $cid : uc_cart_get_id();
    if ($qty < 1) {
        uc_cart_remove_item($nid, $cid, $data);
    } else {
        db_query("UPDATE {uc_cart_products} SET qty = %d, changed = %d WHERE nid = %d AND cart_id = '%s' AND data = '%s'", $qty, time(), $nid, $cid, serialize($data));
    }
    // Rebuild the items hash
    uc_cart_get_contents(NULL, 'rebuild');
    if (!strpos(request_uri(), 'cart', -4)) {
        drupal_set_message(t('Your item(s) have been updated.'));
    }
}
    print $lang;
    ?>
/user/login?destination=join" title="<?php 
    print "Join";
    ?>
"><?php 
    print "Join";
    ?>
 <i class="fa fa-plug"></i></a></li>
                      <?php 
}
?>
        
                      </ul>
                      <?php 
if (sizeof(uc_cart_get_contents()) > 0) {
    ?>
                        <ul class="ucart">
                            <li><a href="/<?php 
    print $lang;
    ?>
/cart"><i class="fa fa-cart-arrow-down"></i></a></li> 
                        </ul>
                      <?php 
}
?>
                  </section>
              </div>
            </nav>
        </div>
        
                  <g>
                    <path d="M15.001,4h-0.57l-3.707-3.707c-0.391-0.391-1.023-0.391-1.414,0c-0.391,0.391-0.391,1.023,0,1.414L11.603,4
                    H4.43l2.293-2.293c0.391-0.391,0.391-1.023,0-1.414s-1.023-0.391-1.414,0L1.602,4H1C0.448,4,0,4.448,0,5s0.448,1,1,1
                    c0,2.69,0,7.23,0,8c0,1.104,0.896,2,2,2h10c1.104,0,2-0.896,2-2c0-0.77,0-5.31,0-8c0.553,0,1-0.448,1-1S15.554,4,15.001,4z
                    M13.001,14H3V6h10V14z"></path>
                    <path d="M11.001,13c0.553,0,1-0.447,1-1V8c0-0.553-0.447-1-1-1s-1,0.447-1,1v4C10.001,12.553,10.448,13,11.001,13z"></path>
                    <path d="M8,13c0.553,0,1-0.447,1-1V8c0-0.553-0.448-1-1-1S7,7.447,7,8v4C7,12.553,7.448,13,8,13z"></path>
                    <path d="M5,13c0.553,0,1-0.447,1-1V8c0-0.553-0.447-1-1-1S4,7.447,4,8v4C4,12.553,4.448,13,5,13z"></path>
                   </g>
                  </svg>
                </div>
                <?php 
    print t('Cart');
    ?>
 <span class = "cart-count"><?php 
    print count(uc_cart_get_contents());
    ?>
</span>
              </a>
              <?php 
    print theme('progressive_cms_cart_block');
    ?>
            </div><!-- .cart-header -->
            <?php 
}
?>
          </div><!-- .header-icons -->
          
          <div class="primary">
          <div class="navbar navbar-default" role="navigation">
            <button type="button" class="navbar-toggle btn-navbar collapsed" data-toggle="collapse" data-target=".primary .navbar-collapse">
/**
 * Handles requests to update a cart item.
 *
 * @param $nid
 *   Node id of the cart item.
 * @param $data
 *   Array of extra information about the item.
 * @param $qty
 *   The quantity of this item in the cart.
 * @param $cid
 *   The cart id. Defaults to NULL, which indicates that the current user's cart
 *   should be retrieved with uc_cart_get_id().
 */
function hook_uc_update_cart_item($nid, $data = array(), $qty, $cid = NULL)
{
    if (!$nid) {
        return NULL;
    }
    $cid = !(is_null($cid) || empty($cid)) ? $cid : uc_cart_get_id();
    if ($qty < 1) {
        uc_cart_remove_item($nid, $cid, $data);
    } else {
        db_update('uc_cart_products')->fields(array('qty' => $qty, 'changed' => REQUEST_TIME))->condition('nid', $nid)->condition('cart_id', $cid)->condition('data', serialize($data))->execute();
    }
    // Rebuild the items hash
    uc_cart_get_contents(NULL, 'rebuild');
    if (!strpos(request_uri(), 'cart', -4)) {
        drupal_set_message(t('Your item(s) have been updated.'));
    }
}
function tendu_cart_review_table($show_subtotal = TRUE)
{
    $subtotal = 0;
    // Set up table header.
    $header = array(array('data' => t('Your Items'), 'class' => 'image'), array('data' => t(''), 'class' => 'desc'), array('data' => t('Item Price'), 'class' => 'itemprice'), array('data' => t('Quantity'), 'class' => 'qty'), array('data' => t('Price'), 'class' => 'price'));
    $context = array();
    // Set up table rows.
    $contents = uc_cart_get_contents();
    foreach ($contents as $item) {
        $price_info = array('price' => $item->price, 'qty' => $item->qty);
        $context['revision'] = 'altered';
        $context['type'] = 'cart_item';
        $context['subject'] = array('cart' => $contents, 'cart_item' => $item, 'node' => node_load($item->nid));
        $total = uc_price($price_info, $context);
        $subtotal += $total;
        $prodnode = $context['subject']['node'];
        $description = l($prodnode->title, 'node/' . $prodnode->nid) . uc_product_get_description($item);
        // Remove node from context to prevent the price from being altered.
        $context['revision'] = 'themed-original';
        $context['type'] = 'amount';
        // dsm($item);
        unset($context['subject']);
        // dsm($prodnode);
        $prodimg = l('<img src="' . imagecache_create_url('cart', $prodnode->field_image_cache[0]['filepath']) . '"/>', 'node/' . $prodnode->nid, array('html' => true));
        $rows[] = array(array('data' => $prodimg, 'class' => 'image'), array('data' => $description, 'class' => 'desc'), array('data' => t('@qty', array('@qty' => $item->price)), 'class' => 'itemprice'), array('data' => t('@qty&times;', array('@qty' => $item->qty)), 'class' => 'qty'), array('data' => uc_price($total, $context), 'class' => 'price'));
        unset($prodimg);
    }
    // Add the subtotal as the final row.
    if ($show_subtotal) {
        $context = array('revision' => 'themed-original', 'type' => 'amount');
        $rows[] = array('data' => array(array('data' => '<span id="backtocart-link">' . l('Back to cart', 'cart/') . '</span> ', 'colspan' => 2, 'class' => 'backtocart-wrapper'), array('data' => '<span id="subtotal-title">' . t('Subtotal:') . '</span> ' . uc_price($subtotal, $context), 'colspan' => 3, 'class' => 'subtotal')), 'class' => 'lastrow');
    }
    $output = '<div class="tableheader">' . t('Currently In Your Shopping Cart') . '</div>';
    return $output . theme('table', $header, $rows, array('class' => 'cart-review'));
}
Exemple #10
0
function runmemo_preprocess_uc_cart_checkout_review(&$variables)
{
    $cart_items = uc_cart_get_contents();
    $no_of_cart_items = count($cart_items);
    foreach ($cart_items as $product => $value) {
        $photo[] = $value->uc_product_image['und'][0];
        //for cost format in the review order page mouse over image
        $cost = $value->sell_price;
        $cost = number_format($cost, 2, '.', '');
        $cost_arr = explode('.', $cost);
        if ($cost_arr['1'] == 00) {
            $price[] = $cost_arr['0'];
        } else {
            $price[] = $cost;
        }
    }
    $output = '<table class="review-order-img" ><tr>';
    $j = 0;
    for ($i = 0; $i < $no_of_cart_items; $i++) {
        $j++;
        $output .= '<td>' . '<div class="views-field-sell-price"><span id="node_cost" style="display:none">&euro;' . $price[$i] . '</span></div>' . theme("image_formatter", array('item' => $photo[$i], 'image_style' => 'search_thumbnail'));
        $output .= '</td>';
        if ($j % 4 == 0) {
            $output .= '</tr><tr>';
        }
    }
    if ($no_of_cart_items < 4) {
        for ($k = 0; $k < 4 - $no_of_cart_items; $k++) {
            $output .= '<td></td>';
        }
    }
    $output .= '</tr></table>';
    $variables['panes']['Cart contents']['0'] = $output;
    return $variables;
}