開発メモ

開発用のメモです。

EC CUBE 税抜き表示 および最大料金の未表示

mtb_constant 概要
NET_OF_TAX 税抜き表示
MAX_PRICE 最大価格表示

SC_Product_Ex

<?php
/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

require_once CLASS_REALDIR . 'SC_Product.php';

class SC_Product_Ex extends SC_Product {

    /**
    * 商品IDに紐づく商品規格を自分自身に設定する.
    *
    * 引数の商品IDの配列に紐づく商品規格を取得し, 自分自身のフィールドに
    * 設定する.
    *
    * @param  array   $arrProductId 商品ID の配列
    * @param  boolean $has_deleted  削除された商品規格も含む場合 true; 初期値 false
    * @return void
    */
    public function setProductsClassByProductIds( $arrProductId, $has_deleted = false ) {

        parent::setProductsClassByProductIds( $arrProductId, $has_deleted );

        foreach( $arrProductId as $productId ) {
            $arrProductClasses = $this->getProductsClassFullByProductId( $productId, $has_deleted );
            foreach( $arrProductClasses as $arrProductsClass ) {
                $arrClassCats2 = array( );
                $classcategory_id1 = $arrProductsClass[ 'classcategory_id1' ];
                $classcategory_id2 = $arrProductsClass[ 'classcategory_id2' ];
                // 価格 税抜き指定の場合 税抜き価格を設定する
                if( NET_OF_TAX == true ) {
                    $this->classCategories[ $productId ][ $classcategory_id1 ][ '#' . $classcategory_id2 ][ 'price01' ] = strlen( $arrProductsClass[ 'price01' ] ) ? number_format( $arrProductsClass[ 'price01' ] ) : '';
                    $this->classCategories[ $productId ][ $classcategory_id1 ][ '#' . $classcategory_id2 ][ 'price02' ] = strlen( $arrProductsClass[ 'price02' ] ) ? number_format( $arrProductsClass[ 'price02' ] ) : '';
                }
            }
        }
    }

}

テンプレートファイル

                <div class="pricebox sale_price">
                    <!--{$smarty.const.SALE_PRICE_TITLE}-->
                        <!--{if $smarty.const.NET_OF_TAX == true}-->(税抜):<!--{else}-->(税込):<!--{/if}-->
                    <span class="price"> <span id="price02_default_<!--{$id}-->">
                        <!--{strip}-->
                            <!--{if $smarty.const.NET_OF_TAX  == true}-->
                                <!--{if $smarty.const.MAX_PRICE  == true}-->
                                    <!--{$arrProduct.price02_max|n2s}-->
                                <!--{elseif $arrProduct.price02_min_inctax == $arrProduct.price02_max_inctax}-->
                                    <!--{$arrProduct.price02_min|n2s}-->
                                <!--{else}-->
                                    <!--{$arrProduct.price02_min|n2s}--><!--{$arrProduct.price02_max|n2s}-->
                                <!--{/if}-->
                            <!--{elseif $smarty.const.MAX_PRICE  == true}-->
                                <!--{$arrProduct.price02_max_inctax|n2s}-->
                            <!--{elseif $arrProduct.price02_min_inctax == $arrProduct.price02_max_inctax}-->
                                <!--{$arrProduct.price02_min_inctax|n2s}-->
                            <!--{else}-->
                                <!--{$arrProduct.price02_min_inctax|n2s}--><!--{$arrProduct.price02_max_inctax|n2s}-->
                            <!--{/if}-->
                        <!--{/strip}-->
                        </span><span id="price02_dynamic_<!--{$id}-->"><!-- --></span></span>
                </div>
Twitter: @asahina_alice