ruạṛ
<?php /** * output printable version of an order (cart) * generally needed on successful print from a payment gateway * centralised here because at time of writing (2012-05-31) this code was common to * - /processes/process-place-order.php * - /paypal_print_true.php * - /catch-credit-card.php (DPS) * and also needed included in other scripts for some sites * * This include assumes that $cart has already been created and filled in the appropriate scope * This include assumes that $script_text if required will have been defined */ /** * @var string $print html to return */ $print = '<div class="print" id="print-order"> <h1>'.SITE_FROM_NAME.' order '.$reference.'</h1> '.$script_text.' <table cellpadding="0" cellspacing="0"> <thead> <tr> <th>Product Name</th> <th>Options</th> <th>Quantity</th> <th>Price</th> </thead> <tfoot> <tr> <th>Items Total</th> <td> </td> <td>'.$cart->num_items.'</td> <td>'.format_price($cart->cart_total).'</td> </tr> '; $print .= ($cart->discount_code != '') ? '<tr> <th>Discount code</th> <td>'.$cart->discount_code.' ('.$cart->discount_format().')</td> <td> </td> <td> - '.format_price($cart->discount_amount).'</td> </tr> ' : ''; $print .= ($cart->ship_id) ? ' <tr> <th>Shipping</th> <td>'.$cart->shipping_location .'</td> <td> </td> <td>'.format_price($cart->shipping_cost).'</td> </tr> ' : ''; $print .= '<tr> <th>Total</th> <td> </td> <td>'.$cart->num_items.'</td> <td>'.format_price($cart->order_total(),2).'</td> </tr> </tfoot> <tbody> '; foreach($cart->products as $pid => $p) { $path = $p->path; $pname = $p->name; $pdescrip = $p->short; $pqty = $p->quantity; $pprice = format_price($p->price*$pqty,2); $dir = '/resources/images/product/'.$pid.'/'; $print .= '<tr> <th valign="top"> '.$pname.' </th> <td valign="top"> '; $hasOpt = false; foreach($p->selected as $o=>$opt) { if($opt != '') { $print .= $o.': '.$opt.' <br /> '; $hasOpt = true; } } if(!$hasOpt){ $print .= ' '; } $print .= ' </td> <td valign="top"> '.$pqty.' </td> <td valign="top"> '.$pprice.' </td> </tr> '; } //end foreach $print .= ' </tbody> </table> <h2>Dispatch to:</h2> <p>'.$cart->customer['name'].'<br />'.nl2br(str_replace('\r\n',"\n",$cart->customer['delivery_address'])).'</p> <h2>Delivery instructions:</h2> <p>'.nl2br(str_replace('\r\n',"\n",$cart->customer['delivery_instructions'])).'</p> <h2>Contact details</h2> <p>Email: '.$cart->customer['email'].'<br /> Phone: '.$cart->customer['phone'].'</p> </div><!-- end print --> '; return $print; ?>
cải xoăn