-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f50d92b
Showing
28 changed files
with
1,346 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) Intelipost | ||
* @author Alex Restani <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Block; | ||
|
||
class Create extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
protected $_scopeConfig; | ||
|
||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | ||
) | ||
{ | ||
$this->setTemplate('create.phtml'); | ||
|
||
parent::__construct($context); | ||
$this->_scopeConfig = $scopeConfig; | ||
} | ||
|
||
public function getLoadPageTime() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/settings/load_page_time'); | ||
} | ||
|
||
public function getCustomState() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer_create/create_custom_state'); | ||
} | ||
|
||
public function getCustomCity() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer_create/create_custom_city'); | ||
} | ||
|
||
public function getCustomStreet() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer_create/create_custom_street'); | ||
} | ||
|
||
public function getCustomQuarter() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer_create/create_custom_quarter'); | ||
} | ||
|
||
public function getCustomAdditionalInfo() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer_create/create_custom_additional_info'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) Intelipost | ||
* @author Alex Restani <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Block; | ||
|
||
class Customer extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
protected $_scopeConfig; | ||
|
||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | ||
) | ||
{ | ||
$this->setTemplate('customer.phtml'); | ||
|
||
parent::__construct($context); | ||
$this->_scopeConfig = $scopeConfig; | ||
} | ||
|
||
public function getLoadPageTime() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/settings/load_page_time'); | ||
} | ||
|
||
public function getCustomState() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer/custom_state'); | ||
} | ||
|
||
public function getCustomCity() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer/custom_city'); | ||
} | ||
|
||
public function getCustomStreet() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer/custom_street'); | ||
} | ||
|
||
public function getCustomQuarter() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer/custom_quarter'); | ||
} | ||
|
||
public function getCustomAdditionalInfo() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_customer/custom_additional_info'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) 2016 Gamuza Technologies (http://www.gamuza.com.br/) | ||
* @author Eneias Ramos de Melo <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Block; | ||
|
||
class Order extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
protected $_scopeConfig; | ||
|
||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | ||
) | ||
{ | ||
$this->setTemplate('order.phtml'); | ||
|
||
parent::__construct($context); | ||
$this->_scopeConfig = $scopeConfig; | ||
} | ||
|
||
public function getLoadPageTime() | ||
{ | ||
$time = $this->_scopeConfig->getValue('intelipost_autocomplete/settings/load_page_time'); | ||
return $time; | ||
} | ||
|
||
public function getCustomState() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_checkout/checkout_custom_state'); | ||
} | ||
|
||
public function getCustomCity() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_checkout/checkout_custom_city'); | ||
} | ||
|
||
public function getCustomStreet() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_checkout/checkout_custom_street'); | ||
} | ||
|
||
public function getCustomQuarter() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_checkout/checkout_custom_quarter'); | ||
} | ||
|
||
public function getCustomAdditionalInfo() | ||
{ | ||
return $this->_scopeConfig->getValue('intelipost_autocomplete/custom_fields_checkout/checkout_custom_additional_info'); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) 2016 Gamuza Technologies (http://www.gamuza.com.br/) | ||
* @author Eneias Ramos de Melo <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Block; | ||
|
||
class Url extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context | ||
) | ||
{ | ||
$this->setTemplate('url.phtml'); | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
public function getAjaxUrl() | ||
{ | ||
return $this->getUrl('intelipost_autocomplete/search/index'); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) 2016 Gamuza Technologies (http://www.gamuza.com.br/) | ||
* @author Eneias Ramos de Melo <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Controller\Adminhtml\Search; | ||
|
||
class Index extends \Magento\Framework\App\Action\Action | ||
{ | ||
|
||
protected $_autocompleteHelper; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\Action\Context $context, | ||
\Intelipost\Autocomplete\Helper\Api $autocompleteHelper | ||
) | ||
{ | ||
$this->_autocompleteHelper = $autocompleteHelper; | ||
|
||
parent::__construct ($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
$postcode = $this->getRequest()->getParam('postcode'); | ||
$postcode = preg_replace ('#[^0-9]#', "", $postcode); | ||
if (empty ($postcode) || strlen ($postcode) != 8) return; | ||
|
||
$result = $this->_autocompleteHelper->getCEPLocationAddressComplete ($postcode); | ||
if (!$result || !is_array ($result)) return; | ||
|
||
if (array_key_exists ('content', $result)) | ||
{ | ||
$this->getResponse()->setBody(json_encode ($result ['content'])); | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) 2016 Gamuza Technologies (http://www.gamuza.com.br/) | ||
* @author Eneias Ramos de Melo <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Controller\Search; | ||
|
||
class Index extends \Intelipost\Autocomplete\Controller\Adminhtml\Search\Index | ||
{ | ||
|
||
protected $_autocompleteHelper; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\Action\Context $context, | ||
\Intelipost\Autocomplete\Helper\Api $autocompleteHelper | ||
) | ||
{ | ||
$this->_autocompleteHelper = $autocompleteHelper; | ||
|
||
parent::__construct ($context, $autocompleteHelper); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) 2016 Gamuza Technologies (http://www.gamuza.com.br/) | ||
* @author Eneias Ramos de Melo <[email protected]> | ||
*/ | ||
|
||
namespace Intelipost\Autocomplete\Helper; | ||
|
||
class Api extends \Intelipost\Basic\Helper\Api | ||
{ | ||
|
||
const AUTOCOMPLETE_CEP_LOCATION_ADDRESS_COMPLETE = 'cep_location/address_complete/'; | ||
|
||
protected $_scopeConfig; | ||
|
||
public function __construct | ||
( | ||
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | ||
) | ||
{ | ||
$this->_scopeConfig = $scopeConfig; | ||
|
||
parent::__construct($scopeConfig); | ||
} | ||
|
||
public function getCEPLocationAddressComplete ($destPostcode) | ||
{ | ||
$response = $this->apiRequest (self::GET, self::AUTOCOMPLETE_CEP_LOCATION_ADDRESS_COMPLETE . "{$destPostcode}"); | ||
|
||
$result = json_decode ($response, true); | ||
|
||
return $result; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "intelipost/magento2-autocomplete", | ||
"description": "Intelipost Autocomplete", | ||
"type": "magento2-module", | ||
"version": "1.0.0", | ||
"authors": [ | ||
{ | ||
"name": "Intelipost", | ||
"email": "[email protected]", | ||
"homepage": "http://www.intelipost.com.br/" | ||
}, | ||
{ | ||
"name": "Eneias Ramos de Melo", | ||
"email": "[email protected]", | ||
"homepage": "http://www.gamuza.com.br/" | ||
} | ||
], | ||
"license": [ | ||
"OSL-3.0" | ||
], | ||
"require": { | ||
"php": "~5.5.0|~5.6.0|~7.0.0", | ||
"intelipost/magento2-basic": "1.*" | ||
}, | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Intelipost\\Autocomplete\\": "" | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
/* | ||
* @package Intelipost_Autocomplete | ||
* @copyright Copyright (c) 2016 Gamuza Technologies (http://www.gamuza.com.br/) | ||
* @author Eneias Ramos de Melo <[email protected]> | ||
*/ | ||
--> | ||
|
||
<config> | ||
<router id="admin"> | ||
<route id="intelipost_autocomplete" frontName="intelipost_autocomplete"> | ||
<module name="Intelipost_Autocomplete" /> | ||
</route> | ||
</router> | ||
</config> | ||
|
Oops, something went wrong.