: </td> <td> <?php $ps_html->list_currency("product_currency", $db->sf("product_currency")); ?> </td> </tr> <tr> <td class="labelcell"> <?php echo $VM_LANG->_('PHPSHOP_PRICE_FORM_GROUP'); ?> : </td> <td><?php echo ps_shopper_group::list_shopper_groups("shopper_group_id", $db->sf("shopper_group_id")); ?> </td> </tr> <tr> <td colspan="2" height="2"> </td> </tr> <tr> <td class="labelcell"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_LIST_QUANTITY_START'); ?> :</td> <td><input type="text" value="<?php echo $db->f("price_quantity_start"); ?>
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ mm_showMyFileName(__FILE__); global $ps_shopper_group, $ps_product; global $acl, $database; include_class('shopper'); include_class('product'); if (!isset($ps_shopper_group)) { $ps_shopper_group = new ps_shopper_group(); } $user_id = intval(vmGet($_REQUEST, 'user_id')); $cid = vmRequest::getVar('cid', array(0), '', 'array'); if (!empty($user_id)) { $q = "SELECT * FROM #__users AS u LEFT JOIN #__{vm}_user_info AS ui ON id=user_id "; $q .= "WHERE id={$user_id} "; $q .= "AND (address_type='BT' OR address_type IS NULL ) "; $q .= "AND gid <= " . $my->gid; $db->query($q); $db->next_record(); } // Set up the CMS General User Information $row = new mosUser($database); $row->load((int) $user_id); if ($user_id) {
/** * Returns the price for a specific shopper group, * Returns nothing, when the shopper group has no price * * @param int $product_id * @param int $shopper_group_id * @param boolean $check_multiple_prices * @param string $additionalSQL * @return mixed */ function getPriceByShopperGroup($product_id, $shopper_group_id, $check_multiple_prices = false, $additionalSQL = '') { global $auth; static $resultcache = array(); $db = new ps_DB(); $vendor_id = $_SESSION['ps_vendor_id']; if (empty($shopper_group_id)) { ps_shopper_group::makeDefaultShopperGroupInfo(); $shopper_group_id = $GLOBALS['vendor_info'][$vendor_id]['default_shopper_group_id']; } $whereClause = 'WHERE product_id=%s AND shopper_group_id=%s '; $whereClause = sprintf($whereClause, intval($product_id), intval($shopper_group_id)); $q = "SELECT `product_price`, `product_price_id`, `product_currency` FROM `#__{vm}_product_price` {$whereClause} {$additionalSQL}"; $sig = sprintf("%u\n", crc32($q)); if (!isset($resultcache[$sig])) { $db->query($q); if (!$db->next_record()) { return false; } $price_info["product_price"] = $db->f("product_price") * ((100 - $auth["shopper_group_discount"]) / 100); $price_info["product_currency"] = $db->f("product_currency"); $price_info["product_base_price"] = $db->f("product_price") * ((100 - $auth["shopper_group_discount"]) / 100); $price_info["product_has_multiple_prices"] = $db->num_rows() > 1; $price_info["product_price_id"] = $db->f("product_price_id"); $price_info["item"] = true; $GLOBALS['product_info'][$product_id]['price'] = $price_info; // Store the result for later $resultcache[$sig] = $price_info; return $GLOBALS['product_info'][$product_id]['price']; } else { return $resultcache[$sig]; } }
/** * Prints a drop-down list with all available payment methods * * @param int $payment_method_id */ function list_method($payment_method_id) { global $VM_LANG; $ps_vendor_id = $_SESSION["ps_vendor_id"]; $db = new ps_DB(); require_once CLASSPATH . 'ps_shopper_group.php'; $ps_shopper_group = new ps_shopper_group(); $q = "SELECT * from #__{vm}_shopper_group WHERE "; $q .= "`default`='1' "; $q .= "AND vendor_id='{$ps_vendor_id}'"; $db->query($q); if (!$db->num_rows()) { $q = "SELECT * from #__{vm}_shopper_group WHERE "; $q .= "vendor_id='{$ps_vendor_id}'"; $db->query($q); } $db->next_record(); $default_shopper_group_id = $db->f("shopper_group_id"); $q = "SELECT * from #__{vm}_payment_method WHERE "; $q .= "vendor_id='{$ps_vendor_id}' AND "; $q .= "shopper_group_id='{$default_shopper_group_id}' "; if ($ps_shopper_group->get_id() != $default_shopper_group_id) { $q .= "OR shopper_group_id='" . $ps_shopper_group->get_id() . "' "; } $q .= "ORDER BY list_order"; $db->query($q); // Start drop down list $array[0] = $VM_LANG->_('PHPSHOP_SELECT'); while ($db->next_record()) { $array[$db->f("payment_method_id")] = $db->f("payment_method_name"); } ps_html::dropdown_display('payment_method_id', $payment_method_id, $array); }
?> " /></td> <td> </td> </tr> </table> </div> <div id="divShopperGroups" > <table class="adminform"> <tr class="row1"> <td class="labelcell"><?php echo $VM_LANG->_('VM_USERFIELDS_EUVATID_MOVESHOPPER'); ?> :</td> <td ><?php $sg_id = is_a($params, 'vmparameters') ? $params->get('shopper_group_id', 5) : ''; echo ps_shopper_group::list_shopper_groups("shopper_group_id", $sg_id); ?> </td> </tr> </table> </div> <div id="divAgeVerification" > <table class="adminform"> <tr class="row1"> <td class="labelcell"><?php echo $VM_LANG->_('VM_FIELDS_AGEVERIFICATION_MINIMUM'); ?> :</td> <td ><?php $min_age = is_a($params, 'vmparameters') ? $params->get('minimum_age', 18) : 18; $ages = array();
require_once CLASSPATH . "ps_perm.php"; require_once CLASSPATH . "ps_shopper_group.php"; require_once CLASSPATH . "ps_vendor.php"; require_once CLASSPATH . 'template.class.php'; require_once CLASSPATH . "htmlTools.class.php"; require_once CLASSPATH . "phpInputFilter/class.inputfilter.php"; // Instantiate the DB class $db = new ps_DB(); // Instantiate the permission class $perm = new ps_perm(); // Instantiate the HTML helper class $ps_html = new ps_html(); // Constructor initializes the session! $sess = new ps_session(); // Instantiate the ps_shopper_group class $ps_shopper_group = new ps_shopper_group(); // Get default and this users's Shopper Group $shopper_group = $ps_shopper_group->get_shoppergroup_by_id($my->id); // User authentication $auth = $perm->doAuthentication($shopper_group); // Initialize the cart $cart = ps_cart::initCart(); // Initialise Recent Products $recentproducts = ps_session::initRecentProducts(); // Instantiate the module class $ps_module = new ps_module(); // Instantiate the function class $ps_function = new ps_function(); // Set the mosConfig_live_site to its' SSL equivalent $GLOBALS['real_mosConfig_live_site'] = $GLOBALS['mosConfig_live_site']; if ($_SERVER['SERVER_PORT'] == 443 || @$_SERVER['HTTPS'] == 'on' || @strstr($page, "checkout.")) {
/** * Returns the price for a specific shopper group, * Returns nothing, when the shopper group has no price * * @param int $product_id * @param int $shopper_group_id * @param boolean $check_multiple_prices * @param string $additionalSQL * @return mixed */ function getPriceByShopperGroup($product_id, $shopper_group_id, $check_multiple_prices = false, $additionalSQL = '') { global $auth; static $resultcache = array(); $db = new ps_DB(); $vendor_id = $_SESSION['ps_vendor_id']; if (empty($shopper_group_id)) { ps_shopper_group::makeDefaultShopperGroupInfo(); $shopper_group_id = $GLOBALS['vendor_info'][$vendor_id]['default_shopper_group_id']; } $dontUseCustomDiscount = 0; if ($shopper_group_id != $GLOBALS['vendor_info'][$vendor_id]['default_shopper_group_id']) { // отменяем пользовательскую скидку, если товар продаётся без скидок if ($this->getProductNodiscount($product_id)) { $shopper_group_id = $GLOBALS['vendor_info'][$vendor_id]['default_shopper_group_id']; $dontUseCustomDiscount = 1; } } $whereClause = 'WHERE product_id=%s AND shopper_group_id=%s '; $whereClause = sprintf($whereClause, intval($product_id), intval($shopper_group_id)); $q = "SELECT `product_price`, `product_price_id`, `product_currency`, price_quantity_start FROM `#__{vm}_product_price` {$whereClause} {$additionalSQL}"; $sig = sprintf("%u\n", crc32($q)); if (!isset($resultcache[$sig])) { $db->query($q); if (!$db->next_record()) { return false; } // обнуляем групповую скидку если товар "без скидки" if ($dontUseCustomDiscount) { $shopper_group_discount = 0; } else { $shopper_group_discount = $auth["shopper_group_discount"]; } // обнуляем скидку группы если есть скидка за объем if ($db->f('price_quantity_start') > 1) { $shopper_group_discount = 0; } // обнуляем скидку группы если есть скидка на товар $prod_discount = $this->get_discount(intval($product_id)); if (isset($prod_discount['amount']) && $prod_discount['amount'] > 0) { $shopper_group_discount = 0; } $price_info["product_price"] = $db->f("product_price") * ((100 - $shopper_group_discount) / 100); $price_info["product_currency"] = $db->f("product_currency"); $price_info["product_base_price"] = $db->f("product_price") * ((100 - $shopper_group_discount) / 100); $price_info["product_has_multiple_prices"] = $db->num_rows() > 1; $price_info["product_price_id"] = $db->f("product_price_id"); $price_info["item"] = true; $GLOBALS['product_info'][$product_id]['price'] = $price_info; // Store the result for later $resultcache[$sig] = $price_info; // проверяем ещё цены while ($db->next_record()) { $price_info["product_price_nd"] = $db->f('product_price'); } $GLOBALS['product_info'][$product_id]['price'] = $price_info; $resultcache[$sig] = $price_info; return $GLOBALS['product_info'][$product_id]['price']; } else { return $resultcache[$sig]; } }