Magento 层级销售价格?

发布于 2025-01-05 12:05:22 字数 17106 浏览 0 评论 0 原文

我一直在尝试镜像一些功能 在 Magento (v1.6) 中,如在另一个网站上看到的。在示例中, 店主已设置将销售价格应用于某个层级的功能。 (最有可能的 tierprices.phtml 作为包装器)通过应用销售价格 (最有可能在管理/产品/价格销售中)

我一直在努力弄清楚它是如何完成的,但还没有 到目前为止,在这方面取得了任何进展。有谁知道这是怎么回事 建造?

这是示例网站 http://www.epromos.com/product/2801001.html

这是表代码:

    if($_tierPrices) {
        echo '<style>
                .strikeRow      {text-decoration: line-through;}
                .saleRow td     {color:red;}
                .quantityRow    {background: #eef} 
                td              {padding:3px 9px; border: 1px solid #fc0;} 
            </style>';          // temporary styling

        $q = "<td>Quantity</td>";
        $p = "<td>{$_product->getName()}</td>";
        $s = "<td>Reduced Price</td>";

        foreach ($_tierPrices as &$tier) { 
        #$tier['tier_sale'] = '0.00';   // trick the dump into thinking there is a product sale
            if($tier['price_qty'])      { $q .= "<td>{$tier['price_qty']}</td>"; }
            if($tier['price'])          { $p .= "<td>".number_format($tier['price'], 2, '.', '')."</td>"; }
            if($tier['tier_sale'])      { $s .= "<td>{$tier['tier_sale']}</td>"; }
        }

        $q = "<tr class='quantityRow'>{$q}</tr>";
        $p = ($_tierPrices[0]['tier_sale'])? "<tr class='strikeRow'>{$p}</tr>"  : "<tr>{$p}</tr>";
        $s = ($_tierPrices[0]['tier_sale'])? "<tr class='saleRow'>{$s}</tr>"    : '';

        echo "<tbody>$q $p $s</tbody></table>";

    }

以及完整来源:

<?php
/**
 * @see Mage_Catalog_Block_Product_View
 */
$_product = $this->getProduct();
$_tierPrices = $this->getTierPrices();
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);

/** @var $_catalogHelper Mage_Catalog_Helper_Data */
$_catalogHelper = Mage::helper('catalog');

$_weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($_product);

if (Mage::helper('weee')->typeOfDisplay($_product, array(1,2,4))) {
    $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
}

 if (count($_tierPrices) > 0) { 

    // start table group with class type if  (obj)getInGrouped() == 1
    echo ($this->getInGrouped()) ? '<table class="tier-prices-grouped product-pricing-grouped">' : '<table class="tier-prices product-pricing">'; 

    // assign tier pricing to $_tierPrices
    if ($this->getInGrouped()) {
         $_tierPrices = $this->getTierPrices($_product);
    }

        Mage::helper('weee')->processTierPrices($_product, $_tierPrices);

    foreach ($_tierPrices as $_price) {

        echo '<tr>';

        if ($_catalogHelper->canApplyMsrp($_product)) {

            if ($this->getInGrouped()) {

                echo $this->__('Buy %1$s for', $_price['price_qty']) .':';

            } else { 

                echo $this->__('Buy %1$s', $_price['price_qty']);

            } 

        } else {

                if ($this->helper('tax')->displayBothPrices()) {

                    if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {

                        echo $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price_incl_weee_only'], $_price['formated_price_incl_weee']);

                    } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) {

                            echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                            if ($_weeeTaxAttributes) {

                                echo '(<small>';
                                echo $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);

                                $separator = ' + '; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                        echo $separator;
                                        echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                    }

                                echo '</small>)';

                            }

                            echo $this->__('each');

                    } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) {

                            echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                            if ($_weeeTaxAttributes) {

                                echo '(<small>';
                                echo $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);

                                $separator = ' + '; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                        echo $separator;
                                        echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount());

                                    }

                                echo '</small>)';

                            }

                            echo $this->__('each');

                    } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) {

                            echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);

                            if ($_weeeTaxAttributes) {

                                echo '(<small>';

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                        echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                    }

                                echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']);
                                echo '</small>)';

                            }

                            echo $this->__('each');

                    } else {

                            echo $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price'], $_price['formated_price_incl_tax']);

                    }

                } else {

                    if ($this->helper('tax')->displayPriceIncludingTax()) {

                        if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {

                                echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee']);

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                        $separator = ' + '; 

                                    }

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) { 

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount());

                                        $separator = ' + ';

                                    } 

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_tax']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                        }

                                    echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']);
                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } else {

                                echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_tax']);
                        }

                    } else {

                        if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {

                                echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount());

                                        $separator = ' + '; 

                                        }

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount());

                                        $separator = ' + '; 

                                        }

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount());

                                        }

                                    echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee_only']);
                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } else {

                                // concern
                                //echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price']);

                                $priceSchema['quantity'][] =  $_price['price_qty'];
                                $priceSchema['formated_price'][] =  $_price['formated_price'];

                        }


                    } 

        }


        } // Can apply MSRP

        if (!$this->getInGrouped()) {

        // we need this ~

            // funky ass OR switch, can i rework this in a saner way?
            if( ($_product->getPrice() == $_product->getFinalPrice() && $_product->getPrice() > $_price['price'])
             || ($_product->getPrice() != $_product->getFinalPrice() &&  $_product->getFinalPrice() > $_price['price']) ) {

//               echo ' '. $this->__('and') .'&nbsp;<strong class="benefit">'. $this->__('save') .'&nbsp;'. $_price['savePercent'] .'%';

            } 

//          echo '</strong>'; // why the hell isn't this in the OR switch??? 

        // we need this ~

        }

        if ($_catalogHelper->isShowPriceOnGesture($_product)) {

            $popupId = 'msrp-popup-' . $_product->getId() . $this->helper('core')->getRandomString(20);

            echo '<a href="#" id="'. $popupId .'">'. $this->__('Click for price') .'</a>';
            echo '<script type="text/javascript">';

            if (!$this->getInGrouped()) {

                echo 'var newLink = {';

                    echo 'url: "'. $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty'])) .'",';
                    echo 'qty: "'. $_price['price_qty'] .'"';

                echo '};';

            } else {

                echo 'var newLink = {';

                    echo 'url: "'. $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty'])) .'",';
                    echo 'notUseForm: true';

                echo '};';

            }

                echo 'Catalog.Map.addHelpLink(';

                    echo "$('{$popupId}'),";
                    echo '"'. $_product->getName() .'",';
                    echo json_encode($_price['real_price_html']) .',';
                    echo '"'. $this->helper('core')->currency($_product->getMsrp(),true,false) .'",';
                    echo 'newLink';

                echo ');';

            echo '</script>';

        } else {

            echo '<span class="msrp-price-hide-message">'. $_catalogHelper->getMsrpPriceMessage($_product) .'</span>';

        }

    }
}

    if($_tierPrices) {
        echo '<style>
                .strikeRow      {text-decoration: line-through;}
                .saleRow td     {color:red;}
                .quantityRow    {background: #eef} 
                td              {padding:3px 9px; border: 1px solid #fc0;} 
            </style>';          // temporary styling

        $q = "<td>Quantity</td>";
        $p = "<td>{$_product->getName()}</td>";
        $s = "<td>Reduced Price</td>";

        foreach ($_tierPrices as &$tier) { 
        #$tier['tier_sale'] = '0.00';   // trick the dump into thinking there is a product sale
            if($tier['price_qty'])      { $q .= "<td>{$tier['price_qty']}</td>"; }
            if($tier['price'])          { $p .= "<td>".number_format($tier['price'], 2, '.', '')."</td>"; }
            if($tier['tier_sale'])      { $s .= "<td>{$tier['tier_sale']}</td>"; }
        }

        $q = "<tr class='quantityRow'>{$q}</tr>";
        $p = ($_tierPrices[0]['tier_sale'])? "<tr class='strikeRow'>{$p}</tr>"  : "<tr>{$p}</tr>";
        $s = ($_tierPrices[0]['tier_sale'])? "<tr class='saleRow'>{$s}</tr>"    : '';

        echo "<tbody>$q $p $s</tbody></table>";

    }
?>

I've been trying to mirror some functionality
in Magento (v1.6) as seen on another website. In the example, the
store owner has set up the ability to apply sales prices to a tier.
(most likely tierprices.phtml as the wrapper) by applying a sales price
(most likely in admin / product / price sales)

I've been working on figuring out exactly how it is done, but haven't
made any headway on it insofar. Does anyone have any idea how this was
constructed?

Here's the example website
http://www.epromos.com/product/2801001.html

Here's the Table code:

    if($_tierPrices) {
        echo '<style>
                .strikeRow      {text-decoration: line-through;}
                .saleRow td     {color:red;}
                .quantityRow    {background: #eef} 
                td              {padding:3px 9px; border: 1px solid #fc0;} 
            </style>';          // temporary styling

        $q = "<td>Quantity</td>";
        $p = "<td>{$_product->getName()}</td>";
        $s = "<td>Reduced Price</td>";

        foreach ($_tierPrices as &$tier) { 
        #$tier['tier_sale'] = '0.00';   // trick the dump into thinking there is a product sale
            if($tier['price_qty'])      { $q .= "<td>{$tier['price_qty']}</td>"; }
            if($tier['price'])          { $p .= "<td>".number_format($tier['price'], 2, '.', '')."</td>"; }
            if($tier['tier_sale'])      { $s .= "<td>{$tier['tier_sale']}</td>"; }
        }

        $q = "<tr class='quantityRow'>{$q}</tr>";
        $p = ($_tierPrices[0]['tier_sale'])? "<tr class='strikeRow'>{$p}</tr>"  : "<tr>{$p}</tr>";
        $s = ($_tierPrices[0]['tier_sale'])? "<tr class='saleRow'>{$s}</tr>"    : '';

        echo "<tbody>$q $p $s</tbody></table>";

    }

And the full source:

<?php
/**
 * @see Mage_Catalog_Block_Product_View
 */
$_product = $this->getProduct();
$_tierPrices = $this->getTierPrices();
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);

/** @var $_catalogHelper Mage_Catalog_Helper_Data */
$_catalogHelper = Mage::helper('catalog');

$_weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($_product);

if (Mage::helper('weee')->typeOfDisplay($_product, array(1,2,4))) {
    $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
}

 if (count($_tierPrices) > 0) { 

    // start table group with class type if  (obj)getInGrouped() == 1
    echo ($this->getInGrouped()) ? '<table class="tier-prices-grouped product-pricing-grouped">' : '<table class="tier-prices product-pricing">'; 

    // assign tier pricing to $_tierPrices
    if ($this->getInGrouped()) {
         $_tierPrices = $this->getTierPrices($_product);
    }

        Mage::helper('weee')->processTierPrices($_product, $_tierPrices);

    foreach ($_tierPrices as $_price) {

        echo '<tr>';

        if ($_catalogHelper->canApplyMsrp($_product)) {

            if ($this->getInGrouped()) {

                echo $this->__('Buy %1$s for', $_price['price_qty']) .':';

            } else { 

                echo $this->__('Buy %1$s', $_price['price_qty']);

            } 

        } else {

                if ($this->helper('tax')->displayBothPrices()) {

                    if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {

                        echo $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price_incl_weee_only'], $_price['formated_price_incl_weee']);

                    } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) {

                            echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                            if ($_weeeTaxAttributes) {

                                echo '(<small>';
                                echo $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);

                                $separator = ' + '; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                        echo $separator;
                                        echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                    }

                                echo '</small>)';

                            }

                            echo $this->__('each');

                    } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) {

                            echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                            if ($_weeeTaxAttributes) {

                                echo '(<small>';
                                echo $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']);

                                $separator = ' + '; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                        echo $separator;
                                        echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount());

                                    }

                                echo '</small>)';

                            }

                            echo $this->__('each');

                    } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) {

                            echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);

                            if ($_weeeTaxAttributes) {

                                echo '(<small>';

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                        echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                    }

                                echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']);
                                echo '</small>)';

                            }

                            echo $this->__('each');

                    } else {

                            echo $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price'], $_price['formated_price_incl_tax']);

                    }

                } else {

                    if ($this->helper('tax')->displayPriceIncludingTax()) {

                        if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {

                                echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee']);

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                        $separator = ' + '; 

                                    }

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) { 

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                    foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount());

                                        $separator = ' + ';

                                    } 

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_tax']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount());

                                        }

                                    echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']);
                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } else {

                                echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_tax']);
                        }

                    } else {

                        if (Mage::helper('weee')->typeOfDisplay($_product, 0)) {

                                echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount());

                                        $separator = ' + '; 

                                        }

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';
                                    $separator = ''; 

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $separator;
                                            echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount());

                                        $separator = ' + '; 

                                        }

                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) {

                                echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']);

                                if ($_weeeTaxAttributes) {

                                    echo '(<small>';

                                        foreach ($_weeeTaxAttributes as $_attribute) {

                                            echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount());

                                        }

                                    echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee_only']);
                                    echo '</small>)';

                                }

                                echo $this->__('each');

                        } else {

                                // concern
                                //echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price']);

                                $priceSchema['quantity'][] =  $_price['price_qty'];
                                $priceSchema['formated_price'][] =  $_price['formated_price'];

                        }


                    } 

        }


        } // Can apply MSRP

        if (!$this->getInGrouped()) {

        // we need this ~

            // funky ass OR switch, can i rework this in a saner way?
            if( ($_product->getPrice() == $_product->getFinalPrice() && $_product->getPrice() > $_price['price'])
             || ($_product->getPrice() != $_product->getFinalPrice() &&  $_product->getFinalPrice() > $_price['price']) ) {

//               echo ' '. $this->__('and') .' <strong class="benefit">'. $this->__('save') .' '. $_price['savePercent'] .'%';

            } 

//          echo '</strong>'; // why the hell isn't this in the OR switch??? 

        // we need this ~

        }

        if ($_catalogHelper->isShowPriceOnGesture($_product)) {

            $popupId = 'msrp-popup-' . $_product->getId() . $this->helper('core')->getRandomString(20);

            echo '<a href="#" id="'. $popupId .'">'. $this->__('Click for price') .'</a>';
            echo '<script type="text/javascript">';

            if (!$this->getInGrouped()) {

                echo 'var newLink = {';

                    echo 'url: "'. $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty'])) .'",';
                    echo 'qty: "'. $_price['price_qty'] .'"';

                echo '};';

            } else {

                echo 'var newLink = {';

                    echo 'url: "'. $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty'])) .'",';
                    echo 'notUseForm: true';

                echo '};';

            }

                echo 'Catalog.Map.addHelpLink(';

                    echo "$('{$popupId}'),";
                    echo '"'. $_product->getName() .'",';
                    echo json_encode($_price['real_price_html']) .',';
                    echo '"'. $this->helper('core')->currency($_product->getMsrp(),true,false) .'",';
                    echo 'newLink';

                echo ');';

            echo '</script>';

        } else {

            echo '<span class="msrp-price-hide-message">'. $_catalogHelper->getMsrpPriceMessage($_product) .'</span>';

        }

    }
}

    if($_tierPrices) {
        echo '<style>
                .strikeRow      {text-decoration: line-through;}
                .saleRow td     {color:red;}
                .quantityRow    {background: #eef} 
                td              {padding:3px 9px; border: 1px solid #fc0;} 
            </style>';          // temporary styling

        $q = "<td>Quantity</td>";
        $p = "<td>{$_product->getName()}</td>";
        $s = "<td>Reduced Price</td>";

        foreach ($_tierPrices as &$tier) { 
        #$tier['tier_sale'] = '0.00';   // trick the dump into thinking there is a product sale
            if($tier['price_qty'])      { $q .= "<td>{$tier['price_qty']}</td>"; }
            if($tier['price'])          { $p .= "<td>".number_format($tier['price'], 2, '.', '')."</td>"; }
            if($tier['tier_sale'])      { $s .= "<td>{$tier['tier_sale']}</td>"; }
        }

        $q = "<tr class='quantityRow'>{$q}</tr>";
        $p = ($_tierPrices[0]['tier_sale'])? "<tr class='strikeRow'>{$p}</tr>"  : "<tr>{$p}</tr>";
        $s = ($_tierPrices[0]['tier_sale'])? "<tr class='saleRow'>{$s}</tr>"    : '';

        echo "<tbody>$q $p $s</tbody></table>";

    }
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独留℉清风醉 2025-01-12 12:05:22

我很确定您正在寻找的是选项的绝对定价,无论级别如何,如果是这样,这里是如何实现此目的的链接:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/use-absolute-price-for-custom-options

I am pretty sure what you are looking for is absolute pricing for options regardless of tier, if so here is the link to how this could be accomplished:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/use-absolute-price-for-custom-options

韵柒 2025-01-12 12:05:22

这是为您提供的快速解决方案。

您可以使用产品的“成本”字段来定义零售价高于您的价格的百分比。默认情况下,“成本”字段用作您为产品支付的费用的备忘录,并且不在前端的任何地方使用。

然后转到主题的 templates/template/catalog/product/view/tierprices.phtml 并在 $_product = $this->getProduct(); 行后添加以下行:

$multiplier = $_product->getData('cost');
$multiplier = $multiplier ? $multiplier : 1;

以及以下行getInGrouped()): ?>:

Retail price: <?php echo $_coreHelper->currency($_price['price']*$multiplier, true, false) ?>

我相信您将能够按照您的意愿设置它的样式。如果有不清楚的地方,请告诉我。

Here is quick solution for you.

You can use a 'cost' field of the product to define the percentage by which the retail price is higher then your price. By default 'cost' field is used as a memo of how much you paid for the product and is not used anywhere at the front-end.

Then go to templates/template/catalog/product/view/tierprices.phtml of your theme and add the following lines after $_product = $this->getProduct(); line:

$multiplier = $_product->getData('cost');
$multiplier = $multiplier ? $multiplier : 1;

And the following line between <?php endif; ?> and <?php if (!$this->getInGrouped()): ?>:

Retail price: <?php echo $_coreHelper->currency($_price['price']*$multiplier, true, false) ?>

I'm sure you will be able to style it as you wish. Please let me know if something is unclear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文