Title: Insert button anywhere
Last modified: April 29, 2022

---

# Insert button anywhere

 *  Resolved [Jorge Razor](https://wordpress.org/support/users/jorgehoffmann/)
 * (@jorgehoffmann)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/insert-button-anywhere/)
 * Is there a shortcode or something similar that generates the button anywhere 
   I want? I need to insert it in some places on my site. Thanks for your attention.
   This plugin is awesome e so easy to use 🙂 Congratz!

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

 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15605492)
 * [@jorgehoffmann](https://wordpress.org/support/users/jorgehoffmann/)
 * Hello
 * There is not a shortcode, rather a function to render the button. However you
   can use this to create a shortcode such as the following:
 *     ```
       function child_wc_cart_pdf_shortcode( $atts, $content = '' ) {
           if ( function_exists( 'wc_cart_pdf_button' ) ) {
               ob_start();
   
               wc_cart_pdf_button();
   
               return ob_get_clean();
           }
   
           return '';
       }
       add_shortcode( 'wc_cart_pdf_button', 'child_wc_cart_pdf_shortcode' );
       ```
   
 * Then you can use the shortcode **[wc_cart_pdf_button]**.
 *  Thread Starter [Jorge Razor](https://wordpress.org/support/users/jorgehoffmann/)
 * (@jorgehoffmann)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15608680)
 * Hello, thanks for the reply. Unfortunately the shortcode only works on the cart
   page, I guess because the function wc_cart_pdf_button is only called there by
   the plugin. If I am right, is there a way of calling this function on other pages
   thru functions.php?
 * Neither does this code works: add_action( ‘woocommerce_after_add_to_cart_form’,‘
   wc_cart_pdf_button’ );, for the same reason I think.
 * Thanks.
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15609260)
 * [@jorgehoffmann](https://wordpress.org/support/users/jorgehoffmann/) Ah yes you
   are right. Try the following shortcode instead:
 *     ```
       function child_wc_cart_pdf_shortcode( $atts, $content = '' ) {
           if ( function_exists( 'wc_get_cart_url' ) ) {
               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();
           }
   
           return '';
       }
       add_shortcode( 'wc_cart_pdf_button', 'child_wc_cart_pdf_shortcode' );
       ```
   
 *  Thread Starter [Jorge Razor](https://wordpress.org/support/users/jorgehoffmann/)
 * (@jorgehoffmann)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15612249)
 * All working good now. Thanks a lot for the replys and patience.
 * Now I can print almoust anything from any front-end page just by passing the 
   right parameters thru the URL.
 * Once again, congratulations on the plugin.
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15612272)
 * [@jorgehoffmann](https://wordpress.org/support/users/jorgehoffmann/) Neat, thanks!
 *  [margob](https://wordpress.org/support/users/margob/)
 * (@margob)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15884803)
 * Edit: sorry for the inconvenience, I already removed it with css 🙂
 * Hi David, thanks so much for this, working like a charm 🙂
    How can I remove 
   the automatically placed button? It’s below the page and I placed the new one
   with the shortcode on top of my page.
    -  This reply was modified 3 years, 10 months ago by [margob](https://wordpress.org/support/users/margob/).
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-15898108)
 * [@margob](https://wordpress.org/support/users/margob/) You can use the following
   code to remove the default placed button:
 * `remove_action( 'woocommerce_proceed_to_checkout', 'wc_cart_pdf_button', 21 );`
   `
   remove_action( 'woocommerce_review_order_before_payment', 'wc_cart_pdf_show_checkout');`
 *  [hassamsharik007](https://wordpress.org/support/users/hassamsharik007/)
 * (@hassamsharik007)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-16391713)
 * can please someone tell me where to put the functions provided here because I
   don’t know where to place that code and then start using my shortcode
 *  Plugin Author [David Jensen](https://wordpress.org/support/users/dkjensen/)
 * (@dkjensen)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-16393434)
 * [@hassamsharik007](https://wordpress.org/support/users/hassamsharik007/) You 
   can add the code to your child theme `functions.php` file or use a plugin like
   [Code Snippets](https://wordpress.org/plugins/code-snippets/).
 *  [Anuar](https://wordpress.org/support/users/anuarsaba/)
 * (@anuarsaba)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-16418971)
 * [@jorgehoffmann](https://wordpress.org/support/users/jorgehoffmann/) How would
   the HTML code be to pass those parameters? please an example
 * [@dkjensen](https://wordpress.org/support/users/dkjensen/) thanks
 *  Thread Starter [Jorge Razor](https://wordpress.org/support/users/jorgehoffmann/)
 * (@jorgehoffmann)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-16421367)
 * Hi, [@anuarsaba](https://wordpress.org/support/users/anuarsaba/) 🙂
 * I’ve created a form on the single product page that opens a bootstrap modal where
   the customer can choose between open the PDF in a new window or receive it by
   e-mail:
 *     ```wp-block-code
       <form id="orcamento-single-product-form" method="GET" action="<?php echo wc_get_cart_url(); ?>" target="_blank" class="w-100 br-24 mt-5 mt-lg-0">
       <?php wp_nonce_field('cart-pdf', '_wpnonce', false, true ); ?>
       <input class="d-none" type="text" readonly="readonly" name="cart-pdf" value="1" />
       <input class="d-none" type="text" readonly="readonly" name="pagina" value="2" />
       <input class="d-none" type="text" readonly="readonly" name="idproduto" value="<?php the_ID(); ?>" />
       <input class="d-none" type="text" readonly="readonly" id="precoproduto" name="precoproduto" value="" />
       <input class="d-none" type="text" readonly="readonly" id="emailorcamento" name="email" value="" />
       <button id="enviar-form-personalizacao" type="submit" class="d-none">BAIXAR ORÇAMENTO</button>
       <div class="divisor-texto mb-4 mt-3"></div>
       <a href="#" class="cor-roxo hover-roxo text-center text-lg-start d-inline-block w-100" title="Baixar orçamento" data-bs-toggle="modal" data-bs-target="#modal-orcamento-passo-1"><b>BAIXAR ORÇAMENTO ></b></a>
       <small id="orcamento-texto" class="d-none mb-4">*Selecione todos os componentes para habilitar o botão de orçamento.</small>
       </form>
       ```
   
 * Then I modified the code on the plugin file (not recommended, but needed to achive
   what I wanted it) plugins/wc-cart-pdf/wc-cart-pdf.php to menage the parameters
   and behave the way I wanted, generating the PDF on the browser or send it via
   email to the custumer (with wp_mail).
 * Hope this helps you.

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

The topic ‘Insert button anywhere’ is closed to new replies.

 * ![](https://ps.w.org/wc-cart-pdf/assets/icon-256x256.png?rev=3339735)
 * [Cart PDF for WooCommerce](https://wordpress.org/plugins/wc-cart-pdf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wc-cart-pdf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wc-cart-pdf/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-cart-pdf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-cart-pdf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-cart-pdf/reviews/)

 * 11 replies
 * 5 participants
 * Last reply from: [Jorge Razor](https://wordpress.org/support/users/jorgehoffmann/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/insert-button-anywhere/#post-16421367)
 * Status: resolved