Pickup.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\OfflineShipping\Model\Carrier;
  7. use Magento\Quote\Model\Quote\Address\RateRequest;
  8. /**
  9. * Pickup shipping model
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Pickup extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
  15. \Magento\Shipping\Model\Carrier\CarrierInterface
  16. {
  17. /**
  18. * @var string
  19. */
  20. protected $_code = 'pickup';
  21. /**
  22. * @var bool
  23. */
  24. protected $_isFixed = true;
  25. /**
  26. * @var \Magento\Shipping\Model\Rate\ResultFactory
  27. */
  28. protected $_rateResultFactory;
  29. /**
  30. * @var \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory
  31. */
  32. protected $_rateMethodFactory;
  33. /**
  34. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  35. * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  36. * @param \Psr\Log\LoggerInterface $logger
  37. * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
  38. * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  39. * @param array $data
  40. */
  41. public function __construct(
  42. \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
  43. \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory,
  44. \Psr\Log\LoggerInterface $logger,
  45. \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory,
  46. \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory,
  47. array $data = []
  48. ) {
  49. $this->_rateResultFactory = $rateResultFactory;
  50. $this->_rateMethodFactory = $rateMethodFactory;
  51. parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
  52. }
  53. /**
  54. * @param RateRequest $request
  55. * @return \Magento\Shipping\Model\Rate\Result
  56. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  57. */
  58. public function collectRates(RateRequest $request)
  59. {
  60. // Pickup shipping method is not supported in Magento2 yet.
  61. return false;
  62. }
  63. /**
  64. * Get allowed shipping methods
  65. *
  66. * @return array
  67. */
  68. public function getAllowedMethods()
  69. {
  70. return ['pickup' => __('Store Pickup')];
  71. }
  72. }