If this is your first visit, check our documentation. To post, register or login.
Forums / Templates, Stylesheets, Page Layout / Displaying Sold Out Image in place of Add to Cart

Displaying Sold Out Image in place of Add to Cart

Started by kenshirou on 23 Apr 2013, 8:19 AM · Views: 2,514

Results 21 to 39 of 39
25 Apr 2013, 2:09 PM
#21
ajeh avatar

ajeh

Oba-san

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

Displaying Sold Out Image in place of Add to Cart

I do not know the variable in your code for the products_id, but find that and replace $your_products_id with it ...

Something like this may work for you:

      <p class="desc"> <?php echo ($list_box_contents[$row][1]['text']); ?>
<?php
if (zen_get_products_stock($your_products_id) > 0) {
?>  
      <p class="submit">
        <input type="button" class="add2cart medium_button" onclick="window.location.href='<?php echo ($list_box_contents[$row][1]['link'])."&action=buy_now"; ?>';"  value="Add to Cart"/>
      </p>
<?php
} else {
?>    
      <p class="desc">Out of Stock</p>  
<?php
}
?>      
    </div>
  </div>

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!

25 Apr 2013, 2:34 PM
#22
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Ajeh:

I do not know the variable in your code for the products_id, but find that and replace $your_products_id with it ...

Something like this may work for you:

  <p class="desc"> <?php echo ($list_box_contents[$row][1]['text']); ?>

<?php if (zen_get_products_stock($your_products_id) > 0) { ?>
<p class="submit">
<input type="button" class="add2cart medium_button" onclick="window.location.href='<?php echo ($list_box_contents[$row][1]['link'])."&action=buy_now"; ?>';" value="Add to Cart"/>
</p>
<?php } else { ?>
<p class="desc">Out of Stock</p>
<?php } ?>
</div>

</div> ```

What normal file would I normally find that variable in? And thank you so much! :)

25 Apr 2013, 2:51 PM
#23
ajeh avatar

ajeh

Oba-san

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

Re: Displaying Sold Out Image in place of Add to Cart

You'd have to see what file is calling: tpl_tabular_display.php

You might try a search in the Tools ... Developers Tool Kit ... and in the bottom input box enter:
tabular_display

to see what is calling that file and see if it helps you ...

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!

25 Apr 2013, 3:26 PM
#24
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Appears in custom_template/templates/tpl_modules_product_listing.php

and twice again in
template_default/common/tpl_list_box_content.php

25 Apr 2013, 4:08 PM
#25
ajeh avatar

ajeh

Oba-san

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

Re: Displaying Sold Out Image in place of Add to Cart

What is in the file:
/includes/modules/product_listing2.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!

26 Apr 2013, 8:19 AM
#26
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Ajeh:

What is in the file:
/includes/modules/product_listing2.php

okay found this in the custom template files.

26 Apr 2013, 10:55 PM
#27
ajeh avatar

ajeh

Oba-san

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

Re: Displaying Sold Out Image in place of Add to Cart

I do not have all the code and settings to test this, but you might try in the file:
product_listing2.php

        $lc_price2 = '<p class="wrap_price"><span class="price">'.zen_get_products_display_price($listing->fields['products_id']).'</span> </p>';

[B]        if ($listing->fields['products_quantity'] <= 0) {
      $lc_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']) . '">' . 'Out of Stock' . '</a>';
    } else {
[/B]          $lc_link = 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']);
[B]        }[/B]

then in the code for tpl_tabular_display.php use:

  <div class="list_item list_item_1 smaller odd <?php echo $xtra ?>">
    <?php
$disp1 = ereg_replace('<a href="', '<a class="thumbnail" href="', $list_box_contents[$row][0]['text']);
echo $disp1; ?>
    <div class="grid_item_left"> <?php echo ($list_box_contents[$row][1]['head']); ?> <?php echo ($list_box_contents[$row][1]['price2']); ?>
      <p class="desc"> <?php echo ($list_box_contents[$row][1]['text']); ?>
[B]<?php
if (!strstr($lc_link, 'Out of Stock')) {
?>
[/B]      <p class="submit">
        <input type="button" class="add2cart medium_button" onclick="window.location.href='<?php echo ($list_box_contents[$row][1]['link'])."&action=buy_now"; ?>';"  value="Add to Cart"/>
      </p>
[B]<?php
} else {
?>
[/B]      <p class="desc">Out of Stock</p>
[B]<?php
}
?>
[/B]    </div>
  </div>

Just be aware that what ever you use for the text "Out of Stock" you need to use in both files as that is the phrase being tested for to know when to show what ...

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!

29 Apr 2013, 8:28 AM
#28
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Hi I added the code and part of it worked, however I encounter another problem. http://screencast.com/t/TSMV7Unxx9

29 Apr 2013, 8:32 AM
#29
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Displaying Sold Out Image in place of Add to Cart

I added the code and part of it worked, however I encounter another problem
Post a link to your site - an image does nothing to assist in troubleshooting an issue

Zen-Venom Get Bitten

29 Apr 2013, 9:04 AM
#30
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

http://kidsartandcraft.co.uk/ But I've taken out that piece of code for the moment.

30 Apr 2013, 3:53 AM
#31
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Displaying Sold Out Image in place of Add to Cart

But I've taken out that piece of code for the moment
Well we can not assist with the issue

Zen-Venom Get Bitten

30 Apr 2013, 8:14 AM
#32
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Hi there, I have added the code back in to my site. http://www.kidsartandcraft.co.uk/index.php?main_page=index&cPath=75_107_129 As you can see I have used the code Ajeh told me to create and its half worked, I believe I have pasted it into the correct place, but still very unsure of where its going wrong. :/

30 Apr 2013, 11:20 AM
#33
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Displaying Sold Out Image in place of Add to Cart

Post the contents of the edited file

Zen-Venom Get Bitten

30 Apr 2013, 3:15 PM
#35
ajeh avatar

ajeh

Oba-san

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

Re: Displaying Sold Out Image in place of Add to Cart

This will only work if both files have something to match against such as:
Out of Stock

For the lines:

if (!strstr($lc_link, 'Out of Stock')) {
      $lc_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']) . '">' . 'Out of Stock' . '</a>';

Otherwise, there is nothing to test what should display ...

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!

1 May 2013, 7:59 AM
#36
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Sorry about this I'm a bit confused, my knowledge of php isn't great, but where do I post those 2 pieces of code?

1 May 2013, 12:39 PM
#37
ajeh avatar

ajeh

Oba-san

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

Re: Displaying Sold Out Image in place of Add to Cart

In tpl_tabular_display.php you need:

<?php
if (!strstr($lc_link, '[B]Out of Stock[/B]')) {
?>
      <p class="submit">

then in product_listing2.php you need:

        if ($listing->fields['products_quantity'] <= 0) {
      $lc_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']) . '">' . '[B]Out of Stock[/B]' . '</a>';
    } else {
          $lc_link = 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']);
        }

this places the Out of Stock as an identifier between the two files to know when to display the Buy Now or just a link to the product_info page ...

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!

3 May 2013, 8:28 AM
#38
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Hi, I have tried to amend the code and it is still displaying as out of stock&action=buy-now'." value = "add to cart"/> . I spent another 30 mins trying to get it to work and now I've just disabled the out of stock products. Is there any reason why its displaying part of this code?

8 May 2013, 4:14 PM
#39
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Displaying Sold Out Image in place of Add to Cart

Rather than display Out of stock, is just possible to just disable the 'Add to Cart' function when it goes out of stock?