Support » Plugin: WooCommerce PDF Invoices & Packing Slips » 'You don't have sufficient permissions..' on printting invoice from shortcode

  • Resolved Dani Harp


    Hi. I’ve read that next solution:
    “You may wish to open /classes/class-wcdn-print.php and comment out these two blocks:
    if( !is_admin() ) {
    wp_die( __( ‘You do not have sufficient permissions to access this page.’ ) );

    if( !current_user_can( ‘manage_woocommerce_orders’ ) && !current_user_can( ‘edit_shop_orders’ ) ) {
    wp_die( __( ‘You do not have sufficient permissions to access this page.’ ) );
    But neither I find out the file, nor these lines at the plugin folder…

    What I mean to do, is just to print or/and put to dowload the ‘invoicefromthe userlogged.pdf’ at the frontend. I have the id_order, user_id, etc.

    Thank you in advance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Ewout


    Hello Dani,
    I think you’re using another plugin:

    because that’s what this is referring to. The PDF invoice plugin doesn’t have a shortcode.
    Also, I would definitely not remove all those permissions checks, otherwise anyone would be able to access the invoices from outside…

    Good luck!

    Hi, you actually answered my question by email. I have installed WooCommerce PDF Invoices & Packing Slips and WooCommerce Print Invoice/Packing list.

    Is there any way to print or to download the logged user’s invoices through any filter or hook used at my own shortcode at functions.php? Sorry if I didn’t explain myself correctly before, and thanks for the prompt answer!

    Plugin Author Ewout


    Hello Dani,
    I think you must be mistaking me for someone else, I don’t think I have received an email from you! “/classes/class-wcdn-print.php” is not part of this plugin.

    I think the item “How can I add a download link to the invoice on the Thank you page?” in the FAQ should get you on track, but note that this only works for logged in users. It’s simply not possible for non logged in users to create a PDF because it would be a major security risk.

    Hope that helps!

    Hello Ewout.
    It’s a logged user in fact who must able to download his invoices. I tryed with the code from “How can I add a download link to the invoice on the Thank you page?”, but not as a filter, so I’ve write the next code at functions.php, where I need to add the .pdf’s links from each invoce on each row:
    Here is a preview:
    And here the code (Hope the backticksdoesn’t execute it…)
    ” // Factura
    $num_factura = $results->idfactura;

    if ( is_user_logged_in() ) {
    $pdf_url = wp_nonce_url( admin_url( ‘admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=’ . $num_factura . ‘&my-account’), ‘generate_wpo_wcpdf’ );
    $text = ‘<span><img border=”0″ alt=”Factura” src=”” width=”100″ height=”100″></span>‘;

    $html= ‘<tr>’;
    $html .= ‘<td width=”4%” align=”left” valign=”top” bordercolor=”#017dc5″><small>’. $num_compra.'</small></span></td>’;
    $html .= ‘<td width=”14%” align=”center” valign=”top” bordercolor=”#017dc5″><small>’. $fech.'</small></td>’;
    $html .= ‘<td width=”60%” valign=”top” bordercolor=”#017dc5″>Asunto</br><small>’.$asunto.'</small></br></br>Descripción</br><small>’.$refma[0].'</small></br></br>Contacto</br><small> ■ <b>Nombre</b> – ‘.$nombre.'</br> ■ <b>Localización</b> – ‘.$localizacion.'</br> ■ <b>Email</b> – ‘.$email.'</br> ■ <b>Tel</b> – ‘.$tel.'</br> ■ <b>Urgencia para empezar</b> – ‘.$urgencia.'</br> ■ <b>Preferencia</b> – ‘.$preferencia.'</br> ■ <b>Horario contacto</b> – ‘.$horario.'</small></br></br></td>’;
    $html .= ‘<td width=”12%” align=”center” valign=”top” bordercolor=”#017dc5″><small>’.$text.'</br><b>Nº.factura</b><small></br>’.$num_factura.'</small></br></br><b>Nº.reforma</b><small></br>’.$refr.'</small></br></small></td>’;
    $html .= ‘<td width=”10%” align=”center” valign=”top” bordercolor=”#017dc5″><small>’. $prc .’ € </small></td>’;
    $html .= ‘</tr>’;

    $data_html .=$html;

    Thousand thanks by the way Ewout

    So, the respond’s page says: “No tiene suficientes permitos para acceder a esta página”

    I’ve rewrite this but still the display: “You don’t have sufficient permissions to view this page”.

    $fac = wpo_wcpdf_thank_you_link( "", $num_factura );
    			$html= '<tr>';
    			$html .= '<td width="4%" align="left" valign="top" bordercolor="#017dc5"><small>'. $num_compra.'</small></span></td>';
    			$html .= '<td width="14%" align="center" valign="top" bordercolor="#017dc5"><small>'. $fech.'</small></td>';
    			$html .= '<td width="60%" valign="top" bordercolor="#017dc5"><strong>Asunto</strong></br><small>'.$asunto.'</small><strong></br></br>Descripción</strong></br><small>'.$refma[0].'</small></br></br><strong>Contacto</strong></br><small> ■ <b>Nombre</b> - '.$nombre.'</br> ■ <b>Localización</b> - '.$localizacion.'</br> ■ <b>Email</b> - '.$email.'</br> ■ <b>Tel</b> - '.$tel.'</br> ■ <b>Urgencia para empezar</b> - '.$urgencia.'</br> ■ <b>Preferencia</b> - '.$preferencia.'</br> ■ <b>Horario contacto</b> - '.$horario.'</small></br></br></td>';
    			$html .= '<td width="12%" align="center" valign="top" bordercolor="#017dc5"><small>'.$fac.'</br><b>Nº.factura</b><small></br>'.$num_factura.'</small></br></br><b>Nº.reforma</b><small></br>'.$refr.'</small></br></small></td>';
    			$html .= '<td width="10%" align="center" valign="top" bordercolor="#017dc5"><small>'.  $prc .' € </small></td>';
    			$html .= '</tr>';
    			$data_html .=$html;
    		$page_links = paginate_links( array(
    			'base' => add_query_arg( 'paged1', '%#%' ),
    			'format' => '?paged1=%#%',
    			'prev_text' => '&laquo;',
    			'next_text' => '&raquo;',
    			'total' => $num_of_pages,
    			'current' => $paged1 ) );
    		if ( $page_links ) {
    			$data_html.= '</table>' . '<p><div align="center">' . $page_links . '</div></p>';
    			$data_html.= '</table>';
    		// Punto de Interrupción
    		// $data_html .= 'Pag: ' . $_POST['paged1'] . ', s: ' . $paged1;
    		return $data_html;
    	add_filter('woocommerce_thankyou_order_received_text', 'wpo_wcpdf_thank_you_link', 10, 2);
    	function wpo_wcpdf_thank_you_link( $text, $order ) {
    		if ( is_user_logged_in() ) {
    			$pdf_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=' . $order . '&my-account'), 'generate_wpo_wcpdf' );
    			$text .= '<a href="'.esc_attr($pdf_url).'"><span><img border="0" alt="Factura" src="" width="100" height="100"></span></a>';
    		return $text;


    Into this file are my solution for this issue…

    wp_die( __( ‘You do not have sufficient permissions to access this page.’, ‘wpo_wcpdf’ ) );

    … to comment.

    That’s it. Thanks again Ewout, you definatly put me in the track!!!!!

    Plugin Author Ewout


    Awesome! I’d appreciate a review if you have the time!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘'You don't have sufficient permissions..' on printting invoice from shortcode’ is closed to new replies.