function invoice($invoice_id) { $this->load->model('billing/invoice_model'); $invoice = $this->invoice_model->get_invoice($invoice_id); if (empty($invoice_id) or empty($invoice)) { die(show_error('Unable to find an invoice by that ID.')); } $cur_user_id = $this->user_model->active_user['id']; if ($cur_user_id != $invoice['user_id']) { die(show_error('That invoice does not belong to you.')); } // get invoice lines $lines = $this->invoice_model->invoice_lines($invoice['id']); // format address $this->load->helper('format_street_address'); $formatted_address = format_street_address($invoice['billing_address']); // remove <br />'s $formatted_address = strip_tags($formatted_address); // get shipping address $this->load->model('store/order_model'); $order = $this->order_model->get_order($invoice['id'], 'order_id'); $shipping_address = FALSE; if (!empty($order)) { if (!empty($order['shipping'])) { $shipping_address = $order['shipping']; } } if (!empty($shipping_address)) { $formatted_shipping_address = format_street_address($shipping_address); // remove <br />'s $formatted_shipping_address = strip_tags($formatted_shipping_address); } else { $formatted_shipping_address = FALSE; } // get other invoice data $data = $this->invoice_model->get_invoice_data($invoice['id']); $this->smarty->assign('invoice', $invoice); $this->smarty->assign('lines', $lines); $this->smarty->assign('formatted_address', $formatted_address); $this->smarty->assign('shipping_address', $shipping_address); $this->smarty->assign('formatted_shipping_address', $formatted_shipping_address); $this->smarty->assign('shipping', $data['shipping']); $this->smarty->assign('subtotal', $data['subtotal']); $this->smarty->assign('tax', $data['tax']); $this->smarty->assign('total', $data['total']); $this->smarty->assign('discount', $data['discount']); return $this->smarty->display('account_templates/invoice'); }
function profile($id) { $user = $this->user_model->get_user($id); if (!$user) { die(show_error('User does not exist.')); } // navigation $this->admin_navigation->module_link('Edit Profile', site_url('admincp/users/edit/' . $user['id'])); // prep data $custom_fields = $this->user_model->get_custom_fields(); if (module_installed('billing')) { $this->load->model('billing/subscription_model'); $subscriptions = $this->subscription_model->get_subscriptions_friendly(array(), $user['id']); } // prep $show_usergroups $this->load->model('usergroup_model'); $usergroups = $this->usergroup_model->get_usergroups(); $usergroup_options = array(); foreach ($usergroups as $group) { $usergroup_options[$group['id']] = $group['name']; } $usergroups = $usergroup_options; foreach ($user['usergroups'] as $key => $group) { $user['usergroups'][$key] = $usergroups[$group]; } $user['show_usergroups'] = implode(', ', $user['usergroups']); // get billing address if (module_installed('billing')) { $billing_address = $this->user_model->get_billing_address($user['id']); $this->load->helper('format_street_address'); $formatted_billing_address = format_street_address($billing_address); } $data = array('user' => $user, 'custom_fields' => $custom_fields, 'subscriptions' => isset($subscriptions) ? $subscriptions : FALSE, 'usergroups' => $usergroups, 'billing_address' => isset($formatted_billing_address) ? $formatted_billing_address : FALSE); $this->load->view('profile', $data); }
/** * Register Data * * Loads a type of data into the hook before calling. * This makes it available for emails. * They may cross-reference to save resources. * * @param string $data * @param int $id * * @return boolean TRUE */ public function data($type, $id) { if ($type == 'member') { // check for cross-reference if ($this->member == $id) { return TRUE; } $this->CI->load->model('users/user_model'); $user = $this->CI->user_model->get_user($id, TRUE); if (empty($user)) { die(show_error('Trigger Data: Unable to load data for user #' . $id)); } $this->data_var('member', $user); // save ID $this->member = $user['id']; } elseif ($type == 'order') { // check for cross-reference if ($this->order == $id) { return TRUE; } $this->CI->load->model('store/order_model'); $order = $this->CI->order_model->get_order($id, 'order_id'); if (empty($order)) { die(show_error('Trigger Data: Unable to load data for order #' . $id)); } // shipping address if (!empty($order['shipping'])) { $this->CI->load->helper('format_street_address'); $shipping_address = str_replace('<br />', "\n", str_replace("\n", '', format_street_address($order['shipping']))); } else { $shipping_address = FALSE; } $this->data_var('shipping_address', $shipping_address); // set totals $this->data_var('order_totals', $order['totals']); // products $products = $this->CI->order_model->get_order_products(array('invoice_id' => $order['invoice_id'])); $this->data_var('products', $products); // cross-reference $this->data('invoice', $order['invoice_id']); // save ID $this->order = $order['invoice_id']; } elseif ($type == 'product') { // check for cross-reference if ($this->product == $id) { return TRUE; } $this->CI->load->model('store/products_model'); $product = $this->CI->products_model->get_product($id); if (empty($product)) { die(show_error('Trigger Data: Unable to load data for product #' . $id)); } $this->data_var('product', $product); // save ID $this->product = $product['id']; } elseif ($type == 'invoice') { $this->CI->load->helper('format_street_address'); // check for cross-reference if ($this->invoice == $id) { return TRUE; } $this->CI->load->model('billing/invoice_model'); $invoice = $this->CI->invoice_model->get_invoice($id); if (empty($invoice)) { die(show_error('Trigger Data: Unable to load data for invoice #' . $id)); } // for consistency, we'll move the billing address to a main variable $billing_address = $invoice['billing_address']; unset($invoice['billing_address']); // ... and format it $billing_address = str_replace('<br />', "\n", str_replace("\n", '', format_street_address($billing_address))); $this->data_var('invoice', $invoice); $this->data_var('billing_address', $billing_address); // cross-reference if ($invoice['subscription_id']) { $this->data('subscription', $invoice['subscription_id']); } $this->data('member', $invoice['user_id']); // save ID $this->invoice = $invoice['id']; } elseif ($type == 'subscription') { // check for cross-reference if ($this->subscription == $id) { return TRUE; } $this->CI->load->model('billing/subscription_model'); $subscription = $this->CI->subscription_model->get_subscription($id); if (empty($subscription)) { die(show_error('Trigger Data: Unable to load data for subscription #' . $id)); } $this->data_var('subscription', $subscription); // cross reference $this->data('member', $subscription['user_id']); $this->data('subscription_plan', $subscription['plan_id']); // save ID $this->subscription = $subscription['id']; } elseif ($type == 'subscription_plan') { // check for cross-reference if ($this->subscription_plan == $id) { return TRUE; } $this->CI->load->model('billing/subscription_plan_model'); $subscription_plan = $this->CI->subscription_plan_model->get_plan($id); if (empty($subscription_plan)) { die(show_error('Trigger Data: Unable to load data for subscription plan #' . $id)); } $this->data_var('subscription_plan', $subscription_plan); // save ID $this->subscription_plan = $subscription_plan['id']; } log_message('debug', 'Hook: ' . $type . ' (#' . $id . ') data registered to active hook.'); return TRUE; }
<h3>Billing Address</h3> <?php echo format_street_address($invoice['billing_address']); ?> <br/><?php echo isset($invoice['billing_address']['email']) && !empty($invoice['billing_address']['email']) ? $invoice['billing_address']['email'] : $invoice['user_email']; ?> </div> <?php if (!empty($order) and isset($order['shipping']) and !empty($order['shipping'])) { ?> <div style="float: left; width: 45%"> <h3>Shipping Address</h3> <?php echo format_street_address($order['shipping']); ?> </div> <?php } ?> <div style="clear:both"></div> </div> <?php if (!empty($invoice['coupon_name'])) { ?> <div> <p><b>Coupon Used: </b> <?php echo $invoice['coupon_name']; ?>
/** * Billing & Shipping Addresses */ function billing_shipping() { // is this a free cart? if so, it doesn't require an address // by doing this prior to the methods below, we can retain any notices that may need to be shown $this->load->model('store/cart_model'); if ($this->cart_model->free_cart()) { return redirect('checkout/free_confirm'); } $this->get_errors_and_notices(); $this->prep_cart(); $this->require_login(); // show a new account thank you if we just registered a new account if ($this->input->get('new_account') == 'true') { $this->session->set_userdata('notices', '<p>You have successfully created a new account. You may continue your checkout below.</p>'); return redirect('checkout/billing_shipping'); } // do we have a valid billing address on file? $valid_billing_address = $this->user_model->validate_billing_address($this->user_model->get('id')) == TRUE ? TRUE : FALSE; $billing_address = $this->user_model->get_billing_address($this->user_model->get('id')); $this->load->helper('format_street_address'); $formatted_billing_address = format_street_address($billing_address); // get states & countries $this->load->model('states_model'); $countries = $this->states_model->GetCountries(); $states = $this->states_model->GetStates(); // billing address values if ($this->input->get('billing_values')) { $billing_values = unserialize(query_value_decode($this->input->get('billing_values'))); } else { if (empty($billing_address)) { $billing_values = array('first_name' => $this->user_model->get('first_name'), 'last_name' => $this->user_model->get('last_name'), 'address_1' => '', 'address_2' => '', 'company' => '', 'city' => '', 'state' => '', 'country' => '', 'postal_code' => '', 'phone_number' => ''); } else { $billing_values = array('first_name' => $billing_address['first_name'], 'last_name' => $billing_address['last_name'], 'address_1' => $billing_address['address_1'], 'address_2' => $billing_address['address_2'], 'company' => $billing_address['company'], 'city' => $billing_address['city'], 'state' => $billing_address['state'], 'country' => $billing_address['country'], 'postal_code' => $billing_address['postal_code'], 'phone_number' => $billing_address['phone_number']); } } // shipping address values if ($this->input->get('shipping_values')) { $shipping_values = unserialize(query_value_decode($this->input->get('shipping_values'))); } else { $shipping_values = array('first_name' => $this->user_model->get('first_name'), 'last_name' => $this->user_model->get('last_name'), 'company' => '', 'city' => '', 'state' => '', 'country' => '', 'postal_code' => '', 'phone_number' => ''); } $this->smarty->assign('billing_values', $billing_values); $this->smarty->assign('shipping_values', $shipping_values); $this->smarty->assign('countries', $countries); $this->smarty->assign('states', $states); $this->smarty->assign('formatted_billing_address', $formatted_billing_address); $this->smarty->assign('valid_billing_address', $valid_billing_address); $this->smarty->assign('billing_address', $billing_address); return $this->smarty->display('checkout_templates/billing_shipping.thtml'); }
?> name="shipped_<?php echo $row['order_products_id']; ?> " value="1" /> Yes</td> <td> <?php if (!empty($row['shipping_address'])) { ?> <a href="#" class="show_shipping">show details</a> <a href="#" class="hide_shipping">hide details</a> <div class="shipping_address"><i>Ship via <b><?php echo $row['shipping_name']; ?> </b> to:</i><br /><?php echo format_street_address($row['shipping_address']); ?> </div> <?php } else { ?> none <?php } ?> </td> <td> <input type="hidden" name="action_id" value="<?php echo $row['invoice_id']; ?> " />