コード例 #1
0
 public function index()
 {
     $this->loadLanguageFile('backend/Product');
     $productID = (int) $this->request->get('id');
     $product = Product::getInstanceByID($productID, ActiveRecord::LOAD_DATA);
     $rppa = RecurringProductPeriod::getRecordSetByProduct($product)->toArray();
     $response = new ActionResponse();
     $response->set('recurringProductPeriods', $rppa);
     $response->set('product', $product->toArray());
     $newRpp = RecurringProductPeriod::getNewInstance($product);
     $response->set('newRecurringProductPeriod', $newRpp->toArray());
     $response->set('newForm', $this->createForm($newRpp->toArray()));
     $response->set('currencies', $this->application->getCurrencyArray(true));
     $response->set('periodTypes', array_map(array($this, 'translate'), RecurringProductPeriod::getAllPeriodTypes(RecurringProductPeriod::PERIOD_TYPE_NAME_PLURAL)));
     return $response;
 }
コード例 #2
0
ファイル: Product.php プロジェクト: saiber/livecart
 public function getDefaultRecurringProductPeriod()
 {
     $filter = new ARSelectFilter();
     $filter->setLimit(1);
     $rs = RecurringProductPeriod::getRecordSetByProduct($this, $filter);
     if ($rs->size() == 0) {
         return null;
     }
     return $rs->shift();
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: GregerA/livecart
 private function getCartPageResponse()
 {
     $this->addBreadCrumb($this->translate('_my_session'), $this->router->createUrlFromRoute($this->request->get('return'), true));
     $this->order->setUser($this->user);
     $this->order->loadItemData();
     $response = new ActionResponse();
     if ($result = $this->order->updateToStock()) {
         $response->set('changes', $result);
     }
     $options = $this->getItemOptions();
     $currency = Currency::getValidInstanceByID($this->request->get('currency', $this->application->getDefaultCurrencyCode()), Currency::LOAD_DATA);
     $form = $this->buildCartForm($this->order, $options);
     if ($this->isTosInCartPage()) {
         $form->set('tos', $this->session->get('tos'));
     }
     if ($this->config->get('ENABLE_SHIPPING_ESTIMATE')) {
         $this->loadLanguageFile('User');
         if ($this->estimateShippingCost()) {
             $this->order->getTotal(true);
             $response->set('isShippingEstimated', true);
         }
         $address = $this->order->shippingAddress->get();
         foreach (array('countryID' => 'country', 'stateName' => 'state_text', 'postalCode' => 'postalCode', 'city' => 'city') as $addressKey => $formKey) {
             $form->set('estimate_' . $formKey, $address->{$addressKey}->get());
         }
         if ($address->state->get() && $address->state->get()->getID()) {
             $form->set('estimate_state_select', $address->state->get()->getID());
         }
         $response->set('countries', $this->getCountryList($form));
         $response->set('states', $this->getStateList($form->get('estimate_country')));
         $hideConf = (array) $this->config->get('SHIP_ESTIMATE_HIDE_ENTRY');
         $hideForm = !empty($hideConf['UNREGISTERED']) && $this->user->isAnonymous() || !empty($hideConf['ALL_REGISTERED']) && !$this->user->isAnonymous() || !empty($hideConf['REGISTERED_WITH_ADDRESS']) && !$this->user->isAnonymous() && !$this->user->defaultBillingAddress->get() || !$this->order->isShippingRequired() || $this->order->isMultiAddress->get();
         $response->set('hideShippingEstimationForm', $hideForm);
     }
     $orderArray = $this->order->toArray();
     $itemsById = array();
     $recurringItemsByItem = array();
     $hasRecurringItem = false;
     foreach (array('cartItems', 'wishListItems') as $type) {
         if (!empty($orderArray[$type])) {
             foreach ($orderArray[$type] as &$item) {
                 $itemsById[$item['ID']] =& $item;
                 if ($item['Product']['type'] == Product::TYPE_RECURRING) {
                     $hasRecurringItem = true;
                     $recurringProductPeriods = RecurringProductPeriod::getRecordSetByProduct($item['Product']['ID'])->toArray();
                     $recurringItemsByItem[$item['ID']] = $recurringProductPeriods;
                 }
             }
         }
     }
     if ($hasRecurringItem) {
         $response->set('periodTypesPlural', RecurringProductPeriod::getAllPeriodTypes(RecurringProductPeriod::PERIOD_TYPE_NAME_PLURAL));
         $response->set('periodTypesSingle', RecurringProductPeriod::getAllPeriodTypes(RecurringProductPeriod::PERIOD_TYPE_NAME_SINGLE));
         $response->set('recurringItemsByItem', $recurringItemsByItem);
     }
     $response->set('cart', $orderArray);
     $response->set('itemsById', $itemsById);
     $response->set('form', $form);
     $response->set('return', $this->request->get('return'));
     $response->set('currency', $currency->getID());
     $response->set('options', $options['visible']);
     $response->set('moreOptions', $options['more']);
     $response->set('orderTotal', $currency->getFormattedPrice($this->order->getTotal()));
     $response->set('expressMethods', $this->application->getExpressPaymentHandlerList(true));
     $response->set('isCouponCodes', DiscountCondition::isCouponCodes());
     $response->set('isOnePageCheckout', $this->config->get('CHECKOUT_METHOD') == 'CHECKOUT_ONEPAGE' && !$this->order->isMultiAddress->get() && !$this->session->get('noJS'));
     $this->order->getSpecification()->setFormResponse($response, $form);
     SessionOrder::getOrder()->getShoppingCartItems();
     return $response;
 }
コード例 #4
0
 public function recurringBlock()
 {
     $response = new BlockResponse();
     if ($this->product->type->get() == Product::TYPE_RECURRING) {
         ClassLoader::import('application.model.product.RecurringProductPeriod');
         ClassLoader::import('application.model.product.RecurringItem');
         $response->set('isRecurring', true);
         $response->set('periodTypesPlural', RecurringProductPeriod::getAllPeriodTypes(RecurringProductPeriod::PERIOD_TYPE_NAME_PLURAL));
         $response->set('periodTypesSingle', RecurringProductPeriod::getAllPeriodTypes(RecurringProductPeriod::PERIOD_TYPE_NAME_SINGLE));
         $response->set('recurringProductPeriods', RecurringProductPeriod::getRecordSetByProduct($this->product)->toArray());
     }
     return $response;
 }