Exemplo n.º 1
0
function deleteItem($itemId)
{
    $item = new Item($itemId);
    $cart = get_cart();
    $cart->deleteItem($item);
    update_cart($cart);
}
Exemplo n.º 2
0
function updateData($userOrig = null)
{
    global $errorMsg;
    $user = null;
    if ($userOrig == null) {
        $user = new User();
    } else {
        $user = new User($userOrig->email, $userOrig->password);
    }
    $objectVars = array_keys(get_object_vars($user));
    foreach ($_REQUEST as $key => $value) {
        if (NP_startsWith("user_", $key)) {
            $path = split("_", $key);
            $property = $path[1];
            if (in_array($property, $objectVars)) {
                if (is_array($user->{$property})) {
                    if (isset($_REQUEST['sameData']) && $_REQUEST['sameData'] == "true") {
                        if ($property == "billingData") {
                            $user->billingData = array_merge($user->billingData, array($path[2] => $value));
                            $user->shippingData = array_merge($user->shippingData, array($path[2] => $value));
                        }
                    } else {
                        $user->{$property} = array_merge($user->{$property}, array($path[2] => $value));
                    }
                } else {
                    $user->{$property} = $value;
                }
            }
        }
    }
    if (isset($_REQUEST['user_password']) && isset($_REQUEST['newPassword1']) && isset($_REQUEST['newPassword2']) && $_REQUEST['newPassword1'] == $_REQUEST['newPassword2']) {
        if ($user->password == $userOrig->password) {
            $user->password = $_REQUEST['newPassword1'];
            $cart = get_cart();
            $cart->user->update($user);
            update_cart($cart);
        } else {
            global $error;
            $errorMsg = _("El password antiguo no es correcto o los nuevos no coinciden.");
            return false;
        }
    } else {
        $cart = get_cart();
        $cart->user->update($user);
        update_cart($cart);
    }
    /*
        $cart = get_cart();
        print_r($cart->user);
    	$cart->user->update();
    */
    // reload data from DDBB
    $cart->user = new User($cart->user->email, $cart->user->password);
    update_cart($cart);
    return true;
}
Exemplo n.º 3
0
 public function testSumCart()
 {
     empty_cart();
     $add_to_cart = array('content_id' => 1, 'qty' => 3, 'price' => 300);
     $cart_add = update_cart($add_to_cart);
     $cart_items = get_cart();
     $sum = cart_sum();
     $this->assertEquals($sum, 900);
     $this->assertEquals(isset($cart_add['success']), true);
     $this->assertEquals(!empty($cart_items), true);
 }
Exemplo n.º 4
0
function get_cart_information($dbh, $values)
{
    $user_id = $values['user_id'];
    $cart = get_cart(array('user_id' => $user_id));
    //    $details = get_cart_details($dbh, $user_id);
    $cart['shipping_address_id'] = $cart['address_id'];
    //if comments were passed in, append those to the front of the cart comments
    $cart['comments'] = isset($values['comments']) ? $values['comments'] . $cart['comments'] : $cart['comments'];
    //convert values to integers that can be converted to integers
    return $cart;
}
Exemplo n.º 5
0
Arquivo: cg35.php Projeto: kyfr59/cg35
/**
 * Add an item to the cart 
 * @param $dbname The name of the database (e.g. instance of Omeka)
 * @param $item_id The ID of the item
 * @return false|interger Returns the number of item in the user's cart, otherwhise false
 */
function add_to_cart($dbname, $item_id)
{
    if (isset($dbname) && isset($item_id) && ($user_id = get_connected_user_id())) {
        if (!is_in_cart($dbname, $item_id)) {
            $masterdb = get_master_db();
            $table_name = $masterdb->getConfig()['prefix'] . 'carts';
            $result = $masterdb->insert($table_name, array('user_id' => $user_id, 'dbname' => $dbname, 'item_id' => $item_id));
        }
        return count(get_cart());
    }
    return false;
}
Exemplo n.º 6
0
function GetLandingPageContent($dbh, $user_id)
{
    $query = "SELECT COUNT(*) count FROM cart_headers where user_id = :user_id";
    $sth = $dbh->prepare($query);
    if (!$sth->execute(array(":user_id" => $user_id))) {
        throw new Exception($sth->errorInfo()[2]);
    }
    $count = (int) $sth->fetch(PDO::FETCH_ASSOC)['count'];
    if ($count > 0) {
        //user has details in cart
        $landing_page = get_cart(array('user_id' => $user_id));
    } else {
        //user does not have cart_details, so return delivery options page
        $landing_page = get_delivery_options();
    }
    //merge user_id to top level of array
    $landing_page = array_merge($landing_page, array('user_id' => $user_id));
    return $landing_page;
}
Exemplo n.º 7
0
 /**
  * This shows the cart details
  * 
  * @return void
  */
 public function indexAction()
 {
     if ($cart = get_cart()) {
         $db = array();
         $i = 0;
         foreach ($cart as $c) {
             if (!isset($db[$c['dbname']])) {
                 $db[$c['dbname']] = get_instance_db($c['dbname']);
             }
             // Title
             $table_name = $db[$c['dbname']]->getConfig()['prefix'] . 'element_texts';
             $sql = "SELECT text FROM {$table_name} WHERE record_id = " . $c['item_id'] . " AND element_id = 50";
             $items[$i]['text'] = utf8_encode($db[$c['dbname']]->fetchOne($sql));
             // Description
             $table_name = $db[$c['dbname']]->getConfig()['prefix'] . 'element_texts';
             $sql = "SELECT text FROM {$table_name} WHERE record_id = " . $c['item_id'] . " AND element_id = 41";
             $items[$i]['description'] = utf8_encode($db[$c['dbname']]->fetchOne($sql));
             // Date
             $table_name = $db[$c['dbname']]->getConfig()['prefix'] . 'element_texts';
             $sql = "SELECT text FROM {$table_name} WHERE record_id = " . $c['item_id'] . " AND element_id = 40";
             $items[$i]['date'] = utf8_encode($db[$c['dbname']]->fetchOne($sql));
             // Référence
             $table_name = $db[$c['dbname']]->getConfig()['prefix'] . 'element_texts';
             $sql = "SELECT text FROM {$table_name} WHERE record_id = " . $c['item_id'] . " AND element_id = 43";
             $items[$i]['reference'] = utf8_encode($db[$c['dbname']]->fetchOne($sql));
             $items[$i]['id'] = $c['id'];
             $items[$i]['item_id'] = $c['item_id'];
             $items[$i]['dbname'] = $c['dbname'];
             $items[$i]['note'] = $c['note'];
             $items[$i]['url'] = MASTER_URL . $db[$c['dbname']]->getConfig()['url'] . '/items/show/' . $c['item_id'];
             $items[$i]['name'] = $db[$c['dbname']]->getConfig()['name'];
             $i++;
         }
         $this->view->items = $items;
     } else {
         $this->view->empty = true;
     }
     $ariane['panier'] = null;
     $this->view->ariane = $ariane;
 }
Exemplo n.º 8
0



<?php 
if (isset($orders) and is_array($orders)) {
    ?>
                    <div class="ptab ptab-orders">
                    <h2 class="icon-section-title">Orders</h2>
                    <?php 
    foreach ($orders as $order) {
        ?>


                         <?php 
        $cart = get_cart('order_id=' . $order['id']);
        ?>
                         <?php 
        if (is_array($cart) and !empty($cart)) {
            ?>
<div class="mw-ui-box mw-ui-box-content my-order">
                                <span class="my-order-status">Status:
                                    <?php 
            if ($order['order_status'] == 'completed') {
                ?>
                                        <span class="my-order-status-completed">Completed</span>
                                    <?php 
            } else {
                ?>
                                        <span class="my-order-status-pending">Pending</span>
                                    <?php 
Exemplo n.º 9
0
</span>
                              <a href="<?php 
            print admin_url();
            ?>
view:shop/action:orders#vieworder=<?php 
            print $item['id'];
            ?>
" class="mw-ui-btn unselectable"><span class="mw-icon-cart"></span><?php 
            _e("Go to order");
            ?>
</a>
                            </div>
                        </div>
                          <div class="mw-ui-box-content mw-accordion-content">
                            <?php 
            $cart_items = get_cart('order_completed=any&order_id=' . $item['id'] . '&no_session_id=1');
            ?>
                            <?php 
            if (is_array($cart_items)) {
                ?>
                            <table cellspacing="0" cellpadding="0" class="mw-ui-table mw-ui-table-basic client-order-table" width="100%">
                              <thead>
                                <tr>
                                  <th></th>
                                  <th><?php 
                _e("Product Name");
                ?>
</th>
                                  <th><?php 
                _e("Price");
                ?>
Exemplo n.º 10
0
        <?php 
    }
    ?>

     <?php 
    if (get_option('shop_require_registration', 'website') == 'y' and is_logged() == false) {
        ?>
        <?php 
        include THIS_TEMPLATE_DIR . "signin.php";
        ?>
     <?php 
    } else {
        ?>

        <?php 
        $thecart = get_cart();
        if ($thecart != false) {
            ?>
        <div class="mw-ui-row shipping-and-payment">
            <div class="mw-ui-col" style="width: 33%;">
                <div class="mw-ui-col-container">
                    <div class="well">
                        <?php 
            $user = get_user();
            ?>
                        <h2 style="margin-top:0 " class="edit nodrop" field="checkout_personal_inforomation_title"
                            rel="global" rel_id="<?php 
            print $params['id'];
            ?>
"><?php 
            _e("Personal Information");
Exemplo n.º 11
0
            if ($action == "update") {
                if (isset($_GET["username"]) && isset($_GET["hours"])) {
                    $username = $_GET["username"];
                    $hours = $_GET["hours"];
                    update_user_total($username, $hours);
                    update_order_total();
                } else {
                    echo json_encode(array("message" => "Error: missing username parameter."));
                }
            } else {
                if ($action == "clear") {
                    clear_cart();
                    update_order_total();
                } else {
                    if ($action == "get") {
                        get_cart();
                    }
                }
            }
        }
    }
}
/**
 * Function to return all cart info - order total and products (selected users/developers)
 */
function get_cart()
{
    if (count($_SESSION["cart"]["products"]) == 0) {
        echo json_encode(array("message" => "Your cart is empty."));
    } else {
        echo json_encode($_SESSION);
Exemplo n.º 12
0
<?php

$cart = cart_logic(get_cart());
$products = $pages->find('products')->children()->visible();
snippet('header');
?>

<?php 
if (count($cart) == 0) {
    ?>

<main id="cart" class="main black" role="main">
	<div class="text">
		<h1>Votre panier est vide.</h1>
		<a class="btn-white" href="<?php 
    echo url('products');
    ?>
">Voir les produits</a>
	</div>
</main>

<?php 
} else {
    ?>

<main id="cart" class="main" role="main">
	<div class="text">
		<h1><?php 
    echo $page->title()->html();
    ?>
</h1>
Exemplo n.º 13
0
<script>mw.require("tools.js", true);</script>
<script>mw.require("shop.js", true);</script>

<?php 
$template = get_option('data-template', $params['id']);
$template_css_prefix = '';
$template_file = false;
$module_template = false;
if ($template != false and strtolower($template) != 'none') {
    $template_css_prefix = no_ext($template);
    $template_file = module_templates($params['type'], $template);
} else {
    if ($template == false and isset($params['template'])) {
        $module_template = $params['template'];
        $template_file = module_templates($params['type'], $module_template);
    } else {
        $template_file = module_templates($params['type'], 'default');
    }
}
$sid = mw()->user_manager->session_id();
if ($sid == '') {
    // //session_start();
}
$cart = array();
$cart['session_id'] = mw()->user_manager->session_id();
$cart['order_completed'] = 0;
$data = get_cart($cart);
if (is_file($template_file) and !isset($params['hide-cart'])) {
    include $template_file;
}
Exemplo n.º 14
0
<?php

require_once "npshop/skin.php";
$cart = get_cart();
?>
<html><head><title><?php 
echo _("David Benavente. Estudio de bonsái");
?>
</title>
<link rel=stylesheet href="<?php 
echo SKIN_ROOT;
?>
include/estilos.css"> 
			<script language="javascript">
			<!--
			function doRedirect(myObject) {
			 	if (myObject.options[myObject.selectedIndex].value!="") { 
					top.location.href=myObject.options[myObject.selectedIndex].value; 
				}	else {
					return false;
				}
			}			
            function doPayment() {
                payment = document.getElementById("payment_method");
                top.location.href = "payment.php?method=" + payment.value;
            }
			// -->
			</script>
<script>
    <?php 
include_once 'include/javascript.php';
Exemplo n.º 15
0
    function TPV_printForm()
    {
        global $npshop, $_SERVER_DATA;
        $cart = get_cart();
        $tpv = $npshop['tpv'];
        $scriptURL = dirname(dirname($_SERVER["PHP_SELF"]));
        $amount = $cart->getTotal(1) * 100;
        // format: MMDDxxxxxxSS"
        $orderId = date("md") . sprintf("%06d", $cart->orderId) . date("s");
        $signature = __signature($amount, $orderId, $tpv['code'], $tpv['currency'], $tpv['key']);
        ?>
    	<form id="npshop_form" action="<?php 
        echo $tpv['url'];
        ?>
" method="POST">
    		<input type="hidden" name="DS_Merchant_Amount" value="<?php 
        echo $amount;
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_Currency" value="<?php 
        echo $tpv['currency'];
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_Order" value="<?php 
        echo $orderId;
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_ProductDescription" value="<?php 
        echo $tpv['productDescription'] . " " . $orderId;
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_Titular" value="<?php 
        echo $tpv['name'];
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_MerchantCode" value="<?php 
        echo $tpv['code'];
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_Terminal" value="<?php 
        echo $tpv['terminal'];
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_MerchantSignature" value="<?php 
        echo $signature;
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_MerchantURL" value="http://<?php 
        echo $_SERVER["HTTP_HOST"] . $scriptURL;
        ?>
/common/modules/payment/TPV_cajamadrid.php?LANG=<?php 
        echo NP_LANG;
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_URLOK" value="http://<?php 
        echo $_SERVER["HTTP_HOST"] . $scriptURL;
        ?>
/flows/payment.php?result=ok&LANG=<?php 
        echo NP_LANG;
        ?>
"/>
    		<input type="hidden" name="DS_Merchant_URLKO" value="http://<?php 
        echo $_SERVER["HTTP_HOST"] . $scriptURL;
        ?>
/flows/payment.php?result=error&LANG=<?php 
        echo NP_LANG;
        ?>
"/> 
    		<input type="hidden" name="DS_Merchant_MerchantData" value="<?php 
        echo $cart->orderId;
        ?>
"/> 
    		<input type="hidden" name="DS_Merchant_ConsumerLanguage" value="<?php 
        echo NP_LANG === "es_ES" ? "001" : "002";
        ?>
"/>
    		<!-- 
    		    Castellano-001, Inglés-002, Catalán-003,
                Francés-004, Alemán-005, Holandés-006,
                Italiano-007, Sueco-008, Portugués-009,
                Valenciano-010, Polaco-011, Gallego-012 y
                Euskera-013.
            -->
    	</form>
<?php 
    }
Exemplo n.º 16
0
                <div class="content">
                    <a href="http://archives.ille-et-vilaine.fr/fr" target="_blank">ARCHIVES ET PATRIMOINE D'ILLE-VILAINE</a>
                    <p class="right">
                        
                        <?php 
if (get_connected_user_id()) {
    ?>
                            <a href="<?php 
    echo MASTER_URL;
    ?>
/guest-user/user/update-account" class="account">MON COMPTE</a>
                            <a href="<?php 
    echo MASTER_URL;
    ?>
/cart" class="cart">MON PANIER<span id="cart"><?php 
    echo count(get_cart());
    ?>
</span></a>
                            <a href="<?php 
    echo MASTER_URL;
    ?>
/users/logout" class="logout">DECONNEXION</a>
                        <?php 
} else {
    ?>
    
                            <a href="<?php 
    echo MASTER_URL;
    ?>
/users/login" class="connexion">CONNEXION</a>
                            <a href="<?php 
Exemplo n.º 17
0
switch ($function) {
    case 'add_cart_header':
        include_once __DIR__ . '/orders/add_cart.php';
        add_cart_header($values);
        $responseArray['status'] = 'success';
        $responseArray['message'] = 'Cart header created successfully.';
        break;
    case 'add_cart_detail':
        include_once __DIR__ . '/orders/add_cart.php';
        add_cart_detail($values);
        $responseArray['status'] = 'success';
        $responseArray['message'] = 'Cart detail added successfully.';
        break;
    case 'get_cart':
        include_once __DIR__ . '/orders/get_cart.php';
        $responseArray['response'] = get_cart($values);
        $responseArray['status'] = 'success';
        $responseArray['message'] = 'Here is your cart';
        break;
    case 'update_cart_header':
        include_once __DIR__ . '/orders/update_cart.php';
        $responseArray['response'] = update_cart_header($values);
        $responseArray['status'] = 'success';
        $responseArray['message'] = 'Cart successfully updated';
        break;
    case 'delete_cart':
        include_once __DIR__ . '/orders/delete_cart.php';
        $responseArray['response'] = delete_cart($values);
        $responseArray['status'] = 'success';
        $responseArray['message'] = 'Successfully deleted cart';
        break;
Exemplo n.º 18
0
        print $recart_base . '?recart=' . $item['session_id'];
        ?>
" target="_blank"><?php 
        _e("Recover");
        ?>
</a>
            </div>
          </td>
      </tr>

    </tbody>
  </table><?php 
    }
    ?>
    <?php 
    $abandoned_carts = get_cart('count=1&no_session_id=true&order_completed=0&group_by=session_id');
    $completed_carts = get_orders('count=1&order_completed=1');
    ?>
  <script>mw.lib.require("morris");</script> 
  <script>
      $(document).ready(function(){
         mw.on.moduleReload("<?php 
    print $params['id'];
    ?>
", function(){
             OrdersChart = Morris.Donut({
                element: 'orders_stat',
                data: [
                  {label: "Completed Carts", value: <?php 
    print intval($completed_carts);
    ?>
Exemplo n.º 19
0
<?php

require_once 'lib/lib.php';
require_once 'lib/dblibs.php';
output_html5_header('Shopping Cart', array("bootstrap/css/bootstrap.css", "bootstrap/css/bootstrap-theme.css", "css/style.css"), array("js/jquery.min.js", "bootstrap/js/bootstrap.min.js", "js/carousel.js"));
if (array_key_exists('loggedin', $_SESSION)) {
    output_page_menu();
    db_connect();
    $user_id = db_get_user_id($_SESSION['loggedin']);
    $cart = get_cart($user_id);
    ?>

<?php 
    ?>
<h1>Shopping Cart</h1>
<div class="row">
<table class="table table-hover cart_table">
	<thead>
		<th>Product</th>
		<th></th>
		<th>Price</th>
		<th>Quantity</th>
	</thead>
	<tbody>
	<?php 
    $i = 0;
    $s = 's';
    $subtotal = 0;
    if ($cart != NULL) {
        $i = 0;
        $s = 's';