• Hello,

    I am trying to include a function which runs ok in my-theme/functions.php. But when i copy the function in mail.class.php (this is where i need the function) it doesn’t work anymore?

    I have added these 2 functions in mail.class.php after modify_mail_operation() and i alter modify_mail_operation() a bit by
    $attachments = self::render_tickets();

    to test with but i doesn’t work. The pdf isn’t generated it looks like generate_pdf doesn’t work. If however i call eticket.class.php from another file it works as expected.

    any pointers, tips?

    static function render_tickets(){
    			/**
    			* some dummy static data to test with, should be the purchase data
    			*/
                $data['ticket-name'] = 'Nike';
     			$data['ticket-address'] = 'beaverton';
    
                $pdf_filename = self::generate_pdf($data);
                //store a copy in a seperate folder
                copy(WP_CONTENT_DIR .'/uploads/tickets-tmp/'.$pdf_filename, WP_CONTENT_DIR .'/uploads/tickets/'.$pdf_filename);
                return $pdf_filename;
            }
    
    		 static function generate_pdf($data) {
            //using xampp so set root
            $docRoot = $_SERVER["DOCUMENT_ROOT"] . '/mydomain.com';
            //temp store the pdf
            if(!defined('COUPON_UPLOAD_PATH')) {
            define ('COUPON_UPLOAD_PATH',$docRoot.'/site/wp-content/uploads/tickets-tmp');
            }
            // Include the main TCPDF library (search for installation path).
            require_once( $docRoot . '/tcpdf_min/config/lang/en.php' );
            require_once( $docRoot . '/tcpdf_min/tcpdf.php' );
            require_once( $docRoot . '/tcpdf_min/tcpdf_barcodes_2d.php' );
            // include 1D barcode class (search for installation path)
            require_once( $docRoot . '/tcpdf_min/tcpdf_barcodes_1d.php');
    
            require_once('eticket.class.php');
    
            $pdf = new FACTUURETICKET2014($data, 'P', 'mm', 'A4');
    		// set document information
            $pdf->SetCreator(PDF_CREATOR);
    		//etc more tcpdf specific details
            if ($data['num-of-tickets'] > 1) {
                //aanvrager
                $pdf->make_eticket($data);
    
            } 
    
            # Output the PDF document. F to save I inline
            $pdf->Output('/site/wp-content/uploads/tickets-tmp/eticket-' . $data['ticket-barcode'] . '.pdf', 'F');
        }

    Anyone some tips?

    http://wordpress.org/plugins/wp-e-commerce-style-email/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter DDT

    (@ddt)

    hmm i have enable debug.log and i see

    Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\my-domain.com\site\wp-content\plugins\wp-e-commerce-style-email\mail.class.php:497) in C:\xampp\htdocs\lotusbeurs.nl\tcpdf_min\tcpdf.php on line 7579

    on 497 it reads
    $pid_end = stripos($message, '!ecse! -->', $purch_id_start+1) - 1;

    Can i by pass this so first the pdf is created?

    Thread Starter DDT

    (@ddt)

    Ok found a solution with static data. Now i need to use the purchase data ECSE_purchase::

    Will post some code tomorrow fyi, *beer needed

    Plugin Author Jacob Schwartz

    (@mightyturtle)

    Hi,

    I appreciate your enthusiasm for your project, but I’d recommend not putting your custom code inside my plugin. The main reason is that when I do updates to my plugin, you’ll need to re-integrate your code every time.

    Jacob

    Thread Starter DDT

    (@ddt)

    hi Jacob,

    i hear you and i have created an own class with some functions (i put it in your wp-e-commerce-style-email folder for my own convenience)

    For this particular project i do however have one for me urgent question: Is there a way to alter modify_mail_operation($vars) function so that the attachment is only sent when the Payment status is accepted.
    I am having a problem that the attached ticket.pdf is directly send when a user selects manual payment. In my process i like to sent the attachment as soon as i set the payment to accepted in WP admin dashboard (need to make sure the money is manual payed)

    How can i use your $vars within the function to check if it’s a Purchase Receipt?

    tried

    case __( 'Purchase Receipt', 'wpsc' ):
                                     $attachments = array(WP_CONTENT_DIR . '/uploads/tickets/'.ETICKETDATA::render_tickets());// hack

    `
    and

    if($subject == __( 'Purchase Receipt', 'wpsc' )){
                      $attachments = array(WP_CONTENT_DIR . '/uploads/tickets/'.ETICKETDATA::render_tickets());//hack
                    }

    Any ideas?

    regards

    Thread Starter DDT

    (@ddt)

    Ok seems simple this works, not very dynamic but good for now

    if($subject == "Invoice"){
                      $attachments = array(WP_CONTENT_DIR . '/uploads/tickets/'.ETICKETDATA::render_tickets());//hack
                    }

    tx

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trying to add my own functio to the plugin?’ is closed to new replies.