i am working on a cart system Plugin, i am setting a variable $cart in cart controller, and now i have to use the same variable in dish controller , how to do this? here is my code, i am working with:
Cart Controller:
class CartsController extends CartAppController {
public function view($cartId = null) {
if (!empty($this->request->data)) {
$this->CartManager->updateItems($this->request->data['CartsItem']);
}
if (!empty($cartId)) {
$cart = $this->Cart->view($cartId, $this->Auth->user('id'));
} else {
$cart = $this->CartManager->content();
}
$this->request->data = $cart;
$this->set('cart', $cart); // This $cart variable is needed to be used in a different controller.
$this->set('requiresShipping', $this->CartManager->requiresShipping());
}
}
Dish Controller
class DishesController extends AppController {
public function index($id='') {
**// here i need to print that **$cart** variable**
$this->layout = false;
$menu=$this->Menu->find('first', array('conditions' => array("Menu.id"=>$id),'limit'=>1));
if(empty($id) || empty($menu)){
$this->redirect(array('controller'=>'menus', 'action'=>'index'));
}
$dishes=$this->Dish->find('all', array('conditions' => array("Dish.status"=>"1", "Dish.menu_id"=>$id), 'limit'=>9, 'recursive'=>0, 'order' => array('Dish.id' => 'DESC')));
$this->set('menu_name',$menu['Menu']['name']);
$this->set('dishes',$dishes);
$this->set('page_name','dishes');
}
}
Any help would be appreciated :)