Shortcode For Listing

Posted by: Kyle Parry

11th December 2020, 7:27 pm

Kyle Parry

@builderkp

11 Dec 2020
7:27 pm

Hi there,

I've been using this product for a while and love it. Was wondering if there's a short code to add the users downloaded products (similar to what can be done automatically in dashboard).

Reason for request - the Woocommerce dashboard can get a bit confusing. I've created individual pages for 'my orders' 'my subscriptions' etc but would love to have one that also has 'my free downloads'.

Thank you!

  • Richard Webster

    @rwebster

    11 Dec 2020
    7:55 pm

    Hi Kyle that's a great question. I have something like this planned, but for a quick custom implementation I might be able to give you a code snippet to use.

    What would you display if a user visits this page but isn't logged in?

  • Kyle Parry

    @builderkp

    11 Dec 2020
    8:21 pm

    Hey Richard - they wouldn't presently have access. If a guest tries to access the 'Dashboard' they get a login / register form.

    A snippet would be wonderful haha

  • Richard Webster

    @rwebster

    12 Dec 2020
    11:19 am

    Use the Code Snippets plugin and create a new snippet with the following code:

    if (function_exists('somdn_downloads_table')) {
    	function customOutputUserFreeDownloadsTable()
    	{
    		if(!is_user_logged_in())
    			return;
    
    		ob_start();
    		somdn_downloads_table();
    		$content = ob_get_clean();
    		return $content;
    	}
    	add_shortcode('custom_free_downloads_history', 'customOutputUserFreeDownloadsTable');
    }

    The shortcode to add to your page is [custom_free_downloads_history]

    Let me know how you get on.

    Last modified: 12th December 2020, 11:19 am by Richard Webster

This topic is closed to new replies.