<?php
//PDF Attachment
$pdfoc = new OCPDF();
$pdfoc->SetCustomerOrderNo($data->customer_order_no);
$pdfoc->SetCustomerNo($data->customer->name);
$template = trim(hikashop_getLayout($view,'address_template',$params,$js));
if(!empty($data->cart->billing_address)){
$billing = $template;
foreach($data->order_addresses_fields as $field){
$fieldname = $field->field_namekey;
$address =& $data->order_addresses[$data->cart->billing_address->address_id];
$billing=str_replace('{'.$fieldname.'}',$fieldsClass->show($field,$address->$fieldname),$billing);
}
$billing = str_replace(array("\r\n","\r","\n"),"\n",preg_replace('#{(?:(?!}).)*}#i','',$billing));
$pdfoc->SetCustomerBillingAddress($billing);
}
$ordercurrency = $currencyHelper->getCurrencies($data->order_currency_id,$null)[1]->currency_symbol;
$pdfoc->SetOrderCurrency($ordercurrency);
$pdfoc->AddPage();
foreach($data->cart->products as $item){
$pdfoc->AppendProduct(strip_tags($item->order_product_name),$item->order_product_code,$item->order_product_price,$item->order_product_quantity);
}
if(bccomp($data->order_shipping_price,0,5)){
$pdfoc->AppendShipping($data->order_shipping_price);
}
$pdfoc->PrintTotal($data->cart->full_total->prices[0]->price_value_with_tax);
$pdfoc->AliasNbPages();
$pdfoc->Output("/Applications/MAMP/htdocs/pdfoc/Summary-".$data->order_number.'.pdf',"F");
$attachObj = null;
$attachObj->name = 'MetaSystems-Summary-'.$data->order_number.'.pdf';
$attachObj->filename = "/Applications/MAMP/htdocs/pdfoc/Summary-".$data->order_number.'.pdf';
$attachObj->url = 'localhost:8888';
$mail->attachments = array($attachObj);
?>