WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
I give - What are the Available Download Shortcodes (14 posts)

  1. Kimber254
    Member
    Posted 11 months ago #

    I've tried ever combo I can think of. I know the downloads are ( I think ) stored in my-downloads.php but need to find a way to show those on the my account page. Pleas advice

    Thank you

    http://wordpress.org/plugins/woocommerce/

  2. wpgeekster
    Member
    Posted 11 months ago #

    I don't understand your question. I don't think your downloads are stored in your downloads.php file. Php files have scripts that tell the server what to do. You downloads will be most likely stored in a folder. Are you trying to sell digital products? What do you mean when you say that they don't show up on your account page? Are you saying that you have downloads that only people who have accounts can download? Are you unable to download those products once you are logged in as a member? If you can give me a better description I can help you.

  3. wpgeekster
    Member
    Posted 11 months ago #

    Sorry I misunderstood. What you need to do is copy all the code in the my-downloads.php file and copy it into your functions.php file. Before you do anything with your functions.php file, back it up so you can revert back to it if you break your site. Paste the code into the top or bottom of functions.php or at least between the existing functions. When you find a good place to put your shortcode function, do it like this:

    function download_shortcode(){
    Place all the code that you are pasting right here
    }
    add_shortcode('downloads'), 'download_shortcode')

    Don't paste it inside of an already existing function. Notice that below the code that you put in put the following code:
    add_shortcode('downloads', 'download_shortcode')
    This code creates the shortcode.
    Then you can call put the shortcode in your page or post like this:
    [downloads]

  4. wpgeekster
    Member
    Posted 11 months ago #

    Let me know if it works and if you need more help, let me know.

  5. Kimber254
    Member
    Posted 11 months ago #

    I tried functions.php in the includes folder and woocommerce-functions.php and ftp'ed in the charges where I pasted

    function download_shortcode(){
    Place all the code that you are pasting right here
    }
    add_shortcode('downloads'), 'download_shortcode')

    at the very bottom under everything else so not to mess with another function.

    Both times I got errors like

    Parse error: syntax error, unexpected T_STRING in /my stuff/wp-content/plugins/woocommerce/woocommerce-functions.php on line 1737

    Thank for the help and any thoughts on what I'm doing wrong?

    BTW: I did a bit of research and read about adding functions to the shortcodes.php and got the same error.

    Thanks
    Kimberly

  6. Kimber254
    Member
    Posted 11 months ago #

    Do the shortcodes go in the theme?

    Thanks

  7. Kimber254
    Member
    Posted 11 months ago #

    I use below following the tutor I found so I could learn to make my own shortcodes but it doesn't work. I did find out how to put functions.php in my child theme.

    // Add Shortcode
    function download_shortcode() {

    // Code
    return '';
    }
    add_shortcode( 'my-download.php', 'download_shortcode' );

  8. Kimber254
    Member
    Posted 11 months ago #

    One last posting tonight. I found woocommerce_available_download_link filter but could really use some advice how to use it.

  9. wpgeekster
    Member
    Posted 11 months ago #

    The shortcodes.php in the Includes file is a core wp file. Don't mess with it. The functions.php file in the Includes folder or the one in the woocommerce plugin file are not the functions.php file you are looking for. The functions.php you are looking for is in your wp-content/themes folder. Some theme developers put custom php functionss in a different folder, but usually you can find it in the themes folder. So it will be in a folder like this:
    yourdomainname.com/wp-content/yourThemeName/functions.php

    If you are putting the code in the functions.php in the child theme, then that is the correct functions.php file

    Also, add the $atts array parameter to the function arguments. It may not need it, but it can't hurt. That way it will be there if it needs it. Do it like this:

    function ($atts){
    Paste all the code that you copied from the my-downloads.php file here.
    }
    add_shortcode( 'my-download.php', 'download_shortcode' );

    If you are working with a Wootheme, then they usually will put a comment in the functions.php file in that looks like this:

    /*-------------------------------------------------------------*/
    /* You can add custom functions below */
    /*-------------------------------------------------------------*/

    When you see it you will be in the right place. If your theme uses a different file to put custom functions in, it should refer to it in the functions.php file that is inside of your themes folder. For instance, one theme I work with has a line in the functions.php file like this:

    require_once locate_template('/lib/custom.php'); // Custom functions

    That means that the custom functions or shortcodes should be put in myThemeFolder/lib/custom.php file.

    In answer to your question: "Do the shortcodes go in the theme?"

    The short codes go in the page or post. Log into your wp dashboard. Then depending on whether you are trying to put your downloads on a Page or Post, click on the appropriate choice. If Downloads is a page, on the menu in the left sidebar click Page > Downloads. Then put your short code in the page editor just like any other text you want to show up in the content area of your page. You can put the short code in a template file, but I don't think that's what you want.

    after you add the short code function and add_shortcode() call and place the shortcode in your page, then refresh your website. If you get an error message then post it here.

    Today I forgot that I tried to help you here yesterday. So tomorrow I will try to remember to check back and see how you are progressing.

  10. Kimber254
    Member
    Posted 11 months ago #

    Thank so very much. I get it a lot better now.

  11. Kimber254
    Member
    Posted 11 months ago #

    I thought I understood but I keep getting errors. I decided to switch gears for one day to see if it helped to take a step back and try again tomorrow. I really want to learn short codes but I really only need available download to show on one page. I decided to spend today reading up on hooks since I found hook woocommerce_available_download_link to file my-downloads.php at http://docs.woothemes.com/document/hooks/

    I thank you for all your help. Shortcodes are on my list to learn but not today :)
    Kimberly

  12. wpgeekster
    Member
    Posted 11 months ago #

    The problem is not how you are using the shortcode. If you use an action hook the same exact thing will happen. The problem is with the function. Copy and paste the function that I have provided here into your functions.php file and let me know if you still get an error. If you don't get an error, then put the short code in your page or post content like this: [downloads]
    Let me know if it works.

  13. Kimber254
    Member
    Posted 10 months ago #

    Hi, sorry it too me so long to get back to you. A charity event which will thank goodness be over this week took over my life.

    I tried your codes and it till takes down my web site no matter how I do this.

    I'm putting this functions.php in the wp-content/themes/responsive-childtheme-pro-child-theme folder

    Thoughts?

  14. wpgeekster
    Member
    Posted 10 months ago #

    No problem. Are you using a wootheme? If so, then which wootheme are you using? If not, let me know what theme you are using. When it breaks the website, does it give you an error message? If so, then post it here. Also, copy and paste the file that the error code refers to in the ubuntu paste bin http://paste.ubuntu.com/ and click on the paste button at the bottom. Post the link that the paste bin generates in here.

    So go ahead and put the code back in functions.php and break your site so you can get the error message and paste it here. Then copy and paste the file that is referred to in the error message in the ubuntu pase bin and put the link here.

Reply

You must log in to post.

About this Plugin

About this Topic