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


PHP Product::getInstance方法代码示例

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


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

示例1: setup_game_data

 /**
  * setup initial game data when player play the game for the first time.
  * invoked by: Controller.GameServer.setup_data()
  * @param $game_data
  * @return bool
  */
 public function setup_game_data($game_data)
 {
     $game_data["gme_player"] = $_SESSION['ply_id'];
     $this->Create(Utility::TABLE_GAME_DATA, $game_data);
     $product = Product::getInstance();
     $product->initialize_product();
     $asset = Asset::getInstance();
     $asset->initialize_asset();
     return true;
 }
开发者ID:anggadarkprince,项目名称:web-businesscareer,代码行数:16,代码来源:Memorycard.class.php

示例2: update_product_price

 /**
  * update product price.
  *
  * role: player
  */
 public function update_product_price()
 {
     if (Authenticate::is_player()) {
         if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) {
             $this->model_product = Product::getInstance();
             $product = $_POST['product_data'];
             $result = $this->model_product->update_player_product($product);
             $binding = array("result_var" => "session_ready", "status_var" => $result);
             binding_data($binding);
         } else {
             transport("error404");
         }
     } else {
         $binding = array("result_var" => "no_session");
         binding_data($binding);
     }
 }
开发者ID:anggadarkprince,项目名称:web-businesscareer,代码行数:22,代码来源:ProductController.php

示例3: OnlineStore_getExpiryNotification

/**
 * retrieve message for when someone tries to add an expired item to cart
 *
 * @return string message
 */
function OnlineStore_getExpiryNotification()
{
    $id = (int) $_REQUEST['id'];
    $p = dbRow('select * from products where id=' . $id);
    $product = Product::getInstance($id, $p, true);
    $typeid = $p['product_type_id'];
    $nfile = USERBASE . '/ww.cache/products/templates/expiry_notification_' . $typeid;
    if (!file_exists($nfile)) {
        $t = dbRow('select template_expired_notification from products_types where id=' . $typeid);
        $template = strlen($t['template_expired_notification']) > 4 ? $t['template_expired_notification'] : '' . __('This product has expired. You cannot add it to the cart.') . '';
        file_put_contents($nfile, $template);
    }
    require_once SCRIPTBASE . '/ww.incs/common.php';
    $smarty = Products_setupSmarty();
    $smarty->assign('product', $product);
    $smarty->assign('product_id', $product->get('id'));
    $smarty->assign('_name', __FromJson($product->name));
    $smarty->assign('_stock_number', $product->stock_number);
    return $smarty->fetch($nfile);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:25,代码来源:api.php

示例4: retrieve_inventory

 /**
  * retrieve inventory data.
  * role: player
  */
 public function retrieve_inventory()
 {
     if (Authenticate::is_player()) {
         if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) {
             $this->model_product = Product::getInstance();
             $this->model_material = Material::getInstance();
             $this->model_asset = Asset::getInstance();
             $product = $this->model_product->get_player_product();
             $material = $this->model_material->get_player_material();
             $asset = $this->model_asset->get_player_asset();
             $binding = array("result_var" => "session_ready", "product_var" => json_encode($product, JSON_PRETTY_PRINT), "material_var" => json_encode($material, JSON_PRETTY_PRINT), "asset_var" => json_encode($asset, JSON_PRETTY_PRINT));
             binding_data($binding);
         } else {
             transport("error404");
         }
     } else {
         $binding = array("result_var" => "no_session");
         binding_data($binding);
     }
 }
开发者ID:anggadarkprince,项目名称:web-businesscareer,代码行数:24,代码来源:InventoryController.php

示例5: OnlineStore_productPriceFull2

/**
 * generates a formatted price, including currency symbol
 *
 * @param array  $params parameters for the function
 * @param object $smarty the current Smarty object
 *
 * @return string HTML of the price
 */
function OnlineStore_productPriceFull2($params, $smarty)
{
    $params = array_merge(array('vat' => 0), $params);
    if (!$params['vat'] && $_SESSION['onlinestore_prices_shown_post_vat']) {
        $params['vat'] = 1;
    }
    $pid = $smarty->smarty->tpl_vars['product']->value->id;
    $product = Product::getInstance($pid);
    $vat = $params['vat'] ? (100 + $_SESSION['onlinestore_vat_percent']) / 100 : 1;
    $vatclass = $params['vat'] ? ' vat' : '';
    $sale_price = $product->getPriceSale();
    if ($sale_price) {
        $tmp = '<strike class="os_price">' . OnlineStore_numToPrice($product->getPrice() * $vat) . '</strike> <strong class="os_price with-sale-price' . $vatclass . '">' . OnlineStore_numToPrice($sale_price * $vat) . '</strong>';
    } else {
        $tmp = '<strong class="os_price' . $vatclass . '">' . OnlineStore_numToPrice($product->getPriceBase() * $vat) . '</strong>';
    }
    list($bp, $ba) = $product->getPriceBulkAll();
    if ($bp && $ba) {
        $tmp .= '<br />' . OnlineStore_numToPrice($bp * $vat) . ' for ' . $ba . ' or more';
    }
    $tmp = '<span class="os_full_price">' . $tmp . '</span>';
    return $tmp;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:31,代码来源:smarty-functions.php

示例6: __

 }
 $c .= '<th>' . __('Price', 'core') . '</th>' . '<th>' . __('Amount', 'core') . '</th>' . '<th class="totals">' . __('Total') . '</th>' . '</tr>';
 // }
 // { set up variables
 $grandTotal = 0;
 $deliveryTotal = 0;
 $discountableTotal = 0;
 $vattable = 0;
 $has_vatfree = false;
 // }
 foreach ($_SESSION['online-store']['items'] as $md5 => $item) {
     $c .= '<tr product="' . $md5 . '" class="os_item_numbers ' . $md5 . '">';
     // { item name and details
     $c .= '<td class="products-itemname">';
     if (isset($item['id']) && $item['id']) {
         $p = Product::getInstance($item['id']);
         if ($p) {
             $img = $p->getDefaultImage();
             if ($img) {
                 $c .= '<a href="/f/' . $img . '" target="popup" ' . 'class="online-store-thumb-wrapper">' . '<img src="/a/f=getImg/w=auto/h=125/' . $img . '"/>' . '</a>';
             }
         }
     }
     if (isset($item['url']) && !empty($item['url'])) {
         $c .= '<a href="' . $item['url'] . '">';
     }
     $c .= htmlspecialchars(__FromJson($item['short_desc']));
     if (isset($item['url']) && !empty($item['url'])) {
         $c .= '</a>';
     }
     if (!$item['vat'] && !$user_is_vat_free) {
开发者ID:raylouis,项目名称:kvwebme,代码行数:31,代码来源:index.php

示例7: dirname

<?php

/**
 * export products to CSV
 *
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <kae@kvsites.ie>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
require_once 'datatable-libs.php';
require_once dirname(__FILE__) . '/../api.php';
$i = 0;
header('Content-type: text/csv; Charset=utf-8');
header('Content-Disposition: attachment; filename="nfgws-export.csv"');
echo '"' . join('","', $columns) . "\"\n";
for (; $i < $total_records; ++$i) {
    $arr = array();
    $p = Product::getInstance($products->product_ids[$i]);
    foreach ($columns as $name) {
        $arr[] = $p->getString($name);
    }
    echo Products_arrayToCSV($arr);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:27,代码来源:export.php

示例8: OnlineStore_updateProductSales

function OnlineStore_updateProductSales($id, $items = false, $date_created = false)
{
    if (!$items) {
        $r = dbRow('select date_created, items from online_store_orders where id=' . $id);
        $items = json_decode($r['items'], true);
        $date_created = $r['date_created'];
    }
    dbQuery('delete from online_store_sales where order_id=' . $id);
    foreach ($items as $k => $v) {
        $p = Product::getInstance($v['id']);
        $profit = 0;
        if ($p) {
            $profit = $p->vals['os_base_price'] - $p->vals['os_supplier_price'];
        }
        $sql = 'insert into online_store_sales set order_id=' . $id . ', source="eBay", product_id=' . $v['id'] . ', profit=' . $profit * $v['amt'] . ', quantity=' . $v['amt'] . ', cdate="' . addslashes($date_created) . '"';
        dbQuery($sql);
    }
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:18,代码来源:plugin.php

示例9: load_data

 /**
  * load game data every play game.
  * role: player
  * @return string
  */
 public function load_data()
 {
     if (Authenticate::is_player()) {
         if (true || isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) {
             $this->model_product = Product::getInstance();
             $this->model_material = Material::getInstance();
             $this->model_asset = Asset::getInstance();
             $this->model_supplier = Supplier::getInstance();
             $this->model_employee = Employee::getInstance();
             $this->model_achievement = Achievement::getInstance();
             $this->model_journal = Journal::getInstance();
             $this->model_memorycard = Memorycard::getInstance();
             $this->model_leaderboard = Leaderboard::getInstance();
             /*
              * retrieve data each component.
              * log this event, wrap it up and convert to json format.
              */
             $game = $this->model_memorycard->load_game_data();
             $work_history = $this->model_memorycard->get_work_stress_history();
             $total_work = $this->model_memorycard->get_total_work();
             $candidate = $this->model_employee->get_candidate();
             $employee = $this->model_employee->get_player_employee();
             $material = $this->model_material->get_material_data();
             $player_material = $this->model_material->get_player_material();
             $asset = $this->model_asset->get_asset_data();
             $player_asset = $this->model_asset->get_player_asset();
             $product = $this->model_product->get_product_data();
             $player_product = $this->model_product->get_player_product();
             $product_material = $this->model_product->get_product_material();
             $supplier = $this->model_supplier->get_supplier_data();
             $achievement = $this->model_achievement->get_achievement();
             $account = $this->model_journal->get_account();
             $simulation = $this->model_memorycard->get_simulation();
             $star = $this->model_leaderboard->get_player_ranking();
             $binding = array("result_var" => "session_ready", "game_var" => json_encode($game, JSON_PRETTY_PRINT), "candidate_var" => json_encode($candidate, JSON_PRETTY_PRINT), "employee_var" => json_encode($employee, JSON_PRETTY_PRINT), "product_var" => json_encode($product, JSON_PRETTY_PRINT), "player_product_var" => json_encode($player_product, JSON_PRETTY_PRINT), "product_material_var" => json_encode($product_material, JSON_PRETTY_PRINT), "material_var" => json_encode($material, JSON_PRETTY_PRINT), "player_material_var" => json_encode($player_material, JSON_PRETTY_PRINT), "asset_var" => json_encode($asset, JSON_PRETTY_PRINT), "player_asset_var" => json_encode($player_asset, JSON_PRETTY_PRINT), "supplier_var" => json_encode($supplier, JSON_PRETTY_PRINT), "achievement_var" => json_encode($achievement, JSON_PRETTY_PRINT), "account_var" => json_encode($account, JSON_PRETTY_PRINT), "simulation_var" => json_encode($simulation, JSON_PRETTY_PRINT), "work_history_var" => json_encode($work_history, JSON_PRETTY_PRINT), "work_total_var" => $total_work, "star" => $star["star"]);
             $log = Log::getInstance();
             $log->logging_game_load(json_encode($binding));
             binding_data($binding);
         } else {
             transport("error404");
         }
     } else {
         $binding = array("result_var" => "no_session");
         binding_data($binding);
     }
 }
开发者ID:anggadarkprince,项目名称:web-businesscareer,代码行数:51,代码来源:GameServerController.php

示例10: Products_adminProductEditVal

/**
 * edit a single value of a product
 *
 * @return array status
 */
function Products_adminProductEditVal()
{
    $id = (int) $_REQUEST['id'];
    $name = strtolower($_REQUEST['name']);
    $value = $_REQUEST['val'];
    if ($name == 'id') {
        return array('error' => 'field not allowed');
    }
    Product::getInstance($id, false, true)->set($name, $value);
    if ($name == 'enabled') {
        if ($value == '0') {
            dbQuery('update products set activates_on=now() where id=' . $id . ' and activates_on>now()');
            dbQuery('update products set expires_on=now() where id=' . $id . ' and expires_on>now()');
        } else {
            dbQuery('update products set expires_on=null where id=' . $id . ' and expires_on<now()');
        }
    }
    Core_cacheClear();
    return array('ok' => 1);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:25,代码来源:api-admin.php

示例11: OnlineStoreEbay_adminLinkProductToEbay

function OnlineStoreEbay_adminLinkProductToEbay()
{
    $id = (int) $_REQUEST['id'];
    $ebay_id = (int) $_REQUEST['ebay_id'];
    Product::getInstance($id)->set(array('ebay_currently_active' => 1, 'ebay_id' => $ebay_id));
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:6,代码来源:api-admin.php

示例12: die

<?php

/**
 * set default image
 *
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <kae@kvsites.ie>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
require $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/basics.php';
if (!Core_isAdmin()) {
    die(__('access denied'));
}
$product_id = (int) $_REQUEST['product_id'];
$imgsrc = '/' . $_REQUEST['imgsrc'];
Product::getInstance($product_id)->set('image_default', $imgsrc);
echo 'ok';
开发者ID:raylouis,项目名称:kvwebme,代码行数:21,代码来源:set-default-image.php

示例13: Products_showQrCode

/**
 * show an image of a QR code leading to a product
 *
 * @return null
 */
function Products_showQrCode()
{
    $pid = (int) $_REQUEST['pid'];
    $product = Product::getInstance($pid);
    if (!$product) {
        redirect('/i/blank.gif');
    }
    $fname = USERBASE . '/ww.cache/products/qr' . $pid;
    if (!file_exists($fname)) {
        require_once SCRIPTBASE . '/ww.incs/phpqrcode.php';
        @mkdir(USERBASE . '/ww.cache/products');
        QRcode::png('http://' . $_SERVER['HTTP_HOST'] . $product->getRelativeUrl(), $fname);
    }
    header('Content-type: image/png');
    header('Cache-Control: max-age=2592000, public');
    header('Expires-Active: On');
    header('Expires: Fri, 1 Jan 2500 01:01:01 GMT');
    header('Pragma:');
    header('Content-Length: ' . filesize($fname));
    readfile($fname);
    Core_quit();
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:27,代码来源:api.php

示例14: foreach

    foreach ($rs as $r) {
        dbQuery('update products_categories set' . ' link="' . addslashes(transcribe($r['name'])) . '"' . 'where id=' . $r['id']);
    }
    $version = 35;
}
if ($version == 35) {
    // fix a bug that has popped up again
    dbQuery('alter table products_types change stock_management stock_control ' . 'smallint default 0');
    $version = 36;
}
if ($version == 36) {
    // change default image to text
    dbQuery('alter table products change image_default image_default text');
    $rs = dbAll('select id from products');
    foreach ($rs as $r) {
        $product = Product::getInstance($r['id']);
        $url = $product->getDefaultImage();
        if (!$url) {
            $url = '';
        }
        dbQuery('update products set' . ' image_default="' . addslashes($url) . '"' . ' where id=' . $r['id']);
    }
    $version = 37;
}
if ($version == 37) {
    // add EAN number to products
    dbQuery('alter table products add ean char(13) default ""');
    $version = 38;
}
if ($version == 38) {
    // periodic imports
开发者ID:raylouis,项目名称:kvwebme,代码行数:31,代码来源:upgrade.php

示例15: OnlineStore_exportToFile

/**
 * exports to file if the status is right
 *
 * @param int   $id    ID of the order
 * @param array $order details of the order
 *
 * @return null
 */
function OnlineStore_exportToFile($id)
{
    $order = dbRow("SELECT * FROM online_store_orders WHERE id={$id}");
    $sendAt = (int) dbOne('select val from online_store_vars where name="export_at_what_point"', 'val');
    if ($sendAt == 0 && $order['status'] != '1') {
        return;
    }
    if ($sendAt == 1) {
        // never send
        return;
    }
    if ($sendAt == 2 && $order['status'] != '2') {
        return;
    }
    if ($sendAt == 3 && $order['status'] != '4') {
        return;
    }
    $form_vals = json_decode($order['form_vals']);
    $items = json_decode($order['items']);
    // { start export
    $export = dbOne('select val from online_store_vars where name="export_dir"', 'val');
    // TODO: ability to edit these values in the admin
    $exportcsv = array('"Phone Number","Customer Name","Address 1","Address 2","Postcode",' . '"Email","Stock Number","Amt","Price","Item ID"');
    // }
    // { handle item-specific stuff (vouchers, stock control)
    foreach ($items as $item_index => $item) {
        if (!$item->id) {
            continue;
        }
        $p = Product::getInstance($item->id);
        $exportcsv[] = '"' . str_replace('"', '""', @$form_vals->Billing_Phone) . '","' . str_replace('"', '""', @$form_vals->Billing_FirstName . ' ' . @$form_vals->Billing_Surname) . '","' . str_replace('"', '""', @$form_vals->Billing_Street) . '","' . str_replace('"', '""', @$form_vals->Billing_Street2) . '","' . str_replace('"', '""', @$form_vals->Billing_Postcode) . ' ' . str_replace('"', '""', @$form_vals->Billing_Town) . '","' . str_replace('"', '""', @$form_vals->Billing_Email) . '","' . str_replace('"', '""', @$p->Billing_stock_number) . '","' . $item->amt . '","' . $item->cost . '","' . $item->id . '"';
        // }
    }
    // }
    Core_cacheClear('products');
    if ($export && strpos($export, '..') === false) {
        $customer = dbOne('select val from online_store_vars where name="export_customers"', 'val');
        if ($customer && strpos($customer, '..') === false) {
            $customer_filename = dbOne('select val from online_store_vars' . ' where name="export_customer_filename"', 'val');
            if (!$customer_filename) {
                $customer_filename = 'customer-{{$Billing_Email}}.csv';
            }
            $customer_filename = str_replace(array('/', '..'), '', $customer_filename);
            $bits = preg_match_all('/{{\\$([^}]*)}}/', $customer_filename, $matches, PREG_SET_ORDER);
            foreach ($matches as $bit) {
                $customer_filename = str_replace('{{$' . $bit[1] . '}}', @$form_vals->{$bit[1]}, $customer_filename);
            }
            $customer_filename = str_replace(array('..', '/'), '', $customer_filename);
            @mkdir(USERBASE . '/' . $customer, 0777, true);
            $phone = preg_replace('/[^0-9\\(\\)\\+]/', '', @$form_vals->Billing_Phone);
            // TODO: must be able to edit values in the admin
            $fcontent = '"Name","Street","Street 2","Postcode","Email","Phone"' . "\n" . '"' . str_replace('"', '""', @$form_vals->Billing_FirstName . ' ' . @$form_vals->Billing_Surname) . '","' . str_replace('"', '""', @$form_vals->Billing_Street) . '","' . str_replace('"', '""', @$form_vals->Billing_Street2) . '","' . str_replace('"', '""', @$form_vals->Billing_Postcode) . '","' . str_replace('"', '""', @$form_vals->Billing_Email) . '","' . str_replace('"', '""', $form_vals->Billing_Phone) . '"';
            file_put_contents(USERBASE . '/' . $customer . '/' . $customer_filename, "" . $fcontent);
        }
        @mkdir(USERBASE . '/' . $export, 0777, true);
        file_put_contents(USERBASE . '/' . $export . '/order' . $id . '.csv', "" . join("\r\n", $exportcsv));
    }
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:66,代码来源:order-status.php


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