本文整理汇总了PHP中ps_DB::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_DB::num_rows方法的具体用法?PHP ps_DB::num_rows怎么用?PHP ps_DB::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ps_DB
的用法示例。
在下文中一共展示了ps_DB::num_rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vmGet
$pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
} else {
// We are in account maintenance
$pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_ACCOUNT_TITLE'), $sess->url(SECUREURL . 'index.php?page=account.index'));
$pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_USER_FORM_SHIPTO_LBL'), $sess->url(SECUREURL . "index.php?page={$next_page}"));
$pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
}
$vm_mainframe->vmAppendPathway($pathway);
// Set the internal VirtueMart pathway
$tpl = vmTemplate::getInstance();
$tpl->set('pathway', $pathway);
$vmPathway = $tpl->fetch('common/pathway.tpl.php');
$tpl->set('vmPathway', $vmPathway);
$missing = vmGet($vars, 'missing');
if (!empty($missing)) {
echo "<script type=\"text/javascript\">alert('" . $VM_LANG->_('CONTACT_FORM_NC', false) . "'); </script>\n";
}
$db = new ps_DB();
if (!empty($user_info_id)) {
$q = "SELECT * from #__{vm}_user_info WHERE user_info_id='" . $database->getEscaped($user_info_id) . "' ";
$q .= " AND user_id='" . $auth['user_id'] . "'";
$q .= " AND address_type='ST'";
$db->query($q);
$db->next_record();
}
if (!$db->num_rows()) {
$vars['country'] = vmGet($_REQUEST, 'country', $vendor_country);
}
$fields = ps_userfield::getUserFields('shipping');
$tpl->set_vars(array('next_page' => $next_page, 'fields' => $fields, 'missing' => $missing, 'vars' => $vars, 'db' => $db, 'user_info_id' => $user_info_id));
echo $tpl->fetch('pages/' . $page . '.tpl.php');
示例2: update
/**
* Function to update a Shopper Entry
* (uses who have perms='shopper')
*/
function update(&$d)
{
global $my, $perm, $sess, $vmLogger, $page;
$auth = $_SESSION['auth'];
$db = new ps_DB();
if (@$d["user_id"] != $my->id && @$d["user_id"] != $auth['user_id'] && $auth["perms"] != "admin") {
$vmLogger->crit("Tricky tricky, but we know about this one.");
return False;
}
require_once CLASSPATH . 'ps_user.php';
if (!empty($d['username'])) {
$_POST['username'] = $d['username'];
} else {
$_POST['username'] = $my->username;
}
$_POST['name'] = $d['first_name'] . " " . $d['last_name'];
$_POST['id'] = $auth["user_id"];
$_POST['gid'] = $my->gid;
$d['error'] = "";
if (VM_REGISTRATION_TYPE != 'NO_REGISTRATION') {
ps_user::saveUser($d);
}
if (!empty($d['error'])) {
return false;
}
if (!$this->validate_update($d)) {
return false;
}
$user_id = $auth["user_id"];
/* Update Bill To */
// Get all fields which where shown to the user
$userFields = ps_userfield::getUserFields('account', false, '', true);
$skip_fields = ps_userfield::getSkipFields();
$fields = array('mdate' => time());
foreach ($userFields as $userField) {
if (!in_array($userField->name, $skip_fields)) {
$fields[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, vmGet($d, $userField->name, strtoupper($userField->name)));
}
}
$fields['user_email'] = $fields['email'];
unset($fields['email']);
$db->buildQuery('UPDATE', '#__{vm}_user_info', $fields, " WHERE user_id=" . $user_id . " AND address_type='BT'");
// Run the query!
$db->query();
// UPDATE #__{vm}_shopper group relationship
$q = "SELECT shopper_group_id FROM #__{vm}_shopper_vendor_xref ";
$q .= "WHERE user_id = '" . $user_id . "'";
$db->query($q);
if (!$db->num_rows()) {
//add
$shopper_db = new ps_DB();
// get the default shopper group
$q = "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
$q .= "`default`='1'";
$shopper_db->query($q);
if (!$shopper_db->num_rows()) {
// when there is no "default", take the first in the table
$q = "SELECT shopper_group_id from #__{vm}_shopper_group";
$shopper_db->query($q);
}
$shopper_db->next_record();
$my_shopper_group_id = $shopper_db->f("shopper_group_id");
if (empty($d['customer_number'])) {
$d['customer_number'] = "";
}
$q = "INSERT INTO #__{vm}_shopper_vendor_xref ";
$q .= "(user_id,vendor_id,shopper_group_id) ";
$q .= "VALUES ('";
$q .= $_SESSION['auth']['user_id'] . "','";
$q .= $_SESSION['ps_vendor_id'] . "','";
$q .= $my_shopper_group_id . "')";
$db->query($q);
}
$q = "SELECT user_id FROM #__{vm}_auth_user_vendor ";
$q .= "WHERE user_id = '" . $_SESSION['auth']['user_id'] . "'";
$db->query($q);
if (!$db->num_rows()) {
// Insert vendor relationship
$q = "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)";
$q .= " VALUES ";
$q .= "('" . $_SESSION['auth']['user_id'] . "','";
$q .= $_SESSION['ps_vendor_id'] . "') ";
$db->query($q);
}
return True;
}
示例3:
/**
* Calculates the taxable order subtotal for the order.
* If an item has no weight, it is non taxable.
* @author Chris Coleman
* @param array $d
* @return float Subtotal
*/
function calc_order_taxable($d)
{
$auth = $_SESSION['auth'];
$cart = $_SESSION['cart'];
$subtotal = 0.0;
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
require_once CLASSPATH . 'ps_shipping_method.php';
$db = new ps_DB();
for ($i = 0; $i < $cart["idx"]; $i++) {
$skip_tax = false;
// do we skip this product due to zero percent tax rate?
$tax_rate_id = $ps_product->get_field($cart[$i]["product_id"], 'product_tax_id');
if ($tax_rate_id != '0') {
// look up the tax rate
$q = "SELECT tax_rate FROM #__{vm}_tax_rate WHERE tax_rate_id='{$tax_rate_id}'";
$db->query($q);
if ($db->num_rows() > 0) {
$tax_rate = $db->f('tax_rate');
if ($tax_rate == 0) {
$skip_tax = true;
}
}
}
$price = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
$product_price = $GLOBALS['CURRENCY']->convert($price["product_price"], $price['product_currency']);
$item_weight = ps_shipping_method::get_weight($cart[$i]["product_id"]) * $cart[$i]['quantity'];
if (($item_weight != 0 or TAX_VIRTUAL == '1') && !$skip_tax) {
$subtotal += $product_price * $cart[$i]["quantity"];
}
}
return $subtotal;
}
示例4: elseif
/**
* Prints a drop-down list of vendor names and their ids.
*
* @param int $vendor_id
*/
function list_vendor($vendor_id = '1')
{
$db = new ps_DB();
$q = "SELECT vendor_id,vendor_name FROM #__{vm}_vendor ORDER BY vendor_name";
$db->query($q);
$db->next_record();
// If only one vendor do not show list
if ($db->num_rows() == 1) {
echo '<input type="hidden" name="vendor_id" value="' . $db->f("vendor_id") . '" />';
echo $db->f("vendor_name");
} elseif ($db->num_rows() > 1) {
$db->reset();
$array = array();
while ($db->next_record()) {
$array[$db->f("vendor_id")] = $db->f("vendor_name");
}
echo ps_html::selectList('vendor_id', $vendor_id, $array);
}
}
示例5: vmGet
/**
* Lists all child/sister products of the given product
*
* @param int $product_id
* @return string HTML code with Items, attributes & price
*/
function list_attribute_list($product_id, $display_use_parent, $child_link, $display_type, $cls_sfuffix, $child_ids, $dw, $aw, $display_header, $product_list_type, $product_list)
{
global $CURRENCY_DISPLAY, $mm_action_url;
require_once CLASSPATH . 'ps_product.php';
$ps_product = new ps_product();
require_once CLASSPATH . 'ps_product_type.php';
$ps_product_type = new ps_product_type();
$Itemid = vmGet($_REQUEST, 'Itemid', "");
$category_id = vmGet($_REQUEST, 'category_id', "");
$curr_product = vmGet($_REQUEST, 'product_id', "");
$db = new ps_DB();
$db_sku = new ps_DB();
$db_item = new ps_DB();
$tpl = vmTemplate::getInstance();
$price = $ps_product->get_adjusted_attribute_price($product_id);
$tpl->set("cls_suffix", $cls_sfuffix);
$tpl->set("product_id", $product_id);
$tpl->set("display_header", $display_header);
$tpl->set("display_product_type", $product_list_type);
$tpl->set("product_price", $price['product_price']);
$html = '';
// Get list of children
$pp = $ps_product->parent_has_children($product_id);
if ($pp) {
$q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id='{$product_id}' ";
} else {
$q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id='{$product_id}' ";
}
if ($child_ids) {
$ids = explode(",", $child_ids);
$child_array = array();
$parent_array = array();
foreach ($ids as $extra_id) {
if ($ps_product->parent_has_children($extra_id)) {
$parent_array[] = $extra_id;
} else {
$child_array[] = $extra_id;
}
}
$parent_ids = implode(',', $parent_array);
$child_ids = implode(',', $child_array);
if ($child_ids) {
$q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_id IN ({$child_ids}) ";
}
if ($parent_ids) {
$q .= "UNION ALL SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock,product_full_image,product_thumb_image FROM #__{vm}_product WHERE product_publish='Y' AND product_parent_id IN ({$parent_ids})";
}
}
$db->query($q);
if ($pp) {
$master_id = $product_id;
} else {
$master_id = $db->f("product_id");
}
$main_master = $master_id;
$master_child_count = 0;
if ($db->num_rows() < 1) {
// Try to Get list of sisters & brothers
$q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$child_id = $product_id;
$product_id = $db->f("product_parent_id") ? $db->f("product_parent_id") : $product_id;
$parent_id = $db->f("product_parent_id");
$q = "SELECT product_id,product_name,product_parent_id,product_sku,product_in_stock FROM #__{vm}_product WHERE product_parent_id='" . $db->f("product_parent_id") . "' AND product_parent_id<>0 AND product_publish='Y'";
$db->query($q);
}
if ($db->num_rows() > 0) {
$products = array();
$headings = array();
$i = 0;
$attrib_heading = array();
$ci = 0;
while ($db->next_record()) {
$parent_id = $db->f("product_parent_id");
if ($db->f("product_id") != $curr_product && @$child_id) {
continue;
}
// Start row for this child
$q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
$q .= "WHERE product_id='" . $db->f("product_parent_id") . "' ORDER BY attribute_list ASC";
$db_sku->query($q);
$attrib_value = array();
while ($db_sku->next_record()) {
$q = "SELECT attribute_name,attribute_value ";
$q .= "FROM #__{vm}_product_attribute WHERE ";
$q .= "product_id='" . $db->f("product_id") . "' AND ";
$q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
$db_item->setQuery($q);
$db_item->query();
while ($db_item->next_record()) {
if ($ci == 0) {
$attrib_heading[] = $db_item->f("attribute_name");
$tpl->set('headings', $attrib_heading);
//.........这里部分代码省略.........
示例6: vmGet
/**
* Lists the payment methods of all available payment modules
* @static
* @param int $payment_method_id
*/
function list_payment_methods($payment_method_id = 0)
{
global $order_total, $sess, $VM_CHECKOUT_MODULES;
$ps_vendor_id = $_SESSION['ps_vendor_id'];
$auth = $_SESSION['auth'];
$ship_to_info_id = vmGet($_REQUEST, 'ship_to_info_id');
$shipping_rate_id = vmGet($_REQUEST, 'shipping_rate_id');
require_once CLASSPATH . 'ps_payment_method.php';
$ps_payment_method = new ps_payment_method();
require_once CLASSPATH . 'ps_creditcard.php';
$ps_creditcard = new ps_creditcard();
$count = 0;
// Do we have Credit Card Payments?
$db_cc = new ps_DB();
$q = "SELECT * from #__{vm}_payment_method,#__{vm}_shopper_group WHERE ";
$q .= "#__{vm}_payment_method.shopper_group_id=#__{vm}_shopper_group.shopper_group_id ";
$q .= "AND (#__{vm}_payment_method.shopper_group_id='" . $auth['shopper_group_id'] . "' ";
$q .= "OR #__{vm}_shopper_group.default='1') ";
$q .= "AND (enable_processor='' OR enable_processor='Y') ";
$q .= "AND payment_enabled='Y' ";
$q .= "AND #__{vm}_payment_method.vendor_id='{$ps_vendor_id}' ";
$q .= " ORDER BY list_order";
$db_cc->query($q);
if ($db_cc->num_rows()) {
$first_payment_method_id = $db_cc->f("payment_method_id");
$count += $db_cc->num_rows();
$cc_payments = true;
} else {
$cc_payments = false;
}
$db_nocc = new ps_DB();
$q = "SELECT * from #__{vm}_payment_method,#__{vm}_shopper_group WHERE ";
$q .= "#__{vm}_payment_method.shopper_group_id=#__{vm}_shopper_group.shopper_group_id ";
$q .= "AND (#__{vm}_payment_method.shopper_group_id='" . $auth['shopper_group_id'] . "' ";
$q .= "OR #__{vm}_shopper_group.default='1') ";
$q .= "AND (enable_processor='B' OR enable_processor='N' OR enable_processor='P') ";
$q .= "AND payment_enabled='Y' ";
$q .= "AND #__{vm}_payment_method.vendor_id='{$ps_vendor_id}' ";
$q .= " ORDER BY list_order";
$db_nocc->query($q);
if ($db_nocc->next_record()) {
$nocc_payments = true;
$first_payment_method_id = $db_nocc->f("payment_method_id");
$count += $db_nocc->num_rows();
$db_nocc->reset();
} else {
$nocc_payments = false;
}
// Redirect to the last step when there's only one payment method
if ($VM_CHECKOUT_MODULES['CHECK_OUT_GET_PAYMENT_METHOD']['order'] != $VM_CHECKOUT_MODULES['CHECK_OUT_GET_FINAL_CONFIRMATION']['order']) {
if ($count <= 1 && $cc_payments == false) {
vmRedirect($sess->url(SECUREURL . basename($_SERVER['PHP_SELF']) . "?page=checkout.index&payment_method_id={$first_payment_method_id}&ship_to_info_id={$ship_to_info_id}&shipping_rate_id=" . urlencode($shipping_rate_id) . "&checkout_stage=" . $VM_CHECKOUT_MODULES['CHECK_OUT_GET_FINAL_CONFIRMATION']['order'], false, false), "");
} elseif (isset($order_total) && $order_total <= 0.0) {
// In case the order total is less than or equal zero, we don't need a payment method
vmRedirect($sess->url(SECUREURL . basename($_SERVER['PHP_SELF']) . "?page=checkout.index&ship_to_info_id={$ship_to_info_id}&shipping_rate_id=" . urlencode($shipping_rate_id) . "&checkout_stage=" . $VM_CHECKOUT_MODULES['CHECK_OUT_GET_FINAL_CONFIRMATION']['order'], false, false), "");
}
}
$theme = new $GLOBALS['VM_THEMECLASS']();
$theme->set_vars(array('db_nocc' => $db_nocc, 'db_cc' => $db_cc, 'nocc_payments' => $nocc_payments, 'payment_method_id' => $payment_method_id, 'first_payment_method_id' => $first_payment_method_id, 'count' => $count, 'cc_payments' => $cc_payments, 'ps_creditcard' => $ps_creditcard, 'ps_payment_method' => $ps_payment_method));
echo $theme->fetch('checkout/list_payment_methods.tpl.php');
}
示例7:
/**
* Validates the Input Parameters onBeforeUserDelete
*
* @param int $id
* @return boolean
*/
function validate_delete($id)
{
global $my, $vmLogger, $perm, $VM_LANG;
$auth = $_SESSION['auth'];
$valid = true;
if (empty($id)) {
$vmLogger->err($VM_LANG->_('VM_USER_DELETE_SELECT'));
return false;
}
$db = new ps_DB();
$q = 'SELECT user_id, perms FROM #__{vm}_user_info WHERE user_id=' . (int) $id;
$db->query($q);
// Only check VirtueMart users - the user may be only a CMS user
if ($db->num_rows() > 0) {
$perms = $db->f('perms');
if (!$perm->hasHigherPerms($perms)) {
$vmLogger->err(sprintf($VM_LANG->_('VM_USER_DELETE_ERR_NOPERMS'), $perms));
$valid = false;
}
if ($id == $my->id) {
$vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_YOURSELF'));
$valid = false;
}
}
return $valid;
}
示例8: while
function list_attribute($product_id, $fils = true)
{
global $VM_LANG, $CURRENCY_DISPLAY;
$ps_product = new ps_product();
$db = new ps_DB();
$db_sku = new ps_DB();
$db_item = new ps_DB();
// Get list of children
if ($fils) {
$q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_id}' AND product_publish='Y'";
} else {
$q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$product_parent_id = $db->f("product_parent_id");
$q = "SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id='{$product_parent_id}' AND product_publish='Y'";
}
$db->setQuery($q);
$db->query();
if ($db->num_rows() > 0) {
$display = '<select name="product_id" onChange="this.form.add_product_validate.value=0;this.form.submit();">';
$display .= '<option value="-1">Choisissez un produit item</option>';
while ($db->next_record()) {
$display .= '<option value="' . $db->f("product_id") . '"';
if ($product_id == $db->f("product_id")) {
$display .= ' selected="yes"';
}
$display .= '>' . $db->f("product_name");
// For each child get attribute values by looping through attribute list
$q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
$q .= "WHERE product_id='{$product_id}' ORDER BY attribute_list ASC";
$db_sku->setQuery($q);
$db_sku->query();
while ($db_sku->next_record()) {
$q = "SELECT attribute_name, attribute_value, product_id ";
$q .= "FROM #__{vm}_product_attribute WHERE ";
$q .= "product_id='" . $db->f("product_id") . "' AND ";
$q .= "attribute_name='" . $db_sku->f("attribute_name") . "'";
$db_item->setQuery($q);
$db_item->query();
while ($db_item->next_record()) {
$display .= ' - ' . $db_item->f("attribute_name") . " ";
$display .= "(" . $db_item->f("attribute_value") . ")";
if (!$db_sku->is_last_record()) {
$display .= '; ';
}
}
}
// Attributes for this item are done.
// Now get item price
$price = $ps_product->get_price($db->f("product_id"));
if ($_SESSION["auth"]["show_price_including_tax"] == 1) {
$tax_rate = 1 + $ps_product->get_product_taxrate($db->f("product_id"));
$price['product_price'] *= $tax_rate;
}
$display .= ' - ' . $CURRENCY_DISPLAY->getFullValue($price["product_price"]);
$display .= '</option>';
}
$display .= '</select>';
} else {
$display = "<input type=\"hidden\" name=\"product_id\" value=\"{$product_id}\" />\n";
}
return $display;
}
示例9: while
<label for="child_' . $db->f("product_id") . '">' . $db->f("product_name") . ' (';
while ($db_att->next_record()) {
echo $db_att->f("attribute_name") . ": " . $db_att->f("attribute_value") . "; ";
}
echo ')</label><br/>';
}
$tabs->endTab();
}
}
if ($product_id) {
// SHOW THE WAITING LIST!
$dbw = new ps_DB();
$dbw->query('SELECT name, username, user_id, notify_email, notified, notify_date FROM `#__{vm}_waiting_list`
LEFT JOIN `#__users` ON `user_id` = `id`
WHERE `product_id`=' . $product_id);
if ($dbw->num_rows() > 0) {
$tabs->startTab($VM_LANG->_('PRODUCT_WAITING_LIST_TAB'), 'waiting-list-tab');
echo '<table class="adminform"><tr><td><h2>' . $VM_LANG->_('PRODUCT_WAITING_LIST_USERLIST') . ':</h2></td></tr>';
echo '<tr><td><input type="hidden" value="' . $db->f('product_in_stock') . '" name="product_in_stock_old" />';
echo '<input type="checkbox" value="1" checked="checked" id="notify_users" name="notify_users" /> <label for="notify_users">' . $VM_LANG->_('PRODUCT_WAITING_LIST_NOTIFYUSERS') . '</label><br /><br /></td></tr>';
echo '<tr><td>';
while ($dbw->next_record()) {
if ($dbw->f("notified") == 1) {
$waiting_notified = ' - <strong style="font-weight:bold">' . $VM_LANG->_('PRODUCT_WAITING_LIST_NOTIFIED') . ' ' . $dbw->f("notify_date") . '</strong>';
} else {
$waiting_notified = '';
}
if ($dbw->f("user_id") == 0) {
$waitinglist[] = '<a href="mailto:' . $dbw->f('notify_email') . '">' . $dbw->f('notify_email') . '</a>' . $waiting_notified;
} else {
$waitinglist[] = $dbw->f('name') . ' (' . $dbw->f('username') . ' - ' . '<a href="mailto:' . $dbw->f('notify_email') . '">' . $dbw->f('notify_email') . '</a>' . ')' . $waiting_notified;
示例10: array
function get_price($product_id, $quantity = 0, $check_multiple_prices = false, $result_attributes = '')
{
if ($check_multiple_prices) {
$db = new ps_DB();
// Get the vendor id for this product.
$q = "SELECT vendor_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$vendor_id = $db->f("vendor_id");
$q = "SELECT svx.shopper_group_id, sg.shopper_group_discount FROM #__{vm}_shopper_vendor_xref svx, #__{vm}_orders o, #__{vm}_shopper_group sg";
$q .= " WHERE svx.user_id=o.user_id AND sg.shopper_group_id=svx.shopper_group_id AND o.order_id=" . $this->order_id;
$db->query($q);
$db->next_record();
$shopper_group_id = $db->f("shopper_group_id");
$shopper_group_discount = $db->f("shopper_group_discount");
// Get the default shopper group id for this vendor
$q = "SELECT shopper_group_id,shopper_group_discount FROM #__{vm}_shopper_group WHERE ";
$q .= "vendor_id='{$vendor_id}' AND `default`='1'";
$db->setQuery($q);
$db->query();
$db->next_record();
$default_shopper_group_id = $db->f("shopper_group_id");
$default_shopper_group_discount = $db->f("shopper_group_discount");
// Get the product_parent_id for this product/item
$q = "SELECT product_parent_id FROM #__{vm}_product WHERE product_id='{$product_id}'";
$db->setQuery($q);
$db->query();
$db->next_record();
$product_parent_id = $db->f("product_parent_id");
$price_info = array();
if (!$check_multiple_prices) {
/* Added for Volume based prices */
// This is an important decision: we add up all product quantities with the same product_id,
// regardless to attributes. This gives "real" volume based discount, because our simple attributes
// depend on one and the same product_id
$volume_quantity_sql = " AND (('{$quantity}' >= price_quantity_start AND '{$quantity}' <= price_quantity_end)\n OR (price_quantity_end='0') OR ('{$quantity}' > price_quantity_end)) ORDER BY price_quantity_end DESC";
/* End Addition */
} else {
$volume_quantity_sql = " ORDER BY price_quantity_start";
}
// Getting prices
//
// If the shopper group has a price then show it, otherwise
// show the default price.
if (!empty($shopper_group_id)) {
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_id}' AND ";
$q .= "shopper_group_id='{$shopper_group_id}' {$volume_quantity_sql}";
$db->setQuery($q);
$db->query();
if ($db->next_record()) {
$price_info["product_price"] = $db->f("product_price");
if ($check_multiple_prices) {
$price_info["product_base_price"] = $db->f("product_price");
$price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
}
$price_info["product_price_id"] = $db->f("product_price_id");
$price_info["product_currency"] = $db->f("product_currency");
$price_info["item"] = true;
$GLOBALS['product_info'][$product_id]['price'] = $price_info;
return $GLOBALS['product_info'][$product_id]['price'];
}
}
// Get default price
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_id}' AND ";
$q .= "shopper_group_id='{$default_shopper_group_id}' {$volume_quantity_sql}";
$db->setQuery($q);
$db->query();
if ($db->next_record()) {
$price_info["product_price"] = $db->f("product_price") * ((100 - $shopper_group_discount) / 100);
if ($check_multiple_prices) {
$price_info["product_base_price"] = $price_info["product_price"];
$price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
}
$price_info["product_price_id"] = $db->f("product_price_id");
$price_info["product_currency"] = $db->f("product_currency");
$price_info["item"] = true;
$GLOBALS['product_info'][$product_id]['price'] = $price_info;
return $GLOBALS['product_info'][$product_id]['price'];
}
// Maybe its an item with no price, check again with product_parent_id
if (!empty($shopper_group_id)) {
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_parent_id}' AND ";
$q .= "shopper_group_id='{$shopper_group_id}' {$volume_quantity_sql}";
$db->setQuery($q);
$db->query();
if ($db->next_record()) {
$price_info["product_price"] = $db->f("product_price");
if ($check_multiple_prices) {
$price_info["product_base_price"] = $db->f("product_price");
$price_info["product_has_multiple_prices"] = $db->num_rows() > 1;
}
$price_info["product_price_id"] = $db->f("product_price_id");
$price_info["product_currency"] = $db->f("product_currency");
$GLOBALS['product_info'][$product_id]['price'] = $price_info;
return $GLOBALS['product_info'][$product_id]['price'];
}
}
$q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='{$product_parent_id}' AND ";
$q .= "shopper_group_id='{$default_shopper_group_id}' {$volume_quantity_sql}";
//.........这里部分代码省略.........
示例11: add
/**
* adds an item to the shopping cart
* @author pablo
* @param array $d
*/
function add(&$d)
{
global $sess, $VM_LANG, $cart, $vmLogger, $func;
$d = $GLOBALS['vmInputFilter']->process($d);
include_class("product");
$db = new ps_DB();
$ci = 0;
$request_stock = "";
$total_quantity = 0;
$total_updated = 0;
$total_deleted = 0;
$_SESSION['last_page'] = "shop.product_details";
if (!empty($d['product_id']) && !isset($d["prod_id"])) {
if (empty($d['prod_id'])) {
$d['prod_id'] = array();
}
if (is_array($d['product_id'])) {
$d['prod_id'] = array_merge($d['prod_id'], $d['product_id']);
} else {
$d['prod_id'] = array_merge($d['prod_id'], array($d['product_id']));
}
}
//Check to see if a prod_id has been set
if (!isset($d["prod_id"])) {
return true;
}
$multiple_products = sizeof($d["prod_id"]);
//Iterate through the prod_id's and perform an add to cart for each one
for ($ikey = 0; $ikey < $multiple_products; $ikey++) {
// Create single array from multi array
$key_fields = array_keys($d);
foreach ($key_fields as $key) {
if (is_array($d[$key])) {
$e[$key] = @$d[$key][$ikey];
} else {
$e[$key] = $d[$key];
}
}
if ($multiple_products > 1) {
$func = "cartUpdate";
}
$e['product_id'] = $d['product_id'];
$e['Itemid'] = $d['Itemid'];
if (is_array($d["prod_id"])) {
$product_id = $d["prod_id"][$ikey];
} else {
$product_id = $e["prod_id"];
}
if (is_array($d["quantity"])) {
$quantity = @$d['quantity'][$ikey];
} else {
$quantity = @$e['quantity'];
}
// Check for negative quantity
if ($quantity < 0) {
vmRequest::setVar('product_id', $product_id);
$vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_NEGATIVE', false));
return False;
}
if (!is_numeric($quantity)) {
vmRequest::setVar('product_id', $product_id);
$vmLogger->warning($VM_LANG->_('PHPSHOP_CART_ERROR_NO_VALID_QUANTITY', false));
return False;
}
$quantity = intval($quantity);
// Check to see if checking stock quantity
if (CHECK_STOCK) {
$product_in_stock = ps_product::get_field($product_id, 'product_in_stock');
if (empty($product_in_stock)) {
$product_in_stock = 0;
}
if ($quantity > $product_in_stock) {
//Create an array for out of stock items and continue to next item
$request_stock[$ci]['product_id'] = $product_id;
$request_stock[$ci]['quantity'] = $quantity;
$ci++;
continue;
}
}
// Check if product exists and is published
if (!ps_product::product_exists($product_id)) {
$vmLogger->tip($VM_LANG->_('VM_CART_PRODUCT_NOTEXIST', false));
return false;
}
// Quick add of item
$q = "SELECT product_id FROM #__{vm}_product WHERE ";
$q .= "product_parent_id = " . (int) $product_id;
$db->query($q);
if ($db->num_rows()) {
vmRequest::setVar('product_id', $e["product_id"]);
$vmLogger->tip($VM_LANG->_('PHPSHOP_CART_SELECT_ITEM', false));
$_REQUEST['flypage'] = ps_product::get_flypage($e["product_id"]);
$GLOBALS['page'] = 'shop.product_details';
return true;
}
//.........这里部分代码省略.........
示例12: trim
function process_coupon_code($d)
{
global $VM_LANG, $vmLogger;
/* init the database */
$coupon_db = new ps_DB();
/* we need some functions from the checkout module */
require_once CLASSPATH . "ps_checkout.php";
$checkout = new ps_checkout();
if (empty($d['total'])) {
$totals = $checkout->calc_order_totals($d);
$d['total'] = $totals['order_subtotal'] + $totals['order_tax'] + $totals['order_shipping'] + $totals['order_shipping_tax'] - $totals['payment_discount'];
}
$d['coupon_code'] = trim(vmGet($_REQUEST, 'coupon_code'));
$coupon_id = vmGet($_SESSION, 'coupon_id', null);
$q = 'SELECT coupon_id, coupon_code, percent_or_total, coupon_value, coupon_type FROM #__{vm}_coupons WHERE ';
if ($coupon_id) {
/* the query to select the coupon coupon_code */
$q .= 'coupon_id = ' . intval($coupon_id);
} else {
/* the query to select the coupon coupon_code */
$q .= 'coupon_code = \'' . $coupon_db->getEscaped($d['coupon_code']) . '\'';
}
/* make the query */
$coupon_db->query($q);
/* see if we have any fields returned */
if ($coupon_db->num_rows() > 0) {
/* we have a record */
/* see if we are calculating percent or dollar discount */
if ($coupon_db->f("percent_or_total") == "percent") {
/* percent */
//$subtotal = $checkout->calc_order_subtotal( $d );
/* take the subtotal for calculation of the discount */
//$_SESSION['coupon_discount'] = round( ($subtotal * $coupon_db->f("coupon_value") / 100), 2);
$coupon_value = round($d["total"] * $coupon_db->f("coupon_value") / 100, 2);
if ($d["total"] < $coupon_value) {
$coupon_value = (double) $d['total'] + (double) $d['order_tax'];
$vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
}
$_SESSION['coupon_discount'] = $coupon_value;
} else {
$coupon_value = $coupon_db->f("coupon_value");
/* Total Amount */
if ($d["total"] < $coupon_value) {
$coupon_value = (double) $d['total'] + (double) $d['order_tax'];
$vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
}
$_SESSION['coupon_discount'] = $GLOBALS['CURRENCY']->convert($coupon_value);
}
/* mark this order as having used a coupon so people cant go and use coupons over and over */
$_SESSION['coupon_redeemed'] = true;
$_SESSION['coupon_id'] = $coupon_db->f("coupon_id");
$_SESSION['coupon_code'] = $coupon_db->f("coupon_code");
$_SESSION['coupon_type'] = $coupon_db->f("coupon_type");
} else {
/* no record, so coupon_code entered was not valid */
$GLOBALS['coupon_error'] = $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID');
return false;
}
}
示例13: urlencode
}
$listObj->addCell($is_exported, 'style="text-align: center;"');
$url = $_SERVER['PHP_SELF'] . "?page={$modulename}.order_print&limitstart={$limitstart}&keyword=" . urlencode($keyword) . "&order_id=" . $db->f("order_id");
$tmp_cell = "<a href=\"" . $sess->url($url) . "\">" . sprintf("%08d", $db->f("order_id")) . "</a><br />";
$listObj->addCell($tmp_cell);
$tmp_cell = $db->f('first_name') . ' ' . $db->f('last_name');
if ($perm->check('admin') && defined('_VM_IS_BACKEND')) {
$url = $_SERVER['PHP_SELF'] . "?page=admin.user_form&user_id=" . $db->f("user_id");
$tmp_cell = '<a href="' . $sess->url($url) . '">' . $tmp_cell . '</a>';
}
$listObj->addCell($tmp_cell);
$pm_db = new ps_DB();
$q = "SELECT order_id,is_cod ";
$q .= "FROM #__zasilkovna_orders WHERE order_id= " . $db->f('order_id') . ";";
$pm_db->query($q);
if ($pm_db->num_rows() == 0) {
//if it hasnt been specified manually yet, look to the payment method config
$q = "SELECT payment_method_id ";
$q .= "FROM #__{vm}_order_payment WHERE order_id= " . $db->f('order_id') . ";";
$pm_db->query($q);
$payment_method_id = $pm_db->f('payment_method_id');
if ($zas_modul->getConfig('cod' . $payment_method_id)) {
$is_cod = true;
} else {
$is_cod = false;
}
} else {
//if cod type has been specified already, use it
if ($pm_db->f('is_cod') == 1) {
$is_cod = true;
} else {
示例14: while
/**
* Gets the username from joomla if there is one associated to the paypal express payerID
* @param string $payerID
* @return string, False on failure
*/
function ppex_getUsername($payerID)
{
global $vmLogger;
if (empty($payerID)) {
$vmLogger->debug("Error: No PayerID Given");
return false;
}
$db = new ps_DB();
$dbb = new ps_DB();
$q = "SELECT * FROM #__{vm}_user_info WHERE extra_field_3 = '" . $db->getEscaped($payerID) . "' ORDER by mdate DESC";
$db->query($q);
if ($db->num_rows() > 0) {
while ($db->next_record()) {
$uid = $db->f('user_id');
//Now lets try and see if the uid has a real username with joomla
$q2 = "SELECT * FROM #__users WHERE `id` = '" . $db->getEscaped($uid) . "'";
$dbb->query($q2);
if ($dbb->num_rows() > 0) {
$dbb->next_record();
$username = $dbb->f('username');
if (!empty($username)) {
return $username;
}
}
}
}
return false;
}
示例15: return_snapshot
/**
* return the html code to show a snapshot of a product based on the product id.
*
* @param array $params
* @return string
*/
function return_snapshot(&$params)
{
global $sess, $VM_LANG, $mosConfig_live_site, $ps_product;
$db = new ps_DB();
$html = "";
$q = "SELECT DISTINCT product_name,product_id,product_parent_id,product_thumb_image,product_s_desc\r\n\t\t\tFROM #__{vm}_product\r\n\t\t\tWHERE product_id IN ({$params['id']})";
$db->query($q);
$ordering = explode(",", $params['id']);
$db->recordx = array();
foreach ($ordering as $key1 => $value1) {
foreach ($db->record as $key2 => $value2) {
$a = "'" . $value2->product_id . "'";
if ($a == $value1) {
$db->recordx[] = $value2;
}
}
}
foreach ($db->record as $key => $value) {
$db->record[$key] = $db->recordx[$key];
}
$product_count = $db->num_rows();
if ($product_count > 0) {
$html .= "<table class=\"productsnap\" width=\"{$params['width']}\" border=\"{$params['border']}\" style=\"{$params['style']}\" ";
$html .= !empty($params['align']) ? "align=\"{$params['align']}\">" : ">";
$html .= "\n";
// set up how the rows and columns are displayed
if ('v' == $params['displayeach']) {
$row_sep_top = "<tr>\n";
$row_sep_btm = "</tr>\n";
} else {
$row_sep_top = "";
$row_sep_btm = "";
}
if ('h' == $params['displaylist']) {
$start = "<tr>\n";
$end = "</tr>\n";
} else {
$start = "";
$end = "";
}
if ('h' == $params['displaylist'] && 'v' == $params['displayeach']) {
$prod_top = "<td valign=\"top\"><table>\n";
$prod_btm = "</table></td>\n";
} else {
if ($params['displaylist'] == $params['displayeach']) {
$prod_top = "";
$prod_btm = "";
} else {
$prod_top = "<tr>\n";
$prod_btm = "</tr>\n";
}
}
/*
eg of display
list h, each h
-- prod_sep_top "" -- prod_sep_btm "" -- start = "<tr>" -- end = "</tr>" -- row_sep_top = "<td>" -- row_sep_btm = "</td>"
<table><tr><td>name</td><td>image</td><td>name</td><td>image</td></tr></table>
list h, each v
-- prod_sep_top "<td><table>" -- prod_sep_btm "</table></td>" -- start = "<tr>" -- end = "</tr>" -- row_sep_top = "<tr><td>" -- row_sep_btm = "</td></tr>"
<table><tr><td><table><tr><td>name</td></tr><tr><td>image</td></tr></table></td><td><table><tr><td>name</td></tr><tr><td>image</td></tr></table></td></tr></table>
list v, each h
-- prod_sep_top "<tr>" -- prod_sep_btm "</tr>" -- start = "" -- end = "" -- row_sep_top = "<td>" -- row_sep_btm = "</td>"
<table><tr><td>name</td><td>image</td></tr><tr><td>name</td><td>image</td></tr></table>
list v, each v
-- prod_sep_top "" -- prod_sep_btm "" -- start = "" -- end = "" -- row_sep_top = "<tr><td>" -- row_sep_btm = "</td></tr>"
<table><tr><td>name</td></tr><tr><td>image</td></tr><tr><td>name</td></tr><tr><td>image</td></tr></table>
*/
$i = 0;
$html .= $start;
while ($db->next_record()) {
$html .= $prod_top;
if ('y' == $params['showname']) {
$html .= $row_sep_top;
$html .= "<td class=\"product_name\" align=\"center\">" . $db->f("product_name") . "</td>\n";
$html .= $row_sep_btm;
}
if ('y' == $params['showimage']) {
$html .= $row_sep_top;
$url = "index.php?page=" . $ps_product->get_flypage($db->f("product_id"));
if ($db->f("product_parent_id")) {
$url = "index.php?page=shop.product_details&flypage=" . $ps_product->get_flypage($db->f("product_parent_id"));
$url .= "&product_id=" . $db->f("product_parent_id");
} else {
$url = "index.php?page=shop.product_details&flypage=" . $ps_product->get_flypage($db->f("product_id"));
$url .= "&product_id=" . $db->f("product_id");
}
$html .= "<td class=\"image\" align=\"center\"><a href=\"" . $sess->url(URL . $url) . "\">";
$html .= "<img alt=\"" . $db->f("product_name") . "\" hspace=\"7\" src=\"" . IMAGEURL . "/product/" . $db->f("product_thumb_image") . "\" width=\"90\" border=\"0\" />";
$html .= "</a></td>\n";
$html .= $row_sep_btm;
}
if ('y' == $params['showdesc']) {
$html .= $row_sep_top;
$html .= "<td class=\"desc\">" . $db->f("product_s_desc") . "</td>\n";
//.........这里部分代码省略.........