public static function notify($order_id) { global $sunshine; $data = maybe_unserialize(get_post_meta($order_id, '_sunshine_order_data', true)); $order_items = maybe_unserialize(get_post_meta($order_id, '_sunshine_order_items', true)); $discount_items = maybe_unserialize(get_post_meta($order_id, '_sunshine_order_discounts', true)); // Send confirmation email $th_style = 'padding: 0 20px 5px 0; border-bottom: 1px solid #CCC; text-align: left; font-size: 10px; color: #999; text-decoration: none;'; $td_style = 'padding: 5px 20px 5px 0; text-align: left; font-size: 12px;'; $items_html = ''; $items_html = apply_filters('sunshine_before_order_receipt_items', $items_html, $order_id, $order_items); $items_html .= '<div class="order-items"><h3 style="font-size: 14px;">' . __('Cart Items', 'sunshine') . '</h3>'; $items_html .= ' <table border="0" cellspacing="0" cellpadding="0" width="100%">'; $items_html .= ' <tr><th style="' . $th_style . '">' . __('Image', 'sunshine') . '</th><th style="' . $th_style . '">' . __('Name', 'sunshine') . '</th><th style="' . $th_style . '">' . __('Quantity', 'sunshine') . '</th><th style="' . $th_style . '">' . __('Cost', 'sunshine') . '</th></tr>'; foreach ($order_items as $key => $order_item) { $items_html .= ' <tr>'; $thumb = wp_get_attachment_image_src($order_item['image_id'], 'sunshine-thumbnail'); $image_html = '<img src="' . $thumb[0] . '" alt="" width="75" />'; $items_html .= ' <td style="' . $td_style . '">' . apply_filters('sunshine_order_image_html', $image_html, $order_item, $thumb) . '</td>'; $items_html .= ' <td style="' . $td_style . '">' . $order_item['product_name'] . '<br />' . apply_filters('sunshine_order_line_item_comments', $order_item['comments'], $order_id, $order_item) . '</td>'; $items_html .= ' <td style="' . $td_style . '">' . $order_item['qty'] . '</td>'; $items_html .= ' <td style="' . $td_style . '">' . sunshine_money_format($order_item['total'], false) . '</td>'; $items_html .= ' </tr>'; } $td_style .= ' font-weight: bold;'; $th_style = 'padding: 0 20px 5px 0; text-align: left; font-size: 12px;'; $items_html .= ' <tr><td colspan="3" style="' . $td_style . ' text-align: right; border-top: 2px solid #CCC;">' . __('Subtotal', 'sunshine') . '</td><td style="' . $td_style . ' border-top: 2px solid #CCC;">' . sunshine_money_format($data['subtotal'], false) . '</td></tr>'; $items_html .= ' <tr><td colspan="3" style="' . $td_style . ' text-align: right;">' . __('Shipping', 'sunshine') . ' (' . sunshine_get_shipping_method_name($data['shipping_method']) . ')</td><td style="' . $td_style . '">' . sunshine_money_format($data['shipping_cost'], false) . '</td></tr>'; if ($sunshine->options['tax_location'] && $sunshine->options['tax_rate']) { $items_html .= ' <tr><td colspan="3" style="' . $td_style . ' text-align: right;">' . __('Tax', 'sunshine') . '</td><td style="' . $td_style . '">' . sunshine_money_format($data['tax'], false) . '</td></tr>'; } if ($data['discount_total'] > 0) { $items_html .= ' <tr><td colspan="3" style="' . $td_style . ' text-align: right;">' . __('Discounts', 'sunshine') . '</td><td style="' . $td_style . '">' . sunshine_money_format($data['discount_total'], false) . '</td></tr>'; } if ($data['credits']) { $items_html .= ' <tr><td colspan="3" style="' . $td_style . ' text-align: right;">' . __('Credits', 'sunshine') . '</td><td style="' . $td_style . '">-' . sunshine_money_format($data['credits'], false) . '</td></tr>'; } $items_html .= ' <tr><td colspan="3" style="' . $td_style . ' text-align: right; font-size: 16px;">' . __('Total', 'sunshine') . '</td><td style="' . $td_style . ' font-size: 16px;">' . sunshine_money_format($data['total'], false) . '</td></tr>'; $items_html .= ' </table></div>'; $customer_info = '<br /><br /><table border="0" cellspacing="0" cellpadding="0"><tr>'; if ($data['country']) { $customer_info .= '<td class="billing-address" valign="top"><h3 style="font-size: 14px;">' . __('Billing Info', 'sunshine') . '</h3><p>'; $customer_info .= $data['first_name'] . ' ' . $data['last_name'] . '<br>'; $customer_info .= $data['address']; if ($data['address2']) { $customer_info .= '<br>' . $data['address2']; } $customer_info .= '<br>' . $data['city'] . ', ' . $data['state'] . ' ' . $data['zip']; if ($data['country']) { $customer_info .= '<br>' . $data['country']; } if ($data['email']) { $customer_info .= '<br>' . $data['email']; } if ($data['phone']) { $customer_info .= '<br>' . $data['phone']; } $customer_info .= '</p></td>'; } if ($data['shipping_country']) { $customer_info .= '<td class="shipping-address" valign="top"><h3 style="font-size: 14px;">' . __('Shipping Info', 'sunshine') . '</h3><p>'; $customer_info .= $data['shipping_first_name'] . ' ' . $data['shipping_last_name'] . '<br>'; $customer_info .= $data['shipping_address']; if ($data['shipping_address2']) { $customer_info .= '<br>' . $data['shipping_address2']; } $customer_info .= '<br>' . $data['shipping_city'] . ', ' . $data['shipping_state'] . ' ' . $data['shipping_zip']; if ($data['shipping_country']) { $customer_info .= '<br>' . $data['shipping_country']; } $customer_info .= '</p></td>'; } $customer_info .= '</tr></table>'; $search = array('[message]', '[items]', '[customer_info]', '[order_id]', '[order_url]', '[first_name]', '[last_name]'); $replace = array(nl2br($sunshine->options['email_receipt']), $items_html, $customer_info, $order_id, get_permalink($order_id), $data['first_name'], $data['last_name']); $mail_result = SunshineEmail::send_email('receipt', $data['email'], $sunshine->options['email_subject_order_receipt'], $sunshine->options['email_subject_order_receipt'], $search, $replace, $data); if ($sunshine->options['order_notifications']) { $admin_emails = explode(',', $sunshine->options['order_notifications']); } else { $admin_emails = array(get_bloginfo('admin_email')); } foreach ($admin_emails as $admin_email) { $mail_result = SunshineEmail::send_email('receipt_admin', trim($admin_email), sprintf(__('Order #%s placed on %s'), $order_id, get_option('blogname')), sprintf(__('<a href="%s">Order #%s</a> placed on %s'), admin_url('/post.php?post=' . $order_id . '&action=edit'), $order_id, get_option('blogname')), $search, $replace, $data); } }
sunshine_money_format($order_data['tax']); ?> </td> </tr> <?php } ?> <?php if ($order_data['shipping_method']) { ?> <tr class="sunshine-shipping"> <th><?php _e('Shipping', 'sunshine'); ?> (<?php echo sunshine_get_shipping_method_name($order_data['shipping_method']); ?> )</th> <td><?php sunshine_money_format($order_data['shipping_cost']); ?> </td> </tr> <?php } ?> <?php if ($order_data['discount_total'] > 0) { ?> <tr class="sunshine-discounts"> <th><?php
function sunshine_order_data_inner($post) { // Use nonce for verification wp_nonce_field(plugin_basename(__FILE__), 'sunshine_noncename'); // The actual fields for data entry $order_data = unserialize(get_post_meta($post->ID, '_sunshine_order_data', true)); $items = unserialize(get_post_meta($post->ID, '_sunshine_order_items', true)); sunshine_array_sort_by_column($items, 'type'); ?> <p><strong><a href="<?php echo admin_url('admin.php?page=sunshine_invoice_display&order=' . $post->ID . '&nonce=' . wp_create_nonce('sunshine_invoice')); ?> "><?php _e('Invoice', 'sunshine'); ?> </a> | <a href="#sunshine-lightroom-file-list" id="sunshine-file-list-link"><?php _e('Image File List', 'sunshine'); ?> </a></strong></p> <div id="sunshine-file-list" style="display: none;"> <?php foreach ($items as $item) { if ($item['type'] == 'image') { $image_file_list[$item['image_id']] = get_post_meta($item['image_id'], 'sunshine_file_name', true); } elseif ($item['type'] == 'package') { foreach ($item['package_products'] as $package_product) { $image_file_list[$package_product['image_id']] = get_post_meta($package_product['image_id'], 'sunshine_file_name', true); } } } foreach ($image_file_list as &$file) { $file = str_replace(array('.jpg', '.JPG'), '', $file); } ?> <textarea rows="4" cols="50" onclick="this.focus();this.select()" readonly="readonly"><?php echo join(', ', $image_file_list); ?> </textarea> <p><?php _e('Copy and paste the file names above into Lightroom\'s search feature (Library filter) to quickly find and create a new collection to make processing this order easier. Make sure you are using the "Contains" (and not "Contains All") search parameter.', 'sunshine'); ?> </p> </div> <script> jQuery(document).ready(function($){ $('#sunshine-file-list-link').click(function(){ $('#sunshine-file-list').slideToggle(); return false; }); }); </script> <p><strong><?php _e('Order Date', 'sunshine'); ?> :</strong> <?php echo date(get_option('date_format'), strtotime($post->post_date)); ?> </p> <?php if ($ip = get_post_meta($post->ID, 'ip', true)) { ?> <p><strong>IP Address:</strong> <?php echo $ip; ?> </p> <?php } ?> <table width="100%" cellspacing="0" cellpadding="0" id="sunshine-order-data"> <tr><th><?php _e('Billing Info', 'sunshine'); ?> </th><th><?php if (isset($order_data['shipping_first_name'])) { _e('Shipping Info', 'sunshine'); } ?> </th></tr> <tr> <td> <?php echo $order_data['first_name'] . ' ' . $order_data['last_name'] . '<br />' . $order_data['address']; if ($order_data['address2']) { echo '<br />' . $order_data['address2']; } echo '<br />' . $order_data['city'] . ', ' . $order_data['state'] . ' ' . $order_data['zip'] . '<br />' . $order_data['country'] . '<br />' . $order_data['email'] . '<br />' . $order_data['phone']; ?> </td> <td> <?php if (isset($order_data['shipping_first_name'])) { echo $order_data['shipping_first_name'] . ' ' . $order_data['shipping_last_name'] . '<br />' . $order_data['shipping_address']; if ($order_data['shipping_address2']) { echo '<br />' . $order_data['shipping_address2']; } echo '<br />' . $order_data['shipping_city'] . ', ' . $order_data['shipping_state'] . ' ' . $order_data['shipping_zip'] . '<br />' . $order_data['shipping_country']; } ?> </td> </tr> </table> <br /><br /><table id="sunshine-cart-items" width="100%" cellspacing="0" cellpadding="0"> <tr> <th class="image"><?php _e('Type', 'sunshine'); ?> </th> <th class="image"><?php _e('Image', 'sunshine'); ?> </th> <th class="name"><?php _e('Product', 'sunshine'); ?> </th> <th class="qty"><?php _e('Qty', 'sunshine'); ?> </th> <th class="price"><?php _e('Item Price', 'sunshine'); ?> </th> <th class="total"><?php _e('Item Total', 'sunshine'); ?> </th> </tr> <?php $i = 1; foreach ($items as $item) { ?> <tr class="item"> <td class="type"> <?php echo ucwords(str_replace('_', ' ', $item['type'])); ?> </td> <td class="image"> <?php if ($item['image_id'] > 0) { $image = get_post($item['image_id']); $gallery = get_post($image->post_parent); if ($thumb = wp_get_attachment_image_src($item['image_id'], array(50, 50))) { $image_html = '<img src="' . $thumb[0] . '" alt="' . $item['image_name'] . '" />'; } else { $image_html = '<img src="http://placehold.it/100&text=Image+deleted" alt="Image has been deleted" />'; } } echo apply_filters('sunshine_cart_image_html', $image_html, $item, $thumb); ?> </td> <td class="name"> <strong><?php echo $item['product_name']; ?> </strong><br /> <div class="comments"><?php echo apply_filters('sunshine_cart_item_comments', $item['comments'], $item); ?> </div> </td> <td class="qty"> <?php echo $item['qty']; ?> </td> <td class="price"> <?php sunshine_money_format($item['price']); ?> </td> <td class="total"> <?php sunshine_money_format($item['total']); ?> </td> </tr> <?php $i++; } ?> <tr class="subtotal totals"> <th colspan="5" align="right"><?php _e('Subtotal', 'sunshine'); ?> </th> <td><?php sunshine_money_format($order_data['subtotal']); ?> </td> </tr> <tr class="tax totals"> <th colspan="5" align="right"><?php _e('Tax', 'sunshine'); ?> </th> <td><?php sunshine_money_format($order_data['tax']); ?> </td> </tr> <tr class="shipping totals"> <th colspan="5" align="right"><?php _e('Shipping', 'sunshine'); ?> (<?php echo sunshine_get_shipping_method_name($order_data['shipping_method']); ?> )</th> <td> <?php sunshine_money_format($order_data['shipping_cost']); ?> </td> </tr> <tr class="discounts totals"> <th colspan="5" align="right"> <?php _e('Discounts', 'sunshine'); ?> <?php if (!empty($order_data['discount_items'])) { $discount_names = array(); foreach ($order_data['discount_items'] as $discount_item) { $discount_names[] = $discount_item->name; } echo '<br />(' . join(', ', $discount_names) . ')'; } ?> </th> <td>-<?php sunshine_money_format($order_data['discount_total']); ?> </td> </tr> <?php if ($order_data['credits'] > 0) { ?> <tr class="credits totals"> <th colspan="5" align="right"><?php _e('Credits', 'sunshine'); ?> </th> <td>-<?php sunshine_money_format($order_data['credits']); ?> </td> </tr> <?php } ?> <tr class="total totals"> <th colspan="5" align="right"><?php _e('Total', 'sunshine'); ?> </th> <td><?php sunshine_money_format($order_data['total']); ?> </td> </tr> <tr class="payment-method totals"> <th colspan="5" align="right"><?php _e('Payment Method', 'sunshine'); ?> </th> <td><?php echo $order_data['payment_method']; ?> </td> </tr> </table> <?php }