Support » Plugin: WooCommerce Cart PDF » Button: PDF ICON instead of text “Download cart to PDF”

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

    (@dkjensen)

    Hello

    Can you try the following CSS

    a.button.cart-pdf-button {
        appearance: none;
        background: url( 'https://test.pahedomotica.nl/wp-content/uploads/pdf-logo-50px.png' );
        background-size: cover;
        width: 50px;
        height: 50px;
        display: inline-block;
        text-indent: -500px;
        overflow: hidden;
        vertical-align: middle;
        font-size: 0px;
    }
    pahedomotica

    (@pahedomotica)

    You are good, that works.
    Is it possible to add a “alt” and “tittle” tekst? on hover it’s now grey and no icon.
    See: https://test.pahedomotica.nl/winkelmand/

    Thanks Paul

    Plugin Author David Jensen

    (@dkjensen)

    Yeah you would have to add something like this to your functions.php:

    function child_wc_cart_pdf_button() {
        if( ! is_cart() || WC()->cart->is_empty() ) {
            return;
        }
        
        ?>
    
        <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" target="_blank" title="<?php esc_attr_e( 'Your title here', 'wc-cart-pdf' ); ?>">
            <img src="//test.pahedomotica.nl/wp-content/uploads/pdf-logo-50px.png" alt="<?php esc_attr_e( 'Alt tag here', 'wc-cart-pdf' ); ?>" width="50" height="50" />
        </a>
    
        <?php
    }
    add_action( 'woocommerce_proceed_to_checkout', 'child_wc_cart_pdf_button', 21 );
    remove_action( 'woocommerce_proceed_to_checkout', 'wc_cart_pdf_button', 21 );

    You probably won’t need the additional CSS I provided earlier

    pahedomotica

    (@pahedomotica)

    This one doesn’t change it, also the icon is gone when I disable the earlyer added css code.

    Plugin Author David Jensen

    (@dkjensen)

    Oops I modified the code above, please copy the new code above and try again.

    pahedomotica

    (@pahedomotica)

    ๐Ÿ™ sorry, still no change.

    Plugin Author David Jensen

    (@dkjensen)

    Hmm it’s working on my end. Are you placing the code in your child themes functions.php?

    pahedomotica

    (@pahedomotica)

    My mistake!
    I had this to move the button to the top:
    remove_action( ‘woocommerce_proceed_to_checkout’, ‘wc_cart_pdf_button’, 21 );
    add_action( ‘woocommerce_before_cart’, ‘wc_cart_pdf_button’ );

    Plugin Author David Jensen

    (@dkjensen)

    Alright cool, you can remove the green background by removing the ‘button’ class from the a element.

    pahedomotica

    (@pahedomotica)

    Is it possible to move it also to the top ๐Ÿ™‚

    Plugin Author David Jensen

    (@dkjensen)

    Yes just replace this line:

    add_action( 'woocommerce_proceed_to_checkout', 'child_wc_cart_pdf_button', 21 );

    With this:

    add_action( 'woocommerce_before_cart', 'child_wc_cart_pdf_button' );

    pahedomotica

    (@pahedomotica)

    Thanks it works ๐Ÿ™‚

    Plugin Author David Jensen

    (@dkjensen)

    Ok great

    pahedomotica

    (@pahedomotica)

    Can you point me in the right direction for this (where to do) ๐Ÿ™‚
    you can remove the green background by removing the โ€˜buttonโ€™ class from the a element.

    Plugin Author David Jensen

    (@dkjensen)

    In the code I gave you previously to paste in your functions.php:

    <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" title="<?php esc_attr_e( 'Your title here', 'wc-cart-pdf' ); ?>">
            <img src="//test.pahedomotica.nl/wp-content/uploads/pdf-logo-50px.png" alt="<?php esc_attr_e( 'Alt tag here', 'wc-cart-pdf' ); ?>" width="50" height="50" />
        </a>

    Change class="cart-pdf-button button"

    To class="cart-pdf-button"

Viewing 15 replies - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.