Skip to content

Commit

Permalink
feat: Desativa serviços centralizados dos correios (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedro0000 authored Jul 25, 2024
1 parent 516264a commit 2cc88a9
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 245 deletions.
24 changes: 0 additions & 24 deletions Models/Agency.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class Agency {

const AGENCY_SELECTED_JADLOG_CENTRALIZED = 'melhorenvio_option_agency_jadlog_centralized';

const AGENCY_SELECTED_CORREIOS_CENTRALIZED = 'melhorenvio_option_agency_correios_centralized';

const AGENCY_SELECTED_LOGGI = 'melhorenvio_option_agency_loggi';

const AGENCY_SELECTED_JET = 'melhorenvio_option_agency_jet';
Expand All @@ -32,15 +30,6 @@ public function getJadlogCentralized() {
return get_option( self::AGENCY_SELECTED_JADLOG_CENTRALIZED, null );
}

/**
* function to get the id of agency Correios centralized selected.
*
* @return array
*/
public function getCorreiosCentralized() {
return get_option( self::AGENCY_SELECTED_CORREIOS_CENTRALIZED, null );
}

/**
* function to get the id of agency Loggi selected.
*
Expand Down Expand Up @@ -86,19 +75,6 @@ public function setJadlogCentralized( $data ) {
return true;
}

/**
* @param array $data
* @return bool
*/
public function setCorreiosCentralized( $data ) {
delete_option( self::AGENCY_SELECTED_CORREIOS_CENTRALIZED );
if ( ! add_option( self::AGENCY_SELECTED_CORREIOS_CENTRALIZED, $data ) ) {
return false;
}

return true;
}

/**
* @param array $data
* @return bool
Expand Down
14 changes: 1 addition & 13 deletions Models/ShippingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ShippingService {

const SERVICES_CORREIOS = array( 1, 2, 17, 28, 29, 30 );
const SERVICES_CORREIOS = array( 1, 2, 17 );

const SERVICES_JADLOG = array( 3, 4, 27 );

Expand All @@ -14,12 +14,8 @@ class ShippingService {

const CORREIOS_PAC = 1;

const CORREIOS_PAC_CENTRALIZED = 28;

const CORREIOS_SEDEX = 2;

const CORREIOS_SEDEX_CENTRALIZED = 29;

const JADLOG_PACKAGE = 3;

const JADLOG_PACKAGE_CENTRALIZED = 27;
Expand All @@ -36,8 +32,6 @@ class ShippingService {

const CORREIOS_MINI = 17;

const CORREIOS_MINI_CENTRALIZED = 30;

const LOGGI_EXPRESS = 31;

const LOGGI_COLETA = 32;
Expand Down Expand Up @@ -86,12 +80,8 @@ public static function getCodeByMethodId( $methodId ) {
switch ( $methodId ) {
case 'melhorenvio_correios_pac':
return self::CORREIOS_PAC;
case 'melhorenvio_correios_pac_centralized':
return self::CORREIOS_PAC_CENTRALIZED;
case 'melhorenvio_correios_sedex':
return self::CORREIOS_SEDEX;
case 'melhorenvio_correios_sedex_centralized':
return self::CORREIOS_SEDEX_CENTRALIZED;
case 'melhorenvio_jadlog_package':
return self::JADLOG_PACKAGE;
case 'melhorenvio_jadlog_package_centralized':
Expand All @@ -112,8 +102,6 @@ public static function getCodeByMethodId( $methodId ) {
return self::AZUL_ECOMMERCE;
case 'melhorenvio_correios_mini':
return self::CORREIOS_MINI;
case 'melhorenvio_correios_mini_centralized':
return self::CORREIOS_MINI_CENTRALIZED;
case 'melhorenvio_latam_juntos':
return self::LATAM_JUNTOS;
case 'melhorenvio_buslog_rodoviario':
Expand Down
2 changes: 1 addition & 1 deletion Models/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

class Version {

const VERSION = '2.15.5';
const VERSION = '2.15.6';
}
21 changes: 1 addition & 20 deletions Services/AgenciesSelectedService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ public function getJadlogCentralized() {
return $this->agencyModel->getJadlogCentralized();
}

/**
* @return array
*/
public function getCorreiosCentralized() {
return $this->agencyModel->getCorreiosCentralized();
}

/**
* @return array
*/
Expand Down Expand Up @@ -71,24 +64,12 @@ public function setJadlogCentralized( $data ) {
return $this->agencyModel->setJadlogCentralized( $data );
}

/**
* @param array $data
* @return bool
*/
public function setCorreiosCentralized( $data ) {
if ( empty( $data ) ) {
return true;
}

return $this->agencyModel->setCorreiosCentralized( $data );
}

/**
* @param array $data
* @return bool
*/
public function setLoggi( $data ) {

if ( empty( $data ) ) {
return true;
}
Expand Down
8 changes: 0 additions & 8 deletions Services/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ private function getAgencyToInsertCart( $shippingMethodId ) {

$agenciesSelectedService = new AgenciesSelectedService();

if (in_array($shippingMethodId, [
ShippingService::CORREIOS_SEDEX_CENTRALIZED,
ShippingService::CORREIOS_PAC_CENTRALIZED,
ShippingService::CORREIOS_MINI_CENTRALIZED])
) {
return $agenciesSelectedService->getCorreiosCentralized();
}

if ((int) $shippingMethodId === ShippingService::JADLOG_PACKAGE_CENTRALIZED) {
return $agenciesSelectedService->getJadlogCentralized();
}
Expand Down
13 changes: 0 additions & 13 deletions Services/ConfigurationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ public function saveConfigurations( $data ) {
( new AgenciesSelectedService() )->set( $response['agency'] );
}

if ( ! empty( $data['agency_correios_centralized'] ) ) {
( new AgenciesSelectedService() )->setCorreiosCentralized( $data['agency_correios_centralized'] );
}

if ( ! empty( $data['agency_jadlog_centralized'] ) ) {
( new AgenciesSelectedService() )->setJadlogCentralized( $data['agency_jadlog_centralized'] );
}
Expand Down Expand Up @@ -140,8 +136,6 @@ public function getConfigurations() {

$agenciesCentralizedsJadlog = array();

$agenciesCentralizedsCorreios = array();

$agenciesLoggi = array();

$agenciesSelecteds = array();
Expand All @@ -158,10 +152,6 @@ public function getConfigurations() {
$address['company'] = ShippingCompany::JADLOG;
$agenciesCentralizedsJadlog = ( new AgenciesService($address))->get();

$address['serviceId'] = ShippingService::CORREIOS_SEDEX_CENTRALIZED;
$address['company'] = ShippingCompany::CORREIOS;
$agenciesCentralizedsCorreios = ( new AgenciesService($address))->get();

$address['serviceId'] = ShippingService::LOGGI_EXPRESS;
$address['company'] = ShippingCompany::LOGGI;
$agenciesLoggi = ( new AgenciesService($address))->get();
Expand All @@ -170,7 +160,6 @@ public function getConfigurations() {
$agenciesSelectedService = new AgenciesSelectedService();

$agenciesSelecteds = $agenciesSelectedService->get();
$agencyCorreiosCentralizedSelected = $agenciesSelectedService->getCorreiosCentralized();
$agencyJadlogCentralizedSelected = $agenciesSelectedService->getJadlogCentralized();
$agencyLoggiSelected = $agenciesSelectedService->getLoggi();

Expand All @@ -182,7 +171,6 @@ public function getConfigurations() {
ShippingCompany::JADLOG
),
'agenciesJadlogCentralized' => $agenciesCentralizedsJadlog,
'agenciesCorreiosCentralized' => $agenciesCentralizedsCorreios,
'agenciesLoggi' => $agenciesLoggi,
'agenciesAzul' => $this->filterAgenciesByCompany(
$agencies,
Expand All @@ -205,7 +193,6 @@ public function getConfigurations() {
ShippingCompany::JADLOG
),
'agencyJadlogCentralizedSelected' => $agencyJadlogCentralizedSelected,
'agencyCorreiosCentralizedSelected' => $agencyCorreiosCentralizedSelected,
'agencyLoggiSelected' => $agencyLoggiSelected,
'agencyLatamSelected' => $this->filterAgencySelectedByCompany(
$agenciesSelecteds,
Expand Down
36 changes: 0 additions & 36 deletions assets/src/admin/components/Configuracoes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,39 +299,6 @@
</div>
<hr />

<div class="wpme_config" v-show="agenciesCorreiosCentralized.length > 0">
<h2>Correios Centralizado</h2>
<p>
Escolha a agência correios centralizado de sua preferência para realizar o envio dos
seus produtos.
</p>
<div class="wpme_flex">
<ul class="wpme_address">
<li>
<template>
<select
name="agency_correios_centralized"
id="agency_correios_centralized"
v-model="agency_correios_centralized"
data-cy="input-agency-correios-centralized"
>
<option value>Selecione...</option>
<option
v-for="option in agenciesCorreiosCentralized"
:value="option.id"
:key="option.id"
:selected="option.selected"
>
<strong>{{ option.name }}</strong>
</option>
</select>
</template>
</li>
</ul>
</div>
</div>
<hr />

<div class="wpme_config" v-show="agenciesJadlogCentralized.length > 0">
<h2>Jadlog Centralizado</h2>
<p>
Expand Down Expand Up @@ -755,7 +722,6 @@ export default {
canUpdate: true,
origin: null,
agency: null,
agency_correios_centralized: null,
agency_jadlog_centralized: null,
agency_loggi: null,
agency_azul: null,
Expand All @@ -766,7 +732,6 @@ export default {
show_calculator: false,
show_all_agencies_jadlog: false,
show_all_agencies_azul: false,
show_all_agencies_correios_centralized: false,
show_all_agencies_jadlog_centralized: false,
show_all_agencies_loggi: false,
options_calculator: {
Expand Down Expand Up @@ -799,7 +764,6 @@ export default {
label: "getLabel",
dimension: "getDimension",
agencySelected_: "getAgencySelected",
agencyCorreiosCentralizedSelected_: "getAgencyCorreiosCentralizedSelected",
agencyJadlogCentralizedSelected_: "getAgencyJadlogCentralizedSelected",
agencyLoggiSelected_: "getAgencyLoggiSelected",
agencyAzulSelected_: "getAgencyAzulSelected",
Expand Down
8 changes: 1 addition & 7 deletions assets/src/admin/components/Pedido/Documentos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
<template
v-if="
item.quotation.choose_method == services.CORREIOS_PAC ||
item.quotation.choose_method == services.CORREIOS_PAC_CENTRALIZED ||
item.quotation.choose_method == services.CORREIOS_SEDEX ||
item.quotation.choose_method == services.CORREIOS_SEDEX_CENTRALIZED ||
item.quotation.choose_method == services.CORREIOS_MINI ||
item.quotation.choose_method == services.CORREIOS_MINI_CENTRALIZED ||
item.quotation.choose_method == services.JADLOG_PACKAGE ||
item.quotation.choose_method == services.JADLOG_PACKAGE_CENTRALIZED ||
item.quotation.choose_method == services.JADLOG_COM ||
Expand All @@ -31,11 +28,8 @@
<template
v-if="
((item.quotation.choose_method == services.CORREIOS_PAC ||
item.quotation.choose_method == services.CORREIOS_PAC_CENTRALIZED ||
item.quotation.choose_method == services.CORREIOS_SEDEX ||
item.quotation.choose_method == services.CORREIOS_SEDEX_CENTRALIZED ||
item.quotation.choose_method == services.CORREIOS_MINI ||
item.quotation.choose_method == services.CORREIOS_MINI_CENTRALIZED ||
item.quotation.choose_method == services.JADLOG_PACKAGE ||
item.quotation.choose_method == services.JADLOG_PACKAGE_CENTRALIZED ||
item.quotation.choose_method == services.JADLOG_COM ||
Expand Down Expand Up @@ -112,4 +106,4 @@ export default {
...mapActions("orders", ["insertInvoice"]),
},
};
</script>
</script>
Loading

0 comments on commit 2cc88a9

Please sign in to comment.