diff --git a/classes/Carrier.php b/classes/Carrier.php index 0b163b0e9..1d0c7c092 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -469,12 +469,11 @@ class CarrierCore extends ObjectModel return Db::getInstance()->getValue(' SELECT id_tax_rules_group FROM ( - SELECT COUNT(*) n, carrier_shop.id_tax_rules_group + SELECT COUNT(*) n, c.id_tax_rules_group FROM '._DB_PREFIX_.'carrier c - '.Shop::addSqlAssociation('carrier', 'c').' - JOIN '._DB_PREFIX_.'tax_rules_group trg ON (carrier_shop.id_tax_rules_group = trg.id_tax_rules_group) + JOIN '._DB_PREFIX_.'tax_rules_group trg ON (c.id_tax_rules_group = trg.id_tax_rules_group) WHERE trg.active = 1 - GROUP BY carrier.id_tax_rules_group + GROUP BY c.id_tax_rules_group ORDER BY n DESC LIMIT 1 ) most_used' diff --git a/controllers/admin/AdminCarrierWizardController.php b/controllers/admin/AdminCarrierWizardController.php index 8b8cbabe3..bda129b4e 100644 --- a/controllers/admin/AdminCarrierWizardController.php +++ b/controllers/admin/AdminCarrierWizardController.php @@ -472,9 +472,11 @@ class AdminCarrierWizardControllerCore extends AdminController public function getStepThreeFieldsValues($carrier) { + $id_tax_rules_group = (is_object($this->object) && !$this->object->id) ? Carrier::getIdTaxRulesGroupMostUsed() : $this->getFieldValue($carrier, 'id_tax_rules_group'); + return array( 'is_free' => $this->getFieldValue($carrier, 'is_free'), - 'id_tax_rules_group' => $this->getFieldValue($carrier, 'id_tax_rules_group'), + 'id_tax_rules_group' => (int)$id_tax_rules_group, 'shipping_handling' => $this->getFieldValue($carrier, 'shipping_handling'), 'shipping_method' => $this->getFieldValue($carrier, 'shipping_method'), 'range_behavior' => $this->getFieldValue($carrier, 'range_behavior'),