0

皆さん、私のマジェントストアにはJNE http://www.magentocommerce.com/magento-connect/suhanto-jne.htmlと呼ばれる配送方法が1つしかありません

顧客が都市を埋めるときに自動的に選択される配送方法を希望します。

私はすでにこれを検索して見つけました:http://www.magentocommerce.com/boards/viewthread/9223/#t33602

彼の解決策はこのようなものです

// find methods loop:
            <?php foreach ($_rates as $_rate): ?>

//  add checking for free shipping method and setting it as default
                <?php if ($_rate->getCode()=='freeshipping_freeshipping' && !$this->getAddress()->getShippingMethod()) {
                $this->getAddress()->setShippingMethod($_rate->getCode());
            } ?>

available.html のどこにコードを配置すればよいかわかりません

ちなみに、このコードは available.html にあります


<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
<strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
<dl class="shipment-methods">
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
    <dt><?php echo $this->getCarrierName($code) ?></dt>
    <dd>
        <ul>

<?php foreach ($_rates as $_rate): ?>
            <li>
               <?php if ($_rate->getErrorMessage()): ?>
                <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
               <?php else: ?>
                    <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> onclick="shippingMethodStep.save()"/>
                    <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
                    <strong>
                    <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
                    <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>

                    <?php echo $_excl; ?>
                    <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
                        (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
                    <?php endif; ?>
                    </strong>
                    </label>
               <?php endif ?>
            </li>
        <?php endforeach; ?>

</ul>
    </dd>
<?php endforeach; ?>


そのソリューションをどこに置き換えまたは追加する必要があるか教えてください。

または、自動選択jne配送方法の別のソリューション

4

1 に答える 1

0

あなたの場合の非常に醜い方法は編集することです

<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?>

あなたの中input

<?php if($_rate->getCode()===$this->getAddressShippingMethod() or true){ echo ' checked="checked"';}  

これはあまり賢明な理由ではありませんが、すべてのラジオ ボタンが選択されるので、あなたの場合はうまくいきます。あなたの場合は 1 つだけです。ただ、発送方法が1つしかないか確認した方が良いでしょう。たぶんこれも機能します(これまでテストしていません):

<?php if($_rate->getCode()===$this->getAddressShippingMethod() or count($_shippingRateGroups) == 1){ echo ' checked="checked"';} 

出荷配列の配列要素数をカウントします。要素が 1 つだけの場合は、selected-tag を設定します。

于 2013-11-08T07:13:50.547 に答える