News:

Looking for documentation? Take a look on our wiki

Main Menu

Manage discontinued products

Started by restodo, November 26, 2016, 14:45:41 PM

Previous topic - Next topic

restodo

Quote from: K&K media production on July 19, 2017, 00:54:34 AM
You wrote that you want to hide the products, not I.

I've added the discontinued products function to the core to mark the products as discontinued.

Yes I'm sure, I wrote the last core changes for discontinued products and stockhandle on product level.

Thanks for the information, I was able to figure out how to do not show discontinued products from listings adding some code in product.php

This is an example of one modification:
      //stock controls
      if(!VmConfig::get('use_as_catalog',0) || $in_stock) {
         if (VmConfig::get('stockhandle','none')=='disableit_children') {
            $where[] = '(p.`product_in_stock` - p.`product_ordered` >0 OR children.`product_in_stock` - children.`product_ordered` >0)';
            $joinChildren = true;
         } else if (VmConfig::get('stockhandle','none')=='disableit') {
            $where[] = 'p.`product_in_stock` - p.`product_ordered` >0';
         } else { // Added //
            // RS - No lista los productos discontinuados //
            $where[] = 'p.`product_discontinued` IS NULL';  // Added //
         }
      }

Marttyn

In my website i choose not to handle stock. So dont matter if i set stock to 0, a discontinued product can still be added to cart, but this is not desirable.
I think the add to cart button should be disabled for discontinued products, and also hide them from listings. Users who purchased that product, when they go to their invoices, when they click on a discontinued product, they will still see the product page, and that is not possible if we unpublish it.
Also for example, in my blog i have links to some of my products. And if at some point i want to stop selling the product, then if i unpublish or delete this product, then all the links in my blog would be broken. This already happened to me, and i have to modify blog post to solve this.

K&K media production

A product can be also discontinued if stock is not 0. You can disable the add-to-cart button with some custom code as template override.

aftertaf

Hi,
for me it all depends on what you want to use it for, and what type of business/products you are using your online shop for.

In my case, discontinued on top of published/unpublished can be useful to show that the product is still for sale, but once the stock is down to zero there wont be any more available in the future.

adjective
adjective: discontinued
(of a product) no longer available or produced.
"discontinued fabrics"

discontinue
verb
past tense: discontinued; past participle: discontinued
cease from doing or providing (something), especially something that has been provided on a regular basis.
"the ferry service was discontinued by the proprietors"
stop making (a particular product).
"their current top-of-the-range running shoe is being discontinued"
synonyms:   stop, end, terminate, bring to an end, put an end to, put a stop to, wind up, finish, bring to a halt, call a halt to, cancel, drop, dispense with, do away with, get rid of, abolish; More
antonyms:   continue, new
cease taking (a newspaper or periodical) or paying (a subscription).

The 'unique' nature of each webshop & products sold means that this can be used/interpreted in many ways.

I guess my questions on this subject are "What did the VM team intend when they introduced this feature? What functionality does this feature make available to those using Virtuemart ?"
But like a lot of features in 'generic' tools like this, it can be used or exploited in different ways, depending on your needs, your shop type, your ability to override, etc...

my 0.02€.
:)

Milbo

Quote from: Marttyn on July 19, 2017, 10:01:26 AM
In my website i choose not to handle stock. So dont matter if i set stock to 0, a discontinued product can still be added to cart, but this is not desirable.
I think the add to cart button should be disabled for discontinued products, and also hide them from listings. Users who purchased that product, when they go to their invoices, when they click on a discontinued product, they will still see the product page, and that is not possible if we unpublish it.
I agree that discontinued products should follow the normal inventory behaviour
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

This is the way discontinued should work for one of my case.
discontinued and stock < Low Stock :  display "Last remaining".
discontinued and stock = 0 : display "Discontinued" + cart disabled.
Of course, if you know a little VM code and PHP, you can add this as overide but this not prevent direct link to add to cart. So it should be prevented in the cart helper, if discontinued and stock = 0 and
config have disable add to cart for discontinued products.
In some case for not discontinued product, the cart should not be disabled, but change the shipment duration(i don't have the case)

Marttyn

Quote
discontinued and stock > 0 : display "Discontinued, Last remaining".
discontinued and stock <= 0 : display "Discontinued" + cart disabled.
But this not prevent direct link to add to cart. So it should be prevented in the cart helper, if discontinued and stock = 0

AGREE  :)

sgrunch

Quote from: restodo on July 19, 2017, 03:26:09 AM
Quote from: K&K media production on July 19, 2017, 00:54:34 AM
You wrote that you want to hide the products, not I.

I've added the discontinued products function to the core to mark the products as discontinued.

Yes I'm sure, I wrote the last core changes for discontinued products and stockhandle on product level.

Thanks for the information, I was able to figure out how to do not show discontinued products from listings adding some code in product.php

This is an example of one modification:
      //stock controls
      if(!VmConfig::get('use_as_catalog',0) || $in_stock) {
         if (VmConfig::get('stockhandle','none')=='disableit_children') {
            $where[] = '(p.`product_in_stock` - p.`product_ordered` >0 OR children.`product_in_stock` - children.`product_ordered` >0)';
            $joinChildren = true;
         } else if (VmConfig::get('stockhandle','none')=='disableit') {
            $where[] = 'p.`product_in_stock` - p.`product_ordered` >0';
         } else { // Added //
            // RS - No lista los productos discontinuados //
            $where[] = 'p.`product_discontinued` IS NULL';  // Added //
         }
      }

I don't want show the dicontinued products in categories view but only if link (call)  the url (google and ecc.) I can try with $where[] = 'p.`product_discontinued` IS NULL'; but the result is not correct.

VM 3.2.4

julash

Quote from: Milbo on July 25, 2017, 08:25:49 AM
Quote from: Marttyn on July 19, 2017, 10:01:26 AM
In my website i choose not to handle stock. So dont matter if i set stock to 0, a discontinued product can still be added to cart, but this is not desirable.
I think the add to cart button should be disabled for discontinued products, and also hide them from listings. Users who purchased that product, when they go to their invoices, when they click on a discontinued product, they will still see the product page, and that is not possible if we unpublish it.
I agree that discontinued products should follow the normal inventory behaviour

Hi, so if I understand correctly discontinued product with 0 stock will not show in category listing, but link will still work.

But it seem not working for me. I tried with virtuemart sample website. In vm config discontinued product is set to omit from listing, but not working. Our products has only 1 stock, so after sold out product need to hide from category listing. So discontinued feature seem really good option for us.

Is this a bug?

Thanks
Julash

julash

Quote from: restodo on July 19, 2017, 03:26:09 AM
Quote from: K&K media production on July 19, 2017, 00:54:34 AM
You wrote that you want to hide the products, not I.

I've added the discontinued products function to the core to mark the products as discontinued.

Yes I'm sure, I wrote the last core changes for discontinued products and stockhandle on product level.

Thanks for the information, I was able to figure out how to do not show discontinued products from listings adding some code in product.php

This is an example of one modification:
      //stock controls
      if(!VmConfig::get('use_as_catalog',0) || $in_stock) {
         if (VmConfig::get('stockhandle','none')=='disableit_children') {
            $where[] = '(p.`product_in_stock` - p.`product_ordered` >0 OR children.`product_in_stock` - children.`product_ordered` >0)';
            $joinChildren = true;
         } else if (VmConfig::get('stockhandle','none')=='disableit') {
            $where[] = 'p.`product_in_stock` - p.`product_ordered` >0';
         } else { // Added //
            // RS - No lista los productos discontinuados //
            $where[] = 'p.`product_discontinued` IS NULL';  // Added //
         }
      }

I was wrong. Discontinued checked don't hide products. Then why is this added, just for a product tag  :o

Above code worked for me. But its don't work 100%. When a product discontinued checked and later again discontinued unchecked, that product still don't show in category listing. Its because now 'product_discontinued' value is 0, not NULL.

I tried this $where[] = 'p.`product_discontinued` = 0' or 'p.`product_discontinued` IS NULL' ; and it works on my local server fine but not in live site  :-\

Studio 42

do not use
$where[] = 'p.`product_discontinued` IS NULL';  // Added //
Use
$where[] = 'p.`product_discontinued` <> 1';
Or perhaps
$where[] = 'p.`product_discontinued` < 1';
Note : i have not tested but should be ok

julash

Quote from: Studio 42 on October 11, 2017, 01:27:27 AM
do not use
$where[] = 'p.`product_discontinued` IS NULL';  // Added //
Use
$where[] = 'p.`product_discontinued` <> 1';
Or perhaps
$where[] = 'p.`product_discontinued` < 1';
Note : i have not tested but should be ok

Thanks for your reply, but not working. Both line only show products that has 'product_discontinued' value as 0. Products that has NULL 'product_discontinued' value don't show. I was hoping to show all NULL and 0 value products.

julash

It seem when a product modified its 'product_discontinued' value changed to 0 even when discontinued was not touched. So that mean only "p.`product_discontinued` IS NULL" won't work because product that has 0 value because of product modification will get hide too.

Here is the solution:
       else { //  Dont show discontinued products
            $where[] = 'p.`product_discontinued` != 1 OR p.`product_discontinued` IS NULL';
          }

Studio 42

Check in the form if product_discontinued field have the value "1" or not when checked

julash

Hi, sorry for bothering again on this thread. But thought it will be a good idea to share it in case anyone need it and for documentation purpose.

My previous attempt from restodo's solution was causing a problem. For out of stock product we use "Displays 'Notify Me' instead of 'Add To Cart' button", so from restodo's idea I was using 'p.`product_discontinued` != 1 OR p.`product_discontinued` IS NULL' in line 416 of product.php. Where it was checking if product is discontinued during product stock handling. Because of that any product that has 0 as 'product_discontinued' value (because of rediting product) was showing in all kind of category page. I was not aware of it for several days.

I was almost giving it up. Anyway, found a solution (really hoping FINALLY ::) ). I added this code in line 437 of product.php in else statement.

if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
if(VmConfig::get('show_subcat_products',false)){
/*GJC add subcat products*/
$catmodel = VmModel::getModel ('category');
$childcats = $catmodel->getChildCategoryList(1, $virtuemart_category_id,null, null, true);
$cats = $virtuemart_category_id;
foreach($childcats as $childcat){
$cats .= ','.$childcat->virtuemart_category_id;
}
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` IN ('.$cats.') ';
} else {
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id . ' AND (p.`product_discontinued` != 1 OR p.`product_discontinued` IS NULL) ';
}
}


Instead of checking if product is discontinued during stock handling, it will not check if product is discontinued during category check. So far its working fine. Hope there no more surprise for discontinued products  :-\