Domanda

In a shippingModule in the collectRates method, i have set up a few values:

$method->setCarrier('test_customrate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('test_customrate');
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice($this->getConfigData('price'));
$method->setCost(2);
$method->setUsername($this->getConfigData('username'));
$method->setPassword($this->getConfigData('password'));
$result->append($method);

Where are these values stored in the checkout session? I can't find them anywhere.

I have now found that with the below mentioned code in the observer, i can get a couple of values back as mentioned above. However, some values like cost, username and password are not present here.

 $rates = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()
->getShippingRatesCollection();


foreach ($rates as $rate) {

Mage::log($rate->getData());

}

this retrieves something of the following structure:

 2013-06-01T15:36:10+00:00 DEBUG (7): Array
(
[rate_id] => 852
[address_id] => 93
[created_at] => 2013-06-01 15:36:06
[updated_at] => 2013-06-01 15:36:09
[carrier] => test_customrate
[carrier_title] => test_customrate
[code] => test_customrate_test_customrate
[method] => test_customrate
[method_description] => 
[price] => 0.0000
[method_title] => test123
[error_message] => 
)
È stato utile?

Soluzione

I worked around this by simply getting the values directly from the shipping module config.

Like this:

Mage::getStoreConfig('section/group/field');

So I'm just getting the data from system.xml like i did in the collectRates().
However this is quite static and i would still prefer a method to get this straight from the order.

For now this fixes my problem. If anything knows any other ways feel free to answer

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top