67 \
Magento\Framework\
App\Config\ScopeConfigInterface $scopeConfig,
68 \
Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory,
69 \Psr\Log\LoggerInterface
$logger,
70 \
Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory,
71 \
Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory,
75 $this->_rateResultFactory = $rateResultFactory;
76 $this->_resultMethodFactory = $resultMethodFactory;
77 $this->_tablerateFactory = $tablerateFactory;
78 parent::__construct($scopeConfig, $rateErrorFactory,
$logger,
$data);
79 foreach ($this->
getCode(
'condition_name') as $k => $v) {
80 $this->_conditionNames[] = $k;
100 if (!$this->
getConfigFlag(
'include_virtual_price') && $request->getAllItems()) {
102 if (
$item->getParentItem()) {
105 if (
$item->getHasChildren() &&
$item->isShipSeparately()) {
106 foreach (
$item->getChildren() as $child) {
107 if ($child->getProduct()->isVirtual()) {
108 $request->setPackageValue(
$request->getPackageValue() - $child->getBaseRowTotal());
119 $freePackageValue = 0;
123 if (
$item->getProduct()->isVirtual() ||
$item->getParentItem()) {
127 if (
$item->getHasChildren() &&
$item->isShipSeparately()) {
128 foreach (
$item->getChildren() as $child) {
129 if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
130 $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
131 $freeQty +=
$item->getQty() * ($child->getQty() - $freeShipping);
134 }
elseif (
$item->getFreeShipping() ||
$item->getAddress()->getFreeShipping()) {
135 $freeShipping =
$item->getFreeShipping() ?
136 $item->getFreeShipping() :
$item->getAddress()->getFreeShipping();
137 $freeShipping = is_numeric($freeShipping) ? $freeShipping : 0;
138 $freeQty +=
$item->getQty() - $freeShipping;
139 $freePackageValue +=
$item->getBaseRowTotal();
142 $oldValue =
$request->getPackageValue();
143 $request->setPackageValue($oldValue - $freePackageValue);
146 if (!
$request->getConditionName()) {
148 $request->setConditionName($conditionName ? $conditionName : $this->_defaultConditionName);
152 $oldWeight =
$request->getPackageWeight();
153 $oldQty =
$request->getPackageQty();
156 $request->setPackageQty($oldQty - $freeQty);
159 $result = $this->_rateResultFactory->create();
162 $request->setPackageWeight($oldWeight);
166 if (
$request->getPackageQty() == $freeQty) {
181 $request->setPackageValue($freePackageValue);
185 $method = $this->createShippingMethod(0, 0);
190 $error = $this->_rateErrorFactory->create(
193 'carrier' => $this->_code,
213 return $this->_tablerateFactory->create()->getRate(
$request);
227 'condition_name' => [
228 'package_weight' =>
__(
'Weight vs. Destination'),
229 'package_value' =>
__(
'Price vs. Destination'),
230 'package_qty' =>
__(
'# of Items vs. Destination'),
232 'condition_name_short' => [
233 'package_weight' =>
__(
'Weight (and above)'),
234 'package_value' =>
__(
'Order Subtotal (and above)'),
235 'package_qty' =>
__(
'# of Items (and above)'),
239 if (!isset($codes[
$type])) {
241 __(
'The "%1" code type for Table Rate is incorrect. Verify the type and try again.',
$type)
246 return $codes[
$type];
251 __(
'The "%1: %2" code type for Table Rate is incorrect. Verify the type and try again.',
$type,
$code)
278 $method = $this->_resultMethodFactory->create();
280 $method->setCarrier(
'tablerate');
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory, \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory, array $data=[])
elseif(isset( $params[ 'redirect_parent']))
getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request)
getFinalPriceWithHandlingFee($cost)
collectRates(RateRequest $request)