我试图让“-1”显示为“5”,这将是1比6-9的数量低。

我的代码...

            <?php
            $_product = $this->getProduct();
            $_tierPrices = $this->getTierPrices();
            if (count($_tierPrices) > 0):
                $_data = array();
                $_prevQty = 0;
                $_counter = 0;
                $_tierPrices = array_reverse($_tierPrices);
                foreach ($_tierPrices as $_index => $_price){
                    $_counter++;
                    if($_price['price_qty']>$_prevQty){
                        $label = $_price['price_qty']. '+';
                        $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price'],'save'=>$_price['savePercent']);
                        $_prevQty = $_price['price_qty']-1;
                    } else {
                        $label = $_price['price_qty'] . '-' . $_prevQty;
                        $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price'],'save'=>$_price['savePercent']);
                        $_prevQty = $_price['price_qty']-1;

                    }
                }
                $_data = array_reverse($_data);

            ?>
<?php $calculate=intval($_row['label'])-1; ?>
                <table width="100%"  align="center" cellpadding="0" cellspacing="0" class="tiered-pricing">
                    <tbody align="center">
                        <tr>
                            <td width="34%" align="center"><b>Quantity</b></td>
                            <td width="33%" align="center"><b>Price</b></td>
                            <td width="33%" align="center"><b>Save</b></td>
                        </tr>

<td><?php echo "1-".$calculate ?></td>
<td><?php echo $this->getPriceHtml($_product, true) ?></td>
<td>--</td>
                    <?php foreach ($_data as $_row): ?>
                        <tr>

                            <td><?php echo $_row['label']; ?></td>
                            <td><?php echo $_row['price']; ?></td>
                            <td><?php echo $_row['save']."%"; ?></td>
                        </tr>
<?php endforeach; ?>
                        <tr>
                          <td colspan="3" height="30px"><i>*Prices will reflect in cart.</i></td>
                        </tr>


                    </tbody>
                </table>
            <?php
            endif;
            ?>
            <!-- Display product tier price -->



    </div>
.

有帮助吗?

解决方案

试试:

<?php $tierFirstQty = number_format($_tierPrices[0]['price_qty']);
if($tierFirstQty > 1) { 
    $newQty = $tierFirstQty - 1; ?>
    <td><?php echo "1-".$newQty?></td>
    <td><?php echo $this->getPriceHtml($_product, true) ?></td>
    <td>--</td>
<?php } ?>
.

许可以下: CC-BY-SA归因
scroll top