-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod.php
More file actions
86 lines (84 loc) · 3.24 KB
/
Copy pathMethod.php
File metadata and controls
86 lines (84 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Doormall\Shipping;
use Doormall\Shipping\Partner\Entity as Partner;
use Magento\Quote\Model\Quote\Address\RateRequest as Req;
use Magento\Quote\Model\Quote\Address\RateResult\Method as ResM;
use Magento\Shipping\Model\Carrier\AbstractCarrier as AC; // 2018-04-17 It is used by PHPDoc.
use Magento\Shipping\Model\Carrier\AbstractCarrierInterface as IAC; // 2018-04-17 It is used by PHPDoc.
use Magento\Shipping\Model\Carrier\CarrierInterface as IC; // 2018-04-17 It is used by PHPDoc.
use Magento\Shipping\Model\Rate\Result as Res;
// 2018-04-17
/** @method Settings s() */
final class Method extends \Df\Shipping\Method {
/**
* 2018-04-17
* @override
* @see \Df\Shipping\Method::collectRates()
* @used-by \Magento\Shipping\Model\Shipping::collectCarrierRates():
* $result = $carrier->collectRates($request);
* https://github.com/magento/magento2/blob/2.2.3/app/code/Magento/Shipping/Model/Shipping.php#L243-L321
* @param Req $req
* @return Res
*/
function collectRates(Req $req) {
$r = df_new_om(Res::class); /** @var Res $r */
foreach ($this->s()->partners() as $p) { /** @var Partner $p */
$m = df_new_omd(ResM::class, [
'carrier' => $this->getCarrierCode()
,'carrier_title' => 'Pickup'
,'cost' => $p->fee()
,'method' => $p->id()
,'method_title' => $p->title()
,'price' => $p->fee()
]); /** @var ResM $m */
$r->append($m);
}
return $r;
}
/**
* 2018-04-17
* @override
* @see IC::getAllowedMethods()
* 1) @used-by \Magento\Shipping\Model\Config\Source\Allmethods::toOptionArray():
* foreach ($carriers as $carrierCode => $carrierModel) {
* if (!$carrierModel->isActive() && (bool)$isActiveOnlyFlag === true) {
* continue;
* }
* $carrierMethods = $carrierModel->getAllowedMethods();
* if (!$carrierMethods) {
* continue;
* }
* $carrierTitle = $this->_scopeConfig->getValue(
* 'carriers/' . $carrierCode . '/title',
* \Magento\Store\Model\ScopeInterface::SCOPE_STORE
* );
* $methods[$carrierCode] = ['label' => $carrierTitle, 'value' => []];
* foreach ($carrierMethods as $methodCode => $methodTitle) {
* $methods[$carrierCode]['value'][] = [
* 'value' => $carrierCode . '_' . $methodCode,
* 'label' => '[' . $carrierCode . '] ' . $methodTitle,
* ];
* }
* }
* https://github.com/magento/magento2/blob/2.2.3/app/code/Magento/Shipping/Model/Config/Source/Allmethods.php#L34-L67
* 2) @used-by \Magento\InstantPurchase\Model\ShippingMethodChoose\CarrierFinder::getCarriersForCustomerAddress()
* $request = new DataObject([
* 'dest_country_id' => $address->getCountryId()
* ]);
* $carriers = [];
* foreach ($this->carriersConfig->getActiveCarriers($this->storeManager->getStore()->getId()) as $carrier) {
* $checked = $carrier->checkAvailableShipCountries($request);
* if (false !== $checked && null === $checked->getErrorMessage() && !empty($checked->getAllowedMethods())) {
* $carriers[] = $checked;
* }
* }
* https://github.com/magento/magento2/blob/2.2.3/app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/CarrierFinder.php#L41-L62
* @return array(string => string)
*/
function getAllowedMethods() {return [0 => 'Default'];}
/**
* 2018-04-17
* @used-by \Df\Shipping\Method::codeS()
*/
const CODE = 'doormall';
}