• Resolved ozgursar

    (@ozgursar)


    I’m using the following codes in my custom template.
    It was working fine until one of the latest plugin o woocommerce updates has broken it.

    <?php $wpo_wcpdf->shop_name(); ?>
    <?php $wpo_wcpdf->shop_address(); ?>

    What are the most up-to-date version of these functions?
    Could you help me with the syntax please…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! In legacy mode the function is still supported, it just gives a deprecation notice:

    The $wpo_wcpdf->shop_name() function is deprecated since version 2.0. Replace with $this->shop_name()!

    Which is also the answer to your question. More information/background in the beta announcement from back in June:
    https://wpovernight.com/2017/06/woocomerce-pdf-invoice-2-0-beta-testers-wanted/

    If you want to suppress all deprecation notices, you can add this to your theme functions.php:

    
    add_filter( 'wcpdf_disable_deprecation_notices', '__return_true' );
    

    Hope that helps!
    Ewout

    Thread Starter ozgursar

    (@ozgursar)

    Hello,
    I’m getting this error now. I was able to use it $wpo_wcpdf-> instead of $this previously.

    Fatal error: Using $this when not in object context in /wp-content/themes/theme-name/filename.php on line 00

    I create this page on the checkout stage where user selects the payment method. Using dynamic shop name and address I’m creating a dynamic terms and conditions text that user should click and confirm. This php is called using iframe into the checkout step.

    Plugin Contributor Ewout

    (@pomegranate)

    Ah I see… This function should not be used outside of the PDF invoice context. If you really want to use those settings values you can use:

    
    $pdf_settings = WPO_WCPDF()->settings->get_common_document_settings();
    $shop_name = !empty($pdf_settings['shop_name']['default']) ? $pdf_settings['shop_name']['default'] : '';
    echo $shop_name;
    

    But I would advise you to not make this dependent of the PDF invoice settings.

    Ewout

    Thread Starter ozgursar

    (@ozgursar)

    OK it works now. Thank you very much for great support!

    Best Regards
    Ozgur

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘$wpo_wcpdf->shop_name(); causes error’ is closed to new replies.