• Resolved Dani Harp

    (@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.

    https://www.ads-software.com/plugins/woocommerce-pdf-invoices-packing-slips/

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

    (@pomegranate)

    Hello Dani,
    I think you’re using another plugin: https://www.ads-software.com/support/plugin/woocommerce-delivery-notes

    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!
    Ewout

    Thread Starter Dani Harp

    (@dani-harp)

    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 Contributor Ewout

    (@pomegranate)

    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!
    Ewout

    Thread Starter Dani Harp

    (@dani-harp)

    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:
    https://www.reformasyservicios.es/wp-content/themes/Avada/images/a.gif
    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=”https://www.reformasyservicios.es/wp-includes/images/euro3.png&#8221; 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>No.factura</b><small></br>’.$num_factura.'</small></br></br><b>No.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

    Thread Starter Dani Harp

    (@dani-harp)

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

    Thread Starter Dani Harp

    (@dani-harp)

    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>No.factura</b><small></br>'.$num_factura.'</small></br></br><b>No.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>';
    		}else{
    			$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="https://www.reformasyservicios.es/wp-includes/images/euro3.png" width="100" height="100"></span></a>';
    		}
    		return $text;
    	}
    
    add_shortcode('registro_reformas_compradas','regrefcomp');
    Thread Starter Dani Harp

    (@dani-harp)

    includes/class-wcpdf-export.php

    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 Contributor Ewout

    (@pomegranate)

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.