Get a formatted billing full name.
public get_formatted_billing_full_name ( ) : string | ||
return | string |
/** * Process customer: updating or creating a new customer/saved CC * * @param WC_Order $order Order object * @param WC_Payment_Token $customer_token Payment Token * @param string $cart_token CC Token */ protected function process_customer($order, $customer_token = null, $cart_token = '') { // Are we saving a new payment method? if (is_user_logged_in() && isset($_POST['wc-simplify_commerce-new-payment-method']) && true === (bool) $_POST['wc-simplify_commerce-new-payment-method']) { $customer_info = array('email' => $order->get_billing_email(), 'name' => trim($order->get_formatted_billing_full_name())); $token = $this->save_token($customer_token, $cart_token, $customer_info); if (!is_null($token)) { $order->add_payment_token($token); } } }
/** * Process the pre-order. * * @param WC_Order $order * @param string $cart_token * @uses Simplify_ApiException * @uses Simplify_BadRequestException * @return array */ protected function process_pre_order($order, $cart_token = '') { if (WC_Pre_Orders_Order::order_requires_payment_tokenization($order->id)) { try { if ($order->order_total * 100 < 50) { $error_msg = __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce'); throw new Simplify_ApiException($error_msg); } if (empty($cart_token)) { $error_msg = __('Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce'); if ('yes' == $this->sandbox) { $error_msg .= ' ' . __('Developers: Please make sure that you\'re including jQuery and there are no JavaScript errors on the page.', 'woocommerce'); } throw new Simplify_ApiException($error_msg); } // Create customer $customer = Simplify_Customer::createCustomer(array('token' => $cart_token, 'email' => $order->billing_email, 'name' => trim($order->get_formatted_billing_full_name()), 'reference' => $order->id)); if (is_object($customer) && '' != $customer->id) { $customer_id = wc_clean($customer->id); // Store the customer ID in the order update_post_meta($order->id, '_simplify_customer_id', $customer_id); } else { $error_msg = __('Error creating user in Simplify Commerce.', 'woocommerce'); throw new Simplify_ApiException($error_msg); } // Reduce stock levels $order->reduce_order_stock(); // Remove cart WC()->cart->empty_cart(); // Is pre ordered! WC_Pre_Orders_Order::mark_order_as_pre_ordered($order); // Return thank you page redirect return array('result' => 'success', 'redirect' => $this->get_return_url($order)); } catch (Simplify_ApiException $e) { if ($e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors()) { foreach ($e->getFieldErrors() as $error) { wc_add_notice($error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error'); } } else { wc_add_notice($e->getMessage(), 'error'); } return array('result' => 'fail', 'redirect' => ''); } } else { return parent::process_standard_payments($order, $cart_token); } }
function _woocommercecivicrm_customer_orders($uid) { $customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('meta_key' => '_customer_user', 'meta_value' => $uid, 'post_type' => 'shop_order', 'post_status' => array_keys(wc_get_order_statuses())))); $site_url = get_site_url(); $orders = array(); foreach ($customer_orders as $customer_order) { $order = new WC_Order(); $order->populate($customer_order); $status = get_term_by('slug', $order->status, 'shop_order_status'); //$items = $order->get_items(); //print_r ($items); $item_count = $order->get_item_count(); $total = $order->get_total(); $orders[$customer_order->ID]['order_number'] = $order->get_order_number(); $orders[$customer_order->ID]['order_date'] = date('Y-m-d', strtotime($order->order_date)); $orders[$customer_order->ID]['order_billing_name'] = $order->get_formatted_billing_full_name(); $orders[$customer_order->ID]['order_shipping_name'] = $order->get_formatted_shipping_full_name(); $orders[$customer_order->ID]['item_count'] = $item_count; $orders[$customer_order->ID]['order_total'] = $total; $orders[$customer_order->ID]['order_link'] = $site_url . "/wp-admin/post.php?action=edit&post=" . $order->get_order_number(); //$orders['order_total'] = $order->get_order_number(); } return $orders; }
/** * Test: get_formatted_billing_full_name */ function test_get_formatted_billing_full_name() { $object = new WC_Order(); $object->set_billing_first_name('Fred'); $object->set_billing_last_name('Flintstone'); $this->assertEquals('Fred Flintstone', $object->get_formatted_billing_full_name()); }
<?php /* * Template Name: Email HTML Template for new order * */ get_header(); $order_id = $_GET['order_id']; $order = new WC_Order($order_id); ?> <div class="row"> <div class="xlarge-6 xlarge-centered large-6 large-centered columns"> <p class="padding_bottom_add" style="font-size:16px; font-family:'Conv_AvenirLTStd-Medium', sans-serif; color:#96a7b0; line-height: 28px;margin:0 auto;padding:0 0 40px 0;"><?php printf(__('You have received an order from %s. The order is as follows:', 'woocommerce'), $order->get_formatted_billing_full_name()); ?> </p> <?php do_action('woocommerce_email_before_order_table', $order, true, false); ?> <h2 style="color:#162c5d; font-size:24px;line-height: 28px; margin:0 auto 20px;font-weight: normal;"><a style="color:#162c5d; text-decoration:none;" class="link" href="<?php echo admin_url('post.php?post=' . $order->id . '&action=edit'); ?> "><?php printf(__('Bestellnummer: %s', 'woocommerce'), $order->get_order_number()); ?> </a> (<?php printf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($order->order_date)), date_i18n(wc_date_format(), strtotime($order->order_date))); ?> )</h2>