PickupIdentity.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Model\Pickup\Email\Container;
  6. use Magento\Sales\Model\Order\Email\Container\OrderIdentity;
  7. use Magento\Store\Model\ScopeInterface;
  8. /**
  9. * Temando Pickup Identity Container
  10. *
  11. * Set the current context before you try to send a mail, to tell the sender which order action for
  12. * pickup orders is sending a notification
  13. *
  14. * @package Temando\Shipping\Model
  15. * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
  16. * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
  17. * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  18. * @link https://www.temando.com/
  19. */
  20. class PickupIdentity extends OrderIdentity
  21. {
  22. const XML_PATH_EMAIL_ENABLED = 'sales_email/temando_pickup/enabled';
  23. const XML_PATH_EMAIL_COPY_TO = 'sales_email/temando_pickup/copy_to';
  24. const XML_PATH_EMAIL_IDENTITY = 'sales_email/temando_pickup/identity';
  25. const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/temando_pickup/copy_method';
  26. /**
  27. * @var string
  28. */
  29. private $templatePath;
  30. /**
  31. * Is email enabled
  32. *
  33. * @return bool
  34. */
  35. public function isEnabled()
  36. {
  37. return $this->scopeConfig->isSetFlag(
  38. self::XML_PATH_EMAIL_ENABLED,
  39. ScopeInterface::SCOPE_STORE,
  40. $this->getStore()->getStoreId()
  41. );
  42. }
  43. /**
  44. * Return list of copy_to emails
  45. *
  46. * @return array|bool
  47. */
  48. public function getEmailCopyTo()
  49. {
  50. $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId());
  51. if (!empty($data)) {
  52. return explode(',', $data);
  53. }
  54. return false;
  55. }
  56. /**
  57. * Return email copy method
  58. *
  59. * @return string
  60. */
  61. public function getCopyMethod()
  62. {
  63. return (string)$this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId());
  64. }
  65. /**
  66. * Return template id
  67. *
  68. * @return string
  69. */
  70. public function getTemplateId()
  71. {
  72. return (string)$this->getConfigValue($this->templatePath, $this->getStore()->getStoreId());
  73. }
  74. /**
  75. * Return guest template id
  76. *
  77. * @return string
  78. */
  79. public function getGuestTemplateId()
  80. {
  81. return $this->getTemplateId();
  82. }
  83. /**
  84. * Return email identity
  85. *
  86. * @return string
  87. */
  88. public function getEmailIdentity()
  89. {
  90. return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId());
  91. }
  92. /**
  93. * @param string $path
  94. * @return void
  95. */
  96. public function setTemplatePath($path)
  97. {
  98. $this->templatePath = $path;
  99. }
  100. }