• Hi,
    I am trying to use the Print This Section plugin with WP-Invoice and have been stuggling for days now trying to figure out where the problem is?

    With Both WP-invoice installed and working and WP Print This section also installed and working. On my Invoice page i have used
    [print_this]
    [wp-invoice]
    [/print_this]

    This displays perfectly the WP-invoice shortcode is read and processed and displays inside the Print this section box.

    The problem is when i click the “Print This” button the page that opens up actually displays the text [wp-invoice] and not the actual invoice ?

    I have been all over the net and tried many things to do with nested shortcodes, from what i can tell I need a “do_shortcode($content)” somewhere but i cant figure out where?

    A link to the sample invoice and problem:
    https://www.yourtechally.com/client-login/invoice-online/?invoice_id=ef77a582808c0973b62d79f40059ce30

    Any help would be greatly appreciated
    Kind regards
    Mark

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not sure of the correct answer, but this is what I’d try.

    The print_this shortcode handler function probably has something like return $output; at its end. This needs to be changed to return do_shortcode($output); to cause contained shortcodes to be expanded before being returned.

    When you update the Print This Section plugin, you’ll need to reapply this hack.

    Thread Starter format19

    (@format19)

    Thanks for responding, I have read this a thousand times now over the last few days….. ?? its what every one says, but unfortunately I can not find anywhere to do this in the PHP file ?

    I have pasted the code from the PHP file so you can see, https://www.yourtechally.com/print-this-section-help/

    I tried line 36
    echo do_shortcode($content)
    but that didnt work

    I think it might be further down, line 67
    href=”#Print” onclick=”window.print(); return false;”

    but im not sure what to edit….?
    there is no where in any of the code that has $output

    Thanks
    M

    Moderator bcworkz

    (@bcworkz)

    Sorry I was not more clear, $output was just an example variable that I made up. I am unfamiliar with this plugin and have no idea what variables are used.

    I do not see anything that looks like a shortcode handler in the code you posted, so this may not be the right place? Thinking a bit harder about how this plugin may work, the shortcode handler return line that I first suggested is probably not the right place either. Look for a code that looks like this, except for the ???function_name??? part:
    add_shortcode('print_this','???fucntion_name???');

    The place to add the do_shortcode() function will be somewhere in the function definition named in the above code in place of '???fucntion_name???'. Being unfamiliar with the plugin, I can’t be more specific.

    Thread Starter format19

    (@format19)

    HI bcworkz
    again thanks for you response…. I have spent another few hours over a few days going over this, I had a good look through the code for the plugin to try and understand it a bit better.

    I have tried everything I can think of as far as i can see the main code (the function code) and the main code for print this is fine, the only place its not working is on the actual “printable” page this seems to all be controlled by the print-this.php this contains both the php code for stripping out the printable info from the non print info and also the HTML to display on screen.

    There is one line where it gets the content using
    <?php extract_content(); ?>
    It is this line that i think is causing the issue, by using this function it returns the words “[wp-invoice]” instead of treating that as a shortcode and returning the contents of the invoice?

    Is there any chance you can have another quick look through the code
    I have updated the details here
    https://www.yourtechally.com/print-this-section-help/

    There is also a link at the top of the right hand column to the files if thats easier?

    I really want to have this working but at this point have spent hours at it, the WP invoice people say its not their problem, the writer of the Print-this section plugin doesnt respond and appears to have given up on the plugin anyway… but I cant find any other product that does this, my only other option is to not have a printable invoice ??

    Thanks
    M

    Moderator bcworkz

    (@bcworkz)

    Thank you for the file download, it was most helpful. I easily found the part that works correctly (big deal, eh?), the part that generates the printable content is not so obvious. So I’ll take your word for it, as you spent way more time on this. It’s not that I did not trust your interpretation, I was trying to avoid falling into the same logic trap you may have by finding my own way. Except that I got lost :/

    I report all this just so you understand the veracity of the following suggestion. The final line (line 36) of the extract-content() function echoes out the content to the browser. Try changing it to this:
    echo do_shortcode($content);

    Fingers crossed…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Nested Shortcode – WP-Invoice and WP Print this section half working’ is closed to new replies.