Пример #1
0
 /**
  * Get product meta
  *
  * @param      pId
  * @return     types
  */
 public function getProductMeta($pId)
 {
     $warehouse = new Warehouse();
     $meta = $warehouse->getProductMeta($pId, true);
     $metaObj = new \stdClass();
     foreach ($meta as $key => $m) {
         $metaObj->{$key} = $m->pmValue;
     }
     return $metaObj;
 }
Пример #2
0
 /**
  * User agreement acceptance
  *
  * @return     void
  */
 public function eulaTask()
 {
     $cart = new CurrentCart();
     $errors = array();
     $transaction = $cart->liftTransaction();
     if (!$transaction) {
         // Redirect to cart if transaction cannot be lifted
         $cart->redirect('home');
     }
     $nextStep = $cart->getNextCheckoutStep();
     // Double check that the current step is indeed EULA, redirect if needed
     if ($nextStep->step != 'eula') {
         $cart->redirect($nextStep->step);
     }
     // Get the SKU id of the item being displayed (from meta)
     $sId = $nextStep->meta;
     // Get the eula text for the product or EULA (EULAs are assigned to products, and if needed, SKUS)
     $warehouse = new Warehouse();
     $skuInfo = $warehouse->getSkuInfo($sId);
     $this->view->productInfo = $skuInfo['info'];
     // Check if there is SKU EULA set
     if (!empty($skuInfo['meta']['eula'])) {
         $productEula = $skuInfo['meta']['eula'];
     } else {
         // Get product id
         $pId = $skuInfo['info']->pId;
         // Get EULA
         $productEula = $warehouse->getProductMeta($pId)['eula']->pmValue;
     }
     $this->view->productEula = $productEula;
     $eulaSubmitted = Request::getVar('submitEula', false, 'post');
     if ($eulaSubmitted) {
         // check if agreed
         $eulaAccepted = Request::getVar('acceptEula', false, 'post');
         if (!$eulaAccepted) {
             $errors[] = array(Lang::txt('COM_CART_MUST_ACCEPT_EULA'), 'error');
         } else {
             // Save item's meta
             $itemMeta = new \stdClass();
             $itemMeta->eulaAccepted = true;
             $itemMeta->machinesInstalled = 'n/a';
             $cart->setTransactionItemMeta($sId, json_encode($itemMeta));
             // Mark this step as completed
             $cart->setStepStatus('eula', $sId);
             // All good, continue
             $nextStep = $cart->getNextCheckoutStep()->step;
             $cart->redirect($nextStep);
         }
     }
     if (!empty($errors)) {
         $this->view->notifications = $errors;
     }
     $this->view->display();
 }