Post by Cyberwoolf » Sat Nov 26, 2011 10:33 am

I'm changing a shop over from prestashop and I'm trying to add text if the product is quantity is 0 (sold out) and different text if it's more than 0 (Available). . Like my last post, I've done a search and found a couple topics, but none of the methods work for 1.5.1.3 and I can't figure it out.

I've tried various methods including quantity set to 0 and price to 0.

I was trying something like this in category.tpl:

Code: Select all

 <?php if (!$product['special'] && == '0.00') { ?>
        <?php echo ='SOLD OUT';  ?>
        <?php } else { ?>
I've been going nuts trying to figure out these 2 problems (other post). :crazy:
Last edited by Cyberwoolf on Sun Nov 27, 2011 2:36 am, edited 1 time in total.

New member

Posts

Joined
Wed Jul 27, 2011 8:43 am

Post by uksitebuilder » Sat Nov 26, 2011 11:40 pm

The first thing you need to do is get the quantity variable and pass the correct text to the template

edit: catalog/controller/product/category.php

find

Code: Select all

					'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
add after

Code: Select all

					'availability' => ($result['quantity']>0?$this->language->get('text_available'):$this->language->get('text_soldout')),
Now you have the availability you can use it in the template file

edit: catalog/view/theme/default/template/product/category.tpl

find

Code: Select all

      </div>
      <?php } ?>
      <?php if ($product['rating']) { ?>
add before

Code: Select all

<?php echo $product['availability']; ?>
and finally create a couple of language defines for 'Available' and 'Sold Out'

edit: catalog/language/english/product/category.php

find

Code: Select all

$_['text_points']       = 'Reward Points:'; 
add after

Code: Select all

$_['text_available']       = ' (<span style="color:green">Available</span>)'; 
$_['text_soldout']       = ' (<span style="color:red">Sold Out</span>)'; 
You will most likely want to do similar for search results page, manufacturers_info page and possibly the product page itself.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Cyberwoolf » Sun Nov 27, 2011 12:43 am

Thank you very much 8) .. I get:

Notice: Undefined variable: availability in catalog/view/theme/default/template/product/category.tpl

New member

Posts

Joined
Wed Jul 27, 2011 8:43 am

Post by uksitebuilder » Sun Nov 27, 2011 2:21 am

apologies the 2nd edit was incorrect

change $availability to $product['availability']

code above edited

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Cyberwoolf » Sun Nov 27, 2011 2:36 am

Thank you! That worked. I'll make a vQmod of that too.

I also had to add this (I made it a div) where I wanted it to go so it would show up:

Code: Select all

html += '<div class="avail">' + $(element).find('.avail').html() + '</div>';
Thanks for letting me know how the system works too. It will help with other modifications :-)

New member

Posts

Joined
Wed Jul 27, 2011 8:43 am
Who is online

Users browsing this forum: Amazon [Bot] and 17 guests