本文整理汇总了PHP中Mage_Catalog_Model_Product_Type_Price类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product_Type_Price类的具体用法?PHP Mage_Catalog_Model_Product_Type_Price怎么用?PHP Mage_Catalog_Model_Product_Type_Price使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Model_Product_Type_Price类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getFinalPrice
/**
* @param float $qty
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getFinalPrice($qty = null, $product)
{
if (!(Mage::helper('amconf')->getConfigUseSimplePrice() == 2 || (Mage::helper('amconf')->getConfigUseSimplePrice() == 1 and $product->getData('amconf_simple_price')))) {
return parent::getFinalPrice($qty, $product);
}
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
if (version_compare(Mage::getVersion(), '1.7', '<')) {
// based on 1.6.2.0 version
// get configurable's own price,
// apply its tier and special prices,
// dispatch 'catalog_product_get_final_price'
// at last apply its custom options price
$finalPrice = Mage_Catalog_Model_Product_Type_Price::getFinalPrice($qty, $product);
// skip native configurable price calculation
// ...
// get child simple product, calculate its price with tier and special prices applied
// and that's the only we need, we ignore all above ))
$finalPrice = $this->_calcAmConfigurablePrice($qty, $product, $finalPrice);
} else {
// based on 1.7.0.2 version
// get configurable's own price,
// apply its group, tier and special prices,
$basePrice = $this->getBasePrice($product, $qty);
// dispatch 'catalog_product_get_final_price'
$finalPrice = $basePrice;
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
// skip native configurable price calculation
// $finalPrice += $this->getTotalConfigurableItemsPrice($product, $finalPrice);
// at last apply its custom options price
$finalPrice += $this->_applyOptionsPrice($product, $qty, $basePrice) - $basePrice;
// get child simple product, calculate its price with tier and special prices applied
// and that's the only we need, we ignore all above ))
$finalPrice = $this->_calcAmConfigurablePrice($qty, $product, $finalPrice);
}
$product->setFinalPrice($finalPrice);
return max(0, $product->getData('final_price'));
}
开发者ID:rcclaudrey,项目名称:dev,代码行数:46,代码来源:Price.php
示例2: _isPriceFixed
/**
* Whether tier price value fixed or percent of original price
*
* @param Mage_Catalog_Model_Product_Type_Price $priceObject
* @return bool
*/
protected function _isPriceFixed($priceObject)
{
return $priceObject->isTierPriceFixed();
}
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:10,代码来源:Tierprice.php
示例3: getPriceByCatalogRules
/**
* @param null $product
* @return mixed
*/
public function getPriceByCatalogRules($product = null)
{
if (is_null($product)) {
$product = $this->getProduct();
}
if (!$this->getConfigVar('apply_catalog_price_rules', 'columns')) {
// Commented to avoid loops: return $this->getPrice($product);
return $product->getPrice();
}
if (!isset($this->_cache_price_by_catalog_rules[$product->getId()])) {
$this->_cache_price_by_catalog_rules[$product->getId()] = Mage_Catalog_Model_Product_Type_Price::calculatePrice($product->getPrice(), false, false, false, false, $this->getWebsiteId(), Mage_Customer_Model_Group::NOT_LOGGED_IN_ID, $product->getId());
if ($this->_cache_price_by_catalog_rules[$product->getId()] <= 0) {
// Commented to avoid loops: $this->_cache_price_by_catalog_rules[$product->getId()] = $this->getPrice($product);
$this->_cache_price_by_catalog_rules[$product->getId()] = $product->getPrice();
}
}
return $this->_cache_price_by_catalog_rules[$product->getId()];
}
开发者ID:AleksNesh,项目名称:pandora,代码行数:22,代码来源:Abstract.php
示例4: getPriceByCatalogRules
/**
* @param null $product
* @return mixed
*/
public function getPriceByCatalogRules($product = null)
{
if (is_null($product)) {
$product = $this->getProduct();
}
if (!$this->getConfigVar('apply_catalog_price_rules', 'columns')) {
// Commented to avoid loops: return $this->getPrice($product);
return $product->getPrice();
}
if (!isset($this->_cache_price_by_catalog_rules[$product->getId()])) {
$this->_cache_price_by_catalog_rules[$product->getId()] = Mage_Catalog_Model_Product_Type_Price::calculatePrice($product->getPrice(), false, false, false, false, $this->getWebsiteId(), Mage::getStoreConfig('customer/create_account/default_group', $this->getStoreId()), $product->getId());
if ($this->_cache_price_by_catalog_rules[$product->getId()] <= 0) {
// Commented to avoid loops: $this->_cache_price_by_catalog_rules[$product->getId()] = $this->getPrice($product);
$this->_cache_price_by_catalog_rules[$product->getId()] = $product->getPrice();
}
}
return $this->_cache_price_by_catalog_rules[$product->getId()];
}
开发者ID:brandontamm,项目名称:api-merchant-center,代码行数:22,代码来源:Abstract.php
示例5: _applyOptionsPrice
protected function _applyOptionsPrice($product, $qty, $finalPrice)
{
if ($amount = $product->getCustomOption('credit_price_amount')) {
$finalPrice = $amount->getValue();
}
return parent::_applyOptionsPrice($product, $qty, $finalPrice);
}
开发者ID:javik223,项目名称:Evron-Magento,代码行数:7,代码来源:Price.php
示例6: getPrice
public function getPrice($product)
{
$product->load($product->getId());
// Mage::log($product->debug(), null, 'test.log');
$data = $product->getData();
$total = $this->getCartTotal();
# Fixed price
$price = (double) parent::getPrice($product);
# Percent price
if ($price_percent = $data['cartproducts_price_percent']) {
$price_percent = $total * (double) $price_percent / 100;
}
# Range price
if ($price_range = $data['cartproducts_price_range']) {
$range = explode(',', $price_range);
foreach ($range as $pair) {
$pair = explode('=', $pair);
if ($total <= $pair[0]) {
return $price_range = (double) $pair[1];
}
}
}
$price = max($price, $price_percent);
return $price;
}
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:25,代码来源:Price.php
示例7: getChildFinalPrice
/**
* @param Mage_Catalog_Model_Product $product
* @param float $productQty
* @param Mage_Catalog_Model_Product $childProduct
* @param float $childProductQty
*
* @return float
*/
public function getChildFinalPrice($product, $productQty, $childProduct, $childProductQty)
{
// Bail if the parameters are unexpected and let the core code handle (or fail)
if (!$product instanceof Mage_Catalog_Model_Product || !$childProduct instanceof Mage_Catalog_Model_Product) {
return parent::getChildFinalPrice($product, $productQty, $childProduct, $childProductQty);
}
// If the parent product type is unexpected then bail and let core handle
$type = $product->getTypeInstance(true);
if (!$type instanceof OpenMage_KittedProduct_Model_Product_Type) {
return parent::getChildFinalPrice($product, $productQty, $childProduct, $childProductQty);
}
// Calculate the normal, unadjusted linked items total
$calculatedTotal = 0.0;
foreach ($type->getAssociatedProducts($product, false) as $associatedProduct) {
$calculatedTotal += $associatedProduct->getPrice() * $associatedProduct->getQty();
}
// Generate a child price multiplier
$priceMultiplier = $calculatedTotal > 0.0 ? $product->getPrice() / $calculatedTotal : 1.0;
// Generate the normal final price
$finalPrice = $childProduct->getFinalPrice($childProductQty);
// Multiply the final price by the multiplier to get the adjusted final price
$finalPrice *= $priceMultiplier;
// Round the final price
$finalPrice = $product->getStore()->roundPrice($finalPrice);
return $finalPrice;
}
开发者ID:OpenMage,项目名称:OpenMage_KittedProduct,代码行数:34,代码来源:Price.php
示例8: getFinalPrice
/**
* Returns product final price depending on options chosen
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = parent::getFinalPrice($qty, $product);
if ($product->hasCustomOptions()) {
/* @var $typeInstance Mage_Catalog_Model_Product_Type_Grouped */
$typeInstance = $product->getTypeInstance(true);
$associatedProducts = $typeInstance->setStoreFilter($product->getStore(), $product)->getAssociatedProducts($product);
foreach ($associatedProducts as $childProduct) {
/* @var $childProduct Mage_Catalog_Model_Product */
$option = $product->getCustomOption('associated_product_' . $childProduct->getId());
if (!$option) {
continue;
}
$childQty = $option->getValue();
if (!$childQty) {
continue;
}
$finalPrice += $childProduct->getFinalPrice($childQty) * $childQty;
}
}
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_type_grouped_price', array('product' => $product));
return max(0, $product->getData('final_price'));
}
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:34,代码来源:Price.php
示例9: getFinalPrice
/**
* Get product final price
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = parent::getFinalPrice($qty, $product);
$product->getTypeInstance(true)->setStoreFilter($product->getStore(), $product);
$attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
$selectedAttributes = array();
if ($product->getCustomOption('attributes')) {
$selectedAttributes = unserialize($product->getCustomOption('attributes')->getValue());
}
$basePrice = $finalPrice;
foreach ($attributes as $attribute) {
$attributeId = $attribute->getProductAttribute()->getId();
$value = $this->_getValueByIndex($attribute->getPrices() ? $attribute->getPrices() : array(), isset($selectedAttributes[$attributeId]) ? $selectedAttributes[$attributeId] : null);
if ($value) {
if ($value['pricing_value'] != 0) {
$finalPrice += $this->_calcSelectionPrice($value, $basePrice);
}
}
}
$product->setFinalPrice($finalPrice);
return max(0, $product->getData('final_price'));
}
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:32,代码来源:Product_Type_Configurable_Price.php
示例10: getTierPrice
/**
* Get product tier price by qty
* Extended to hide tier pricing when product is a subscription product
*
* @param float $qty
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getTierPrice($qty = null, $product)
{
if ($subscription = $this->_helper()->getProductSubscription($product)) {
return array();
}
return parent::getTierPrice($qty, $product);
}
开发者ID:sandermangel,项目名称:adyen-magento-subscription,代码行数:15,代码来源:Simple.php
示例11: getFinalPrice
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = parent::getFinalPrice($qty, $product);
$finalPrice = $finalPrice - $finalPrice / 10;
return $finalPrice;
}
开发者ID:mayurmarwa,项目名称:excellence_magento_blog,代码行数:9,代码来源:Price.php
示例12: _applyOptionsPrice
protected function _applyOptionsPrice($product, $qty, $finalPrice)
{
if ($amount = $product->getCustomOption('amount')) {
$store = Mage::app()->getStore();
$finalPrice = $amount->getValue();
$finalPrice /= $store->convertPrice(1);
}
return parent::_applyOptionsPrice($product, $qty, $finalPrice);
}
开发者ID:protechhelp,项目名称:gamamba,代码行数:9,代码来源:Price.php
示例13: getFinalPrice
public function getFinalPrice($qty = null, $product)
{
// if product was added to cart, get the price from user input, otherwise returns the price was set in admin
if ($product->getCustomOption('info_buyRequest')) {
$price = 0.0;
$buyRequest = unserialize($product->getCustomOption('info_buyRequest')->getValue());
if (is_array($buyRequest) && isset($buyRequest['service_price'])) {
$price += $buyRequest['service_price'];
}
return $price;
}
return parent::getFinalPrice($qty, $product);
}
开发者ID:hanhpv,项目名称:service-product-type,代码行数:13,代码来源:Price.php
示例14: _applyOptionsPrice
protected function _applyOptionsPrice($product, $qty, $finalPrice)
{
if ($option = $product->getCustomOption('giftcard_value')) {
$optionValue = $option->getValue();
if (is_numeric($optionValue)) {
$series = Mage::getModel('giftcard/series');
$price = $series->getProductPrice($product, $optionValue);
if ($price) {
$finalPrice = $price;
}
}
}
return parent::_applyOptionsPrice($product, $qty, $finalPrice);
}
开发者ID:kemeice,项目名称:Giftcards,代码行数:14,代码来源:Price.php
示例15: getFinalPrice
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = parent::getFinalPrice($qty, $product);
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$finalPrice = $this->_applyCustomTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
return $finalPrice;
}
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:15,代码来源:Price.php
示例16: testIsTierPriceFixed
public function testIsTierPriceFixed()
{
$this->assertTrue($this->_model->isTierPriceFixed());
}
开发者ID:natxetee,项目名称:magento2,代码行数:4,代码来源:PriceTest.php
示例17: getPrice
public function getPrice($product)
{
if ($this->getPriceModel()->isSubscriptionPriceSet($product) && $product->getAwSarpEnabled()) {
$priceWithShippingCost = Mage::helper('sarp')->getSarpSubscriptionPrice($product);
if ($product->getCustomOption('aw_sarp_subscription_type') && ($typeId = $product->getCustomOption('aw_sarp_subscription_type')->getValue())) {
if ($typeId == AW_Sarp_Model_Period::PERIOD_TYPE_NONE) {
return parent::getPrice($product);
} else {
return $priceWithShippingCost;
}
} elseif ($product->getTypeInstance()->getDefaultSubscriptionPeriodId() != AW_Sarp_Model_Period::PERIOD_TYPE_NONE) {
return $priceWithShippingCost;
}
} else {
// Probably category page
$_product = Mage::getModel('catalog/product')->load($product->getId());
$priceWithShippingCost = Mage::helper('sarp')->getSarpSubscriptionPrice($_product);
if ($_product->getTypeInstance()->requiresSubscriptionOptions($_product)) {
if ($priceWithShippingCost) {
$price = $priceWithShippingCost;
$product->setData('final_price', $price);
return $price;
}
}
}
return parent::getPrice($product);
}
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:27,代码来源:Price.php
注:本文中的Mage_Catalog_Model_Product_Type_Price类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论