0

我安装了两个模块。

为单页结帐开发的一个模块(module1),它工作正常。它用一些新的运输方式等替换了 available.phtml。

我想将其包含在不基于单页结账的新收银员(模块2)中。所以我试着这样做:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('unifaun/checkout/onepage/shipping_method/available.phtml')->toHtml(); ?>

它成功地包含了 available.phtml。但是,available.phtml 的行为并不正常。

available.phtml 中的第一行是:

<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
    <p><?php echo Mage::helper('unifaun')->__('No shipping methods that suit your order were found. Please contact customer service.') ?></p>
<?php else: ?>
etc... 

问题是我没有像在单页结帐中那样获得任何运费等。我还手动输入了以下内容:

<?php       
    $country = Mage::getStoreConfig('shipping/origin/country_id');
    $postcode = Mage::getStoreConfig('shipping/origin/postcode');
    $city = Mage::getStoreConfig('shipping/origin/city');

    $quote = Mage::getSingleton('checkout/session')->getQuote();
    $quote->getShippingAddress()
        ->setCountryId($country)
        ->setCity($city)
        ->setPostcode($postcode)
        ->setCollectShippingRates(true);        
?>

所以我的问题是我需要做什么才能使以下行正常工作,以便代码实际获得可用的运输方式等......,就像模块包含在单页结帐中一样。

$_shippingRateGroups = $this->getShippingRates()

我不确定这是否足以解决这个问题,但我想我尝试一下并发布它,看看是否有人知道我做错了什么。:)

干杯!

4

1 回答 1

2

You are including a basic block of type core/template, all blocks are based of that.

So in your context there is no method getShippingRates for it to find.

So change the following to something like:

<?php echo $this->getLayout()->createBlock('unifaun_onepage/the_block_name')->setTemplate('unifaun/checkout/onepage/shipping_method/available.phtml')->toHtml(); ?>

Where the_block_name is the folder in the modules block, eg /Block/The/Block/Name.php

于 2013-10-01T15:55:33.550 回答