Show "Out of stock" message on product listing pages

Ask the community for help and support.
User avatar
Kofod95
VIP Member
VIP Member
Posts: 605
Joined: Sat Feb 06, 2021 7:38 pm
Has thanked: 80 times
Been thanked: 141 times

Re: Show "Out of stock" message on product listing pages

Post by Kofod95 »

shopify wrote: Sun Jul 25, 2021 5:34 pm This files does not have anything in it that display products for the month on the index.php page.
The actual display is defined in the template file (includes/modules/content/index/templates/tpl_cm_i_card_products.php), which means you can copy this file into templates/override/includes/modules/content/index and make your changes without changing core - asuming you are on 1.0.7.14 or later

I'm glad you got the other thing sorted!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
shopify
Posts: 54
Joined: Tue Mar 30, 2021 3:36 pm
Has thanked: 23 times
Been thanked: 3 times

Re: Show "Out of stock" message on product listing pages

Post by shopify »

Kofod95 wrote: Sun Jul 25, 2021 6:20 pm
shopify wrote: Sun Jul 25, 2021 5:34 pm This files does not have anything in it that display products for the month on the index.php page.
The actual display is defined in the template file (includes/modules/content/index/templates/tpl_cm_i_card_products.php), which means you can copy this file into templates/override/includes/modules/content/index and make your changes without changing core - asuming you are on 1.0.7.14 or later

I'm glad you got the other thing sorted!

//Daniel
My bad, I was looking at the wrong file in a previous post. The ncludes/modules/content/index/templates/tpl_cm_i_card_products.php seems to be the correct file
shopify
Posts: 54
Joined: Tue Mar 30, 2021 3:36 pm
Has thanked: 23 times
Been thanked: 3 times

Re: Show "Out of stock" message on product listing pages

Post by shopify »

This works in includes/modules/content/index/templates/tpl_cm_i_card_products.php

<?php
echo tep_draw_button(IS_PRODUCT_BUTTON_VIEW, '', tep_href_link('product_info.php', tep_get_all_get_params(array('action', 'products_id', 'sort', 'cPath')) . 'products_id=' . (int)$card_products['products_id']), NULL, NULL, 'btn-info btn-product-listing btn-view') . PHP_EOL;
$has_attributes = (tep_has_product_attributes((int)$card_products['products_id']) === true) ? '1' : '0';

// Start out of stock
if (!$card_products['in_stock'] == 0) {
if ($has_attributes == 0) echo tep_draw_button(IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id', 'sort', 'cPath')) . 'action=buy_now&products_id=' . (int)$card_products['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$card_products['in_stock'] . '" data-product-id="' . (int)$card_products['products_id'] . '"'), 'btn-light btn-product-listing btn-buy') . PHP_EOL;
}
else {
if ($has_attributes == 0) echo tep_draw_button(IS_PRODUCT_BUTTON_SOLD, '', tep_href_link('product_info.php', tep_get_all_get_params(array('action')) . 'products_id=' . (int)$card_products['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$card_products['in_stock'] . '" data-product-id="' . (int)$card_products['products_id'] . '"'), 'btn-product-listing btn-danger') . PHP_EOL;
}
// End out of stock
?>
User avatar
Kofod95
VIP Member
VIP Member
Posts: 605
Joined: Sat Feb 06, 2021 7:38 pm
Has thanked: 80 times
Been thanked: 141 times

Re: Show "Out of stock" message on product listing pages

Post by Kofod95 »

[Code above edited, making this reply unecessary red.]

That is because the variable $prod_list_content is not echoed - the two pages are built differently, one giving a lot of data to a variable, and the other outputting the data directly.

Line 29-31 in tpl_cm_i_card_products.php:

Code: Select all

echo tep_draw_button(IS_PRODUCT_BUTTON_VIEW, '', tep_href_link('product_info.php', tep_get_all_get_params(array('action', 'products_id', 'sort', 'cPath')) . 'products_id=' . (int)$card_products['products_id']), NULL, NULL, 'btn-info btn-product-listing btn-view') . PHP_EOL;
              $has_attributes = (tep_has_product_attributes((int)$card_products['products_id']) === true) ? '1' : '0';
              if ($has_attributes == 0) echo tep_draw_button(IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id', 'sort', 'cPath')) . 'action=buy_now&products_id=' . (int)$card_products['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$card_products['in_stock'] . '" data-product-id="' . (int)$card_products['products_id'] . '"'), 'btn-light btn-product-listing btn-buy') . PHP_EOL;
- that is the format you need in that file

//Daniel
Last edited by Kofod95 on Sun Jul 25, 2021 7:51 pm, edited 2 times in total.
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
shopify
Posts: 54
Joined: Tue Mar 30, 2021 3:36 pm
Has thanked: 23 times
Been thanked: 3 times

Re: Show "Out of stock" message on product listing pages

Post by shopify »

Kofod95 wrote: Sun Jul 25, 2021 7:34 pm That is because the variable $prod_list_content is not echoed - the two pages are built differently, one giving a lot of data to a variable, and the other outputting the data directly.

Line 29-31 in tpl_cm_i_card_products.php:

Code: Select all

echo tep_draw_button(IS_PRODUCT_BUTTON_VIEW, '', tep_href_link('product_info.php', tep_get_all_get_params(array('action', 'products_id', 'sort', 'cPath')) . 'products_id=' . (int)$card_products['products_id']), NULL, NULL, 'btn-info btn-product-listing btn-view') . PHP_EOL;
              $has_attributes = (tep_has_product_attributes((int)$card_products['products_id']) === true) ? '1' : '0';
              if ($has_attributes == 0) echo tep_draw_button(IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id', 'sort', 'cPath')) . 'action=buy_now&products_id=' . (int)$card_products['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$card_products['in_stock'] . '" data-product-id="' . (int)$card_products['products_id'] . '"'), 'btn-light btn-product-listing btn-buy') . PHP_EOL;
- that is the format you need in that file

//Daniel
Thanks, my code above works. Now I need to beautify that Sold Out button - it's way too red (danger) at the moment. :)
User avatar
Kofod95
VIP Member
VIP Member
Posts: 605
Joined: Sat Feb 06, 2021 7:38 pm
Has thanked: 80 times
Been thanked: 141 times

Re: Show "Out of stock" message on product listing pages

Post by Kofod95 »

Enjoy :)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Post Reply