Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    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

    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)

    Ahh thanks allot man, great plugin! Works perfect. 🙂
    Cheers

    Thread Starter alex-carter

    (@alex-carter)

    Thanks for the quick reply!

    That has worked for the tittle and navigation buttons, but not the buttons on the right hand side, is there an element that would hold all these top elemts?

    <a href="/" class="button primary-button">|</a>
    <a href="/" class="button secondary-button">Contact</a>

    This is in the ‘customize’ section with the customize header of “Header Right Block Content” for the buttons.

    Thanks in advance 🙂

Viewing 5 replies - 1 through 5 (of 5 total)