本文整理汇总了PHP中ps_product::get_discount方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_product::get_discount方法的具体用法?PHP ps_product::get_discount怎么用?PHP ps_product::get_discount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ps_product
的用法示例。
在下文中一共展示了ps_product::get_discount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vmGet
//.........这里部分代码省略.........
$c = substr_count($temp_desc, "]");
//echo "open: $o<br>close: $c<br>\n";
// check to see if we have a bracket
if (True == is_int($finish)) {
$length = $finish - $start;
// We found a pair of brackets (price modifier?)
if ($length > 1) {
$my_mod = substr($temp_desc, $start + 1, $length - 1);
//echo "before: ".$my_mod."<br>\n";
if ($o != $c) {
// skip the tests if we don't have to process the string
if ($o < $c) {
$char = "]";
$offset = $start;
} else {
$char = "[";
$offset = $finish;
}
$s = substr_count($my_mod, $char);
for ($r = 1; $r < $s; $r++) {
$pos = strrpos($my_mod, $char);
$my_mod = substr($my_mod, $pos + 1);
}
}
$oper = substr($my_mod, 0, 1);
$my_mod = substr($my_mod, 1);
// if we have a number, allow the adjustment
if (true == is_numeric($my_mod)) {
// Now add or sub the modifier on
if ($oper == "+") {
$adjustment += $my_mod;
} else {
if ($oper == "-") {
$adjustment -= $my_mod;
} else {
if ($oper == '=') {
// NOTE: the +=, so if we have 2 sets they get added
// this could be moded to say, if we have a set_price, then
// calc the diff from the base price and start from there if we encounter
// another set price... just a thought.
$setprice += $my_mod;
$set_price = true;
}
}
}
}
$temp_desc = substr($temp_desc, $finish + 1);
$start = strpos($temp_desc, "[");
$finish = strpos($temp_desc, "]");
}
}
$i++;
// not necessary, but perhaps interesting? ;)
}
}
// no set price was set from the attribs
if ($set_price == false) {
$price["product_price"] = $base_price + $adjustment;
} else {
// otherwise, set the price
// add the base price to the price set in the attributes
// then subtract the adjustment amount
// we could also just add the set_price to the adjustment... not sure on that one.
// $setprice += $adjustment;
$setprice *= 1 - $auth["shopper_group_discount"] / 100;
$price["product_price"] = $setprice;
}
// don't let negative prices get by, set to 0
if ($price["product_price"] < 0) {
$price["product_price"] = 0;
}
// Get the DISCOUNT AMOUNT
$ps_product = new ps_product();
$discount_info = $ps_product->get_discount($product_id);
$my_taxrate = $ps_product->get_product_taxrate($product_id);
if (!empty($discount_info["amount"])) {
if ($auth["show_price_including_tax"] == 1) {
switch ($discount_info["is_percent"]) {
case 0:
$price["product_price"] = ($price["product_price"] * ($my_taxrate + 1) - $discount_info["amount"]) / ($my_taxrate + 1);
break;
//case 1: $price["product_price"] = ($price["product_price"]*($my_taxrate+1) - $discount_info["amount"]/100*$price["product_price"])/($my_taxrate+1); break;
//case 1: $price["product_price"] = ($price["product_price"]*($my_taxrate+1) - $discount_info["amount"]/100*$price["product_price"])/($my_taxrate+1); break;
case 1:
$price["product_price"] = $price["product_price"] - $discount_info["amount"] / 100 * $price["product_price"];
break;
}
} else {
switch ($discount_info["is_percent"]) {
case 0:
$price["product_price"] = $price["product_price"] - $discount_info["amount"];
break;
case 1:
$price["product_price"] = $price["product_price"] - $discount_info["amount"] / 100 * $price["product_price"];
break;
}
}
}
return $price;
}
示例2: vmGet
function get_adjusted_attribute_price($product_id, $quantity = 0, $description = '', $result_attributes = '')
{
global $mosConfig_secret;
$auth = $_SESSION['auth'];
$price = $this->get_price($product_id, $quantity, true, $result_attributes);
$base_price = $price["product_price"];
$setprice = 0;
$set_price = false;
$adjustment = 0;
// We must care for custom attribute fields! Their value can be freely given
// by the customer, so we mustn't include them into the price calculation
// Thanks to AryGroup@ua.fm for the good advice
if (empty($_REQUEST["custom_attribute_fields"])) {
if (!empty($_SESSION["custom_attribute_fields"])) {
$custom_attribute_fields = vmGet($_SESSION, "custom_attribute_fields", array());
$custom_attribute_fields_check = vmGet($_SESSION, "custom_attribute_fields_check", array());
} else {
$custom_attribute_fields = $custom_attribute_fields_check = array();
}
} else {
$custom_attribute_fields = $_SESSION["custom_attribute_fields"] = vmGet($_REQUEST, "custom_attribute_fields", array());
$custom_attribute_fields_check = $_SESSION["custom_attribute_fields_check"] = vmGet($_REQUEST, "custom_attribute_fields_check", array());
}
// if we've been given a description to deal with, get the adjusted price
if ($description != '') {
// description is safe to use at this point cause it's set to ''
require_once CLASSPATH . 'ps_product_attribute.php';
$product_attributes = ps_product_attribute::getAdvancedAttributes($product_id, true);
$attribute_keys = explode(";", $description);
for ($i = 0; $i < sizeof($attribute_keys); $i++) {
$temp_desc = $attribute_keys[$i];
$temp_desc = trim($temp_desc);
// Get the key name (e.g. "Color" )
$this_key = substr($temp_desc, 0, strpos($temp_desc, ":"));
$this_value = substr($temp_desc, strpos($temp_desc, ":") + 1);
if (in_array($this_key, $custom_attribute_fields)) {
if (@$custom_attribute_fields_check[$this_key] == md5($mosConfig_secret . $this_key)) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
if (isset($product_attributes[$this_key]['values'][$this_value])) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];
// if we have a number, allow the adjustment
if (true == is_numeric($modifier)) {
// $modifier = $GLOBALS['CURRENCY']->convert( $modifier, $price['product_currency'], $GLOBALS['product_currency'] );
// Now add or sub the modifier on
if ($operand == "+") {
$adjustment += $modifier;
} else {
if ($operand == "-") {
$adjustment -= $modifier;
} else {
if ($operand == '=') {
// NOTE: the +=, so if we have 2 sets they get added
// this could be moded to say, if we have a set_price, then
// calc the diff from the base price and start from there if we encounter
// another set price... just a thought.
$setprice += $modifier;
$set_price = true;
}
}
}
}
} else {
continue;
}
}
}
// no set price was set from the attribs
if ($set_price == false) {
$price["product_price"] = $base_price + $adjustment * (1 - $auth["shopper_group_discount"] / 100);
} else {
// otherwise, set the price
// add the base price to the price set in the attributes
// then subtract the adjustment amount
// we could also just add the set_price to the adjustment... not sure on that one.
if (!empty($adjustment)) {
$setprice += $adjustment;
}
$setprice *= 1 - $auth["shopper_group_discount"] / 100;
$price["product_price"] = $setprice;
}
// don't let negative prices get by, set to 0
if ($price["product_price"] < 0) {
$price["product_price"] = 0;
}
// Get the DISCOUNT AMOUNT
$ps_product = new ps_product();
$discount_info = $ps_product->get_discount($product_id);
// Read user_info_id from db
$dbu = new ps_DB();
$q = "SELECT user_info_id FROM #__{vm}_orders WHERE order_id = '" . $this->order_id . "' ";
$dbu->query($q);
$dbu->next_record();
$user_info_id = $dbu->f("user_info_id");
$prod_weight = $ps_product->get_weight($product_id);
$my_taxrate = $ps_product->get_product_taxrate($product_id, $prod_weight, $user_info_id);
// If discounts are applied after tax, but prices are shown without tax,
//.........这里部分代码省略.........