當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TaxRulesGroup::hasUniqueTaxRuleForCountry方法代碼示例

本文整理匯總了PHP中TaxRulesGroup::hasUniqueTaxRuleForCountry方法的典型用法代碼示例。如果您正苦於以下問題:PHP TaxRulesGroup::hasUniqueTaxRuleForCountry方法的具體用法?PHP TaxRulesGroup::hasUniqueTaxRuleForCountry怎麽用?PHP TaxRulesGroup::hasUniqueTaxRuleForCountry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TaxRulesGroup的用法示例。


在下文中一共展示了TaxRulesGroup::hasUniqueTaxRuleForCountry方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processCreateRule

 protected function processCreateRule()
 {
     $zip_code = Tools::getValue('zipcode');
     $id_rule = (int) Tools::getValue('id_tax_rule');
     $id_tax = (int) Tools::getValue('id_tax');
     $id_tax_rules_group = (int) Tools::getValue('id_tax_rules_group');
     $behavior = (int) Tools::getValue('behavior');
     $description = pSQL(Tools::getValue('description'));
     if ((int) ($id_country = Tools::getValue('country')) == 0) {
         $countries = Country::getCountries($this->context->language->id);
         $this->selected_countries = array();
         foreach ($countries as $country) {
             $this->selected_countries[] = (int) $country['id_country'];
         }
     } else {
         $this->selected_countries = array($id_country);
     }
     $this->selected_states = Tools::getValue('states');
     if (empty($this->selected_states) || count($this->selected_states) == 0) {
         $this->selected_states = array(0);
     }
     $tax_rules_group = new TaxRulesGroup((int) $id_tax_rules_group);
     foreach ($this->selected_countries as $id_country) {
         $first = true;
         foreach ($this->selected_states as $id_state) {
             if ($tax_rules_group->hasUniqueTaxRuleForCountry($id_country, $id_state, $id_rule)) {
                 $this->errors[] = Tools::displayError('A tax rule already exists for this country/state with tax only behavior.');
                 continue;
             }
             $tr = new TaxRule();
             // update or creation?
             if (isset($id_rule) && $first) {
                 $tr->id = $id_rule;
                 $first = false;
             }
             $tr->id_tax = $id_tax;
             $tax_rules_group = new TaxRulesGroup((int) $id_tax_rules_group);
             $tr->id_tax_rules_group = (int) $tax_rules_group->id;
             $tr->id_country = (int) $id_country;
             $tr->id_state = (int) $id_state;
             list($tr->zipcode_from, $tr->zipcode_to) = $tr->breakDownZipCode($zip_code);
             // Construct Object Country
             $country = new Country((int) $id_country, (int) $this->context->language->id);
             if ($zip_code && $country->need_zip_code) {
                 if ($country->zip_code_format) {
                     foreach (array($tr->zipcode_from, $tr->zipcode_to) as $zip_code) {
                         if ($zip_code) {
                             if (!$country->checkZipCode($zip_code)) {
                                 $this->errors[] = sprintf(Tools::displayError('The Zip/postal code is invalid. It must be typed as follows: %s for %s.'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))), $country->name);
                             }
                         }
                     }
                 }
             }
             $tr->behavior = (int) $behavior;
             $tr->description = $description;
             $this->tax_rule = $tr;
             $_POST['id_state'] = $tr->id_state;
             $this->errors = array_merge($this->errors, $this->validateTaxRule($tr));
             if (count($this->errors) == 0) {
                 $tax_rules_group = $this->updateTaxRulesGroup($tax_rules_group);
                 $tr->id = (int) $tax_rules_group->getIdTaxRuleGroupFromHistorizedId((int) $tr->id);
                 $tr->id_tax_rules_group = (int) $tax_rules_group->id;
                 if (!$tr->save()) {
                     $this->errors[] = Tools::displayError('An error has occurred: Cannot save the current tax rule.');
                 }
             }
         }
     }
     if (count($this->errors) == 0) {
         Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . (int) $tax_rules_group->id . '&conf=4&update' . $this->table . '&token=' . $this->token);
     } else {
         $this->display = 'edit';
     }
 }
開發者ID:ortegon000,項目名稱:tienda,代碼行數:75,代碼來源:AdminTaxRulesGroupController.php


注:本文中的TaxRulesGroup::hasUniqueTaxRuleForCountry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。