protected function completeItem()
 {
     $cart =& $_SESSION['jCart'];
     if (!is_object($cart)) {
         $cart = new jCart();
     }
     $bpm = new Kutu_Core_Bpm_Catalog();
     $result = array('subTotal' => 0, 'taxAmount' => 0, 'grandTotal' => 0, 'items' => array());
     for ($iCart = 0; $iCart < count($cart->items); $iCart++) {
         $itemId = $cart->items[$iCart];
         $qty = 1;
         $itemPrice = $bpm->getPrice($itemId);
         //$itemPrice=20;
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = Kutu_Core_Util::getCatalogAttributeValue($itemId, 'fixedTitle');
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $this->_paymentVars['taxRate'] / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     return $result;
 }
Example #2
0
 private function _checkAccess($itemGuid)
 {
     $bpm = new Kutu_Core_Bpm_Catalog();
     $acl = Kutu_Acl::manager();
     if ($acl->checkAcl("site", 'all', 'user', $this->_auth->getIdentity()->username, false, false)) {
         return true;
     }
     if ($bpm->getPrice($itemGuid) <= 0) {
         // can be downloaded
         return true;
     } else {
         //check if the logged in user has once bought the parent Catalog
         return $bpm->isBoughtByUser($itemGuid, $this->_auth->getIdentity()->guid);
     }
 }
Example #3
0
 public function completeorderAction()
 {
     //this is where we generate invoice
     // and then empty cart
     // and then if payment method is paypal, ask if user wants to continue to pay via paypal.
     // if payment method is manual, then print-out the payment instruction.
     // send invoice to user.
     $tblPaymentSetting = new Kutu_Core_Orm_Table_PaymentSetting();
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $cart =& $_SESSION['jCart'];
     if (!is_object($cart)) {
         $cart = new jCart();
     }
     if (empty($cart) || count($cart->items) == 0) {
         //die("CART IS EMPTY");
         $this->_helper->redirector('cartempty', 'store', 'site');
     }
     $bpm = new Kutu_Core_Bpm_Catalog();
     $result = array('subTotal' => 0, 'taxAmount' => 0, 'grandTotal' => 0, 'items' => array());
     for ($iCart = 0; $iCart < count($cart->items); $iCart++) {
         $itemId = $cart->items[$iCart];
         $qty = 1;
         $itemPrice = $bpm->getPrice($itemId);
         //$itemPrice=20;
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = Kutu_Core_Util::getCatalogAttributeValue($itemId, 'fixedTitle');
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     $method = $this->_request->getParam('paymentMethod');
     $orderId = $this->saveOrder($result, $method);
     $cart = null;
     $data = $this->_request->getParams();
     $this->view->cart = $result;
     $this->view->data = $data;
     $this->view->orderId = $orderId;
     //send notification to user
     // 1. send invoice
     // 2. if paymentmethod=bank, also send instruction
     $mod = new Site_Model_Store_Mailer();
     switch (strtolower($method)) {
         case 'manual':
         case 'bank':
             $mod->sendBankInvoiceToUser($orderId);
             break;
         case 'paypal':
             $mod->sendInvoiceToUser($orderId);
             break;
         case 'postpaid':
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }