• Resolved angelmorillo

    (@angelmorillo)


    Hello, congratulations on your plugin.

    I have a question

    I need pdf cart button in woocommerce block cart

    how could i do it`

    • This topic was modified 4 years, 4 months ago by angelmorillo.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author David Jensen

    (@dkjensen)

    Hello @angelmorillo

    This should be possible. Are you able to take a screenshot and point where you would like the button added to?

    Thread Starter angelmorillo

    (@angelmorillo)

    View post on imgur.com

    I have the button, but in a way that I don’t like.

    The situation is that the woocommerce blocks cart does not add the pdf button, but the woocommerce vanilla cart does, what I did was add a block below the total to pay and delete everything with css and just leave the pdf cart button.

    Is there a way to add it normally to the woocommerce blocks plugin so I don’t have that invention I made on my cart page?

    Plugin Author David Jensen

    (@dkjensen)

    So are you just wanting it to display below the proceed to checkout button natively without custom code?

    Thread Starter angelmorillo

    (@angelmorillo)

    I am wondering if there is a way to place the button below proceed to checkout from woocommerce blocks, or how I would do to have the cart pdf button anywhere in my cart

    Thread Starter angelmorillo

    (@angelmorillo)

    View post on imgur.com

    I would like to have the button here

    I use the gutenberg woocommerce blocks plugin

    Plugin Author David Jensen

    (@dkjensen)

    @angelmorillo

    I tested how to do this a bit, I ended up going with this approach. Create a shortcode in your child theme functions.php file, or in a plugin or a “Code Snippets” type of plugin. This shortcode will then be used to render the PDF button.

    add_shortcode( 'wc_cart_pdf_button', function( $atts, $content ) {
    	ob_start();
    
    	?>
    
    	<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 echo esc_html( get_option( 'wc_cart_pdf_button_label', __( 'Download Cart as PDF', 'wc-cart-pdf' ) ) ); ?>
    	</a>
    
    	<?php
    
    	return ob_get_clean();
    } );

    Now I recorded a screen capture of how I was able to place the PDF button under the proceed to checkout button:

    https://www.loom.com/share/4ad64d2bf25242b69e140ef52559fa61

    Let me know if this helps or not

    Thread Starter angelmorillo

    (@angelmorillo)

    Thanks bro! it helped me a lot, very useful, thanks for the support

    Plugin Author David Jensen

    (@dkjensen)

    Anytime 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘WC Blocks’ is closed to new replies.