Skip to content

Instantly share code, notes, and snippets.

@fleeting
Created May 11, 2010 18:56
Show Gist options
  • Save fleeting/397691 to your computer and use it in GitHub Desktop.
Save fleeting/397691 to your computer and use it in GitHub Desktop.
<?php
function cart_add() {
if (empty($_SESSION["cart"]))
$_SESSION["cart"] = array();
$aProduct = $this->model->getProduct($this->_urlVars->dynamic["id"]);
if (array_key_exists($aProduct["id"], $_SESSION["cart"])) {
$_SESSION["cart"][$aProduct["id"]]["quantity"]++;
} else {
$aProduct["quantity"] = 1;
$_SESSION["cart"][$aProduct["id"]] = $aProduct;
}
$this->forward("/store/cart/?notice=".urlencode($aProduct["title"]." added to cart."));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment