Get a formatted billing address for the order.
public get_formatted_billing_address ( ) : string | ||
Résultat | string |
} ?> </div> </div> </div> <div class="dokan-left" style="width:49%; margin-right:2%"> <div class="dokan-panel dokan-panel-default"> <div class="dokan-panel-heading"><strong><?php _e('Billing Address', 'dokan'); ?> </strong></div> <div class="dokan-panel-body"> <?php echo $order->get_formatted_billing_address(); ?> </div> </div> </div> <div class="dokan-left" style="width:49%;"> <div class="dokan-panel dokan-panel-default"> <div class="dokan-panel-heading"><strong><?php _e('Shipping Address', 'dokan'); ?> </strong></div> <div class="dokan-panel-body"> <?php echo $order->get_formatted_shipping_address(); ?>
/** * Test: get_formatted_billing_address */ function test_get_formatted_billing_address() { $object = new WC_Order(); $object->set_billing_first_name('Fred'); $object->set_billing_last_name('Flintstone'); $object->set_billing_company('Bedrock Ltd.'); $object->set_billing_address_1('34 Stonepants avenue'); $object->set_billing_address_2('Rockville'); $object->set_billing_city('Bedrock'); $object->set_billing_state('Boulder'); $object->set_billing_postcode('00001'); $object->set_billing_country('US'); $this->assertEquals('Fred Flintstone<br/>Bedrock Ltd.<br/>34 Stonepants avenue<br/>Rockville<br/>Bedrock, BOULDER 00001<br/>United States (US)', $object->get_formatted_billing_address()); }
/** * Values for the custom columns on the orders page. * * @access public * @param mixed $column * @return void */ function woocommerce_custom_order_columns($column) { global $post, $woocommerce, $the_order; if (empty($the_order) || $the_order->id != $post->ID) { $the_order = new WC_Order($post->ID); } switch ($column) { case "order_status": printf('<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title($the_order->status), esc_html__($the_order->status, 'woocommerce'), esc_html__($the_order->status, 'woocommerce')); break; case "order_title": if ($the_order->user_id) { $user_info = get_userdata($the_order->user_id); } if (!empty($user_info)) { $user = '******' . absint($user_info->ID) . '">'; if ($user_info->first_name || $user_info->last_name) { $user .= esc_html($user_info->first_name . ' ' . $user_info->last_name); } else { $user .= esc_html($user_info->display_name); } $user .= '</a>'; } else { $user = __('Guest', 'woocommerce'); } echo '<a href="' . admin_url('post.php?post=' . absint($post->ID) . '&action=edit') . '"><strong>' . sprintf(__('Order %s', 'woocommerce'), esc_attr($the_order->get_order_number())) . '</strong></a> ' . __('made by', 'woocommerce') . ' ' . $user; if ($the_order->billing_email) { echo '<small class="meta">' . __('Email:', 'woocommerce') . ' ' . '<a href="' . esc_url('mailto:' . $the_order->billing_email) . '">' . esc_html($the_order->billing_email) . '</a></small>'; } if ($the_order->billing_phone) { echo '<small class="meta">' . __('Tel:', 'woocommerce') . ' ' . esc_html($the_order->billing_phone) . '</small>'; } break; case "billing_address": if ($the_order->get_formatted_billing_address()) { echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_billing_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_billing_address())) . '</a>'; } else { echo '–'; } if ($the_order->payment_method_title) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->payment_method_title) . '</small>'; } break; case "shipping_address": if ($the_order->get_formatted_shipping_address()) { echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_shipping_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_shipping_address())) . '</a>'; } else { echo '–'; } if ($the_order->shipping_method_title) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->shipping_method_title) . '</small>'; } break; case "total_cost": echo esc_html(strip_tags($the_order->get_formatted_order_total())); break; case "order_date": if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished', 'woocommerce'); } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post); $gmt_time = strtotime($post->post_date_gmt . ' UTC'); $time_diff = current_time('timestamp', 1) - $gmt_time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago', 'woocommerce'), human_time_diff($gmt_time, current_time('timestamp', 1))); } else { $h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post); } } echo '<abbr title="' . esc_attr($t_time) . '">' . esc_html(apply_filters('post_date_column_time', $h_time, $post)) . '</abbr>'; break; case "order_actions": ?> <p> <?php do_action('woocommerce_admin_order_actions_start', $the_order); $actions = array(); if (in_array($the_order->status, array('pending', 'on-hold'))) { $actions['processing'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-processing&order_id=' . $post->ID), 'woocommerce-mark-order-processing'), 'name' => __('Processing', 'woocommerce'), 'action' => "processing"); } if (in_array($the_order->status, array('pending', 'on-hold', 'processing'))) { $actions['complete'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-complete&order_id=' . $post->ID), 'woocommerce-mark-order-complete'), 'name' => __('Complete', 'woocommerce'), 'action' => "complete"); } $actions['view'] = array('url' => admin_url('post.php?post=' . $post->ID . '&action=edit'), 'name' => __('View', 'woocommerce'), 'action' => "view"); $actions = apply_filters('woocommerce_admin_order_actions', $actions, $the_order); foreach ($actions as $action) { $image = isset($action['image_url']) ? $action['image_url'] : $woocommerce->plugin_url() . '/assets/images/icons/' . $action['action'] . '.png'; printf('<a class="button tips" href="%s" data-tip="%s"><img src="%s" alt="%s" width="14" /></a>', esc_url($action['url']), esc_attr($action['name']), esc_attr($image), esc_attr($action['name'])); } do_action('woocommerce_admin_order_actions_end', $the_order); ?> </p><?php break; case "note": if ($the_order->customer_note) { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/note.png" alt="yes" class="tips" data-tip="' . __('Yes', 'woocommerce') . '" width="14" height="14" />'; } else { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/note-off.png" alt="no" class="tips" data-tip="' . __('No', 'woocommerce') . '" width="14" height="14" />'; } break; case "order_comments": echo '<div class="post-com-count-wrapper"> <a href="' . esc_url(admin_url('post.php?post=' . $post->ID . '&action=edit')) . '" class="post-com-count"><span class="comment-count">' . $post->comment_count . '</span></a> </div>'; break; } }
function check_type_of_product($order_id) { create_xero_invoice($order_id); if (!is_Null) { $order = NULL; } global $post; $order = new WC_Order($order_id); $items = $order->get_items(); $OrderItemIds = array_keys($items); $numberOfItems = $order->get_item_count(); $counter = 0; foreach ($items as $item) { $orderItemId = $OrderItemIds[$counter]; $product = $order->get_product_from_item($item); $productAttributes = $product->get_attributes(); if (!is_null($productAttributes['webinarid']['value'])) { $webinarId = $productAttributes['webinarid']['value']; } else { $webinarId = NULL; } if (!is_null($webinarId)) { $billingAddress = $order->get_formatted_billing_address(); $firstName = $item['item_meta']['firstName'][0]; $lastName = $item['item_meta']['lastName'][0]; $email = $item['item_meta']['email'][0]; $citrix = new CitrixAPI('5d8ab3cea37233d7d97dc1db5994fc9c', '8876575418305764356'); $registerAttendee = $citrix->createRegistrant($webinarId, $firstName, $lastName, $email); } else { $userID = $order->customer_user; $adviserEmail = $order->billing_email; $billingAddressFormatted = $order->get_formatted_billing_address(); $billingAddress = $order->get_billing_address(); $billingName = $order->billing_first_name . ' ' . $order->billing_last_name; //$billingFormatted;// $billingCompany = $order->billing_company; $billing_phone = $order->billing_phone; if (!is_null($order->billing_address_1)) { $billingAddress1 = $order->billing_address_1; } else { $billingAddress1 = ''; } if (!is_null($order->billing_address_2)) { $billingAddress2 = $order->billing_address_2; } else { $billingAddress2 = ''; } if (!is_null($order->billing_city)) { $billingCity = $order->billing_city; } else { $billingCity = ''; } if (!is_null($order->billing_state)) { $billingState = $order->billing_state; } else { $billingState = ''; } if (!is_null($order->billing_postcode)) { $billingPostcode = $order->billing_postcode; } else { $billingPostcode = ''; } //if virtual product, post data to server as well. //$isVirtual = $product->is_virtual(); //if($isVirtual){ //$emailToAdmin = 0; //post_item_data_to_server($order_id, $orderItemId, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode, $emailToAdmin); //} //24 April 2014 - Altered so that all orders post data when complete so that I can auto-complete all orders, not just electronic ones. post_item_data_to_server($order_id, $orderItemId, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode, $emailToAdmin); generate_docs_on_data_server($order_id, $orderItemId, $product, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode); } $counter = $counter + 1; } $order = NULL; }
function sm_woo_get_packing_slip($purchase_ids, $purchase_id_arr) { if (!empty($purchase_ids) && !empty($purchase_id_arr)) { ?> <style type="text/css"> body { font-family:"Helvetica Neue", Helvetica, Arial, Verdana, sans-serif; } h1 span { font-size:0.75em; } h2 { color: #333; } .no-page-break { page-break-after: avoid; } #wrapper { margin:0 auto; width:95%; page-break-after: always; } #wrapper_last { margin:0 auto; width:95%; page-break-after: avoid; } .address{ width:98%; border-top:1px; border-right:1px; margin:1em auto; border-collapse:collapse; } .address_border{ border-bottom:1px; border-left:1px ; padding:.2em 1em; text-align:left; } table { width:98%; border-top:1px solid #e5eff8; border-right:1px solid #e5eff8; margin:1em auto; border-collapse:collapse; font-size:10pt; } td { border-bottom:1px solid #e5eff8; border-left:1px solid #e5eff8; padding:.3em 1em; text-align:center; } tr.odd td, tr.odd .column1 { background:#f4f9fe url(background.gif) no-repeat; } .column1 { background:#f4f9fe; } thead th { background:#f4f9fe; text-align:center; font:bold 1.2em/2em "Century Gothic","Trebuchet MS",Arial,Helvetica,sans-serif; } .datagrid { position: relative; top:-30pt; } .producthead{ text-align: left; } .pricehead{ text-align: right; } .sm_address_div{ position: relative; left:28pt; } .sm_email_span{ position: relative; left:10pt; } </style> <?php $counter = 0; foreach ($purchase_id_arr as $purchase_id_value) { $order = new WC_Order($purchase_id_value); $date_format = get_option('date_format'); if (is_plugin_active('woocommerce-sequential-order-numbers-pro/woocommerce-sequential-order-numbers.php')) { $purchase_display_id = isset($order->order_custom_fields['_order_number_formatted'][0]) ? $order->order_custom_fields['_order_number_formatted'][0] : $purchase_id_value; } else { $purchase_display_id = $purchase_id_value; } $counter++; if (count($purchase_id_arr) == $counter) { echo '<div id="wrapper_last">'; } else { echo '<div id="wrapper">'; } echo smart_manager_print_logo(); echo '<div style="margin-top:-0.8em;">'; echo '<h4 style="font:bold 1.2em/2em "Century Gothic","Trebuchet MS",Arial,Helvetica,sans-serif; position:relative; 12pt;"> ' . get_bloginfo('name') . '</h4>'; echo '<table class="address" style="position:relative; top:-22pt; left:-35pt;">'; echo '<tr><td class="address_border" colspan="2" valign="top" width="50%"><span style="position:relative; left:27pt; top:10pt;"> <b>Order # ' . $purchase_display_id . ' - ' . date($date_format, strtotime($order->order_date)) . '</b></span><br/></td></tr>'; echo '<tr><td class="address_border" width="35%" align="center"><br/><div class="sm_address_div">'; $formatted_billing_address = $order->get_formatted_billing_address(); if ($formatted_billing_address != '') { echo '<b>' . __('Billing Address', 'smart-manager') . '</b><p>'; echo $formatted_billing_address; echo '</p></td>'; } $formatted_shipping_address = $order->get_formatted_shipping_address(); if ($formatted_shipping_address != '') { echo '<td class="address_border" width="30%"><br/><div style="position:relative; top:3pt;"><b>' . __('Shipping Address', 'smart-manager') . '</b><p>'; echo $formatted_shipping_address; echo '</p></div></td>'; } echo '</tr>'; echo '<tr><td colspan="2" class="address_border"><span class="sm_email_span"><table class="address"><tr><td colspan="2" class="address_border" > <b>' . __('Email id', 'smart-manager') . ':</b> ' . $order->billing_email . '</td></tr> <tr><td class="address_border"><b>' . __('Tel', 'smart-manager') . ' :</b> ' . $order->billing_phone . '</td></tr></table> </span></td></tr>'; echo '</table>'; echo '<div class="datagrid"><table><tr class="column1"> <td class="producthead">' . __('Product', 'smart-manager') . '</td><td>' . __('SKU', 'smart-manager') . '</td> <td>' . __('Quantity', 'smart-manager') . '</td><td class="pricehead">' . __('Price', 'smart-manager') . '</td></tr>'; foreach ($order->get_items() as $item) { $_product = $order->get_product_from_item($item); $sku = $variation = ''; $sku = $_product->get_sku(); $formatted_variation = woocommerce_get_formatted_variation($_product->variation_data, true); $variation = !empty($formatted_variation) ? ' (' . $formatted_variation . ')' : ''; $item_total = $_product->get_price() * $item['item_meta']['_qty'][0]; $total_order += $item_total; echo '<tr><td class="producthead">'; echo $item['name'] . $variation; echo '</td><td>' . $sku . '</td><td>'; echo $item['item_meta']['_qty'][0]; echo '</td><td class="pricehead">'; echo woocommerce_price($item_total); echo '</td></tr>'; } echo '<tr><td colspan="2" rowspan="5" class="address_border" valign="top"><br/> <i>' . ($order->customer_note != '' ? __('Order Notes', 'smart-manager') . ' : ' . $order->customer_note : '') . '</i></td><td style="text-align:right;" class="address_border" valign="top"> <b>Subtotal </b></td><td class="pricehead">' . $order->get_subtotal_to_display() . '</td></tr>'; echo '<tr><td style="text-align:right;" class="address_border"><b>' . __('Shipping', 'smart-manager') . ' </b></td><td class="pricehead">' . $order->get_shipping_to_display() . '</td></tr>'; if ($order->cart_discount > 0) { echo '<tr><td style="text-align:right;" class="address_border">' . __('Cart Discount', 'smart-manager') . '</td><td style="text-align:right;">'; echo woocommerce_price($order->cart_discount); echo '</td></tr>'; } if ($order->order_discount > 0) { echo '<tr><td style="text-align:right;" class="address_border"><b>' . __('Order Discount', 'smart-manager') . ' </b></td>'; echo '<td class="pricehead">' . woocommerce_price($order->order_discount) . '</td></tr>'; } echo '<tr><td style="text-align:right;" class="address_border"><b>' . __('Tax', 'smart-manager') . ' </b></td><td class="pricehead">' . woocommerce_price($order->get_total_tax()) . '</td></tr>'; echo '<tr><td class="column1" style="text-align:right;"><b>' . __('Total', 'smart-manager') . ' </b></td><td class="column1" style="text-align:right;">' . woocommerce_price($order->order_total) . ' -via ' . $order->payment_method_title . '</td></tr>'; echo '</table></div></div></div>'; } } exit; }
/** * Define our custom columns shown in admin. * @param string $column */ public function custom_columns($column) { global $post, $woocommerce, $the_order; if (empty($the_order) || $the_order->id != $post->ID) { $the_order = new WC_Order($post->ID); } switch ($column) { case 'order_status': printf('<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title($the_order->status), esc_html__($the_order->status, 'woocommerce'), esc_html__($the_order->status, 'woocommerce')); break; case 'order_date': if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished', 'woocommerce'); } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post); $gmt_time = strtotime($post->post_date_gmt . ' UTC'); $time_diff = current_time('timestamp', 1) - $gmt_time; $h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post); } echo '<abbr title="' . esc_attr($t_time) . '">' . esc_html(apply_filters('post_date_column_time', $h_time, $post)) . '</abbr>'; break; case 'customer_message': if ($the_order->customer_message) { echo '<span class="note-on tips" data-tip="' . esc_attr($the_order->customer_message) . '">' . __('Yes', 'woocommerce') . '</span>'; } else { echo '<span class="na">–</span>'; } break; case 'billing_address': if ($the_order->get_formatted_billing_address()) { echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_billing_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_billing_address())) . '</a>'; } else { echo '–'; } if ($the_order->payment_method_title) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->payment_method_title) . '</small>'; } break; case 'order_items': echo '<a href="#" class="show_order_items">' . apply_filters('woocommerce_admin_order_item_count', sprintf(_n('%d item', '%d items', $the_order->get_item_count(), 'woocommerce'), $the_order->get_item_count()), $the_order) . '</a>'; if (sizeof($the_order->get_items()) > 0) { echo '<table class="order_items" cellspacing="0">'; foreach ($the_order->get_items() as $item) { $_product = apply_filters('woocommerce_order_item_product', $the_order->get_product_from_item($item), $item); $item_meta = new WC_Order_Item_Meta($item['item_meta']); $item_meta_html = $item_meta->display(true, true); ?> <tr class="<?php echo apply_filters('woocommerce_admin_order_item_class', '', $item); ?> "> <td class="qty"><?php echo absint($item['qty']); ?> </td> <td class="name"> <?php if (wc_product_sku_enabled() && $_product && $_product->get_sku()) { echo $_product->get_sku() . ' - '; } echo apply_filters('woocommerce_order_item_name', $item['name'], $item); ?> <?php if ($item_meta_html) { ?> <a class="tips" href="#" data-tip="<?php echo esc_attr($item_meta_html); ?> ">[?]</a> <?php } ?> </td> </tr> <?php } echo '</table>'; } else { echo '–'; } break; case 'shipping_address': if ($the_order->get_formatted_shipping_address()) { echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_shipping_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_shipping_address())) . '</a>'; } else { echo '–'; } if ($the_order->get_shipping_method()) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->get_shipping_method()) . '</small>'; } break; case 'order_notes': if ($post->comment_count) { // check the status of the post $post->post_status !== 'trash' ? $status = '' : ($status = 'post-trashed'); $latest_notes = get_comments(array('post_id' => $post->ID, 'number' => 1, 'status' => $status)); $latest_note = current($latest_notes); if ($post->comment_count == 1) { echo '<span class="note-on tips" data-tip="' . esc_attr($latest_note->comment_content) . '">' . __('Yes', 'woocommerce') . '</span>'; } else { $note_tip = isset($latest_note->comment_content) ? esc_attr($latest_note->comment_content . '<small style="display:block">' . sprintf(_n('plus %d other note', 'plus %d other notes', $post->comment_count - 1, 'woocommerce'), $post->comment_count - 1) . '</small>') : sprintf(_n('%d note', '%d notes', $post->comment_count, 'woocommerce'), $post->comment_count); echo '<span class="note-on tips" data-tip="' . $note_tip . '">' . __('Yes', 'woocommerce') . '</span>'; } } else { echo '<span class="na">–</span>'; } break; case 'order_total': echo esc_html(strip_tags($the_order->get_formatted_order_total())); if ($the_order->payment_method_title) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->payment_method_title) . '</small>'; } break; case 'order_title': $customer_tip = ''; if ($address = $the_order->get_formatted_billing_address()) { $customer_tip .= __('Billing:', 'woocommerce') . ' ' . $address . '<br/><br/>'; } if ($the_order->billing_phone) { $customer_tip .= __('Tel:', 'woocommerce') . ' ' . $the_order->billing_phone; } echo '<div class="tips" data-tip="' . esc_attr($customer_tip) . '">'; if ($the_order->user_id) { $user_info = get_userdata($the_order->user_id); } if (!empty($user_info)) { $username = '******' . absint($user_info->ID) . '">'; if ($user_info->first_name || $user_info->last_name) { $username .= esc_html(ucfirst($user_info->first_name) . ' ' . ucfirst($user_info->last_name)); } else { $username .= esc_html(ucfirst($user_info->display_name)); } $username .= '</a>'; } else { if ($the_order->billing_first_name || $the_order->billing_last_name) { $username = trim($the_order->billing_first_name . ' ' . $the_order->billing_last_name); } else { $username = __('Guest', 'woocommerce'); } } printf(__('%s by %s', 'woocommerce'), '<a href="' . admin_url('post.php?post=' . absint($post->ID) . '&action=edit') . '"><strong>' . esc_attr($the_order->get_order_number()) . '</strong></a>', $username); if ($the_order->billing_email) { echo '<small class="meta email"><a href="' . esc_url('mailto:' . $the_order->billing_email) . '">' . esc_html($the_order->billing_email) . '</a></small>'; } echo '</div>'; break; case 'order_actions': ?> <p> <?php do_action('woocommerce_admin_order_actions_start', $the_order); $actions = array(); if (in_array($the_order->status, array('pending', 'on-hold'))) { $actions['processing'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce_mark_order_processing&order_id=' . $post->ID), 'woocommerce-mark-order-processing'), 'name' => __('Processing', 'woocommerce'), 'action' => "processing"); } if (in_array($the_order->status, array('pending', 'on-hold', 'processing'))) { $actions['complete'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce_mark_order_complete&order_id=' . $post->ID), 'woocommerce-mark-order-complete'), 'name' => __('Complete', 'woocommerce'), 'action' => "complete"); } $actions['view'] = array('url' => admin_url('post.php?post=' . $post->ID . '&action=edit'), 'name' => __('View', 'woocommerce'), 'action' => "view"); $actions = apply_filters('woocommerce_admin_order_actions', $actions, $the_order); foreach ($actions as $action) { printf('<a class="button tips %s" href="%s" data-tip="%s">%s</a>', esc_attr($action['action']), esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name'])); } do_action('woocommerce_admin_order_actions_end', $the_order); ?> </p><?php break; } }
*/ //Add callback to Hyggligs system to validate Order require '../../../../wp-load.php'; $store_Post = $_POST; $order_id = $_POST['orderReference']; $order = new WC_Order($order_id); $options = get_option('woocommerce_hygglig_checkout_settings'); $log = new WC_Logger(); //Live or test if ($options['testmode'] == 'yes') { $url = "http://sandbox.hygglig.com/"; } else { $url = "https://www.hygglig.com/"; } // Billing if (strlen($order->get_formatted_billing_address()) < 10) { $order->set_address(array('first_name' => $_POST['firstName'], 'last_name' => $_POST['lastName'], 'address_1' => $_POST['address'], 'city' => $_POST['city'], 'postcode' => $_POST['postalCode'], 'email' => $_POST['email'], 'phone' => $_POST['phoneNumber'])); } // Shipping if (strlen($order->get_formatted_shipping_address()) < 10) { $order->set_address(array('first_name' => $_POST['firstName'], 'last_name' => $_POST['lastName'], 'address_1' => $_POST['address'], 'city' => $_POST['city'], 'postcode' => $_POST['postalCode']), 'shipping'); } $order->payment_complete($_POST['orderNumber']); update_post_meta($order_id, '_payment_method', 'Hygglig'); update_post_meta($order_id, '_payment_method_title', 'Hygglig'); if ($options['debug'] == 'yes') { $log->add('marginalen', "Payment for Order #" . $order_id . " completed. Stocks reduced."); } // Store user id in order so the user can keep track of track it in My account if (email_exists($order->billing_email)) { if ($options['debug'] == 'yes') {
function woocommerce_custom_order_columns($column) { global $post, $woocommerce; $order = new WC_Order($post->ID); switch ($column) { case "order_status": echo sprintf('<mark class="%s">%s</mark>', sanitize_title($order->status), __($order->status, 'woocommerce')); break; case "order_title": if ($order->user_id) { $user_info = get_userdata($order->user_id); } if (isset($user_info) && $user_info) { $user = '******' . esc_attr($user_info->ID) . '">'; if ($user_info->first_name || $user_info->last_name) { $user .= $user_info->first_name . ' ' . $user_info->last_name; } else { $user .= esc_html($user_info->display_name); } $user .= '</a>'; } else { $user = __('Guest', 'woocommerce'); } echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '"><strong>' . sprintf(__('Order #%s', 'woocommerce'), $post->ID) . '</strong></a> ' . __('made by', 'woocommerce') . ' ' . $user; if ($order->billing_email) { echo '<small class="meta">' . __('Email:', 'woocommerce') . ' ' . '<a href="' . esc_url('mailto:' . $order->billing_email) . '">' . esc_html($order->billing_email) . '</a></small>'; } if ($order->billing_phone) { echo '<small class="meta">' . __('Tel:', 'woocommerce') . ' ' . esc_html($order->billing_phone) . '</small>'; } break; case "billing_address": if ($order->get_formatted_billing_address()) { echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($order->get_billing_address()) . '&z=16') . '">' . preg_replace('#<br\\s*/?>#i', ', ', $order->get_formatted_billing_address()) . '</a>'; } else { echo '–'; } if ($order->payment_method_title) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($order->payment_method_title) . '</small>'; } break; case "shipping_address": if ($order->get_formatted_shipping_address()) { echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($order->get_shipping_address()) . '&z=16') . '">' . preg_replace('#<br\\s*/?>#i', ', ', $order->get_formatted_shipping_address()) . '</a>'; } else { echo '–'; } if ($order->shipping_method_title) { echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($order->shipping_method_title) . '</small>'; } break; case "total_cost": echo woocommerce_price($order->order_total); break; case "order_date": if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished', 'woocommerce'); } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post); $gmt_time = strtotime($post->post_date_gmt); $time_diff = current_time('timestamp', 1) - $gmt_time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago', 'woocommerce'), human_time_diff($gmt_time, current_time('timestamp', 1))); } else { $h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post); } } echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post) . '</abbr>'; break; case "order_actions": ?> <p> <?php if (in_array($order->status, array('pending', 'on-hold'))) { ?> <a class="button" href="<?php echo wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-processing&order_id=' . $post->ID), 'woocommerce-mark-order-processing'); ?> "><?php _e('Processing', 'woocommerce'); ?> </a><?php } ?> <?php if (in_array($order->status, array('pending', 'on-hold', 'processing'))) { ?> <a class="button" href="<?php echo wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-complete&order_id=' . $post->ID), 'woocommerce-mark-order-complete'); ?> "><?php _e('Complete', 'woocommerce'); ?> </a><?php } ?> <a class="button" href="<?php echo admin_url('post.php?post=' . $post->ID . '&action=edit'); ?> "><?php _e('View', 'woocommerce'); ?> </a> </p><?php break; case "note": if ($order->customer_note) { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/note.png" alt="yes" class="tips" tip="' . __('Yes', 'woocommerce') . '" />'; } else { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/note-off.png" alt="no" class="tips" tip="' . __('No', 'woocommerce') . '" />'; } break; case "order_comments": echo '<div class="post-com-count-wrapper"> <a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" class="post-com-count"><span class="comment-count">' . $post->comment_count . '</span></a> </div>'; break; } }
/** * Order data meta box * * Displays the meta box */ function woocommerce_order_data_meta_box($post) { global $post, $wpdb, $thepostid, $order_status; $thepostid = $post->ID; $order = new WC_Order($thepostid); wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce'); // Custom user $customer_user = (int) get_post_meta($post->ID, '_customer_user', true); // Order status $order_status = wp_get_post_terms($post->ID, 'shop_order_status'); if ($order_status) { $order_status = current($order_status); $order_status = $order_status->slug; } else { $order_status = 'pending'; } if (!isset($post->post_title) || empty($post->post_title)) { $order_title = 'Order'; } else { $order_title = $post->post_title; } ?> <style type="text/css"> #titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none } </style> <div class="panel-wrap woocommerce"> <input name="post_title" type="hidden" value="<?php echo esc_attr($order_title); ?> " /> <input name="post_status" type="hidden" value="publish" /> <div id="order_data" class="panel"> <div class="order_data_left"> <h2><?php _e('Order Details', 'woocommerce'); ?> — #<?php echo $thepostid; ?> </h2> <p class="form-field"><label for="order_status"><?php _e('Order status:', 'woocommerce'); ?> </label> <select id="order_status" name="order_status" class="chosen_select"> <?php $statuses = (array) get_terms('shop_order_status', array('hide_empty' => 0, 'orderby' => 'id')); foreach ($statuses as $status) { echo '<option value="' . $status->slug . '" '; if ($status->slug == $order_status) { echo 'selected="selected"'; } echo '>' . __($status->name, 'woocommerce') . '</option>'; } ?> </select></p> <p class="form-field form-field-wide"><label for="customer_user"><?php _e('Customer:', 'woocommerce'); ?> </label> <select id="customer_user" name="customer_user" class="chosen_select"> <option value=""><?php _e('Guest', 'woocommerce'); ?> </option> <?php $users = new WP_User_Query(array('orderby' => 'display_name')); $users = $users->get_results(); if ($users) { foreach ($users as $user) { echo '<option value="' . $user->ID . '" '; selected($customer_user, $user->ID); echo '>' . $user->display_name . ' (' . $user->user_email . ')</option>'; } } ?> </select></p> <p class="form-field form-field-wide"><label for="excerpt"><?php _e('Customer Note:', 'woocommerce'); ?> </label> <textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php _e('Customer\'s notes about the order', 'woocommerce'); ?> "><?php echo $post->post_excerpt; ?> </textarea></p> </div> <div class="order_data_right"> <div class="order_data"> <h2><?php _e('Billing Details', 'woocommerce'); ?> <a class="edit_address" href="#">(<?php _e('Edit', 'woocommerce'); ?> )</a></h2> <?php $billing_data = apply_filters('woocommerce_admin_billing_fields', array('first_name' => array('label' => __('First Name', 'woocommerce'), 'show' => false), 'last_name' => array('label' => __('Last Name', 'woocommerce'), 'show' => false), 'company' => array('label' => __('Company', 'woocommerce'), 'show' => false), 'address_1' => array('label' => __('Address 1', 'woocommerce'), 'show' => false), 'address_2' => array('label' => __('Address 2', 'woocommerce'), 'show' => false), 'city' => array('label' => __('City', 'woocommerce'), 'show' => false), 'postcode' => array('label' => __('Postcode', 'woocommerce'), 'show' => false), 'country' => array('label' => __('Country', 'woocommerce'), 'show' => false), 'state' => array('label' => __('State/County', 'woocommerce'), 'show' => false), 'email' => array('label' => __('Email', 'woocommerce')), 'phone' => array('label' => __('Phone', 'woocommerce')))); // Display values echo '<div class="address">'; if ($order->get_formatted_billing_address()) { echo '<p><strong>' . __('Address', 'woocommerce') . ':</strong><br/> ' . $order->get_formatted_billing_address() . '</p>'; } else { echo '<p class="none_set"><strong>' . __('Address', 'woocommerce') . ':</strong> ' . __('No billing address set.', 'woocommerce') . '</p>'; } foreach ($billing_data as $key => $field) { if (isset($field['show']) && !$field['show']) { continue; } $field_name = 'billing_' . $key; echo '<p><strong>' . $field['label'] . ':</strong> ' . $order->{$field_name} . '</p>'; } echo '</div>'; // Display form echo '<div class="edit_address"><p><button class="button load_customer_billing">' . __('Load customer billing address', 'woocommerce') . '</button></p>'; foreach ($billing_data as $key => $field) { woocommerce_wp_text_input(array('id' => '_billing_' . $key, 'label' => $field['label'])); } echo '</div>'; ?> </div> <div class="order_data order_data_alt"> <h2><?php _e('Shipping Details', 'woocommerce'); ?> <a class="edit_address" href="#">(<?php _e('Edit', 'woocommerce'); ?> )</a></h2> <?php $shipping_data = apply_filters('woocommerce_admin_shipping_fields', array('first_name' => array('label' => __('First Name', 'woocommerce'), 'show' => false), 'last_name' => array('label' => __('Last Name', 'woocommerce'), 'show' => false), 'company' => array('label' => __('Company', 'woocommerce'), 'show' => false), 'address_1' => array('label' => __('Address 1', 'woocommerce'), 'show' => false), 'address_2' => array('label' => __('Address 2', 'woocommerce'), 'show' => false), 'city' => array('label' => __('City', 'woocommerce'), 'show' => false), 'postcode' => array('label' => __('Postcode', 'woocommerce'), 'show' => false), 'country' => array('label' => __('Country', 'woocommerce'), 'show' => false), 'state' => array('label' => __('State/County', 'woocommerce'), 'show' => false))); // Display values echo '<div class="address">'; if ($order->get_formatted_shipping_address()) { echo '<p><strong>' . __('Address', 'woocommerce') . ':</strong><br/> ' . $order->get_formatted_shipping_address() . '</p>'; } else { echo '<p class="none_set"><strong>' . __('Address', 'woocommerce') . ':</strong> ' . __('No shipping address set.', 'woocommerce') . '</p>'; } foreach ($shipping_data as $key => $field) { if (isset($field['show']) && !$field['show']) { continue; } $field_name = 'shipping_' . $key; echo '<p><strong>' . $field['label'] . ':</strong> ' . $order->{$field_name} . '</p>'; } echo '</div>'; // Display form echo '<div class="edit_address"><p><button class="button load_customer_shipping">' . __('Load customer shipping address', 'woocommerce') . '</button></p>'; foreach ($shipping_data as $key => $field) { woocommerce_wp_text_input(array('id' => '_shipping_' . $key, 'label' => $field['label'])); } echo '</div>'; ?> </div> </div> <div class="clear"></div> </div> </div> <?php }
function sendCustomerInvoice($order_id) { PlexLog::addLog(' Info =>@sendCustomerInvoice order_id=' . $order_id); $wooCommerceOrderObject = new WC_Order($order_id); $user_id = $wooCommerceOrderObject->get_user_id(); $customerMailId = $wooCommerceOrderObject->billing_email; $invoice_mail_content = ''; $invoice_mail_content .= ' <table border="0" cellpadding="0" cellspacing="0" width="600" id="template_container"> <tbody> <tr> <td align="center" valign="top"> <font face="Arial" style="font-weight:bold;background-color:#8fd1c8;color:#202020;"></font> <table border="0" cellpadding="0" cellspacing="0" width="600" id="template_header" bgcolor="#8fd1c8"> <tbody> <tr > <td width="20" height="20" bgcolor="#8fd1c8"> </td> <td bgcolor="#8fd1c8"> </td> <td width="20" bgcolor="#8fd1c8"> </td> </tr> <tr > <td width="20" bgcolor="#8fd1c8"> </td> <td bgcolor="#8fd1c8" style="font-weight:bold;font-size:24px;color:#ffffff;" ><h2 style="margin:0;">Welcome to ' . get_option('blogname') . '! <br>Thank you for your order. We\'ll be in touch shortly with additional order and shipping information.</h2></td> <td width="20" bgcolor="#8fd1c8"> </td> </tr> <tr > <td width="20" height="20" bgcolor="#8fd1c8"> </td> <td bgcolor="#8fd1c8"> </td> <td width="20" bgcolor="#8fd1c8"> </td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="600" id="template_body"> <tbody> <tr> <td valign="top"> <font style="background-color:#f9f9f9"> <table border="0" cellpadding="20" cellspacing="0" width="100%"> <tbody> <tr> <td valign="top"> <div> <font face="Arial" align="left" style="font-size:18px;color:#8a8a8a"> <p>Your order #' . get_post_meta($order_id, "plexOrderId", true) . ' has been received and is now being processed. Your order details are shown below for your reference:</p> <table cellspacing="0" cellpadding="6" border="1" style="width:100%;"> <thead> <tr> <th scope="col"> <font align="left">Product</font> </th> <th scope="col"> <font align="left">Quantity</font> </th> <th scope="col"> <font align="left">Price</font> </th> </tr> </thead> <tbody>'; $allItems = $wooCommerceOrderObject->get_items(); foreach ($allItems as $key => $value) { $invoice_mail_content .= ' <tr> <td> <font align="left">' . $value["name"] . '<br><small></small></font> </td> <td> <font align="left">' . $value["qty"] . '</font> </td> <td> <font align="left"> <span class="amount">$' . $value["line_subtotal"] . '</span> </font> </td> </tr>'; } $invoice_mail_content .= ' </tbody> <tfoot style="text-align: left;"> <tr> <th scope="row" colspan="2"> <font align="left">Cart Subtotal:</font> </th> <td> <font align="left"> <span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_subtotal()) . '</span> </font> </td> </tr>'; if ($wooCommerceOrderObject->get_total_discount() > 0.0) { $invoice_mail_content .= '<tr> <th scope="row" colspan="2"> <font align="left">Discount:</font> </th> <td> <font align="left"> <span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_total_discount()) . '</span> </font> </td> </tr>'; } $invoice_mail_content .= '<tr> <th scope="row" colspan="2"> <font align="left">Tax:</font> </th> <td> <font align="left"> <span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_cart_tax() + $wooCommerceOrderObject->get_shipping_tax()) . '</span> </font> </td> </tr> <tr> <th scope="row" colspan="2"> <font align="left">Shipping:</font> </th> <td> <font align="left"> <span class="amount">$' . $wooCommerceOrderObject->get_total_shipping() . '</span> <small>via ' . $wooCommerceOrderObject->get_shipping_method() . '</small> </font> </td> </tr> <tr> <th scope="row" colspan="2"> <font align="left">Payment Method:</font> </th> <td> <font align="left">' . $wooCommerceOrderObject->payment_method_title . '</font> </td> </tr> <tr> <th scope="row" colspan="2"> <font align="left">Order Total:</font> </th> <td> <font align="left"> <span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_total()) . '</span> </font> </td> </tr> </tfoot> </table> <h2> <font face="Arial" align="left" style="font-weight:bold;font-size:30px;color:#6d6d6d">Customer details</font> </h2> <p><strong>Email:</strong> ' . $customerMailId . '</p> <p><strong>Tel:</strong> ' . $wooCommerceOrderObject->billing_phone . '</p> <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td valign="top" width="50%"> <h3> <font face="Arial" align="left" style="font-weight:bold;font-size:26px;color:#6d6d6d">Billing address</font> </h3> <p>' . $wooCommerceOrderObject->get_formatted_billing_address() . '</p> </td> <td valign="top" width="50%"> <h3> <font face="Arial" align="left" style="font-weight:bold;font-size:26px;color:#6d6d6d">Shipping address</font> </h3> <p>' . $wooCommerceOrderObject->get_formatted_shipping_address() . '</p> </td> </tr> </tbody> </table> </font> </div> </td> </tr> </tbody> </table> </font> </td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" valign="top"> <table border="0" cellpadding="10" cellspacing="0" width="600" id="template_footer"> <tbody> <tr> <td valign="top"> <table border="0" cellpadding="4" cellspacing="0" width="100%"> <tbody> <tr> <td colspan="2" valign="middle" id="credit" style="background-color: #777;"> <font face="Arial" align="center" style="font-size:12px;color:#bce3de"> <p>' . site_url() . '</p> </font> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>'; $emailHeader = "Content-type: text/html"; // To send HTML mail, the Content-type header must be set $emailHeader = 'MIME-Version: 1.0' . "\r\n"; $emailHeader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional emailHeader $emailHeader .= 'From: ' . get_bloginfo('name') . ' <*****@*****.**>' . "\r\n"; $emailSubject = "Your plexuser order receipt from " . date_i18n(wc_date_format(), strtotime($wooCommerceOrderObject->order_date)); wp_mail($customerMailId, $emailSubject, $invoice_mail_content, $emailHeader); }