예제 #1
0
 public function displayRules()
 {
     $classes = array();
     foreach ($this->options['classes'] as $class) {
         $classes[$class['class']] = $class['label'];
     }
     $countries = array_merge(array('' => __('All countries', 'jigoshop')), Country::getAll());
     Render::output('admin/settings/tax/rules', array('rules' => $this->taxService->getRules(), 'classes' => $classes, 'countries' => $countries));
 }
예제 #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)
 {
     $settings['show_message'] = $settings['show_message'] == 'on';
     $settings['demo_store'] = $settings['demo_store'] == 'on';
     if (!in_array($settings['country'], array_keys(Country::getAll()))) {
         $this->messages->addError(__('Invalid shop location (country), please select again.', 'jigoshop'));
         $settings['country'] = '';
     }
     return $settings;
 }
예제 #3
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)
 {
     $settings['catalog_per_page'] = (int) $settings['catalog_per_page'];
     if ($settings['catalog_per_page'] <= 0) {
         $this->messages->addWarning(sprintf(__('Invalid products per page value: "%d". Value set to 12.', 'jigoshop'), $settings['catalog_per_page']));
         $settings['catalog_per_page'] = 12;
     }
     if (!in_array($settings['catalog_order_by'], array_keys($this->catalogOrderBy))) {
         $this->messages->addWarning(sprintf(__('Invalid products sorting: "%s". Value set to %s.', 'jigoshop'), $settings['catalog_order_by'], $this->catalogOrderBy['post_date']));
         $settings['catalog_order_by'] = 'post_date';
     }
     if (!in_array($settings['catalog_order'], array_keys($this->catalogOrder))) {
         $this->messages->addWarning(sprintf(__('Invalid products sorting orientation: "%s". Value set to %s.', 'jigoshop'), $settings['catalog_order'], $this->catalogOrder['DESC']));
         $settings['catalog_order'] = 'DESC';
     }
     $settings['hide_out_of_stock'] = $settings['hide_out_of_stock'] == 'on';
     $settings['enable_verification_message'] = $settings['enable_verification_message'] == 'on';
     $settings['guest_purchases'] = $settings['guest_purchases'] == 'on';
     $settings['show_login_form'] = $settings['show_login_form'] == 'on';
     $settings['allow_registration'] = $settings['allow_registration'] == 'on';
     $settings['login_for_downloads'] = $settings['login_for_downloads'] == 'on';
     $settings['force_ssl'] = $settings['force_ssl'] == 'on';
     $settings['validate_zip'] = $settings['validate_zip'] == 'on';
     $settings['restrict_selling_locations'] = $settings['restrict_selling_locations'] == 'on';
     if (!$settings['restrict_selling_locations']) {
         $settings['selling_locations'] = array();
     } else {
         $settings['selling_locations'] = array_intersect($settings['selling_locations'], array_keys(Country::getAll()));
     }
     if (!in_array($settings['redirect_add_to_cart'], array_keys($this->addToCartRedirectionOptions))) {
         $this->messages->addWarning(sprintf(__('Invalid add to cart redirection: "%s". Value set to %s.', 'jigoshop'), $settings['redirect_add_to_cart'], $this->addToCartRedirectionOptions['same_page']));
         $settings['redirect_add_to_cart'] = 'same_page';
     }
     if (!in_array($settings['redirect_continue_shopping'], array_keys($this->backToShopRedirectionOptions))) {
         $this->messages->addWarning(sprintf(__('Invalid continue shopping redirection: "%s". Value set to %s.', 'jigoshop'), $settings['redirect_continue_shopping'], $this->backToShopRedirectionOptions['product_list']));
         $settings['redirect_continue_shopping'] = 'product_list';
     }
     return $settings;
 }