-
Notifications
You must be signed in to change notification settings - Fork 12
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
1 parent
0bcb1f7
commit 318d9f8
Showing
12 changed files
with
247 additions
and
165 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.log | ||
/tags | ||
/wordpress | ||
.DS_Store |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
This file was deleted.
Oops, something went wrong.
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,62 @@ | ||
<?php | ||
namespace WooCommerce\Jadlog\Classes; | ||
|
||
class PudoInfo { | ||
|
||
public function __construct($pudo_data) { | ||
$this->_data = is_array($pudo_data) ? $pudo_data : array(); | ||
$this->_address = $this->_data['pudoEnderecoList'][0]; | ||
} | ||
|
||
public function nao_esta_ativo() { | ||
return $this->_data['ativo'] != 'S'; | ||
} | ||
|
||
public function get_id() { | ||
return $this->_data['pudoId']; | ||
} | ||
|
||
public function get_name() { | ||
return $this->_data['razao']; | ||
} | ||
|
||
public function get_latitude() { | ||
return $this->_address['latitude']; | ||
} | ||
|
||
public function get_longitude() { | ||
return $this->_address['longitude']; | ||
} | ||
|
||
public function get_postcode() { | ||
return $this->_address['cep']; | ||
} | ||
|
||
public function get_openning_hours() { | ||
return $this->_data['pudoHorario']; | ||
} | ||
|
||
public function get_formatted_address() { | ||
$address = $this->_address['endereco']; | ||
if (!empty($this->_address['numero'])) | ||
$address .= ', '.$this->_address['numero']; | ||
if (!empty($this->_address['compl2'])) | ||
$address .= ' - '.$this->_address['compl2']; | ||
if (!empty($this->_address['bairro']) && $this->_address['bairro'] != $this->_address['compl2']) | ||
$address .= ' - '.$this->_address['bairro']; | ||
if (!empty($this->_address['cidade'])) | ||
$address .= ' - '.$this->_address['cidade']; | ||
if (!empty($this->_address['cep'])) | ||
$address .= ' - CEP '.$this->format_postcode($this->_address['cep']); | ||
return $address; | ||
} | ||
|
||
private function format_postcode($postcode) { | ||
$postcode = str_pad($postcode, 8, "0", STR_PAD_LEFT); | ||
return strlen($postcode) == 8 ? substr($postcode, 0, 5).'-'.substr($postcode, -3) : $postcode; | ||
} | ||
|
||
public function get_formatted_name_and_address() { | ||
return $this->get_name().' ('.$this->get_formatted_address().')'; | ||
} | ||
} |
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
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,40 @@ | ||
<?php | ||
namespace WooCommerce\Jadlog\Classes; | ||
|
||
class ShippingPrice { | ||
|
||
public function __construct($postcode, $shipping_package) { | ||
$this->_shipping_package = $shipping_package; | ||
$this->_postcode = $postcode; | ||
} | ||
|
||
public function get_estimated_value() { | ||
$values = $this->get_estimated_values(); | ||
return $values['estimated_value']; | ||
} | ||
|
||
public function get_formatted_estimated_time() { | ||
$values = $this->get_estimated_values(); | ||
return isset($values['estimated_time']) ? | ||
$values['estimated_time'].__(' dias úteis', 'jadlog') : | ||
''; | ||
} | ||
|
||
public function get_estimated_time() { | ||
$values = $this->get_estimated_values(); | ||
return $values['estimated_time']; | ||
} | ||
|
||
private function get_estimated_values() { | ||
if (!isset($this->_estimated_values)) { | ||
include_once('ShippingPriceService.php'); | ||
$service = new ShippingPriceService($this->_shipping_package->modalidade); | ||
$this->_estimated_values = $service->estimate( | ||
$this->_shipping_package->get_price(), | ||
$this->_postcode, | ||
$this->_shipping_package->get_effective_weight()); | ||
} | ||
|
||
return $this->_estimated_values; | ||
} | ||
} |
Oops, something went wrong.