| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Cpcommerce\ShippingNotifications\Block;
- use Magento\Catalog\Block\Product\View\Description;
- use Magento\Framework\View\Element\Template;
- use Magento\Framework\View\Element\Template\Context;
- use \Magento\Framework\App\Config\ScopeConfigInterface;
- class ShippingCategory extends Template
- {
- private $description;
- private $context;
- private $data;
- private $scopeConfig;
- public function __construct(
- Description $description,
- Context $context,
- array $data = [],
- ScopeConfigInterface $scopeConfig
- ) {
- $this->description = $description;
- $this->scopeConfig = $scopeConfig;
- return parent::__construct($context, $data);
- }
- public function getShippingCategory(){
- $_product = $this->description->getProduct();
- $attributeCode = $this->scopeConfig->getValue('cpcommerce_shipping_notifications/general/attribute',\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $option_id = $_product->getData($attributeCode);
- return $option_id;
- }
- public function getDelayedShippingCategories(){
- $delayedShipCategs = $this->scopeConfig->getValue('cpcommerce_shipping_notifications/general/shipping_categories',\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- if(isset($delayedShipCategs)){
- $delayedShipCategsArray = explode(",",$delayedShipCategs);
- return $delayedShipCategsArray;
- }
- return null;
- }
- public function getBlock(){
- $notifBlock = $this->scopeConfig->getValue('cpcommerce_shipping_notifications/general/shipping_notification_block',\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- if(!isset($notifBlock)){
- return null;
- }
- return $notifBlock;
- }
- }
|