• Resolved alex-carter

    (@alex-carter)


    Hi,

    I am creating a woocommerce store for a client who only sells one-off items. I therefore do not want sold items (out of stock) to show in the shop page by default.

    I could set the woocommerce settings to hide out of stock items, but I DO still want to be able to show past sold items elsewhere (either separate page or in shop page with ‘Availability’ set to ‘sold’).

    I could use the Universal Product Layout on the shop page to filter out-of-stock items (thanks to recent addition) but I would like the ability to still use the Product Horizontal Filter to filter item categories on the shop page which Universal Product Layout doesn’t seem to adjust to.

    Unless there is another method you guys can think of, is adding stock availability to the Product Archive Layout (Default) something planned in the near future?

    Many thanks

    Alex

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Zenaul Islam

    (@zenaulislam)

    Hi @alex-carter

    Thank you very much for reaching out us ??

    I have thoroughly read your message.

    As of the moment, there is no option available to hide the “Out of stock” products from the Product Archive Layout (Default).

    However, I appreciate you bringing this to our attention. I will definitely inform the development team about it.

    Kind regards,

    Zenaul Islam

    Thread Starter alex-carter

    (@alex-carter)

    Thanks @zenaulislam

    Worth mentioning for the development team that it would be great if the implementation was a filter rather than a toggle. This is so we can hide sold items in the shop, but have a separate page with a Product Archive Layout (Default) to ONLY show sold items (as a sort of archive).

    The ideal implementation would be the filter as an internal option in the Product Archive Layout (Default) elementor widget content options, as well as a front end option to have support for availability filtering within the Product Horizontal Filter with default value options.

    Thanks for taking on-board the feedback.

    Best Regards,

    Alex

    Thread Starter alex-carter

    (@alex-carter)

    Looking through your plugin code I may have found a workaround. Seems I CAN filter the Product Archive Layout (Default) if I prepend ?wlfilter=1&wlstock=instock to the shop page url. There just is no built-in UI for the front-end user to adjust this yet.

    Woolentor/ShopLentor plugin code snippet from /classes/class.product_query.php:

            if( isset( $_GET['wlstock'] ) && $_GET['wlstock'] != 'all' ){
    
                if( $_GET['wlstock'] == 'outofstock' ){
                    $meta_query[] = [
                        'key'     => '_stock_status',
                        'value'   => 'outofstock',
                        'compare' => '==',
                    ];
                }else{
                    $meta_query[] = [
                        'key'     => '_stock_status',
                        'value'   => 'instock',
                        'compare' => '==',
                    ];
                }
    
            }

    Hope this helps someone in the meantime. But bare in mind the following if you are also using the Product Horizontal Filter widget:

    @zenaulislam When testing the Product Horizontal Filter I found something unrelated to above that this widget does not seem to be working as expected? It only allows me to use one of the fields at a time, eg I can’t Order by Name and Sort By ASC… or any combination for that matter. When ever I change one of the filter fields, the others are unset. Is this a bug? I am running the latest version of the plugin.

    Thanks,

    Alex

    Plugin Contributor Tarek Aziz

    (@tarekht)

    Hi Alex,

    I am Tarek, a support representative of ShopLentor.

    Thanks a lot for your detailed response ??

    I have thoroughly read your messages. It’s great to hear that you have found a workaround to filter in the output generated by the “Product Archive Layout (Default)” widget.

    Regarding the functionality of the filter widgets:

    We are extremely sorry for the inconvenience you had. The filter widgets offered in the free version of ShopLentor don’t allow users to apply multiple filters at the same time. This feature is only available in the pro version.

    Hope this helps!

    Thread Starter alex-carter

    (@alex-carter)

    Thanks @tarekht

    My final solution for implementation is a code snippet to force a filter on specific pages which I hope may help anyone else wanting this feature:

    add_action( 'parse_request', 'WF_ShowOnlyAvailableProducts' );
    function WF_ShowOnlyAvailableProducts(){
    	$slug = basename($_SERVER['REDIRECT_URL']);
    	switch($slug){
    		case 'shop':
    			$_GET['wlfilter'] = '1';
    			$_GET['wlstock'] = 'instock';
    			break;
    		case 'sold':
    			$_GET['wlfilter'] = '1';
    			$_GET['wlstock'] = 'outofstock';
    			break;
    		default:
    			break;
    	}
    }
    

    All it does is, at the point of WP parsing the page request, run a switch case on the page slug and apply the GET parameter. This means when the woocommerce_product_query action is triggered, WooLentor will see the GET params and filter the results of the Product Archive Layout (Default) appropriately. This is pretty generic so would work for anything like applying a default category filter to a specific pages’ Product Archive Layout (Default) by changing to $_GET['woolentor_product_cat'] = 'mycategory';

    Thanks for the info regarding the free limitations.

    Best regards,

    Alex

    Plugin Contributor Tarek Aziz

    (@tarekht)

    Hi Alex,

    The pleasure is all mine ??

    We are glad to see that you have come up with a code snippet that would solve the issue.

    Best regards,

    Tarek

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Product Archive Layout (Default) – Availability Filter’ is closed to new replies.