• Hello,

    i would like to add your button to my woocommerce cart widget.
    I tried hook it in:

    add_action( ‘woocommerce_before_mini_cart_contents’, ‘wc_cart_pdf_button’ );

    Doesn’t work, what do you recommend? Can I add it via a shortcode in my widget or via php directly in the template?

    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author David Jensen

    (@dkjensen)

    Hello

    Currenty the wc_cart_pdf_button functions checks if the user is on the cart page, but you can manually display the button in the mini cart using the following in your child theme functions.php file

    function child_theme_wc_cart_pdf_mini_cart() {
        ?>
    
        <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( get_option( 'wc_cart_pdf_button_label', __( 'Download Cart as PDF', 'wc-cart-pdf' ) ) ); ?>
        </a>
    
        <?php
    }
    add_action( 'woocommerce_before_mini_cart_contents', 'child_theme_wc_cart_pdf_mini_cart' );
    • This reply was modified 4 years, 2 months ago by David Jensen.
    Plugin Author David Jensen

    (@dkjensen)

    You also might need to clear your browser local storage after adding this code snippet

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woo Mini Cart Widget’ is closed to new replies.