12 class Shipping extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
54 $address = $shippingAssignment->getShipping()->getAddress();
55 $method = $shippingAssignment->getShipping()->getMethod();
58 $total->setBaseTotalAmount($this->
getCode(), 0);
60 if (!count($shippingAssignment->getItems())) {
64 $data = $this->getAssignmentWeightData(
$address, $shippingAssignment->getItems());
68 $addressFreeShipping = (bool)
$address->getFreeShipping();
69 $isFreeShipping = $this->freeShipping->isFreeShipping(
$quote, $shippingAssignment->getItems());
70 $address->setFreeShipping($isFreeShipping);
71 if (!$addressFreeShipping && $isFreeShipping) {
72 $data = $this->getAssignmentWeightData(
$address, $shippingAssignment->getItems());
84 $amountPrice = $this->priceCurrency->convert(
90 $shippingDescription =
$rate->getCarrierTitle() .
' - ' .
$rate->getMethodTitle();
91 $address->setShippingDescription(trim($shippingDescription,
' -'));
93 $total->setShippingAmount($amountPrice);
94 $total->setShippingDescription(
$address->getShippingDescription());
113 $shippingDescription =
$total->getShippingDescription();
115 ?
__(
'Shipping & Handling (%1)', $shippingDescription)
116 :
__(
'Shipping & Handling');
132 return __(
'Shipping');
147 $addressWeight =
$address->getWeight();
148 $freeMethodWeight =
$address->getFreeMethodWeight();
149 $addressFreeShipping = (bool)
$address->getFreeShipping();
155 if (
$item->getProduct()->isVirtual()) {
162 if (
$item->getParentItem()) {
166 $itemQty = (float)
$item->getQty();
167 $itemWeight = (float)
$item->getWeight();
169 if (
$item->getHasChildren() &&
$item->isShipSeparately()) {
170 foreach (
$item->getChildren() as $child) {
171 if ($child->getProduct()->isVirtual()) {
174 $addressQty += $child->getTotalQty();
176 if (!
$item->getProduct()->getWeightType()) {
177 $itemWeight = (float)$child->getWeight();
178 $itemQty = (float)$child->getTotalQty();
179 $addressWeight += ($itemWeight * $itemQty);
180 $rowWeight = $this->getItemRowWeight(
181 $addressFreeShipping,
184 $child->getFreeShipping()
186 $freeMethodWeight += $rowWeight;
187 $item->setRowWeight($rowWeight);
190 if (
$item->getProduct()->getWeightType()) {
191 $addressWeight += ($itemWeight * $itemQty);
192 $rowWeight = $this->getItemRowWeight(
193 $addressFreeShipping,
196 $item->getFreeShipping()
198 $freeMethodWeight += $rowWeight;
199 $item->setRowWeight($rowWeight);
202 if (!
$item->getProduct()->isVirtual()) {
203 $addressQty += $itemQty;
205 $addressWeight += ($itemWeight * $itemQty);
206 $rowWeight = $this->getItemRowWeight(
207 $addressFreeShipping,
210 $item->getFreeShipping()
212 $freeMethodWeight += $rowWeight;
213 $item->setRowWeight($rowWeight);
218 'addressQty' => $addressQty,
219 'addressWeight' => $addressWeight,
220 'freeMethodWeight' => $freeMethodWeight
233 private function getItemRowWeight(
234 bool $addressFreeShipping,
239 $rowWeight = $itemWeight * $itemQty;
244 if ($itemQty > $freeQty) {
245 $rowWeight = $itemWeight * ($itemQty - $freeQty);
250 return (
float)$rowWeight;
elseif(isset( $params[ 'redirect_parent']))
fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
__construct(PriceCurrencyInterface $priceCurrency, FreeShippingInterface $freeShipping)
collect(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)