Exemple #1
0
/**
 * Returns the number of items in the user's cart
 * @return integer the number of items
 */
function get_cart()
{
    if ($user = get_connected_user_id()) {
        $masterdb = get_master_db();
        $table_name = $masterdb->getConfig()['prefix'] . 'carts';
        $sql = "SELECT * FROM {$table_name} WHERE user_id = {$user}";
        return $masterdb->fetchAll($sql);
    }
    return 0;
}
Exemple #2
0
<br style="clear:both" />
<div id="share">
    <h4>Participer, partager, travailler</h4>
    <a target="_blank" style="outline:none;" title="Télécharger" href="<?php 
echo getenv("INSTANCE_URL");
?>
/items/print/id/<?php 
echo $item->id;
?>
"><img src="<?php 
echo WEB_THEME;
?>
/cg35/images/item-download.png"></a>

    <?php 
if (get_connected_user_id()) {
    ?>
        <?php 
    if (!is_in_cart(get_current_instance_name(), $item->id)) {
        ?>
        <a style="outline:none;" title="Mettre au panier" id="add-to-cart-2" href="#"><img src="<?php 
        echo WEB_THEME;
        ?>
/cg35/images/item-cart.png"></a>
        <?php 
    }
    ?>
    <?php 
} else {
    ?>
        <a style="outline:none;" href="<?php 
Exemple #3
0
 /**
  * Save a note (ajax)
  * @param (AJAX param) id The id of the cart
  * @param (AJAX param) note the note
  * @return cart_id The cart ID (for removing the 'save button')
  */
 public function saveAction()
 {
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $cart_id = $this->getParam('id');
     $note = addslashes($this->getParam('note'));
     if (isset($cart_id) && ($user_id = get_connected_user_id())) {
         $masterdb = get_master_db();
         $table_name = $masterdb->getConfig()['prefix'] . 'carts';
         $sql = "SELECT user_id FROM {$table_name} WHERE id = {$cart_id}";
         if ($masterdb->fetchOne($sql) == $user_id) {
             $sql = "UPDATE {$table_name} SET note = '{$note}' WHERE id = {$cart_id}";
             $masterdb->query($sql);
         }
     }
     echo $cart_id;
 }