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


PHP product::price_prod方法代码示例

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


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

示例1: changeqty

 /**
  * Change the quantity of an item 
  */
 function changeqty($VAR)
 {
     if (empty($this->account_id)) {
         $this->account_id = SESS_ACCOUNT;
     }
     if (empty($this->session_id)) {
         $this->session_id = SESS;
     }
     @($id = $VAR['id']);
     @($qty = $VAR['qty']);
     if ($id <= 0) {
         return;
     }
     $db =& DB();
     if ($qty == '0') {
         # Product Plugin Level deletion
         $cartid =& $db->Execute($sql = sqlSelect($db, "cart", "*", "id=::{$id}:: AND session_id = ::{$this->session_id}::"));
         if ($cartid) {
             $product =& $db->Execute($sql = sqlSelect($db, "product", "*", "id=::{$cartid->fields['product_id']}::"));
         }
         if (!empty($product->fields['prod_plugin']) && !empty($product->fields['prod_plugin_data'])) {
             $prodplgfile = PATH_PLUGINS . 'product/' . $product->fields['prod_plugin_file'] . '.php';
             if (is_file($prodplgfile)) {
                 include_once PATH_PLUGINS . 'product/' . $product->fields['prod_plugin_file'] . '.php';
                 eval('$prodplg = new plgn_prov_' . $product->fields['prod_plugin_file'] . ';');
                 if (is_object($prodplg)) {
                     if (is_callable(array($prodplg, 'delete_cart'))) {
                         $prodplg->delete_cart($VAR, $cartid->fields);
                     }
                 }
             }
         }
         # delete main cart items & subitems:
         $sql = '';
         if (empty($this->admin)) {
             $sql = "AND session_id = ::{$this->session_id}::";
         }
         $rs =& $db->Execute($sql = sqlDelete($db, "cart", "(id=::{$id}:: OR cart_parent_id=::{$id}:: ) {$sql}"));
         global $smarty;
         $smarty->assign('js', false);
         return false;
     }
     # update the quantity:
     if (!eregi("^[0-9]{1,5}\$", $qty)) {
         $qty = 1;
     }
     if ($qty < 1) {
         $qty = 1;
     }
     if (!$this->admin) {
         $sql_extra = " AND session_id=::{$this->session_id}::";
     } else {
         $sql_extra = '';
     }
     if ($VAR["type"] == 1) {
         $fields = array('quantity' => $qty);
         $db->Execute($sql = sqlUpdate($db, "cart", $fields, "id=::{$id}:: {$sql_extra}"));
     } else {
         if ($VAR["type"] == 2) {
             $fields = array('recurr_schedule' => $VAR["schedule"]);
             $db->Execute($sql = sqlUpdate($db, "cart", $fields, "id=::{$id}:: {$sql_extra}"));
         } else {
             if ($VAR["type"] == 3) {
                 # change domain term
                 $fields = array('domain_term' => $VAR["term"]);
                 $db->Execute($sql = sqlUpdate($db, "cart", $fields, "id=::{$id}:: {$sql_extra}"));
             }
         }
     }
     # get the product id:
     $result = $db->Execute(sqlSelect($db, "cart", "*", "id={$id} {$sql_extra}", "cart_type,date_orig"));
     # get the product details:
     $product = $db->Execute(sqlSelect($db, "product", "*", "id={$result->fields["product_id"]}"));
     if ($result->fields["cart_type"] == "2") {
         # domain name, get pricing
         include_once PATH_MODULES . 'host_tld/host_tld.inc.php';
         $tldObj = new host_tld();
         $tldprice = $tldObj->price_tld_arr($result->fields["domain_tld"], $result->fields["host_type"], false, false, false, $this->account_id);
         $qty = $result->fields["domain_term"];
         $base_price = $tldprice[$qty];
         $setup_price = 0;
     } else {
         if ($result->fields["cart_type"] == "3") {
             # ad-hoc, get price
             $base_price = $result->fields["ad_hoc_amount"] * $result->fields["quantity"];
             $setup_price = $result->fields["ad_hoc_setup"] * $result->fields["quantity"];
         } else {
             include_once PATH_MODULES . 'product/product.inc.php';
             $productObj = new product();
             # get pricing for this product:
             $prod_price = $productObj->price_prod($product->fields, $result->fields["recurr_schedule"], $this->account);
             $setup_price = $prod_price["setup"] * $result->fields["quantity"];
             $base_price = $prod_price["base"] * $result->fields["quantity"];
             # get pricing for any attributes:
             $attr_price = $productObj->price_attr($product->fields, $result->fields["product_attr"], $result->fields["recurr_schedule"], $this->account);
             $setup_price += $attr_price["setup"] * $result->fields["quantity"];
             $base_price += $attr_price["base"] * $result->fields["quantity"];
//.........这里部分代码省略.........
开发者ID:hbustun,项目名称:agilebill,代码行数:101,代码来源:cart.inc.php

示例2: invoiceItemToService

 function invoiceItemToService($invoice_item_id, $invoice, $service_id = false)
 {
     include_once PATH_MODULES . 'product/product.inc.php';
     $product = new product();
     $trial = false;
     $db =& DB();
     # Get the invoice_item record
     $item =& $db->Execute(sqlSelect($db, "invoice_item", "*", "id = {$invoice_item_id}"));
     # Get the product details
     $prod =& $db->Execute(sqlSelect($db, "product", "*", "id = {$item->fields['product_id']}"));
     # Determine Price, Price Type, and Next Invoice Date:
     if ($item->fields['price_type'] == '2') {
         ### Item is trial for another item:
         $trial = true;
         # Determine trial length.
         $tl = $prod->fields['price_trial_length_type'];
         if ($tl == 0) {
             $this->next_invoice = time() + $prod->fields['price_trial_length'] * 86400;
         } elseif ($tl == 1) {
             $this->next_invoice = time() + $prod->fields['price_trial_length'] * 86400 * 7;
         } elseif ($tl == 2) {
             $this->next_invoice = mktime(0, 0, 0, date('m') + $prod->fields['price_trial_length'], date('d'), date('Y'));
         } else {
             $this->next_invoice = time() + 365 * 86400;
         }
         # get the details of the permanent item
         $q = "SELECT * FROM " . AGILE_DB_PREFIX . "product WHERE\n\t\t        \t  id \t\t=  " . $db->qstr($prod->fields['price_trial_prod']) . " AND\n\t\t        \t  site_id \t=  " . $db->qstr(DEFAULT_SITE);
         $prod = $db->Execute($q);
         /* set the product id to the perm item */
         $item->fields['product_id'] = $prod->fields['id'];
         $this->recurring_schedule = $item->fields['recurring_schedule'];
         ### Get the price
         $price = $product->price_prod($prod->fields, $prod->fields['price_recurr_default'], $invoice->fields['account_id'], false);
         $this->price = @$price['base'] / $item->fields['quantity'];
         $this->bind = '1';
         $item->fields['sku'] = $prod->fields['sku'];
     } elseif ($item->fields['price_type'] == '1') {
         # Recurring Item
         $this->recurring_schedule = $item->fields['recurring_schedule'];
         $this->price = $item->fields['price_base'] / $item->fields['quantity'];
         $this->bind = '1';
         # Determine the next invoice date:
         $this->next_invoice = $this->calcNextInvoiceDate($invoice->fields['due_date'], $this->recurring_schedule, $prod->fields['price_recurr_type'], $prod->fields['price_recurr_weekday'], $prod->fields['price_recurr_week']);
     } elseif ($item->fields['price_type'] == '0') {
         # One-time charge
         $this->recurring_schedule = '';
         $this->next_invoice = '';
         $this->price = $item->fields['price_base'] / $item->fields['quantity'];
         $this->bind = '0';
     } else {
         return false;
     }
     # If set-date type recurring transaction, determine full price:
     if (!$trial && $prod->fields['price_type'] == '1' && $prod->fields['price_recurr_type'] == '1') {
         # Get the base product price:
         $price = $product->price_prod($prod->fields, $this->recurring_schedule, $invoice->fields['account_id'], false);
         $this->price = $price['base'] / $item->fields['quantity'];
         # Get the price of any attributes:
         $price = $product->price_attr($prod->fields, $item->fields['product_attr_cart'], $this->recurring_schedule, $invoice->fields['account_id'], false);
         $this->price += $price['base'] / $item->fields['quantity'];
     }
     # Service settings:
     $this->active = '1';
     $this->queue = 'new';
     $this->host_ip = '';
     $this->host_username = '';
     $this->host_password = '';
     $this->domain_host_tld_id = '';
     $this->domain_host_registrar_id = '';
     $this->domain_date_expire = '';
     # Parent ID
     $this->parent_id = $service_id;
     # determine if groups defined:
     $groups_defined = false;
     if (!empty($prod->fields['assoc_grant_group'])) {
         // type > 0 or num of days defined?
         if ($prod->fields['assoc_grant_group_type'] > 0 || $prod->fields['assoc_grant_group_days'] > 0) {
             // actual groups defined?
             $grant_groups = unserialize($prod->fields['assoc_grant_group']);
             if (is_array($grant_groups) && count($grant_groups) > 0) {
                 foreach ($grant_groups as $key => $group_id) {
                     if ($group_id > 0) {
                         $groups_defined = true;
                         break;
                     }
                 }
             }
         }
         if (!$groups_defined) {
             $prod->fields['assoc_grant_group'] = false;
             $prod->fields['assoc_grant_group_type'] = false;
             $prod->fields['assoc_grant_group_days'] = false;
         }
     }
     # Determine the Service Type:
     $this->type = 'none';
     if ($item->fields['item_type'] == '0') {
         # NONE, GROUP, PRODUCT, OR PRODUCT_GROUP:
         if (!$groups_defined && empty($prod->fields['prod_plugin'])) {
             $this->type = 'none';
//.........这里部分代码省略.........
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:service.inc.php

示例3: addItem

 /**
  * Add an invoice item
  *
  * @param int $id 					Reference ID for use in Cart or false
  * @param object $taxObj			Object for Tax Calculation
  * @param object $discountObj		Object for Discount Calculation
  * @param int $item_type 			0/1=Product/Service/Hosting  2=Domain  3=Add Hoc 
  * @param string $taxable			True, False, or 'validate' to locate the specified $product id and verify
  * @param int $service_id			If this is for a service upgrade, this will be defined
  * @param int $parent_id			Item Parent Id
  * @param int $product_id			Item Product Id
  * @param array $product_attr		Item attributes from the cart/prev service
  * @param string $product_name		Item product name
  * @param string $sku				Item Product SKU
  * @param int $quantity				Item Quantity
  * @param float $price_base			Item Base price 
  * @param float $price_setup		Item Setup Price
  * @param float $discount_manual	Ad Hoc Discount Amount
  * @param int $recurring_schedule	Item recurring schedule, 0=week, 1=month, 2=quarter, 3=semi-annual, 4=annual, 5=bi-year
  * @param int $date_start			Date service started
  * @param int $date_stop			Date service stops
  * @param string $domain_name		Domain name
  * @param string $domain_tld		Domain TLD
  * @param int $domain_term			Domain Term
  * @param string $domain_type		Domain Type (register, transfer, renew, park, ns_transfer)	 
  */
 function addItem($id, &$taxObj, &$discountObj, $item_type, $taxable = false, $service_id = false, $parent_id = false, $product_id = false, $product_attr = false, $product_name = false, $sku = false, $quantity = 1, $price_base = false, $price_setup = false, $discount_manual = false, $recurring_schedule = false, $date_start = false, $date_stop = false, $domain_name = false, $domain_tld = false, $domain_term = false, $domain_type = false)
 {
     $tax_amt = 0;
     $total_amt = 0;
     $discount_amt = 0;
     // define correct qty
     if ($quantity <= 0) {
         $quantity = 1;
     }
     // determine the reference id for this item
     if ($id > 0) {
         $this->item_id = $id;
     } else {
         $this->item_id++;
     }
     // get the product details
     if ($product_id && $item_type < 2) {
         $db =& DB();
         $product = $db->Execute(sqlSelect($db, "product", "*", "id={$product_id}"));
         if ($product && $product->RecordCount()) {
             $taxable = $product->fields['taxable'];
             $this->product["{$this->item_id}"] = $product->fields;
         }
         // get the tld details
     } elseif ($item_type == 2) {
         $db =& DB();
         $tld = $db->Execute(sqlSelect($db, "host_tld", "*", "name=::{$domain_tld}::"));
         if ($tld && $tld->RecordCount()) {
             $taxable = $tld->fields['taxable'];
         }
     }
     // get the product pricing details if product
     $price_type = 0;
     if ($price_base === false && $price_setup === false && $product_id && $item_type < 2) {
         if ($product && $product->RecordCount()) {
             $price_type = $product->fields['price_type'];
             $sku = $product->fields['sku'];
             include_once PATH_MODULES . 'product/product.inc.php';
             $productObj = new product();
             // get pricing for this product:
             $prod_price = $productObj->price_prod($product->fields, $recurring_schedule, $this->account_id);
             $price_base = $prod_price["base"];
             $price_setup = $prod_price["setup"];
             // get the recurring price (do NOT prorate!)
             $prod_price = $productObj->price_prod($product->fields, $recurring_schedule, $this->account_id, false);
             $recur_price = $prod_price["base"];
             // calculate any product attributes fees
             $attr_price = $productObj->price_attr($product->fields, $product_attr, $recurring_schedule, $this->account_id);
             $price_base += $attr_price["base"];
             $price_setup += $attr_price["setup"];
             // determine price type for checkout
             if ($product->fields["price_type"] == '0') {
                 $this->any_new = true;
             } else {
                 if ($product->fields["price_type"] == '1') {
                     $this->any_recurring = true;
                 } else {
                     if ($product->fields["price_type"] == '2') {
                         $this->any_trial = true;
                     }
                 }
             }
         } else {
             $this->any_new = true;
         }
     } else {
         $this->any_new = true;
     }
     // get the TLD pricing details if domain
     if ($price_base === false && $price_setup === false && $domain_tld && $domain_term && $domain_type) {
         include_once PATH_MODULES . 'host_tld/host_tld.inc.php';
         $tldObj = new host_tld();
         $tldprice = $tldObj->price_tld_arr($domain_tld, $domain_type, false, false, false, $this->account_id);
         if ($domain_type == "park") {
//.........这里部分代码省略.........
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:101,代码来源:invoice.inc.php


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