Author Topic: Manage discontinued products  (Read 22076 times)

restodo

  • Jr. Member
  • **
  • Posts: 77
Re: Manage discontinued products
« Reply #30 on: July 19, 2017, 03:26:09 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

  • Jr. Member
  • **
  • Posts: 117
Re: Manage discontinued products
« Reply #31 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.
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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Manage discontinued products
« Reply #32 on: July 19, 2017, 11:41:01 am »
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

  • Jr. Member
  • **
  • Posts: 205
    • sO couture
  • VirtueMart Version: 3.2.14
Re: Manage discontinued products
« Reply #33 on: July 23, 2017, 14:14:54 pm »
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€.
:)
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.6//VM 3.2.14//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10124
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Manage discontinued products
« Reply #34 on: July 25, 2017, 08:25:49 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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4485
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Manage discontinued products
« Reply #35 on: July 25, 2017, 12:38:21 pm »
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

  • Jr. Member
  • **
  • Posts: 117
Re: Manage discontinued products
« Reply #36 on: July 25, 2017, 12:45:32 pm »
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

  • Beginner
  • *
  • Posts: 22
  • A beginner
Re: Manage discontinued products
« Reply #37 on: September 30, 2017, 17:39:02 pm »
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

  • Beginner
  • *
  • Posts: 35
Re: Manage discontinued products
« Reply #38 on: October 10, 2017, 16:26:53 pm »
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

  • Beginner
  • *
  • Posts: 35
Re: Manage discontinued products
« Reply #39 on: October 10, 2017, 19:41:56 pm »
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
Code: [Select]
$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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4485
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Manage discontinued products
« Reply #40 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

julash

  • Beginner
  • *
  • Posts: 35
Re: Manage discontinued products
« Reply #41 on: October 11, 2017, 11:41:57 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

  • Beginner
  • *
  • Posts: 35
Re: Manage discontinued products
« Reply #42 on: October 12, 2017, 10:27:05 am »
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:
Code: [Select]
       else { //  Dont show discontinued products
            $where[] = 'p.`product_discontinued` != 1 OR p.`product_discontinued` IS NULL';
          }

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4485
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Manage discontinued products
« Reply #43 on: October 12, 2017, 10:45:35 am »
Check in the form if product_discontinued field have the value "1" or not when checked

julash

  • Beginner
  • *
  • Posts: 35
Re: Manage discontinued products
« Reply #44 on: October 22, 2017, 16:23:21 pm »
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.
Code: [Select]
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  :-\