本文整理汇总了PHP中Mage_Sales_Model_Quote_Address::setBaseShippingAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote_Address::setBaseShippingAmount方法的具体用法?PHP Mage_Sales_Model_Quote_Address::setBaseShippingAmount怎么用?PHP Mage_Sales_Model_Quote_Address::setBaseShippingAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote_Address
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote_Address::setBaseShippingAmount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Abstract
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
$payment = $quote->getPayment();
if ($address->getAddressType() === 'billing') {
return $this;
}
$configId = $payment->getPayoneConfigPaymentMethodId();
if (empty($configId)) {
return $this;
}
$config = $this->helperConfig()->getConfigPaymentMethodById($configId, $quote->getStoreId());
if (empty($config)) {
return $this;
}
$feeConfig = $config->getFeeConfigForQuote($quote);
if (!is_array($feeConfig) or !array_key_exists('fee_config', $feeConfig)) {
return $this;
}
$paymentFee = $feeConfig['fee_config'];
$oldShippingAmount = $address->getBaseShippingAmount();
$newShippingAmount = $oldShippingAmount + $paymentFee;
$address->setBaseShippingAmount($newShippingAmount);
$address->setShippingAmount($quote->getStore()->convertPrice($newShippingAmount, false));
return parent::collect($address);
}
示例2: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$oldWeight = $address->getWeight();
$address->setWeight(0);
$address->setShippingAmount(0);
$method = $address->getShippingMethod();
$freeAddress = $address->getFreeShipping();
$address->setFreeMethodWeight(0);
foreach ($address->getAllItems() as $item) {
$item->calcRowWeight();
$address->setWeight($address->getWeight() + $item->getRowWeight());
if ($freeAddress || $item->getFreeShipping() === true) {
$item->setRowWeight(0);
} elseif (is_numeric($item->getFreeShipping())) {
$origQty = $item->getQty();
if ($origQty > $item->getFreeShipping()) {
$item->setQty($origQty - $item->getFreeShipping());
$item->calcRowWeight();
$item->setQty($origQty);
} else {
$item->setRowWeight(0);
}
}
$address->setFreeMethodWeight($address->getFreeMethodWeight() + $item->getRowWeight());
}
$address->collectShippingRates();
$address->setShippingAmount(0);
$address->setBaseShippingAmount(0);
$method = $address->getShippingMethod();
if ($method) {
foreach ($address->getAllShippingRates() as $rate) {
if ($rate->getCode() == $method) {
$amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
$address->setShippingAmount($amountPrice);
$address->setBaseShippingAmount($rate->getPrice());
$address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodDescription());
break;
}
}
}
$address->setGrandTotal($address->getGrandTotal() + $address->getShippingAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseShippingAmount());
return $this;
}
示例3: collect
/**
* Collect totals information about shipping
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Shipping
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$_code = 'customshippingrate';
$method = $address->getShippingMethod();
if ($method == $_code) {
$amountPrice = $address->getQuote()->getStore()->convertPrice($address->getBaseShippingAmount(), false);
if (Mage::helper('customshippingrate')->isMage13()) {
$address->setShippingAmount($amountPrice);
$address->setBaseShippingAmount($address->getBaseShippingAmount());
$address->setGrandTotal($address->getGrandTotal() + $address->getShippingAmount());
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseShippingAmount());
} else {
$this->_setAddress($address);
$this->_setAmount($amountPrice);
$this->_setBaseAmount($address->getBaseShippingAmount());
}
return $this;
} else {
return parent::collect($address);
}
}
示例4: collect
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$oldWeight = $address->getWeight();
$address->setWeight(0);
$address->setShippingAmount(0);
$address->setBaseShippingAmount(0);
$address->setFreeMethodWeight(0);
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
$method = $address->getShippingMethod();
$freeAddress = $address->getFreeShipping();
$addressWeight = $address->getWeight();
$freeMethodWeight = $address->getFreeMethodWeight();
$addressQty = 0;
foreach ($items as $item) {
/**
* Skip if this item is virtual
*/
if ($item->getProduct()->isVirtual()) {
continue;
}
/**
* Children weight we calculate for parent
*/
if ($item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getProduct()->isVirtual()) {
continue;
}
$addressQty += $item->getQty() * $child->getQty();
if (!$item->getProduct()->getWeightType()) {
$itemWeight = $child->getWeight();
$itemQty = $item->getQty() * $child->getQty();
$rowWeight = $itemWeight * $itemQty;
$addressWeight += $rowWeight;
if ($freeAddress || $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;
$item->setRowWeight($rowWeight);
}
}
if ($item->getProduct()->getWeightType()) {
$itemWeight = $item->getWeight();
$rowWeight = $itemWeight * $item->getQty();
$addressWeight += $rowWeight;
if ($freeAddress || $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;
$item->setRowWeight($rowWeight);
}
} else {
if (!$item->getProduct()->isVirtual()) {
$addressQty += $item->getQty();
}
$itemWeight = $item->getWeight();
$rowWeight = $itemWeight * $item->getQty();
$addressWeight += $rowWeight;
if ($freeAddress || $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;
$item->setRowWeight($rowWeight);
}
}
if (isset($addressQty)) {
$address->setItemQty($addressQty);
}
$address->setWeight($addressWeight);
$address->setFreeMethodWeight($freeMethodWeight);
$address->collectShippingRates();
$address->setShippingAmount(0);
$address->setBaseShippingAmount(0);
//.........这里部分代码省略.........