Exemple #1
0
 public function validate($args)
 {
     $e = Loader::helper('validation/error');
     if ($args['symbol'] == "") {
         $e->add(t('You must set a currency symbol'));
     }
     if ($args['taxEnabled'] == 'yes') {
         if (!is_numeric(trim($args['taxRate']))) {
             $e->add(t('Tax Rate must be set, and a number'));
         }
     }
     if ($args['shippingEnabled'] == 'yes') {
         if (!is_numeric(trim($args['shippingBasePrice']))) {
             $e->add(t('Shipping Base Rate must be set, and a number'));
         }
         if (!is_numeric(trim($args['shippingItemPrice']))) {
             $e->add(t('Shipping Base Rate must be set, and a number (even if just zero)'));
         }
     }
     $paymentMethodsEnabled = 0;
     foreach ($args['paymentMethodEnabled'] as $method) {
         if ($method == 1) {
             $paymentMethodsEnabled++;
         }
     }
     if ($paymentMethodsEnabled == 0) {
         $e->add(t('At least one payment method must be enabled'));
     }
     foreach ($args['paymentMethodEnabled'] as $pmID => $value) {
         $pm = PaymentMethod::getByID($pmID);
         $controller = $pm->getMethodController();
         $e = $controller->validate($args, $e);
     }
     if (!isset($args['osName'])) {
         $e->add(t('You must have at least one Order Status.'));
     }
     return $e;
 }
Exemple #2
0
 public function getPaymentMethodName()
 {
     $pm = PaymentMethod::getByID($this->pmID);
     if (is_object($pm)) {
         return $pm->getPaymentMethodName();
     }
 }
Exemple #3
0
 public function external()
 {
     $pm = Session::get('paymentMethod');
     /*print_r($pm);
       exit();die();
       */
     foreach ($pm as $pmID => $handle) {
         $pm = PaymentMethod::getByID($pmID);
     }
     //$pm = PaymentMethod::getByHandle($pm[3]);
     $this->set('pm', $pm);
     $this->set('action', $pm->getMethodController()->getAction());
 }
Exemple #4
0
 public function validate($args)
 {
     $e = Loader::helper('validation/error');
     if ($args['symbol'] == "") {
         $e->add(t('You must set a currency symbol'));
     }
     if ($args['taxEnabled'] == 'yes') {
         if (!is_numeric(trim($args['taxRate']))) {
             $e->add(t('Tax Rate must be set, and a number'));
         }
     }
     if ($args['shippingEnabled'] == 'yes') {
         if (!is_numeric(trim($args['shippingBasePrice']))) {
             $e->add(t('Shipping Base Rate must be set, and a number'));
         }
         if (!is_numeric(trim($args['shippingItemPrice']))) {
             $e->add(t('Shipping Base Rate must be set, and a number (even if just zero)'));
         }
     }
     $paymentMethodsEnabled = 0;
     foreach ($args['paymentMethodEnabled'] as $method) {
         if ($method == 1) {
             $paymentMethodsEnabled++;
         }
     }
     if ($paymentMethodsEnabled == 0) {
         $e->add(t('At least one payment method must be enabled'));
     }
     foreach ($args['paymentMethodEnabled'] as $pmID => $value) {
         $pm = StorePaymentMethod::getByID($pmID);
         $controller = $pm->getMethodController();
         $e = $controller->validate($args, $e);
     }
     if (!isset($args['osName'])) {
         $e->add(t('You must have at least one Order Status.'));
     }
     //before changing tax settings to "Extract", make sure there's only one rate per class
     $taxClasses = StoreTaxClass::getTaxClasses();
     foreach ($taxClasses as $taxClass) {
         $taxClassRates = $taxClass->getTaxClassRates();
         if (count($taxClassRates) > 1) {
             $e->add(t("The %s Tax Class can't contain more than 1 Tax Rate if you change how the taxes are calculated", $taxClass->getTaxClassName()));
         }
     }
     return $e;
 }