Page 1 of 1
Add label to latly added products
Posted: Fri Dec 02, 2016 10:53 pm
by jasminej
I need to have a label on products which were added latly .I have this done on extension/module/latest.tpl ,but i'd like also to have this label working on another pages too ,like product/product.tpl,product/category and so on....
How to get this done

(without buying extensions

)
Thanks in advance
opencart 2.3
template -default
Re: Add label to latly added products
Posted: Sat Dec 03, 2016 2:38 am
by thekrotek
The same way you did this to latest module. Products display is pretty much generic in all modules and pages.
Re: Add label to latly added products
Posted: Sun Dec 04, 2016 1:36 am
by jasminej
Thanks for your reply
This is a part of product/product.tpl page structure
Code: Select all
<div class="row">
<?php $i = 0; ?>
<?php foreach ($products as $product) { ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-xs-8 col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-xs-6 col-md-4'; ?>
<?php } else { ?>
<?php $class = 'col-xs-6 col-sm-3'; ?>
<?php } ?>
<div class="<?php echo $class; ?>">
<div class="product-thumb transition" id="related-pr">
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></a></div>
<div class="caption">
<h4><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></h4>
<p><?php echo $product['description']; ?></p>
<?php if ($product['rating']) { ?>
<div class="rating">
<?php for ($j = 1; $j <= 5; $j++) { ?>
<?php if ($product['rating'] < $j) { ?>
<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>
<?php } else { ?>
<span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['price']) { ?>
<p class="price" style="display:none;">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</p>
<?php } ?>
</div>
<div class="button-group">
<!-- <button type="button" onclick="cart.add('<?php// echo $product['product_id']; ?>', '<?php//echo $product['minimum']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php //echo $button_cart; ?></span></button>
<button type="button" data-toggle="tooltip" title="<?php //echo $button_wishlist; ?>" onclick="wishlist.add('<?php //echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
<button type="button" data-toggle="tooltip" title="<?php //echo $button_compare; ?>" onclick="compare.add('<?php //echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>--><!-- <button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php //echo $button_cart; ?></span></button>-->
<button type="button" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php //echo $button_cart; ?></span></button>
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<span id="one-price"><?php echo $product['price']; ?></span>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span><span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<!--<span class="price-tax"><?php //echo $text_tax; ?> <?php //echo $product['tax']; ?></span>-->
<?php } ?>
</p>
<?php } ?>
<?php if ($minimum > 0) { ?>
<input type="text" value="<?php echo $minimum ?>" class="item-<?php echo $product['product_id']; ?>" id="min-numb-input"/>
<!--<span id="min-numb"><?php //echo $product['minimum']; ?></span>
<input type="text" name="quantity" value="<?php //echo $minimum; ?>" size="2" id="input-quantity" class="form-control" />-->
<!--<div class="alert alert-info"><i class="fa fa-info-circle"></i> <?php //echo $text_minimum; ?></div>-->
<?php } ?>
</div>
</div>
</div>
<?php if (($column_left && $column_right) && (($i+1) % 2 == 0)) { ?>
<div class="clearfix visible-md visible-sm"></div>
<?php } elseif (($column_left || $column_right) && (($i+1) % 3 == 0)) { ?>
<div class="clearfix visible-md"></div>
<?php } elseif (($i+1) % 4 == 0) { ?>
<div class="clearfix visible-md"></div>
<?php } ?>
<?php $i++; ?>
<?php } ?>
</div>
Here i just have only one unique foreach loop which just brings prosuct's details .(Almost the same code as in default template ).
Is there any way to check --- if it is latly added product ,then show a label on thumbnail (ONLY for those products ,that have been added latly)???
Re: Add label to latly added products
Posted: Sun Dec 04, 2016 1:59 am
by thekrotek
You sure your template doesn't have such feature already? I saw a lot of templates, which have "New" badge on latest products all over the store.
Re: Add label to latly added products
Posted: Mon Dec 05, 2016 9:40 pm
by jasminej
I am using default template ,here i don't have any labels,that's why i need help to get this done
Re: Add label to latly added products
Posted: Thu Dec 08, 2016 9:37 pm
by jasminej