本文整理汇总了PHP中Cart::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getInstance方法的具体用法?PHP Cart::getInstance怎么用?PHP Cart::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cart
/**
* Recupera o carrinho de compras.
* @return Cart
*/
public function cart() {
if ( $this->cart == null ) {
$this->cart = Cart::getInstance();
}
return $this->cart;
}
示例2: action_add
public function action_add()
{
$goods_id = $this->getQuery('goods_id');
$cart = Cart::getInstance();
$cart->add($goods_id, 1);
$this->request->redirect('/cart/list');
$this->auto_render = false;
}
示例3: buy
function buy()
{
if (isset($_POST['id']) & isset($_POST['count']) & isset($_POST['cost']) & Cart::getInstance()->IsCookie($_POST['id'])) {
try {
//header("Location: ".$_SERVER['PHP_SELF']); //решаем проблему повторной отправки данных формы
$dbh = new PDO('mysql:host=localhost;dbname=iba', USER, PASS);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$zapros = 'INSERT INTO purchases (id, id_good, id_user, data, count, cost) VALUES (null, :id_good, :id_user, :data, :count, :cost)';
$sth = $dbh->prepare($zapros);
$data = array('id_good' => $_POST['id'], 'id_user' => $_SESSION['id_user'], 'data' => date("Y.n.j"), 'count' => $_POST['count'], 'cost' => $_POST['cost']);
$sth->execute($data);
$result = $dbh->lastInsertId();
$dbh = null;
Cart::getInstance()->deleteCookie($_POST['id']);
// или call_user_func(array('Cart', 'DeleteCookie'));
return $result;
} catch (PDOException $e) {
echo "Error occurred! " . $e->getMessage();
}
}
}
示例4: array
$GLOBALS['seo']->getItem($_GET['seo_path']);
}
//Initialize SSL
$GLOBALS['ssl'] = SSL::getInstance();
//Initialize GUI
$GLOBALS['gui'] = GUI::getInstance();
//Initialize Taxes
$GLOBALS['tax'] = Tax::getInstance();
//Initialize catalogue
$GLOBALS['catalogue'] = Catalogue::getInstance();
//Initialize cubecart
$GLOBALS['cubecart'] = Cubecart::getInstance();
//Initialize user
$GLOBALS['user'] = User::getInstance();
//Initialize cart
$GLOBALS['cart'] = Cart::getInstance();
// Set store timezone - default to UTC
date_default_timezone_set($GLOBALS['config']->get('config', 'time_zone') ? $GLOBALS['config']->get('config', 'time_zone') : 'UTC');
if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->get('confirmed', 'recaptcha')) {
$recaptcha['error'] = null;
$recaptcha['confirmed'] = false;
if ($GLOBALS['config']->get('config', 'recaptcha') == 2 && isset($_POST['g-recaptcha-response'])) {
if (empty($_POST['g-recaptcha-response'])) {
$recaptcha['error'] = $GLOBALS['language']->form['verify_human_fail'];
} else {
$g_data = array('secret' => $GLOBALS['config']->get('config', 'recaptcha_secret_key'), 'response' => $_POST['g-recaptcha-response'], 'remoteip' => get_ip_address());
$json = file_get_contents('https://www.google.com/recaptcha/api/siteverify?' . http_build_query($g_data));
$g_result = json_decode($json);
if ($g_result->success) {
$recaptcha['confirmed'] = true;
} else {
示例5: Goods
include_once "../models/goods.php";
include_once "../views/functions.php";
$GLOBALS['title'] = "Корзина";
include_once "header.php";
?>
<h2>Корзина</h2>
<?php
if (!isset($_SESSION['id_user'])) {
echo "<p>*Требуется войти, чтобы совершить покупку</p>";
}
?>
<div>
<?php
$cart_goods = Cart::getInstance()->getAllCookies();
if (!empty($cart_goods)) {
echo "<a href='http://localhost/iba/cart/removeAll'>Очистить корзину</a><br><br>";
$good = new Goods();
foreach ($cart_goods as $key => $value) {
$good->getGood($key);
echo "<form action='" . PATHSITE . "/purchase/buy' method='post' oninput='cost.value=(price.valueAsNumber * count.valueAsNumber)'>";
echo "<a href='" . PATHSITE . "/good/" . $key . "'>" . $good->name . "</a> ";
echo "<input name='id' type='number' hidden='true' value='{$key}'>";
echo "<input name='count' type='number' min='1' step='1' required='true' value={$value}> ";
echo "<input name='price' type='number' hidden='true' value={$good->price}>";
echo "<input name='cost' type='number' min='1' readonly='true' required='true' value={$good->price}> ";
if (isset($_SESSION['id_user'])) {
echo "<input name='submitButton' type='submit' value='Купить'> ";
}
echo "<a href='" . PATHSITE . "/cart/remove?id={$key}'>Удалить</a><br>";
示例6: foreach
{
if (isset($_COOKIE['goods'])) {
foreach ($_COOKIE['goods'] as $id => $value) {
setcookie("goods[{$id}]", "", time() - 1, "/");
}
}
}
function IsCookie($id)
{
if (isset($_COOKIE['goods'][$id])) {
return TRUE;
} else {
return FALSE;
}
}
}
switch ($action) {
case "add":
Cart::getInstance()->putCookie();
break;
case "remove":
header("Location:" . PATHSITE . "/cart");
Cart::getInstance()->deleteCookie($_GET['id']);
break;
case "removeAll":
header("Location:" . PATHSITE . "/cart");
Cart::getInstance()->deleteAllCookies();
break;
default:
break;
}