Cart PDF for WooCommerce

توسط

Adds ability for users and guests to download their WooCommerce cart as PDF. Useful for many cases such as if a user needs a quote before completing purchase.

Features

  • Full PDF template customization
  • Send copy of each generated cart PDF to admin
  • Capture customer / guest information from checkout and display on generated PDF
  1. Upload plugin and then activate
  2. Ensure WooCommerce is installed and activated as well

سوالات متداول

How to view or open PDF instead of download?

Add the following code snippet to your themes functions.php:

function child_theme_wc_cart_pdf_destination( $dest ) {
    if ( class_exists( 'WCCartPDFMpdfOutputDestination' ) ) {
        $dest = WCCartPDFMpdfOutputDestination::INLINE;
    }

    return $dest;
}
add_filter( 'wc_cart_pdf_destination', 'child_theme_wc_cart_pdf_destination' );

How to require user to be logged in to download cart as PDF?

Add the following code snippet to your themes functions.php:

/**
* Remove the default download cart button
*/
remove_action( 'woocommerce_proceed_to_checkout', 'wc_cart_pdf_button', 21 );


/**
* Replace the default download cart button with our own logic to display a login notice for guests
*/
function child_theme_wc_cart_pdf_button() {
    if( ! is_cart() || WC()->cart->is_empty() ) {
        return;
    }

    if ( is_user_logged_in() ) :
    ?>

    <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'cart-pdf' => '1' ), wc_get_cart_url() ), 'cart-pdf' ) );?>" class="cart-pdf-button button" target="_blank">
        <?php esc_html_e( 'Download Cart as PDF', 'wc-cart-pdf' ); ?>
    </a>

    <?php else : ?>

    <p><a href="<?php echo get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ); ?>" class="cart-pdf-login"><?php esc_html_e( 'Please login to download your cart as a PDF', 'wc-cart-pdf' ); ?></a></p>

    <?php 
    endif;
}
add_action( 'woocommerce_proceed_to_checkout', 'child_theme_wc_cart_pdf_button', 21 );

Product images are not showing on PDF

Try adding the following to your wp-config.php file:

define( 'WC_CART_PDF_THUMBNAIL_COMPATIBILITY', true );

How can I customize the PDF template?

Copy the PDF template from the plugin folder wc-cart-pdf/templates/cart-table.php into your child theme folder child-theme/woocommerce/wc-cart-pdf/cart-table.php.

From there you can modify the PDF template in your child theme.

×
نظری برای این آیتم موجود نیست.
0 0 رای ها
امتیازدهی
اشتراک در
اطلاع از
0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
هیچ نسخه‌ای برای این آیتم موجود نیست.
★★★★★
★★★★★
5.0 /5 (25 نظر)

قیمت:

رایگان

نگارش

آخرین انتشار

13 اردیبهشت 1405

آخرین بروزرسانی

4 ماه پیش

نصب های فعال

1,000+

نگارش وردپرس

وردپرس 6.2+

تست شده از نسخه

وردپرس 6.8.5

نگارش PHP

PHP 8.0.0+

تگ ها

نسخه ها

0 نسخه