It's the older version of @zipurman Product Manager
Show "Out of stock" message on product listing pages
- Kofod95
- VIP Member
- Posts: 613
- Joined: Sat Feb 06, 2021 7:38 pm
- Has thanked: 80 times
- Been thanked: 142 times
Re: Show "Out of stock" message on product listing pages
Using something similar to what Burt suggested, we have this:
We are not measuring stock, as we have a physical store that is too small for POS-systems, but when we sell the last item of any sort, we change the product status to '2' ('0' is the red cross, '1' is the green check, '2' is something we have added to signify 'still visible, but out of stock'.). We have added a class to the product cards so they include the status, allowing us to target the sold out products with css.
//Daniel
We are not measuring stock, as we have a physical store that is too small for POS-systems, but when we sell the last item of any sort, we change the product status to '2' ('0' is the red cross, '1' is the green check, '2' is something we have added to signify 'still visible, but out of stock'.). We have added a class to the product cards so they include the status, allowing us to target the sold out products with css.
//Daniel
You do not have the required permissions to view the files attached to this post.
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Here are a lot of corns: Phoenix user guide
-
- Lead Developer
- Posts: 2439
- Joined: Tue Oct 29, 2019 9:37 am
- : Buy Me A Beverage
- Has thanked: 51 times
- Been thanked: 138 times
Re: Show "Out of stock" message on product listing pages
Per the two posts above, you could drop a copy of this file:
/templates/default/includes/components/product_card.php
into the following location:
/templates/override/includes/components/product_card.php (note that if you use a different template to override, you should drop it into what template you are using)
Now find:
Change to:
This is the stunning beauty of Matts templating system. You can do similar in the other places that show product lists (eg new roducts for month etc), but note that some files are in the older style of coding (but still templatable and over-rideable), it is just that the code will look slightly different.
/templates/default/includes/components/product_card.php
into the following location:
/templates/override/includes/components/product_card.php (note that if you use a different template to override, you should drop it into what template you are using)
Now find:
Code: Select all
if (!$product->get('has_attributes')) {
echo PHP_EOL, tep_draw_button(
IS_PRODUCT_BUTTON_BUY,
'',
tep_href_link(basename($GLOBALS['PHP_SELF']), tep_get_all_get_params(['action', 'products_id']) . 'action=buy_now&products_id=' . (int)$product->get('id')),
null,
['params' => 'data-has-attributes="0" data-in-stock="' . (int)$product->get('in_stock') . '" data-product-id="' . (int)$product->get('id') . '"'],
'btn-light btn-product-listing btn-buy');
}
Code: Select all
if ($product->get('in_stock') > 0) { // is stock greater than zero? YES:
if (!$product->get('has_attributes')) {
echo PHP_EOL, tep_draw_button(
IS_PRODUCT_BUTTON_BUY,
'',
tep_href_link(basename($GLOBALS['PHP_SELF']), tep_get_all_get_params(['action', 'products_id']) . 'action=buy_now&products_id=' . (int)$product->get('id')),
null,
['params' => 'data-has-attributes="0" data-in-stock="' . (int)$product->get('in_stock') . '" data-product-id="' . (int)$product->get('id') . '"'],
'btn-light btn-product-listing btn-buy');
}
}
else { // NO:
echo tep_draw_button('<i class="fas fa-battery-empty"></i>', '', $product->get('link'), null, ['params' => 'title="OOS"'], 'btn-danger btn-product-listing btn-view');
}
Gamechanger Addon: Queued Emails, try before you buy.
Re: Show "Out of stock" message on product listing pages
I haven't a /templates/override/includes/components/ folder so I modified the file /templates/default/includes/components/product_card.php file but nothing changes. I still have the add to cart button even when I change stock to zero.burt wrote: ↑Tue Jul 13, 2021 10:55 am Per the two posts above, you could drop a copy of this file:
/templates/default/includes/components/product_card.php
into the following location:
/templates/override/includes/components/product_card.php (note that if you use a different template to override, you should drop it into what template you are using)
Now find:
Change to:Code: Select all
if (!$product->get('has_attributes')) { echo PHP_EOL, tep_draw_button( IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($GLOBALS['PHP_SELF']), tep_get_all_get_params(['action', 'products_id']) . 'action=buy_now&products_id=' . (int)$product->get('id')), null, ['params' => 'data-has-attributes="0" data-in-stock="' . (int)$product->get('in_stock') . '" data-product-id="' . (int)$product->get('id') . '"'], 'btn-light btn-product-listing btn-buy'); }
Code: Select all
if ($product->get('in_stock') > 0) { // is stock greater than zero? YES: if (!$product->get('has_attributes')) { echo PHP_EOL, tep_draw_button( IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($GLOBALS['PHP_SELF']), tep_get_all_get_params(['action', 'products_id']) . 'action=buy_now&products_id=' . (int)$product->get('id')), null, ['params' => 'data-has-attributes="0" data-in-stock="' . (int)$product->get('in_stock') . '" data-product-id="' . (int)$product->get('id') . '"'], 'btn-light btn-product-listing btn-buy'); } } else { // NO: echo tep_draw_button('<i class="fas fa-battery-empty"></i>', '', $product->get('link'), null, ['params' => 'title="OOS"'], 'btn-danger btn-product-listing btn-view'); }
- zipurman
- PhoenixCart Developer
- Posts: 473
- Joined: Tue Oct 13, 2020 5:20 pm
- : Buy Me A Beverage
- Has thanked: 84 times
- Been thanked: 147 times
Re: Show "Out of stock" message on product listing pages
Modules - Content - New Products (index)
zipurman
aka Preston Lord
-----------
Happy to help where I can
https://phoenixaddons.com
https://www.youtube.com/zipurman/ ** PHOENIX HOW-TO VIDEOS **
aka Preston Lord
-----------
Happy to help where I can
https://phoenixaddons.com
https://www.youtube.com/zipurman/ ** PHOENIX HOW-TO VIDEOS **
- Kofod95
- VIP Member
- Posts: 613
- Joined: Sat Feb 06, 2021 7:38 pm
- Has thanked: 80 times
- Been thanked: 142 times
Re: Show "Out of stock" message on product listing pages
You should create the directory and copy the file into it, as that will preserve your changes throughout updates in the future - the point about templates is that it allows you to override core-layout instead of changing it directly.
However, on my 1.0.8.0 the product_card.php doesn't do anything (at least as far as I could tell), meaning the relevant change should be in product_listing.php instead (templates/override/includes/components/product_listing.php - just copy the one from the default template, and create the directories in the override template)
//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Here are a lot of corns: Phoenix user guide
- Kofod95
- VIP Member
- Posts: 613
- Joined: Sat Feb 06, 2021 7:38 pm
- Has thanked: 80 times
- Been thanked: 142 times
Re: Show "Out of stock" message on product listing pages
The file is cm_i_card_products.php (includes/modules/content/index)
//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Here are a lot of corns: Phoenix user guide
Re: Show "Out of stock" message on product listing pages
This files does not have anything in it that display products for the month on the index.php page. I need to modify the file that displays these products like the product_listing.php file to show item is out of stock. The index page is first place customers see products and if product is not in stock, then I'd like to display the out of stock button here too.
Re: Show "Out of stock" message on product listing pages
I created the folder as dvised and changes are picked up here. Next thing is applying to the index.php page.Kofod95 wrote: ↑Sat Jul 24, 2021 5:58 pmYou should create the directory and copy the file into it, as that will preserve your changes throughout updates in the future - the point about templates is that it allows you to override core-layout instead of changing it directly.
However, on my 1.0.8.0 the product_card.php doesn't do anything (at least as far as I could tell), meaning the relevant change should be in product_listing.php instead (templates/override/includes/components/product_listing.php - just copy the one from the default template, and create the directories in the override template)
//Daniel