• Resolved dirtcheaprc

    (@dirtcheaprc)


    Hi There. This plugin is awesome! Very functional. I am currently using it with WP All Import plugin and it’s working great to set products to discontinued on the front end.

    I have 2 suggestions:

    1. Currently, by default, a discontinued product is hidden from the shop archive page and search results. But I am finding that when I browse through categories in the online store, they are not hidden. I’m assuming that there is a different template page than the shop template that is used when showing category contents…? I feel that if you are hiding discontinued products from the shop archive, they should also be hidden from the category listings.

    2. Discontinued products that are in the shopping cart should be removed. For example, A customer adds Product A to their cart on Monday. They log off and their cart is saved. On Tuesday, we set Product A to discontinued. On Wednesday, they log back in and checkout with the discontinued product still in their cart.

    Let me know if I can be of any help with this.

    Thanks,
    Chris

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter dirtcheaprc

    (@dirtcheaprc)

    I am actually noticing that when I view the ‘shop’, all products are listed, even discontinued ones. I currently have 7,583 products. Of these, 1,651 are marked as ‘discontinued’ in the database. Unfortunately, they are all showing up on the front end. So maybe I actually overlooked something.

    When setting the discontinued status when I use WP All Import, I set the _is_discontinued meta_key to yes or no. Is there something else that I need to set as well?

    I feel there must be something else I need to set. When I manually edit a product and set it to discontinued, it actually does not show up on the front end when viewing the ‘shop’. It still does show up when viewing a category as mentioned above in section 1 though.

    Plugin Author twoelevenjay

    (@twoelevenjay)

    Thank you so much for pointing this out. I will have to mention this answer on another thread that asked how to use CSV Import Suite to set products as discontinued.

    For the sake of performance, products that should be hidden are cached in a transient. This is flushed on “save”. Once you have imported, you can simply go save a product and this should flush the cache. Alternatively you can got to WooCommerce > System Status > Tools > WC Transients > Clear transients.

    Thread Starter dirtcheaprc

    (@dirtcheaprc)

    OK I see. Maybe this plugin wont work so well for my application after all. Is there any way to make the plugin use the database value instead?

    Plugin Author twoelevenjay

    (@twoelevenjay)

    Sorry for the late reply, you could do this by editing the woocommerce-discontinued-products/blob/master/includes/wc-class-dp-discontinued-product.php file. However, discontinued products are defined by meta data, meta queries can be extremely slow. You mentioned that you have 7K+ products, this would probably cause a performance issue.

    If you want to change this then find the code on line 299 of woocommerce-discontinued-products/blob/master/includes/wc-class-dp-discontinued-product.php:

    $query->set( 'post__not_in', $ids_to_hide );

    and change it to:

    $meta_query = array(
    	array(
    		'key'     => '_is_discontinued',
    		'value'   => 'yes',
    	),
    	// If you want to hide from shop.
    	array(
    		'key'     => _hide_from_shop,
    		'value'   => 'show',
    		'compare' => '!=',
    	),
    	// If you want to hide from search.
    	array(
    		'key'     => _hide_from_search,
    		'value'   => 'show',
    		'compare' => '!=',
    	),
    );
    $query->set( 'meta_query', $meta_query );
    Thread Starter dirtcheaprc

    (@dirtcheaprc)

    Ya know, I didn’t realize this at the time of downloading this plugin and trying to make it work with my site that built in WordPress functionality works just fine for me.

    Discontinued items are set to _visibility=’hidden’. This hides them from search and catalog just fine and the site reads it straight from the database.

    coadr93

    (@coadr93)

    Have you solved the problem with the products still showing in Category pages ? Please help ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove from Category and Cart’ is closed to new replies.