Я пытаюсь сделать так, чтобы способы доставки зависели от региона/штата. Я просматриваю app/code/core/Mage/Shipping/, там есть 3 файла, которые, как мне кажется, могут понадобиться для того, чтобы что-то произошло: etc/system.xml — содержит конфигурацию:
223 <show_in_store>0</show_in_store>
224 </sallowspecific>
225: <specificcountry translate="label">
226 <label>Ship to Specific Countries</label>
227 <frontend_type>multiselect</frontend_type>
...
232 <show_in_store>0</show_in_store>
233 <can_be_empty>1</can_be_empty>
234: </specificcountry>
235 <showmethod translate="label">
236 <label>Show Method if Not Applicable</label>
...
312 <show_in_store>0</show_in_store>
313 </sallowspecific>
314: <specificcountry translate="label">
315 <label>Ship to Specific Countries</label>
316 <frontend_type>multiselect</frontend_type>
...
321 <show_in_store>0</show_in_store>
322 <can_be_empty>1</can_be_empty>
323: </specificcountry>
324 <showmethod translate="label">
325 <label>Show Method if Not Applicable</label>
...
445 <show_in_store>0</show_in_store>
446 </sallowspecific>
447: <specificcountry translate="label">
448 <label>Ship to Specific Countries</label>
449 <frontend_type>multiselect</frontend_type>
...
454 <show_in_store>0</show_in_store>
455 <can_be_empty>1</can_be_empty>
456: </specificcountry>
457 <showmethod translate="label">
458 <label>Show Method if Not Applicable</label>
Другие файлы: Model/Carrier/Abstract.php
/**
* Return delivery confirmation types of carrier
*
* @param Varien_Object|null $params
* @return array
*/
public function getDeliveryConfirmationTypes(Varien_Object $params = null)
{
return array();
}
public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request)
{
$speCountriesAllow = $this->getConfigData('sallowspecific');
/*
* for specific countries, the flag will be 1
*/
if ($speCountriesAllow && $speCountriesAllow == 1){
$showMethod = $this->getConfigData('showmethod');
$availableCountries = array();
if($this->getConfigData('specificcountry')) {
$availableCountries = explode(',',$this->getConfigData('specificcountry'));
}
if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) {
return $this;
} elseif ($showMethod && (!$availableCountries || ($availableCountries
&& !in_array($request->getDestCountryId(), $availableCountries)))
){
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$errorMsg = $this->getConfigData('specificerrmsg');
$error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.'));
return $error;
} else {
/*
* The admin set not to show the shipping module if the devliery country is not within specific countries
*/
return false;
}
}
return $this;
}
Последний: Модель/Доставка.php
/**
* Collect rates of given carrier
*
* @param string $carrierCode
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Shipping
*/
public function collectCarrierRates($carrierCode, $request)
{
/* @var $carrier Mage_Shipping_Model_Carrier_Abstract */
$carrier = $this->getCarrierByCode($carrierCode, $request->getStoreId());
if (!$carrier) {
return $this;
}
$carrier->setActiveFlag($this->_availabilityConfigField);
$result = $carrier->checkAvailableShipCountries($request);
if (false !== $result && !($result instanceof Mage_Shipping_Model_Rate_Result_Error)) {
$result = $carrier->proccessAdditionalValidation($request);
}
Я думаю, мне нужно как-то изменить Mage_Shipping_Model_Carrier, $ availableCountries и «конкретную страну» в регионах, но мне нужна помощь с этим. Я знаю, что не должен редактировать основные файлы, поэтому я думаю, что если я выясню, как сделать методы доставки по регионам, я внесу изменения в локальную папку.