当前位置: 首页>>代码示例>>PHP>>正文


PHP invoice::initNew方法代码示例

本文整理汇总了PHP中invoice::initNew方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::initNew方法的具体用法?PHP invoice::initNew怎么用?PHP invoice::initNew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invoice的用法示例。


在下文中一共展示了invoice::initNew方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 /**
  * View Cart Contents 
  */
 function view($VAR)
 {
     global $smarty;
     $db =& DB();
     // get cart contents RS
     $result = $this->get_contents($db);
     if ($result->RecordCount() == 0) {
         $smarty->assign('result', '0');
         return false;
     }
     // init invoice object
     include_once PATH_MODULES . 'invoice/invoice.inc.php';
     $invoice = new invoice();
     $invoice->initNew(0);
     $invoice->taxable = false;
     $invoice->discount = false;
     $smart = '';
     $this->put_contents_invoice($db, $result, $invoice, $smart);
     $smarty->assign('results', count($invoice->invoice_item));
     $smarty->assign('cart', $smart);
 }
开发者ID:hbustun,项目名称:agilebill,代码行数:24,代码来源:cart.inc.php

示例2: checkoutnow

 /**
  * Create the Invoice Record and send user to checkout	 
  */
 function checkoutnow($VAR)
 {
     global $C_translate, $C_list, $smarty;
     $db =& DB();
     // Validate user is logged in:
     if (!SESS_LOGGED) {
         echo '<script language="JavaScript">alert("You must be logged in to complete this purchase! Please refresh this page in your browser to login now...");</script>';
         return false;
     }
     // check for admin
     if (!$this->admin_checkout && !empty($VAR['account_id'])) {
         global $C_auth;
         if (!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout', 'admin_checkoutnow')) {
             $this->account_id = $VAR['account_id'];
             $this->admin_checkout = true;
         } else {
             $this->account_id = SESS_ACCOUNT;
         }
     }
     if (empty($this->session_id)) {
         $this->session_id = SESS;
     }
     if (empty($this->account_id)) {
         $this->account_id = SESS_ACCOUNT;
     }
     include_once PATH_MODULES . '/cart/cart.inc.php';
     $cartObj = new cart();
     $cartObj->account_id = $this->account_id;
     $cartObj->session_id = $this->session_id;
     $result = $cartObj->get_contents($db);
     if ($result->RecordCount() == 0) {
         return false;
     }
     // load invoice object
     include_once PATH_MODULES . 'invoice/invoice.inc.php';
     $invoice = new invoice();
     $invoice->account_id = $this->account_id;
     $invoice->initNew(0);
     // Get the account details:
     $account = $db->Execute(sqlSelect($db, "account", "*", "id=::{$this->account_id}::"));
     $invoice->country_id = $account->fields['country_id'];
     $invoice->state = $account->fields['state'];
     // load tax object for tax calculation
     include_once PATH_MODULES . 'tax/tax.inc.php';
     $taxObj = new tax();
     // load discount object for discount calculation
     include_once PATH_MODULES . 'discount/discount.inc.php';
     $discountObj = new discount();
     $discountObj->available_discounts($invoice->account_id);
     // put cart contents into invoice format
     $cartObj->put_contents_invoice($db, $result, $invoice, $smart, $taxObj, $discountObj);
     // Validate and init a checkout plugin
     $checkout = false;
     if ($this->admin_checkout_option) {
         // admin checkout option specified
         include_once PATH_MODULES . 'checkout/checkout_admin.inc.php';
         $PLG = new checkout_admin();
         $checkout = true;
         $invoice->checkout_plugin_id = false;
     } else {
         // get available checkout options and check against the one provided
         $invoice->checkout_plugin_id = $VAR['option'];
         foreach ($invoice->invoice_item as $item) {
             if (!empty($item['product_id'])) {
                 $product_arr[] = $item['product_id'];
             }
         }
         $checkout_options = $this->get_checkout_options($this->account_id, $invoice->total_amt, @$product_arr, $invoice->country_id, $invoice->any_new, $invoice->any_trial, $invoice->any_recurring);
         if ($checkout_options) {
             foreach ($checkout_options as $a) {
                 if ($a['fields']['id'] == $invoice->checkout_plugin_id) {
                     // load the selected checkout plugin and run pre-validation
                     $checkout_plugin = $a['fields']['checkout_plugin'];
                     $plugin_file = PATH_PLUGINS . 'checkout/' . $checkout_plugin . '.php';
                     include_once $plugin_file;
                     eval('$PLG = new plg_chout_' . $checkout_plugin . '("' . $invoice->checkout_plugin_id . '");');
                     $plugin_validate = $PLG->validate($VAR, $this);
                     if ($plugin_validate != true) {
                         echo $plugin_validate;
                         return false;
                     }
                     $checkout = true;
                     break;
                 }
             }
         }
     }
     if (!$checkout) {
         echo '<script language=Javascript> alert("Unable to checkout with the selected method, please select another."); </script> ';
         return false;
     }
     // validate credit card on file details
     global $VAR;
     if (!empty($VAR['account_billing_id']) && @$VAR['new_card'] == 2) {
         $invoice->account_billing_id = $VAR['account_billing_id'];
         /* validate credit card on file details */
         if (!$PLG->setBillingFromDB($this->account_id, $invoice->account_billing_id, $invoice->checkout_plugin_id)) {
//.........这里部分代码省略.........
开发者ID:hbustun,项目名称:agilebill,代码行数:101,代码来源:checkout.inc.php


注:本文中的invoice::initNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。