/** * Indicates wether the minimum order value is reached. * * @return bool * * @author Sascha Koehler <*****@*****.**> * @since 09.06.2011 */ public function IsMinimumOrderValueReached() { if (SilvercartConfig::UseMinimumOrderValue() && SilvercartConfig::MinimumOrderValue() && SilvercartConfig::MinimumOrderValue()->getAmount() > $this->getAmountTotalWithoutFees()->getAmount()) { return false; } return true; }
/** * Initializes the step form. Includes forms and requirements. * * @return void * * @author Sebastian Diel <*****@*****.**>, * Sascha Koehler <*****@*****.**> * @since 15.11.2014 */ public function init() { $this->preferences['templateDir'] = PIXELTRICKS_CHECKOUT_BASE_PATH_REL . 'templates/Layout/'; if (SilvercartConfig::EnableSSL()) { Director::forceSSL(); } parent::init(); // Inject payment and shippingmethods to shoppingcart, if available $member = SilvercartCustomer::currentUser(); if ($member) { $stepData = $this->getCombinedStepData(); $shoppingCart = $member->getCart(); // If minimum order value is set and shoppingcart value is below we // have to redirect the customer to the shoppingcart page and set // an appropriate error message. if ($this->getCurrentStep() < 5 && SilvercartConfig::UseMinimumOrderValue() && SilvercartConfig::MinimumOrderValue() && SilvercartConfig::MinimumOrderValue()->getAmount() > $shoppingCart->getAmountTotalWithoutFees()->getAmount()) { $silvercartSessionErrors = Session::get('Silvercart.errors'); $silvercartSessionErrors[] = sprintf(_t('SilvercartShoppingCart.ERROR_MINIMUMORDERVALUE_NOT_REACHED'), SilvercartConfig::MinimumOrderValue()->Nice()); Session::set('Silvercart.errors', $silvercartSessionErrors); Session::save(); $this->redirect(SilvercartPage_Controller::PageByIdentifierCode('SilvercartCartPage')->Link()); } if (isset($stepData['ShippingMethod'])) { $shoppingCart->setShippingMethodID($stepData['ShippingMethod']); } if (isset($stepData['PaymentMethod'])) { $shoppingCart->setPaymentMethodID($stepData['PaymentMethod']); } $requestParams = $this->getRequest()->allParams(); if ($requestParams['Action'] == 'editAddress') { $addressID = (int) $requestParams['ID']; $membersAddresses = SilvercartCustomer::currentUser()->SilvercartAddresses(); $membersAddress = $membersAddresses->find('ID', $addressID); if ($membersAddress instanceof SilvercartAddress && $membersAddress->exists()) { Session::set("redirect", $this->Link()); $preferences = array(); $preferences['submitAction'] = 'editAddress/' . $addressID . '/customHtmlFormSubmit'; $this->registerCustomHtmlForm('SilvercartEditAddressForm', new SilvercartEditAddressForm($this, array('addressID' => $addressID), $preferences)); } } elseif ($requestParams['Action'] == 'addNewAddress') { Session::set("redirect", $this->Link()); $preferences = array(); $preferences['submitAction'] = 'addNewAddress/customHtmlFormSubmit'; $this->registerCustomHtmlForm('SilvercartAddAddressForm', new SilvercartAddAddressForm($this, array(), $preferences)); } } }