Forums / Templates, Stylesheets, Page Layout / Show image on product listing if on special

Show image on product listing if on special

Views: 756

Results 1 to 8 of 8
19 Feb 2012, 11:44 AM
#1
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Show image on product listing if on special

Hi All.

just wanted to know if someone knew of a conditional statement to show an image (e.g. On Sale) based on the fact that it has special price. I'm not using sale maker as its only a couple of products and a category, so something like...

if product has special price {
show images/on-sale.jpg
} else {
do nothing
}

Just need the correct coding, if possible

Thanks,
Jay

19 Feb 2012, 7:28 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show image on product listing if on special

You can test for the special with:

$chk_specials = $db->Execute("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$listing->fields['products_id'] . "' and status='1'");
$specials_image = ($chk_specials->RecordCount() > 0 ? zen_image(DIR_WS_IMAGES . 'specials.gif', 'On Special') : '');

Then the $specials_image will either be nothing or have the image ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Feb 2012, 8:12 AM
#3
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: Show image on product listing if on special

Thanks for the code, but I am a little stuck....

Should I put this code in common/tbl_columnar_display.php or modules/product_listing.php? and if so where about would I place it?

I have tried placing it in these files but nothing happens, so perhaps its a different file or a certain place in the file?

Just to add, I have created a 'specials.gif' in my public_html/images folder.

20 Feb 2012, 2:11 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show image on product listing if on special

No this would go in the:
/includes/modules/product_listing.php

using your templates and overrides where you want to test for the specials and add the special image as the result ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Feb 2012, 2:30 PM
#5
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: Show image on product listing if on special

Hi Ajeh

Thanks for help, but I don't seem to be getting anywhere.

I have placed your code in modules/product_listing.php at the end of the closing '?>' tag... is this right?

20 Feb 2012, 2:46 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show image on product listing if on special

Say you wanted this to show on the Product Listing next to the Product Price ...

You could add it around line 142:

$chk_specials = $db->Execute("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$listing->fields['products_id'] . "' and status='1'");
$specials_image = ($chk_specials->RecordCount() > 0 ? zen_image(DIR_WS_IMAGES . 'specials.gif', 'On Special') : '');
        $the_button = $lc_button;
        $products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
        $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
        $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
        $lc_text .= '<br />' . $specials_image;
        break;

Note: if you wanted this to appear everywhere the is a Product on Special and next to the Product Price, then a different approach would be to customize the function:
function zen_get_products_display_price($products_id) {

in the file:
/includes/functions/functions_prices.php

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Feb 2012, 3:07 PM
#7
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: Show image on product listing if on special

YOU ARE THE BEST!!!!

Thanks so much for that. place it there, but just added this...

$lc_text .= '<br />' . '<div class="specialsImage">' . $specials_image . '</div>';

So now I can CSS position:absolute and position anywhere.

Thanks again,
Jay

P.S. Anyone using this, remember position:absolute will work properly if the container its in is position:relative, otherwise it will use the whole window.

20 Feb 2012, 3:12 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show image on product listing if on special

You are most welcome ... thanks for the update and sharing your solution ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!