function get_order_email_arguments($order_id) { $options = FFLCommerce_Base::get_options(); $order = new fflcommerce_order($order_id); $inc_tax = $options->get('fflcommerce_calc_taxes') == 'no' || $options->get('fflcommerce_prices_include_tax') == 'yes'; $can_show_links = $order->status == 'completed' || $order->status == 'processing'; $statuses = $order->get_order_statuses_and_names(); $variables = array('blog_name' => get_bloginfo('name'), 'order_number' => $order->get_order_number(), 'order_date' => date_i18n(get_option('date_format')), 'order_status' => $statuses[$order->status], 'shop_name' => $options->get('fflcommerce_company_name'), 'shop_address_1' => $options->get('fflcommerce_address_1'), 'shop_address_2' => $options->get('fflcommerce_address_2'), 'shop_tax_number' => $options->get('fflcommerce_tax_number'), 'shop_phone' => $options->get('fflcommerce_company_phone'), 'shop_email' => $options->get('fflcommerce_company_email'), 'customer_note' => $order->customer_note, 'order_items_table' => fflcommerce_get_order_items_table($order, $can_show_links, true, $inc_tax), 'order_items' => $order->email_order_items_list($can_show_links, true, $inc_tax), 'order_taxes' => fflcommerce_get_order_taxes_list($order), 'subtotal' => $order->get_subtotal_to_display(), 'shipping' => $order->get_shipping_to_display(), 'shipping_cost' => fflcommerce_price($order->order_shipping), 'shipping_method' => $order->shipping_service, 'discount' => fflcommerce_price($order->order_discount), 'total_tax' => fflcommerce_price($order->get_total_tax()), 'total' => fflcommerce_price($order->order_total), 'is_local_pickup' => $order->shipping_method == 'local_pickup' ? true : null, 'checkout_url' => $order->status == 'pending' ? $order->get_checkout_payment_url() : null, 'payment_method' => $order->payment_method_title, 'is_bank_transfer' => $order->payment_method == 'bank_transfer' ? true : null, 'is_cash_on_delivery' => $order->payment_method == 'cod' ? true : null, 'is_cheque' => $order->payment_method == 'cheque' ? true : null, 'bank_info' => str_replace(PHP_EOL, '', fflcommerce_bank_transfer::get_bank_details()), 'cheque_info' => str_replace(PHP_EOL, '', $options->get('fflcommerce_cheque_description')), 'billing_first_name' => $order->billing_first_name, 'billing_last_name' => $order->billing_last_name, 'billing_company' => $order->billing_company, 'billing_euvatno' => $order->billing_euvatno, 'billing_address_1' => $order->billing_address_1, 'billing_address_2' => $order->billing_address_2, 'billing_postcode' => $order->billing_postcode, 'billing_city' => $order->billing_city, 'billing_country' => fflcommerce_countries::get_country($order->billing_country), 'billing_state' => strlen($order->billing_state) == 2 ? fflcommerce_countries::get_state($order->billing_country, $order->billing_state) : $order->billing_state, 'billing_country_raw' => $order->billing_country, 'billing state_raw' => $order->billing_state, 'billing_email' => $order->billing_email, 'billing_phone' => $order->billing_phone, 'shipping_first_name' => $order->shipping_first_name, 'shipping_last_name' => $order->shipping_last_name, 'shipping_company' => $order->shipping_company, 'shipping_address_1' => $order->shipping_address_1, 'shipping_address_2' => $order->shipping_address_2, 'shipping_postcode' => $order->shipping_postcode, 'shipping_city' => $order->shipping_city, 'shipping_country' => fflcommerce_countries::get_country($order->shipping_country), 'shipping_state' => strlen($order->shipping_state) == 2 ? fflcommerce_countries::get_state($order->shipping_country, $order->shipping_state) : $order->shipping_state, 'shipping_country_raw' => $order->shipping_country, 'shipping_state_raw' => $order->shipping_state); if ($options->get('fflcommerce_calc_taxes') == 'yes') { $variables['all_tax_classes'] = $variables['order_taxes']; } else { unset($variables['order_taxes']); } return apply_filters('fflcommerce_order_email_variables', $variables, $order_id); }
/** Gets the country and state from the current session for cart shipping display */ public static function get_shipping_country_or_state() { $country = self::get_customer_session('shipping_country'); if ($country) { $state = trim(self::get_customer_session('shipping_state'), ':'); if ($state && fflcommerce_countries::country_has_states($country)) { return fflcommerce_countries::get_state($country, $state); } else { return fflcommerce_countries::get_country($country); } } $country = fflcommerce_countries::get_default_customer_country(); return fflcommerce_countries::get_country($country); }
function column_default($user, $column_name) { switch ($column_name) { case 'customer_name': if ($user->last_name && $user->first_name) { return $user->last_name . ', ' . $user->first_name; } else { return '-'; } case 'username': return $user->user_login; case 'location': $state_code = get_user_meta($user->ID, 'billing_state', true); $country_code = get_user_meta($user->ID, 'billing_country', true); $state = fflcommerce_countries::has_state($country_code, $state_code) ? fflcommerce_countries::get_state($country_code, $state_code) : $state_code; $country = fflcommerce_countries::has_country($country_code) ? fflcommerce_countries::get_country($country_code) : $country_code; $value = ''; if ($state) { $value .= $state . ', '; } $value .= $country; if ($value) { return $value; } else { return '-'; } case 'email': return '<a href="mailto:' . $user->user_email . '">' . $user->user_email . '</a>'; case 'spent': return fflcommerce_price(fflcommerce_get_customer_total_spent($user->ID)); case 'orders': return fflcommerce_get_customer_order_count($user->ID); case 'last_order': $order_ids = get_posts(array('posts_per_page' => 1, 'post_type' => 'shop_order', 'post_status' => array('publish'), 'orderby' => 'date', 'order' => 'desc', 'meta_query' => array(array('key' => 'customer_user', 'value' => $user->ID)), 'fields' => 'ids')); if ($order_ids) { $order = new fflcommerce_order($order_ids[0]); return '<a href="' . admin_url('post.php?post=' . $order->id . '&action=edit') . '">' . $order->get_order_number() . '</a> – ' . date_i18n(get_option('date_format'), strtotime($order->order_date)); } else { return '-'; } break; case 'user_actions': ob_start(); ?> <p> <?php do_action('fflcommerce_admin_user_actions_start', $user); $actions = array(); $actions['refresh'] = array('url' => wp_nonce_url(add_query_arg('refresh', $user->ID), 'refresh'), 'name' => __('Refresh stats', 'fflcommerce'), 'action' => 'refresh'); $actions['edit'] = array('url' => admin_url('user-edit.php?user_id=' . $user->ID), 'name' => __('Edit', 'fflcommerce'), 'action' => 'edit'); $order_ids = $this->get_guest_orders(); $order_ids = array_map(function ($order) { return $order->ID; }, array_filter($order_ids, function ($order) use($user) { return $order->data['billing_email'] == $user->user_email; })); if ($order_ids) { $actions['link'] = array('url' => wp_nonce_url(add_query_arg('link_orders', $user->ID), 'link_orders'), 'name' => __('Link previous orders', 'fflcommerce'), 'action' => 'link'); } $actions = apply_filters('fflcommerce_admin_user_actions', $actions, $user); 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('fflcommerce_admin_user_actions_end', $user); ?> </p><?php $user_actions = ob_get_contents(); ob_end_clean(); return $user_actions; } return ''; }