Пример #1
0
 /**
  * Displays the product data box, tabbed, with several panels covering price, stock etc
  *
  * @since    1.0
  */
 public function box()
 {
     $post = $this->wp->getGlobalPost();
     $coupon = $this->couponService->findForPost($post);
     $methods = array();
     foreach ($this->paymentService->getAvailable() as $method) {
         /** @var $method Method */
         $methods[$method->getId()] = $method->getName();
     }
     Render::output('admin/coupon/box', array('coupon' => $coupon, 'types' => $this->couponService->getTypes(), 'paymentMethods' => $methods));
 }
Пример #2
0
 /**
  * Validate and sanitize input values.
  *
  * @param array $settings Input fields.
  *
  * @return array Sanitized and validated output.
  * @throws ValidationException When some items are not valid.
  */
 public function validate($settings)
 {
     $activeGatewayFromPost = array();
     foreach ($this->paymentService->getAvailable() as $method) {
         /** @var $method Method */
         $methodId = $method->getId();
         $settings[$methodId] = $method->validateOptions($settings[$methodId]);
         //			$_POST 'enabled' need be used by all as payment gateways
         if ($_POST['jigoshop'][$methodId]['enabled'] == 'on') {
             $activeGatewayFromPost[] = $methodId;
         }
     }
     if (count($activeGatewayFromPost) == 0) {
         $settings['default_gateway'] = 'no_default_gateway';
         return $settings;
     }
     if ($_POST['jigoshop'][$this->options['default_gateway']]['enabled'] == 'off') {
         $settings['default_gateway'] = $activeGatewayFromPost[0];
     }
     return $settings;
 }