public function indexAction() { $this->_helper->layout()->setLayout('redesign-2014'); $Page = new Model_Page(); if ($this->_getParam('pid') == 'index') { //$this->_redirect('/'); } $pagedata = $Page->Display($this->_getParam('pid')); if (!$pagedata) { //check if product url $products = new Model_Products(); $product = $products->ListProductByURL($this->_getParam('pid')); if ($product) { $this->_helper->layout()->setLayout('redesign-2014-product'); $product_id = $product['ProductID']; $this->view->data = $product; $this->view->images = $products->DisplayProductImages($product_id); $this->view->pagetype = "product"; $this->view->product_page = 1; $this->view->site_title = $product['Name']; $this->view->product_categories = $products->DisplayProductCategories($product_id); $this->view->product_attributes = $products->DisplayProductAttributes($product_id); $this->render('product'); } else { throw new Zend_Controller_Action_Exception('This page does not exist', 404); } } else { $this->view->pagetype = "page"; $this->view->data = $pagedata; } if ($pagedata['PageType'] == 'About') { $site = new Model_Site(); $this->view->blurb_1 = $site->widget_blurb("Who We Are"); $this->view->blurb_2 = $site->widget_blurb("Our Mission"); $this->render('about'); } if ($pagedata['PageType'] == 'Contact') { $this->render('contact'); } }
public function productsdisplayAction() { //$this->_helper->layout()->setLayout('admin'); $products = new Model_Products(); $generic = new Model_Generic(); $categories = new Model_Categories(); $product_id = $this->_getParam('pid'); $this->view->data = $products->ListProducts($product_id); $this->view->images = $products->DisplayProductImages($product_id); $this->view->product_attributes = $products->DisplayProductAttributes($product_id); $this->view->product_categories = $products->GetProductTreeIDs($product_id); $this->view->Brands = $generic->getData("Brands"); #$this->view->Categories = $generic->getData("Category","","Name asc"); $this->view->category_tree = $categories->listCategoryTree(); $this->view->orphan_categories = $categories->listOrphanCategories(); $this->render('productscreate'); }
public function cartAction() { $this->_helper->layout()->setLayout('redesign-2014'); $this->view->cart_page = 1; //@todo replace iwth pagetype $this->view->pagetype = 'cart'; $shop = new Model_Shop(); $product = new Model_Products(); $generic = new Model_Generic(); $login_info = $this->isLoggedIn(); $this->view->loginInfo = $login_info; $cookie_items = isset($_COOKIE['cart_items']) ? $_COOKIE['cart_items'] : array(); $items = $shop->listCartItems($cookie_items); foreach ($items as $row) { $images[$row['ProductID']] = $product->DisplayProductImages($row['ProductID']); } if (isset($images)) { $this->view->images = $images; } $this->view->itemcount = count($items); $this->view->items = $items; if ($_POST) { // Empty the Basket if (isset($_POST['emptycart'])) { $shop->emptyCart(); $this->_redirect('/cart/'); } // Refresh Cart if (isset($_POST['refreshcart'])) { $products = new Model_Products(); $updated_quantities = $products->CheckInventory($_POST['Quantity']); //validation for item quantities //$this->view->updated_quantities = $updated_quantities; $this->_redirect('/cart/'); //this is done to refresh the cart items } // Checkout if (isset($_POST['checkout'])) { $this->view->showCheckOutForm = 1; //$this->view->updated_quantities = $_POST['Quantity'] ; if (isset($_POST['Quantity'])) { $products = new Model_Products(); $products->CheckInventory($_POST['Quantity']); $this->view->updated_quantities = $_POST['Quantity']; } // Member Checkout if ($this->isLoggedIn()) { $user_details = $this->isLoggedIn(); $this->view->isLoggedIn = 1; $this->view->User = $user_details; $this->view->states = $shop->shippingTable(); $this->view->shipping_rate = $generic->getData("Shipping", "", "State asc"); if (isset($_POST['StoreCredits'])) { $this->view->store_credits_to_use = $_POST['StoreCredits']; if ($_POST['StoreCredits'] > $user_details['StoreCredits']) { $this->view->StoreCreditError = 'Error! You have entered more than your available store credits. '; $this->view->store_credits_to_use = 0; } } // Member Transaction if (isset($_POST['memcheckout'])) { //echo '<pre>'; print_r($_POST);exit; $state = isset($_POST['State']) ? $_POST['State'] : 0; $shipping_details = $generic->getData("Shipping", "ID=" . $state); //$shipping_fee = isset($shipping_details[0]['Fee']) ? $shipping_details[0]['Fee'] : 0; //unset($_POST['ShippingFee']); $data = $_POST; $data['ShippingFee'] = $_POST['ShippingFee']; $Transaction = new Model_Transaction(); $process = $Transaction->AddMemberTransaction($data, $user_details); if ($process) { $shop->emptyCart(); $trackingid = $process; $this->_redirect('/thankyou/?esig1234=' . $user_details['SiteEmail'] . '&trackingID=' . $trackingid); } } else { $this->render('cartuser'); } } // Create Transaction if (isset($_POST['excheckout'])) { $Transaction = new Model_Transaction(); $process = $Transaction->Add($_POST); if ($process) { $shop->emptyCart(); //$this->view->trackingid = $_POST['excheckout']; $this->view->trackingid = $process; $this->view->email = $_POST['Email']; $this->render('confirm'); } //else { //$this->render('confirm'); //@todo why is this here? //} } } } }