Magento Add a "new" or a discount quantity label to the product Magento the new label. Discount label_php Tutorials

Source: Internet
Author: User
The bottom of the article is.

Add a "new" label to the new product. Give discount products, show the quantity of discount.

This can be written on your own a piece of code added to the template folder under the catalog/product/list.phtml. Here is the code

Timestamp (time ());?>



$new _str_tm = Strtotime ($_product->getnews_from_date ());
$new _end_tm = Strtotime ($_product->getnews_to_date ());
?>





0):?>
$new _str_tm) && (! $new _end_tm)):?>
NEW



$spe _end_tm = Strtotime ($_product->getspecial_to_date ());
$spe _str_tm = Strtotime ($_product->getspecial_from_date ());
$spe _pri = $_product->getspecial_price ();
?>
GetResource ()->getattribute (' Price ')->getfrontend ()->getvalue ($_product)?>
$spe _str_tm) && (! $spe _end_tm)):?>


%



The above code is inserted into the appropriate location: It's better to put it behind this.

After this is done. But also to change the CSS. Make it appear in the appropriate location.

. Products-grid. ico_new_bg {height:33px; font-size:14px; line-height:24px; color: #ffffff; Background:url (".. /images/ico_bg.png "); Position:absolute; margin: -10px-10px 0; padding:0 10px 0; Z-index:10; }
. Products-grid. ico_percent_bg {height:33px; font-size:14px; line-height:24px; color: #ffffff; Background:url (".. /images/ico_bg.png "); Position:absolute; margin: -10px-10px 0; padding:0 10px 0; Z-index:10; }


This CSS code is added below the styles.css. Add to/* View Type:grid */This below: Products-grid Li.item, add the last two lines of code after this line.

Margin's position adjusts itself to fit your website.

http://www.bkjia.com/PHPjc/477287.html www.bkjia.com true http://www.bkjia.com/PHPjc/477287.html techarticle the bottom of the article is. Add a new label to the new product. Give discount products, show the quantity of discount. This can write your own piece of code added to the template folder under the Cata ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.