| Current Path : /var/www/www.indacotrentino.com/www/app/code/Webkul/BuyButton/Block/Adminhtml/BuyButton/ |
| Current File : //var/www/www.indacotrentino.com/www/app/code/Webkul/BuyButton/Block/Adminhtml/BuyButton/Create.php |
<?php
/**
* Webkul Software.
*
* @category Webkul
* @package Webkul_BuyButton
* @author Webkul
* @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
* @license https://store.webkul.com/license.html
*/
namespace Webkul\BuyButton\Block\Adminhtml\BuyButton;
class Create extends \Magento\Backend\Block\Template
{
/**
* @var \Webkul\BuyButton\Helper\Data
*/
protected $helper;
/**
* Constructor.
*
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Webkul\BuyButton\Helper\Data $helper,
array $data = []
) {
$this->helper = $helper;
parent::__construct($context, $data);
}
/**
* get frontend base url
*
* @return string
*/
public function getBaseUrl()
{
$storeId = $this->getStoreId();
return $this->_storeManager->getStore($storeId)->getBaseUrl();
}
/**
* get js plugin url
*
* @return string
*/
public function getJsUrl()
{
$storeId = $this->getStoreId();
$url = $this->getBaseUrl().'bb/loadbutton/index/access/'.$this->getAccessKey();
return $url;
}
/**
* get buy button files directory from media
*
* @return string
*/
public function getStaticUrl()
{
$storeId = $this->getStoreId();
return $this->_storeManager->getStore($storeId)
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)."buybutton";
}
/**
* get product ids for the page
*
* @return void
*/
public function getProductIds()
{
$productIds = $this->getRequest()->getParam('productIds');
return $productIds;
}
/**
* get access key for the plugin
*/
public function getAccessKey()
{
return $this->helper->getAccessKey();
}
/**
* get do redirect to product page
*
* @return boolean
*/
public function getRedirectToProductPage()
{
return $this->helper->getDoRedirect();
}
/**
* get store id
*/
public function getStoreId()
{
$storeId = $this->getRequest()->getParam("store");
return $storeId?$storeId:$this->_storeManager->getDefaultStoreView()->getStoreId();
}
/**
* get currency
*/
public function getCurrencyCode()
{
$currency = $this->getRequest()->getParam("currency");
return $currency?$currency:'USD';
}
/**
* get locale code for javascript
*
* @return string
*/
public function getLocale()
{
$localeCode = $this->helper->getLocaleCode($this->getStoreId());
if ($localeCode) {
$code = explode("_", $localeCode);
$code[0] = strtolower($code[0]);
$code[1] = strtolower($code[1]);
return implode("-", $code);
} else {
return 'en-us';
}
}
}