If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / append product name if on special or sale or new

append product name if on special or sale or new

Started by abcisme on 24 Feb 2015, 4:38 PM · Views: 659

Results 1 to 5 of 5
24 Feb 2015, 4:38 PM
#1
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Post #1 by abcisme

I'd like to append the product name with "ON SALE" if the product is on sale, or "SPECIAL PRICE" if the product is on special, or "NEW" if the product is new. Can anyone tell me what codes I would need to use if an item is on sale, on special or new?

What I want to do is this:

<!--bof Product Name-->
<h1 id="productName" class="productGeneral"><?php echo $products_name; ?>
<?php IF PRODUCT IS SPECIAL { echo 'SPECIAL PRICE'; } ?>
<?php IF PRODUCT IS NEW { echo 'NEW'; } ?>
<?php IF PRODUCT IS ON SALE { echo 'ON SALE'; } ?>
</h1>
<!--eof Product Name-->
17 Mar 2015, 7:27 PM
#2
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Post #2 by abcisme

I still need help with the code to check if a product is on special or on sale.

Here's what I have to check if a product is new and display "new" after the product name:

<?php 
	$datesql = "select products_date_added from " . TABLE_PRODUCTS . " where products_id=" . (int)$_GET['products_id'] . ";";
	$date_display = $db->Execute($datesql);
	$prod_add_date = $date_display->fields['products_date_added'];
	$nib_days = time() - ((int)NEW_ITEM_BADGE_DAYS * 86400);
<?php if ((strtotime($prod_add_date) >= $nib_days)) { echo '<div class="productIcon new2">'.TITLE_TXT_NEW.'</div>'; } ?>

To check if a product is in a specific category and display "clearance" after the product name:

	<?php $clearlink = zen_product_in_category($_GET['products_id'], 284);
if ($clearlink == 1) { echo '<div class="productIcon disc">'.TITLE_TXT_CLEARANCE.'</div>'; }?>
17 Mar 2015, 7:42 PM
#3
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Post #3 by abcisme

For specials:

<?php 	$specialsql = "select specials_id from " . TABLE_SPECIALS . " where products_id=" . (int)$_GET['products_id'] . ";";
	$special_result = $db->Execute($specialsql);
	if (isset($special_result->fields['specials_id']))  { echo '<div class="productIcon disc">'.TITLE_TXT_SALE.'</div>'; } ?>
17 Mar 2015, 7:43 PM
#4
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Post #4 by abcisme

Oops. To check if a product is new and display "new" after the product name should be:

<?php 
        $datesql = "select products_date_added from " . TABLE_PRODUCTS . " where products_id=" . (int)$_GET['products_id'] . ";";
	$date_display = $db->Execute($datesql);
	$prod_add_date = $date_display->fields['products_date_added'];
	$nib_days = time() - ((int)NEW_ITEM_BADGE_DAYS * 86400); ?>

<?php if ((strtotime($prod_add_date) >= $nib_days)) { echo '<div class="productIcon new2">'.TITLE_TXT_NEW.'</div>'; } ?>
18 Mar 2015, 3:47 PM
#5
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Post #5 by abcisme

For specials:

<?php 	
        $specialsql = "select specials_id from " . TABLE_SPECIALS . " where status = "1" products_id=" . (int)$_GET['products_id'] . ";";
	$special_result = $db->Execute($specialsql);
	if (isset($special_result->fields['specials_id']))  { echo '<div class="productIcon disc">'.TITLE_TXT_SALE.'</div>'; } ?>

Have to specify that the special is active...