css - Magento:带有 CSS 的简单股票指标

标签 css magento retina-display magento-1.6 hdpi

我一直在寻找一个简单的股票指标。

最佳答案

将此添加到您想要股票指标的 yourTheme/template/catalog/product/view.phtml 中。

<?php

    $qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();

    switch ($qty) {
        case $qty > 5 :
        $stockcss .= 'stockindicator-green';
        $stocktext = "In stock";
        break;
        case $qty <= 5:
        $stockcss .= 'stockindicator-green';
        $stocktext = "Low stock";
        break;
        case $qty <= 0:
        $stockcss .= 'stockindicator-green';
        $stocktext = "Out of stock";
        break;
    }
?>

Stock: <div class="stockindicator <?php echo $stockcss ?>" title="<?php echo $stocktext ?>"></div>



将下面的代码添加到/skin/frontend/yourTheme/default/css/styles.css

.stockindicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
}

.stockindicator-green { background-color: #46A40E; }
.stockindicator-yellow { background-color: #F9E700; }
.stockindicator-red { background-color: #E42620; }

关于css - Magento:带有 CSS 的简单股票指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14205850/

相关文章:

javascript - 使用jquery单击按钮上的slidetoggle div容器

magento - 使用自定义渲染器过滤网格

caching - Magento:如何知道缓存了多少 block

ios - 使用 UIWebView 创建样式文本(在视网膜屏幕上模糊)

html - 尽管分配了百分比宽度,IMG 仍生成滚动条

jquery - selected-select 显示组标签和选项选择

layout - Magento 登录和注册表单页面

css - 没有 2x 图像大小 hack 的视网膜模糊图标

css - 为网络导出图像的最佳实践 - DPI/PPI

CSS - Div不改变背景颜色