1

チェックアウト プロセスの配送セクションで、次のコア テンプレートをオーバーライドしました。

app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml

2つの配送方法があります。1 つ目は「配送率」です。このモジュールでは、上記のテンプレート ファイルをオーバーライドしました。2 番目の出荷モジュールは「店舗受け取り」です。しかし、「Store-Pickup」をロードすると、常に Deliveryrate がロードされます。エラーが見つかりませんでした。提案をお願いします。以下は、編集されたテンプレート ファイルです。

<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
    <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else: ?>
    <dl class="sp-methods">
    <?php $shippingCodePrice = array(); ?>
    <?php $_sole = count($_shippingRateGroups) == 1; 
    foreach ($_shippingRateGroups as $code => $_rates): ?>    
    <?php 
    $helper = Mage::helper('deliveryrate');
    $isFlorist = $helper->IsCollectFromFlorist();
    if(!$isFlorist)
    {
    ?>
    <?php if($code == 'deliveryrate') // If the shipping method is deliveryshipping
    {?>
    <?php 
    // Get deliveryrate option details.
    $all_options = Mage::getModel('deliveryrate/alloptions')->getCollection();

    ?>
        <dt><?php echo $this->getCarrierName($code) ?></dt> <?php //header ?>

        <dd>
            <ul>
                <table id="tbl-delivery-shipping">
                <tbody>
                    <tr>
                        <td><label for="delivery-options" class="required" style="float:right;"><em>*</em>Delivery Time :</label></td>
                        <td><a href="#">Option 1 - Standard Delivery</a>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
            <?php $_sole = $_sole && count($_rates) == 1; 

            foreach ($_rates as $_rate): ?>
                 <?php 
                        $option = $_rate->getCode();
                        $optionArray = explode( '_', $option );
                        $array_last_index = count($optionArray)-1;
                        $delivery_option =  $optionArray[$array_last_index-1];
                        if($delivery_option == 1)
                        {
                        ?>

            <li>

                         <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
                <li>

                   <?php if ($_rate->getErrorMessage()): ?>
                    <ul class="messages">
                        <li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li>
                    </ul>
                   <?php else: ?>
                        <?php if ($_sole) : ?>
                        <span class="no-display">
                        <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" />
                        </span>
                        <?php else: ?>
                        <?php // radio button ?>

                        <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"' ?> class="radio"/>

                        <?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
                        <script type="text/javascript">
                            //<![CDATA[
                                lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
                            //]]>
                        </script>
                        <?php endif; ?>

                        <?php endif; ?>

                        <?php // option name ?>
                        <label for="s_method_<?php echo $_rate->getCode() ?>">
                        <?php $option_name = $_rate->getMethodTitle();   
                         $optionNameArray = explode( '(', $option_name );
                         if(count($optionNameArray)>1)
                         {
                             echo $optionNameArray[0];
                             ?>
                             <br>
                             <?php 
                             echo '('.$optionNameArray[1];
                         }
                         else 
                         {
                            echo $optionNameArray[0];
                         }

                        ?>
                        <?php // echo $_rate->getMethodTitle() ?>
                        <?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; ?>
                        </label>


                        <?php
                            $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
                            if($carrier->getFormBlock()){
                                $block = $this->getLayout()->createBlock($carrier->getFormBlock());
                                $block->setMethodCode($code);
                                $block->setRate($_rate);
                                $block->setMethodInstance($carrier);
                                echo $block->_toHtml();
                            } 

                        ?>

                   <?php endif ?>

                </li>
                <?php } ?>
                  <?php endforeach; ?>
                        </td>
                    </tr>
                        <tr>
                            <td><br></td>
                            <td></td>
                        </tr>
                    <tr>
                        <td></td>
                        <td><a href="#">Option 2 - specific Time</a>
                        <label style="font-size: 12px;font-weight:normal;color:silver;">(There will be an additional delivery charge for specific delivery time.)</label>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                        <ul>
                         <?php $_sole = $_sole && count($_rates) == 1; 

            foreach ($_rates as $_rate): ?>
                <?php 

                        $option = $_rate->getCode();
                        $optionArray = explode( '_', $option );
                        $array_last_index = count($optionArray)-1;
                        $delivery_option =  $optionArray[$array_last_index-1];
                        if($delivery_option == 2)
                        {
                        ?> 
                <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
                <li style="width:250px;float:left;">           
                   <?php if ($_rate->getErrorMessage()): ?>
                    <ul class="messages">
                        <li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li>
                    </ul>
                   <?php else: ?>
                        <?php if ($_sole) : ?>
                        <span class="no-display">
                        <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" />
                        </span>
                        <?php else: ?>
                        <?php // radio button ?>


                      <?php 

                        foreach($all_options as $opt)
                        {
                            $data = $opt->getData();
                            if($current_category_id == 12)//Cake
                            {$kk = trim(date("Y-m-d", $tomorrow));
                                if(trim(date("Y-m-d", $tomorrow)) == trim($order_delivery_date))
                                {
                                    if(strcmp(trim($_rate->getMethodTitle()),trim($data['delivery_type'])) == 0)
                                    {
                                        $start_time = $data['start_time'];
                                        $end_time = $data['end_time'];

                                        if($delivery_start_time < $start_time)// || (($start_time < $delivery_start_time) && ($delivery_start_time < $end_time)))
                                        {
                                            // Enable option.
                                            ?>
                                            <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"' ?> class="radio"/>
                                        <?php 
                                        }
                                        else 
                                        {
                                            ?>
                                            <input disabled="disabled" 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"' ?> class="radio"/>
                                            <?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"' ?> class="radio"/>
                                <?php 
                                break;
                                }
                            }
                            else //Rest all products
                            {
                                if(trim(date("Y-m-d")) == trim($order_delivery_date))//today's delivery
                                {
                                    //check the server time to enable option
                                    if(strcmp(trim($_rate->getMethodTitle()),trim($data['delivery_type'])) == 0)
                                    {
                                        $start_time = $data['start_time'];
                                        $end_time = $data['end_time'];

                                        if($server_time < $start_time)// || (($start_time < $server_time) && ($server_time < $end_time)))
                                        {
                                            // Enable option.
                                            ?>
                                            <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"' ?> class="radio"/>
                                        <?php 
                                        }
                                        else 
                                        {
                                            ?>
                                            <input disabled="disabled" 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"' ?> class="radio"/>
                                            <?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"' ?> class="radio"/>
                                <?php 
                                break;
                                }

                            }
                        }//foreach
                      ?>



                        <?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
                        <script type="text/javascript">
                            //<![CDATA[
                                lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
                            //]]>
                        </script>
                        <?php endif; ?>

                        <?php endif; ?>

                        <?php // option name ?>

                        <label for="s_method_<?php echo $_rate->getCode() ?>">
                         <?php $option_name = $_rate->getMethodTitle();   
                         $optionNameArray = explode( '(', $option_name );
                         if(count($optionNameArray)>1)
                         {
                             echo $optionNameArray[0];
                             ?>
                             <br>
                             <?php 
                             echo '('.$optionNameArray[1];
                         }
                         else 
                         {
                            echo $optionNameArray[0];
                         }

                        ?>
                        <?php // echo $_rate->getMethodTitle() ?>
                        <?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; ?>
                        </label>

                        <?php
                            $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
                            if($carrier->getFormBlock()){
                                $block = $this->getLayout()->createBlock($carrier->getFormBlock());
                                $block->setMethodCode($code);
                                $block->setRate($_rate);
                                $block->setMethodInstance($carrier);
                                echo $block->_toHtml();
                            } 
                        ?>
                   <?php endif ?>
                </li>
               <?php } ?>
                  <?php endforeach; ?>
                  </ul>
                  <div style="clear: both;"></div>
                        </td>
                        <tr>
                            <td><br></td>
                            <td></td>
                        </tr>

                    <tr>
                        <td style="text-align: right;"><label >Special<br> Instruction : </label></td>
                        <td><textarea class="textarea-delivery" rows="3" cols="50" name="shipping_deliveryrate[special_instructions]" id="shipping_deliveryrate[special_instructions]" cols="20" rows="4"></textarea></td>
                    </tr>
                    <tr>
                    <td></td>
                        <td><label style="font-size: 12px;font-weight:normal;font-style:italic;color:silver;">Enter any special instructions or notes about this order<br>
                        Example: "Call the recipient before the delivery. Try to deliver before 4.00pm"
                        </label></td>
                    </tr>
                    <tr>
                            <td><br></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td  style="text-align: right;">
                            <div style="width: 430px;padding-right: 83px;padding-bottom: 4px;">
                                <div style="float: left;width: 322px;height: 30px;"><a href="#" style="text-decoration: none;"><label style="font-size: 10px;font-weight:normal;color: #839821;">If you need to type our personal message<br>
                                in Sinhala or Tamil, please use relevant keyboard here</label></a>
                                </div>
                                <div style="width: 108px;height: 30px;float: left;padding-bottom: 4px;padding-top: 8px;">
                                <input type="button" name="sinhala_keyboard" id="sinhala_keyboard" class="button-checkout-language" value="Sinhala" onclick="opensinhalakeyboard();" />
                                <input type="button" name="tamil_keyboard" id="tamil_keyboard" class="button-checkout-language" value="Tamil" onclick="opentamilkeyboard();" />
                                </div>
                            </div>
                            </td>
                        </tr>
                    <tr>
                        <td><label style="float:right;">Personel <br>Message : </label></td>
                        <td><textarea class="textarea-delivery" rows="3" cols="50" name="shipping_deliveryrate[msg]" id="shipping_deliveryrate[msg]" cols="20" rows="4"></textarea></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><label style="font-size: 12px;font-weight:normal;font-style:italic;color:silver;">Your message will be hand written on a white card & sent with the gift item.</label></td>
                    </tr>
                </tbody>
            </table>
            </li>
          </ul>


        </dd>


        <?php 
        break;
    } 

   }//not florist
        else 
        {
            // if florist selected
    if($code == 'pickup') // If the shipping method is pickup
    {
        ?>
        <dt><?php echo $this->getCarrierName($code) ?></dt>
        <dd>
            <ul>
            <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
                <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
                <li>
                   <?php if ($_rate->getErrorMessage()): ?>
                    <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
                   <?php else: ?>
                        <?php if ($_sole) : ?>
                        <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
                        <?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"' ?> class="radio"/>

                        <?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
                        <script type="text/javascript">
                            //<![CDATA[
                                lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
                            //]]>
                        </script>
                        <?php endif; ?>

                        <?php endif; ?>
                        <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
                        <?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; ?>
                        </label>
                        <?php
                            $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
                            if($carrier->getFormBlock()){
                                $block = $this->getLayout()->createBlock($carrier->getFormBlock());
                                $block->setMethodCode($code);
                                $block->setRate($_rate);
                                $block->setMethodInstance($carrier);
                                echo $block->_toHtml();
                            } 
                        ?>
                   <?php endif ?>
                </li>
            <?php endforeach; ?>
            </ul>
        </dd>
        <?php 
        break;
    }
        } ?>
    <?php endforeach; ?>
    </dl>
<script type="text/javascript">
//<![CDATA[

    <?php if (!empty($shippingCodePrice)): ?>
        var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
    <?php endif; ?>

    $$('input[type="radio"][name="shipping_method"]').each(function(el){
        Event.observe(el,'click', function(){
            if (el.checked == true) {
                var getShippingCode = el.getValue();
                <?php if (!empty($shippingCodePrice)): ?>
                    var newPrice = shippingCodePrice[getShippingCode];
                    if (!lastPrice) {
                        lastPrice = newPrice;
                        quoteBaseGrandTotal += newPrice;
                    }
                    if (newPrice != lastPrice) {
                        quoteBaseGrandTotal += (newPrice-lastPrice);
                        lastPrice = newPrice;
                    }
                <?php endif; ?>
                checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
                return false;
            }
       });
    });
//]]>




jQuery(document).ready(function(){
    hideShippingAll();
    jQuery('input[type="radio"][name="shipping_method"]').click(function(){
            hideShippingAll();
            var code = jQuery(this).val();
            if(jQuery(this).is(':checked')){
                showShipping(code);
            }
    });
    jQuery('input[type="radio"][name="shipping_method"]').each(function(){
        var code = jQuery(this).val();
        if(jQuery(this).is(":checked")){
            showShipping(code);
        }       
    });
});
function showShipping(code){
    if(jQuery('#'+'shipping_form_'+code).length != 0){
        jQuery('#'+'shipping_form_'+code).show();
        jQuery(this).find('.required-entry').attr('disabled','false');
    }
}
function hideShippingAll(){
    jQuery('input[type="radio"][name="shipping_method"]').each(function(){
        var code = jQuery(this).val();
        jQuery('#'+'shipping_form_'+code).hide();
        jQuery(this).find('.required-entry').attr('disabled','true');   
    });
}

function open_in_new_tab(url)
{
  window.open(url, '_blank');
  window.focus();
}



</script>
<?php endif; ?>
4

1 に答える 1

0

解決策を見つけました。

どちらの配送方法も同じイベント オブザーバー名を持っています。そのため、常に 1 つのオブザーバーを実行します。イベントオブザーバーの名前を変更するとうまくいきました

于 2013-03-19T09:15:15.787 に答える