本文整理汇总了PHP中Mage_Sales_Model_Quote_Item_Abstract::getRowWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item_Abstract::getRowWeight方法的具体用法?PHP Mage_Sales_Model_Quote_Item_Abstract::getRowWeight怎么用?PHP Mage_Sales_Model_Quote_Item_Abstract::getRowWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Item_Abstract
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Item_Abstract::getRowWeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requestShippingRates
/**
* Request shipping rates for entire address or specified address item
* Returns true if current selected shipping method code corresponds to one of the found rates
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return bool
*/
public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
{
//Mage::log("requestShippingRates");
/** @var $request Mage_Shipping_Model_Rate_Request */
$request = Mage::getModel('shipping/rate_request');
$request->setAllItems($item ? array($item) : $this->getAllItems());
$request->setDestCountryId($this->getCountryId());
$request->setDestRegionId($this->getRegionId());
$request->setDestRegionCode($this->getRegionCode());
/**
* need to call getStreet with -1
* to get data in string instead of array
*/
$request->setDestStreet($this->getStreet(-1));
$request->setDestCity($this->getCity());
$request->setDestPostcode($this->getPostcode());
$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
$packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
$request->setPackageValueWithDiscount($packageValueWithDiscount);
$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
$request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
/**
* Need for shipping methods that use insurance based on price of physical products
*/
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
$request->setPackagePhysicalValue($packagePhysicalValue);
$request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
/**
* Store and website identifiers need specify from quote
*/
/*$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
$request->setStoreId($this->getQuote()->getStore()->getId());
$request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
$request->setFreeShipping($this->getFreeShipping());
/**
* Currencies need to convert in free shipping
*/
$request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
$request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($this->getLimitCarrier());
$result = Mage::getModel('shipping/shipping')->collectRatesWithAddress($request, $this)->getResult();
$found = false;
if ($result) {
$shippingRates = $result->getAllRates();
foreach ($shippingRates as $shippingRate) {
$rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
if (!$item) {
$this->addShippingRate($rate);
}
if ($this->getShippingMethod() == $rate->getCode()) {
if ($item) {
$item->setBaseShippingAmount($rate->getPrice());
} else {
/**
* possible bug: this should be setBaseShippingAmount(),
* see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
* where this value is set again from the current specified rate price
* (looks like a workaround for this bug)
*/
$this->setShippingAmount($rate->getPrice());
}
$found = true;
}
}
}
return $found;
}
示例2: requestShippingRates
/**
* Request shipping rates for entire address or specified address item
* Returns true if current selected shipping method code corresponds to one of the found rates
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return bool
*/
public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
{
/** @var $request Mage_Shipping_Model_Rate_Request */
$request = Mage::getModel('shipping/rate_request');
$request->setAllItems($item ? array($item) : $this->getAllItems());
$request->setDestCountryId($this->getCountryId());
$request->setDestRegionId($this->getRegionId());
$request->setDestRegionCode($this->getRegionCode());
/**
* need to call getStreet with -1
* to get data in string instead of array
*/
$request->setDestStreet($this->getStreet(-1));
$request->setDestCity($this->getCity());
$request->setDestPostcode($this->getPostcode());
$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
$packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
$request->setPackageValueWithDiscount($packageValueWithDiscount);
$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
$request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
/**
* Need for shipping methods that use insurance based on price of physical products
*/
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
$request->setPackagePhysicalValue($packagePhysicalValue);
$request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
/**
* Store and website identifiers need specify from quote
*/
/*$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
$request->setStoreId($this->getQuote()->getStore()->getId());
$request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
$request->setFreeShipping($this->getFreeShipping());
/**
* Currencies need to convert in free shipping
*/
$request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
$request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($this->getLimitCarrier());
$request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax());
$result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
$found = false;
if ($result) {
$shippingRates = $result->getAllRates();
// ============ Apply shipping on order minimum value after discount specific to coupon code only =================
if (!Mage::app()->getStore()->isAdmin()) {
foreach ($shippingRates as $i => $r) {
if ($r->getMethod() == 'freeshipping') {
unset($shippingRates[$i]);
}
}
}
$isfree = true;
$minimum_purchange_amount = Mage::getStoreConfig('sales/minimum_order_custom/minimum_purchange_amount');
$minimum_purchange_amount_status = Mage::getStoreConfig('sales/minimum_order_custom/minimum_purchange_amount_status');
if ($minimum_purchange_amount_status == '1' && $minimum_purchange_amount > 0) {
$minPurchaseAmt = Mage::helper('common')->checkMinPurchageAmount($minimum_purchange_amount);
if ($minPurchaseAmt) {
foreach ($shippingRates as $i => $r) {
if ($r->getMethod() == 'standard') {
$shippingRates[$i]->setPrice(0);
$shippingRates[$i]->setCost(0);
$isfree = true;
}
}
}
}
// ==========================================================================================
foreach ($shippingRates as $shippingRate) {
$rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
if (!$item) {
$this->addShippingRate($rate);
}
if ($this->getShippingMethod() == $rate->getCode()) {
if ($item) {
$item->setBaseShippingAmount($rate->getPrice());
} else {
/**
* possible bug: this should be setBaseShippingAmount(),
* see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
* where this value is set again from the current specified rate price
* (looks like a workaround for this bug)
*/
$this->setShippingAmount($rate->getPrice());
}
$found = true;
}
}
}
return $found;
}
示例3: requestShippingRates
/**
* Request shipping rates for entire address or specified address item
* Returns true if current selected shipping method code corresponds to one of the found rates
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return bool
*/
public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
{
/** @var $request Mage_Shipping_Model_Rate_Request */
$request = Mage::getModel('shipping/rate_request');
$request->setAllItems($item ? array($item) : $this->getAllItems());
$request->setDestCountryId($this->getCountryId());
$request->setDestRegionId($this->getRegionId());
$request->setDestRegionCode($this->getRegionCode());
/**
* need to call getStreet with -1
* to get data in string instead of array
*/
$request->setDestStreet($this->getStreet(-1));
$request->setDestCity($this->getCity());
$request->setDestPostcode($this->getPostcode());
$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
$packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
$request->setPackageValueWithDiscount($packageValueWithDiscount);
$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
$request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
/**
* Need for shipping methods that use insurance based on price of physical products
*/
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
$request->setPackagePhysicalValue($packagePhysicalValue);
$request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
/**
* Store and website identifiers need specify from quote
*/
/*$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
$request->setStoreId($this->getQuote()->getStore()->getId());
$request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
$request->setFreeShipping($this->getFreeShipping());
/**
* Currencies need to convert in free shipping
*/
$request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
$request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($this->getLimitCarrier());
$request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax());
$result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
$found = true;
return $found;
}
示例4: requestShippingRates
/**
* WE NEEDED TO OVERRIDE THIS METHOD CALL TO UPDATE THE SHIPPING RATES AS
* SOON AS WE RECEIVED THEM
*
*
*
*
* Request shipping rates for entire address or specified address item
* Returns true if current selected shipping method code corresponds to one of the found rates
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return bool
*/
public function requestShippingRates(Mage_Sales_Model_Quote_Item_Abstract $item = null)
{
/**
* CUSTOMIZED THIS FUNCTION BY ADDING THIS EVENT CALL
*/
if (!$this->getQuote()->getShippingAddress()->getResidentialIndicator()) {
Mage::dispatchEvent('widgetized_validate_address', array($this->_eventObject => $this, 'order' => $this->getQuote()));
}
/** @var $request Mage_Shipping_Model_Rate_Request */
$request = Mage::getModel('shipping/rate_request');
$request->setQuote($this->getQuote());
$request->setAllItems($item ? array($item) : $this->getAllItems());
$request->setDestCountryId($this->getCountryId());
$request->setDestRegionId($this->getRegionId());
$request->setDestRegionCode($this->getRegionCode());
/**
* need to call getStreet with -1
* to get data in string instead of array
*/
$request->setDestStreet($this->getStreet(self::DEFAULT_DEST_STREET));
$request->setDestCity($this->getCity());
$request->setDestPostcode($this->getPostcode());
$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
$packageValueWithDiscount = $item ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
$request->setPackageValueWithDiscount($packageValueWithDiscount);
$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
$request->setPackageQty($item ? $item->getQty() : $this->getItemQty());
/**
* Need for shipping methods that use insurance based on price of physical products
*/
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() - $this->getBaseVirtualAmount();
$request->setPackagePhysicalValue($packagePhysicalValue);
$request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());
/**
* Store and website identifiers need specify from quote
*/
/*$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());*/
$request->setStoreId($this->getQuote()->getStore()->getId());
$request->setWebsiteId($this->getQuote()->getStore()->getWebsiteId());
$request->setFreeShipping($this->getFreeShipping());
/**
* Currencies need to convert in free shipping
*/
$request->setBaseCurrency($this->getQuote()->getStore()->getBaseCurrency());
$request->setPackageCurrency($this->getQuote()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($this->getLimitCarrier());
$request->setBaseSubtotalInclTax($this->getBaseSubtotalInclTax() + $this->getBaseExtraTaxAmount());
$result = Mage::getModel('shipping/shipping')->collectRates($request)->getResult();
$found = false;
if ($result) {
$shippingRates = $result->getAllRates();
// var_dump($shippingRates);die;
/**
* CUSTOMIZED THIS FUNCTION BY ADDING THIS EVENT CALL
*/
Mage::dispatchEvent($this->_eventPrefix . '_update_shipping_rates', array($this->_eventObject => $this, 'shipping_rates' => $shippingRates));
foreach ($shippingRates as $shippingRate) {
$rate = Mage::getModel('sales/quote_address_rate')->importShippingRate($shippingRate);
/**
* COST is Cheaper than the PRICE
*
* We don't want to use the price, we want to give shipping
* to users at cost.
*/
if (!$item) {
$this->addShippingRate($rate);
}
if ($this->getShippingMethod() == $rate->getCode()) {
$price = $rate->getCost();
if (!$price) {
$price = $rate->getPrice();
}
if ($item) {
$item->setBaseShippingAmount($price);
} else {
/**
* possible bug: this should be setBaseShippingAmount(),
* see Mage_Sales_Model_Quote_Address_Total_Shipping::collect()
* where this value is set again from the current specified rate price
* (looks like a workaround for this bug)
*/
$this->setShippingAmount($price);
}
$found = true;
}
}
//.........这里部分代码省略.........
示例5: itemToOrderItem
/**
* Convert quote item to order item
*
* @param Mage_Sales_Model_Quote_Item_Abstract $item
* @return Mage_Sales_Model_Order_Item
*/
public function itemToOrderItem(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$orderItem = Mage::getModel('sales/order_item')->setStoreId($item->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setSuperProductId($item->getSuperProductId())->setParentProductId($item->getParentProductId())->setSku($item->getSku())->setName($item->getName())->setDescription($item->getDescription())->setWeight($item->getWeight())->setIsQtyDecimal($item->getIsQtyDecimal())->setQtyOrdered($item->getQty())->setOriginalPrice($item->getOriginalPrice())->setAppliedRuleIds($item->getAppliedRuleIds())->setAdditionalData($item->getAdditionalData())->setPrice($item->getCalculationPrice())->setTaxPercent($item->getTaxPercent())->setTaxAmount($item->getTaxAmount())->setRowWeight($item->getRowWeight())->setRowTotal($item->getRowTotal())->setBasePrice($item->getBaseCalculationPrice())->setBaseOriginalPrice($item->getPrice())->setBaseTaxAmount($item->getBaseTaxAmount())->setBaseRowTotal($item->getBaseRowTotal());
if (!$item->getNoDiscount()) {
$orderItem->setDiscountPercent($item->getDiscountPercent())->setDiscountAmount($item->getDiscountAmount())->setBaseDiscountAmount($item->getBaseDiscountAmount());
}
Mage::dispatchEvent('sales_convert_quote_item_to_order_item', array('order_item' => $orderItem, 'item' => $item));
return $orderItem;
}