本文整理汇总了PHP中Mage_Sales_Model_Quote_Item::getWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Item::getWeight方法的具体用法?PHP Mage_Sales_Model_Quote_Item::getWeight怎么用?PHP Mage_Sales_Model_Quote_Item::getWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Item::getWeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importQuoteItem
public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
{
$this->setQuoteItemId($quoteItem->getId())->setProductId($quoteItem->getProductId())->setProduct($quoteItem->getProduct())->setSuperProductId($quoteItem->getSuperProductId())->setSuperProduct($quoteItem->getSuperProduct())->setSku($quoteItem->getSku())->setImage($quoteItem->getImage())->setName($quoteItem->getName())->setDescription($quoteItem->getDescription())->setWeight($quoteItem->getWeight())->setPrice($quoteItem->getPrice())->setCost($quoteItem->getCost());
if (!$this->hasQty()) {
$this->setQty($quoteItem->getQty());
}
$this->setQuoteItemImported(true);
return $this;
}
示例2: _getStdWeightQtyTotals
/**
* Gets the item information for standard items or child items of configurable products
*
* @param Mage_Sales_Model_Quote_Item $item
* @param bool $cartFreeShipping
* @return Webshopapps_Wsacommon_Model_Totals
*/
protected function _getStdWeightQtyTotals($item, $cartFreeShipping)
{
$finalTotals = new Webshopapps_Wsacommon_Model_Totals();
$addressWeight = 0;
$addressQty = 0;
$freeMethodWeight = 0;
if ($item->getHasChildren() && ($item->isShipSeparately() || $item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)) {
foreach ($item->getChildren() as $child) {
if ($child->getProduct()->isVirtual()) {
continue;
}
$addressQty += $item->getQty() * $child->getQty();
$itemWeight = $child->getWeight();
$itemQty = $child->getTotalQty();
$rowWeight = $itemWeight * $itemQty;
if ($cartFreeShipping || $child->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($child->getFreeShipping())) {
$freeQty = $child->getFreeShipping();
if ($itemQty > $freeQty) {
$rowWeight = $itemWeight * ($itemQty - $freeQty);
} else {
$rowWeight = 0;
}
}
$freeMethodWeight += $rowWeight;
$addressWeight += $rowWeight;
}
} else {
$addressQty += $item->getQty();
$itemWeight = $item->getWeight();
$rowWeight = $itemWeight * $item->getQty();
$addressWeight += $rowWeight;
if ($cartFreeShipping || $item->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($item->getFreeShipping())) {
$freeQty = $item->getFreeShipping();
if ($item->getQty() > $freeQty) {
$rowWeight = $itemWeight * ($item->getQty() - $freeQty);
} else {
$rowWeight = 0;
}
}
$freeMethodWeight += $rowWeight;
}
$finalTotals->setWeight($addressWeight);
$finalTotals->setFreeMethodWeight($freeMethodWeight);
// TODO This wasnt in original, needs checking
$finalTotals->setQty($addressQty);
return $finalTotals;
}