diff --git a/classes/Admin/Settings.php b/classes/Admin/Settings.php index 353c214..b679ef8 100644 --- a/classes/Admin/Settings.php +++ b/classes/Admin/Settings.php @@ -14,6 +14,9 @@ public function __start () { // plugin action links add_filter( 'plugin_action_links_' . plugin_basename( h::config_get( 'FILE' ) ), [ $this, 'add_plugin_action_links' ] ); + + // Maybe enable integration: Autofill Addresses + add_filter( 'wc_shipping_simulator_integration_autofill_br_addresses_enabled', [ $this, 'enable_autofill_addresses' ] ); } public static function get_option ( $key ) { @@ -77,4 +80,9 @@ public function add_plugin_action_links ( $actions ) { $actions ); } + + public function enable_autofill_addresses ( $value ) { + $value = 'yes' === self::get_option( 'autofill_addresses' ); + return $value; + } } diff --git a/classes/Admin/inc/settings_fields.php b/classes/Admin/inc/settings_fields.php index 23bee0f..4ef4f08 100644 --- a/classes/Admin/inc/settings_fields.php +++ b/classes/Admin/inc/settings_fields.php @@ -33,6 +33,14 @@ 'desc_tip' => esc_html__( 'Disable this option to allow customers simulate shipping rates even when a variation is not selected on variable products. However, always make sure that the variable product has a defined weight.', 'wc-shipping-simulator' ), 'default' => 'yes' ], + [ + 'id' => $prefix . 'autofill_addresses', + 'type' => 'checkbox', + 'name' => esc_html__( 'Display full address', 'wc-shipping-simulator' ), + 'desc' => esc_html__( 'Enable', 'wc-shipping-simulator' ), + 'desc_tip' => esc_html__( 'When this option is activated, the street, neighborhood and city will be displayed in the shipping simulator.', 'wc-shipping-simulator' ), + 'default' => 'yes' + ], [ 'id' => $prefix . 'update_address', 'type' => 'radio', diff --git a/classes/Helpers.php b/classes/Helpers.php index 562ef8e..a3f57cf 100644 --- a/classes/Helpers.php +++ b/classes/Helpers.php @@ -35,7 +35,12 @@ public static function user_is_admin ( $user_id = null ) { } public static function sanitize_postcode ( $postcode ) { - return preg_replace( '/[^0-9]/', '', $postcode ); + $sanitized = preg_replace( '/[^0-9]/', '', $postcode ); + return (string) apply_filters( + 'wc_shipping_simulator_sanitize_postcode', + $sanitized, + $postcode + ); } public static function product_needs_shipping ( $product ) { @@ -63,8 +68,8 @@ public static function product_needs_shipping ( $product ) { ); } - public static function logger ( $args = [] ) { - return \apply_filters( h::prefix( 'get_logger' ), null, $args ); + public static function logger () { + return \apply_filters( h::prefix( 'get_logger' ), null ); } public static function get_estimating_delivery ( $days ) { @@ -76,6 +81,6 @@ public static function get_estimating_delivery ( $days ) { $result = sprintf( _n( 'Delivery within %d working day', 'Delivery within %d working days', $days, 'wc-shipping-simulator' ), $days ); } //woocommerce-correios - return apply_filters( 'woocommerce_correios_get_estimating_delivery', $result, $days ); + return apply_filters( 'wc_shipping_simulator_get_estimating_delivery', $result, $days ); } } diff --git a/classes/Integration/Autofill_Brazilian_Addresses.php b/classes/Integration/Autofill_Brazilian_Addresses.php new file mode 100644 index 0000000..256481d --- /dev/null +++ b/classes/Integration/Autofill_Brazilian_Addresses.php @@ -0,0 +1,147 @@ +is_enabled() ) { + add_filter( 'wc_shipping_simulator_package_data', [ $this, 'fill_package_destination' ] ); + add_filter( 'wc_shipping_simulator_results_title_address', [ $this, 'results_title_address' ], 20, 2 ); + } + } + + public function fill_package_destination ( $package ) { + $dest = $package['destination']; + + if ( 'BR' !== h::get( $dest['country'] ) ) return $package; + + $postcode = h::get( $dest['postcode'] ); + $address = $this->get_address( $postcode ); + + if ( $address ) { + h::log( $package['destination'] ); + $package['destination'] = [ + 'postcode' => $address['postcode'], + 'address' => implode( + ', ', + array_filter( [ + $address['address_1'], + $address['address_2'], + $address['neighborhood'], + ] ) + ), + 'address_1' => $address['address_1'], + 'address_2' => $address['address_2'], + 'city' => $address['city'], + 'state' => $address['state'], + 'country' => 'BR', + ]; + h::log( $package['destination'] ); + } + + return $package; + } + + public function results_title_address ( $address_string, $data ) { + $postcode = h::get( $data['postcode'] ); + $address = $this->get_address( $postcode ); + if ( $address ) { + $parts = [ + $address['address_1'], + $address['address_2'], + $address['city'], + $address['state'] + ]; + $address_string = '' . apply_filters( + 'wc_shipping_simulator_integration_correios_results_address', + implode( ', ', array_filter( $parts ) ), + $address + ) . ''; + } + return $address_string; + } + + /** + * @param string $postcode + * @return array|false + */ + private function get_address ( $postcode ) { + $address = $this->address_cache; + $postcode = h::sanitize_postcode( $postcode ); + + if ( ! $postcode ) return false; + if ( $address && $postcode === $address['postcode'] ) return $address; + + $url = 'https://opencep.com/v1/' . $postcode; + $response = wp_remote_get( $url ); + + h::logger()->info( "Requesting address to {$url}" ); + + if ( is_wp_error( $response ) ) { + h::logger()->error( "Request failed: " . $response->get_error_message() ); + return false; + } + + $status = (int) $response['response']['code']; + $body = (string) $response['body']; + + h::logger()->info( "Response status code: {$status}" ); + h::logger()->info( "Response body: {$body}" ); + + if ( 200 === $status ) { + $address = json_decode( $body, true ); + if ( is_array( $address ) ) { + $address = $this->format_address( $address ); + $this->address_cache = $address; + return $address; + } + } + + return false; + } + + /** + * @param array $address + * @return array + */ + private function format_address ( $address ) { + return [ + 'postcode' => h::sanitize_postcode( h::get( $address['cep'], '' ) ), + 'address_1' => h::get( $address['logradouro'], '' ), + 'address_2' => str_replace( [ '(', ')' ], '', h::get( $address['complemento'], '' ) ), + 'neighborhood' => h::get( $address['bairro'], '' ), + 'city' => h::get( $address['localidade'], '' ), + 'state' => h::get( $address['uf'], '' ), + 'country' => 'BR' + ]; + } +} diff --git a/classes/Integration/Brazil.php b/classes/Integration/Brazil.php index 157f3b8..a367caf 100644 --- a/classes/Integration/Brazil.php +++ b/classes/Integration/Brazil.php @@ -41,6 +41,8 @@ public function add_hooks () { add_filter( 'wc_shipping_simulator_wrapper_css_class', [ $this, 'wrapper_css_class' ] ); add_filter( 'wc_shipping_simulator_form_input_type', [ $this, 'form_input_type' ] ); + + add_filter( 'wc_shipping_simulator_results_title_address', [ $this, 'results_title_address' ], 10, 2 ); } } @@ -98,10 +100,30 @@ public function add_cep_finder_link () { get_state_by_postcode( $postcode ); + if ( $state ) { + $address_string = '' . $this->format_cep( $postcode ) . ', ' . $state . ', Brasil'; + } + } + + return $address_string; + } + protected function is_cep ( $postcode ) { return h::str_length( $postcode ) === 8; } + protected function format_cep ( $postcode ) { + $postcode = h::sanitize_postcode( $postcode ); + $mask = $this->form_input_mask( null ); + return $mask ? h::str_mask( $postcode, $mask ) : $postcode; + } + protected function get_state_by_postcode ( $postcode ) { $result = null; @@ -128,4 +150,5 @@ protected function get_states_postcode_range () { return $this->state_list; } + } diff --git a/classes/Integration/Correios.php b/classes/Integration/Correios.php deleted file mode 100644 index ad96bd2..0000000 --- a/classes/Integration/Correios.php +++ /dev/null @@ -1,95 +0,0 @@ -is_enabled() ) { - add_filter( 'wc_shipping_simulator_package_data', [ $this, 'fill_package_destination' ] ); - add_filter( 'wc_shipping_simulator_results_title_address', [ $this, 'results_title_address' ], 10, 2 ); - } - } - - public function fill_package_destination ( $package ) { - $dest = $package['destination']; - if ( 'BR' === h::get( $dest['country'] ) ) { - $postcode = h::get( $dest['postcode'] ); - $address = $this->get_address( $postcode ); - if ( null !== $address ) { - $dest = [ - 'postcode' => $postcode, - 'country' => 'BR', - 'state' => $address->state, - 'city' => $address->city, - 'address' => implode( - ', ', - array_filter( [ - h::get( $address->address ), - h::get( $address->neighborhood ), - ] ) - ), - 'address_1' => h::get( $address->address, '' ), - 'address_2' => '', - ]; - $package['destination'] = $dest; - } - } - return $package; - } - - public function results_title_address ( $address_string, $data ) { - $postcode = h::get( $data['postcode'] ); - $address = $this->get_address( $postcode ); - if ( null !== $address ) { - $parts = [ - h::get( $address->address ), - h::get( $address->city ), - h::get( $address->state ) - ]; - $address_string = '' . apply_filters( - 'wc_shipping_simulator_integration_correios_results_address', - implode( ', ', array_filter( $parts ) ), - $address - ) . ''; - } - return $address_string; - } - - public function get_address ( $postcode ) { - $address = null; - if ( $this->address_cache && $postcode === $this->address_cache->postcode ) { - $address = $this->address_cache; - } else { - $address = $postcode ? WC_Correios_Autofill_Addresses::get_address( $postcode ) : null; - if ( h::filled( $address ) ) { - $address->postcode = $postcode; - $this->address_cache = $address; // cache - } - } - return $address; - } -} diff --git a/classes/Logger.php b/classes/Logger.php index 649b48b..f1832c1 100644 --- a/classes/Logger.php +++ b/classes/Logger.php @@ -10,7 +10,7 @@ public function __start () { add_filter( h::prefix( 'get_logger' ), [ $this, 'get_logger' ] ); } - public function get_logger ( $logger = null, $args = null ) { + public function get_logger () { return $this; } diff --git a/classes/Tweaks.php b/classes/Tweaks.php index aa98fe1..b15fa47 100644 --- a/classes/Tweaks.php +++ b/classes/Tweaks.php @@ -76,7 +76,7 @@ public function results_after () { public function update_customer_address ( $rates, $package ) { $opt_update_address = (int) Settings::get_option( 'update_address' ); - $dest = $package['destination']; + $dest = $package['destination'] ?? []; $enabled = apply_filters( 'wc_shipping_simulator_update_shipping_address', // option enabled AND has shipping options AND has country @@ -94,6 +94,9 @@ public function update_customer_address ( $rates, $package ) { h::get( $dest['postcode'] ), h::get( $dest['city'] ) ); + $customer->set_shipping_address_1( $dest['address_1'] ?? '' ); + $customer->set_shipping_address_2( $dest['address_1'] ?? '' ); + h::logger()->info( 'Customer shipping address updated to ' . wp_json_encode( $dest ) ); $should_update_billing_address = apply_filters( @@ -109,6 +112,9 @@ public function update_customer_address ( $rates, $package ) { h::get( $dest['postcode'] ), h::get( $dest['city'] ) ); + $customer->set_billing_address_1( $dest['address_1'] ?? '' ); + $customer->set_billing_address_2( $dest['address_2'] ?? '' ); + h::logger()->info( 'Customer billing address updated to ' . wp_json_encode( $dest ) ); } diff --git a/composer.lock b/composer.lock index aaaee8f..c586678 100644 --- a/composer.lock +++ b/composer.lock @@ -9,16 +9,16 @@ "packages-dev": [ { "name": "php-stubs/woocommerce-stubs", - "version": "v7.7.0", + "version": "v7.9.0", "source": { "type": "git", "url": "https://github.com/php-stubs/woocommerce-stubs.git", - "reference": "2fec812b7bb3458a232f4637bf83e4037106537d" + "reference": "3a2f522e29451490c357af550227795d2b0fc55a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/2fec812b7bb3458a232f4637bf83e4037106537d", - "reference": "2fec812b7bb3458a232f4637bf83e4037106537d", + "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/3a2f522e29451490c357af550227795d2b0fc55a", + "reference": "3a2f522e29451490c357af550227795d2b0fc55a", "shasum": "" }, "require": { @@ -47,27 +47,27 @@ ], "support": { "issues": "https://github.com/php-stubs/woocommerce-stubs/issues", - "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v7.7.0" + "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v7.9.0" }, - "time": "2023-05-10T05:40:44+00:00" + "time": "2023-07-17T22:41:38+00:00" }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.2.1", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "0009429e639b748eef1c955200ea0d4e5ad5627d" + "reference": "adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0009429e639b748eef1c955200ea0d4e5ad5627d", - "reference": "0009429e639b748eef1c955200ea0d4e5ad5627d", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c", + "reference": "adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c", "shasum": "" }, "require-dev": { - "nikic/php-parser": "< 4.12.0", - "php": "~7.3 || ~8.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ~8.0.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpstan": "^1.10.12", @@ -75,7 +75,6 @@ }, "suggest": { "paragonie/sodium_compat": "Pure PHP implementation of libsodium", - "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" }, "type": "library", @@ -92,22 +91,22 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.2.1" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.3.0" }, - "time": "2023-05-18T04:35:23+00:00" + "time": "2023-08-10T16:34:11+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.15", + "version": "1.10.35", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd" + "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/762c4dac4da6f8756eebb80e528c3a47855da9bd", - "reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3", + "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3", "shasum": "" }, "require": { @@ -156,20 +155,20 @@ "type": "tidelift" } ], - "time": "2023-05-09T15:28:01+00:00" + "time": "2023-09-19T15:27:56+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", "shasum": "" }, "require": { @@ -178,7 +177,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -219,7 +218,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" }, "funding": [ { @@ -235,7 +234,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "szepeviktor/phpstan-wordpress", diff --git a/languages/wc-shipping-simulator-pt_BR.mo b/languages/wc-shipping-simulator-pt_BR.mo index 30e71dd..e81a6fa 100644 Binary files a/languages/wc-shipping-simulator-pt_BR.mo and b/languages/wc-shipping-simulator-pt_BR.mo differ diff --git a/languages/wc-shipping-simulator-pt_BR.po b/languages/wc-shipping-simulator-pt_BR.po index 4a0a1dc..27f01de 100644 --- a/languages/wc-shipping-simulator-pt_BR.po +++ b/languages/wc-shipping-simulator-pt_BR.po @@ -5,8 +5,8 @@ msgstr "" "Project-Id-Version: Shipping Simulator for WooCommerce 1.0.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shipping-" "simulator-for-woocommerce\n" -"POT-Creation-Date: 2023-06-20T09:51:05-03:00\n" -"PO-Revision-Date: 2023-06-20 09:52-0300\n" +"POT-Creation-Date: 2023-09-19T16:16:41-03:00\n" +"PO-Revision-Date: 2023-09-19 16:17-0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: pt_BR\n" @@ -54,7 +54,8 @@ msgstr "Ativar inserção automática" #: classes/Admin/inc/settings_fields.php:20 #: classes/Admin/inc/settings_fields.php:32 -#: classes/Admin/inc/settings_fields.php:96 +#: classes/Admin/inc/settings_fields.php:40 +#: classes/Admin/inc/settings_fields.php:104 msgid "Enable" msgstr "Ativar" @@ -83,22 +84,34 @@ msgstr "" "Porém, tenha sempre certeza de que o produto variável tem um peso definido." #: classes/Admin/inc/settings_fields.php:39 +msgid "Display full address" +msgstr "Mostrar endereço completo" + +#: classes/Admin/inc/settings_fields.php:41 +msgid "" +"When this option is activated, the street, neighborhood and city will be " +"displayed in the shipping simulator." +msgstr "" +"Quando essa opção está ativada, a rua, bairro e cidade serão exibidos no " +"simulador de frete." + +#: classes/Admin/inc/settings_fields.php:47 msgid "Update customer address" msgstr "Atualizar endereço do cliente" -#: classes/Admin/inc/settings_fields.php:41 +#: classes/Admin/inc/settings_fields.php:49 msgid "Don't update" msgstr "Não atualizar" -#: classes/Admin/inc/settings_fields.php:42 +#: classes/Admin/inc/settings_fields.php:50 msgid "Update only shipping address" msgstr "Atualizar apenas o endereço de entrega" -#: classes/Admin/inc/settings_fields.php:43 +#: classes/Admin/inc/settings_fields.php:51 msgid "Update billing and shipping address" msgstr "Atualizar o endereço de cobrança e de entrega" -#: classes/Admin/inc/settings_fields.php:45 +#: classes/Admin/inc/settings_fields.php:53 msgid "" "The customer address can be updated when a shipping simulation returns " "shipping options." @@ -106,56 +119,56 @@ msgstr "" "O endereço do cliente pode ser atualizado quando uma simulação de frete " "retornar opções de entrega." -#: classes/Admin/inc/settings_fields.php:51 +#: classes/Admin/inc/settings_fields.php:59 msgid "Title" msgstr "Título" -#: classes/Admin/inc/settings_fields.php:52 +#: classes/Admin/inc/settings_fields.php:60 msgid "Text that appears before the simulator fields." msgstr "Texto que aparece antes dos campos do simulador." -#: classes/Admin/inc/settings_fields.php:53 +#: classes/Admin/inc/settings_fields.php:61 msgid "Check shipping cost and delivery time:" msgstr "Consulte o frete e o prazo de entrega:" -#: classes/Admin/inc/settings_fields.php:58 +#: classes/Admin/inc/settings_fields.php:66 msgid "Input placeholder" msgstr "Placeholder do campo" -#: classes/Admin/inc/settings_fields.php:59 +#: classes/Admin/inc/settings_fields.php:67 msgid "Text that appears when the postcode field is empty." msgstr "Texto que aparece quando o campo do código postal está vazio." -#: classes/Admin/inc/settings_fields.php:60 +#: classes/Admin/inc/settings_fields.php:68 msgid "Type your postcode" msgstr "Digite seu CEP" -#: classes/Admin/inc/settings_fields.php:65 +#: classes/Admin/inc/settings_fields.php:73 msgid "Button Text" msgstr "Texto do botão" -#: classes/Admin/inc/settings_fields.php:66 +#: classes/Admin/inc/settings_fields.php:74 msgid "Text that appears on the shipping simulator button." msgstr "Texto que aparece no botão do simulador de frete." -#: classes/Admin/inc/settings_fields.php:67 +#: classes/Admin/inc/settings_fields.php:75 msgid "Apply" msgstr "Consultar" -#: classes/Admin/inc/settings_fields.php:72 +#: classes/Admin/inc/settings_fields.php:80 msgid "Text after results." msgstr "Texto depois dos resultados." -#: classes/Admin/inc/settings_fields.php:73 +#: classes/Admin/inc/settings_fields.php:81 msgid "Delivery times start from the confirmation of payment." msgstr "" "Os prazos de entrega começam a contar a partir da confirmação do pagamento." -#: classes/Admin/inc/settings_fields.php:79 +#: classes/Admin/inc/settings_fields.php:87 msgid "Text when there are no results." msgstr "Texto quando não existir resultados." -#: classes/Admin/inc/settings_fields.php:80 +#: classes/Admin/inc/settings_fields.php:88 msgid "" "Unfortunately at this moment this product cannot be delivered to the " "specified region." @@ -163,15 +176,15 @@ msgstr "" "Infelizmente, neste momento, este produto não pode ser entregue na região " "informada." -#: classes/Admin/inc/settings_fields.php:90 +#: classes/Admin/inc/settings_fields.php:98 msgid "Debug" msgstr "Depuração" -#: classes/Admin/inc/settings_fields.php:95 +#: classes/Admin/inc/settings_fields.php:103 msgid "Debug mode" msgstr "Modo de depuração" -#: classes/Admin/inc/settings_fields.php:97 +#: classes/Admin/inc/settings_fields.php:105 msgid "" "Enable debug mode to log your shipping simulations and display helpful " "informations in product page." @@ -187,11 +200,11 @@ msgstr "Suporte da comunidade" msgid "Donate" msgstr "Faça uma doação" -#: classes/Admin/Settings.php:59 +#: classes/Admin/Settings.php:62 msgid "Shipping simulator" msgstr "Simulador de frete" -#: classes/Admin/Settings.php:75 +#: classes/Admin/Settings.php:78 msgid "Settings" msgstr "Configurações" @@ -240,7 +253,7 @@ msgid "This box not appears for your customers." msgstr "Essa caixa não aparece para seus clientes." #. translators: %d: days to delivery -#: classes/Helpers.php:76 +#: classes/Helpers.php:81 msgid "Delivery within %d working day" msgid_plural "Delivery within %d working days" msgstr[0] "Entrega em %d dia útil" @@ -277,16 +290,11 @@ msgstr "Este produto é virtual e não pode ser enviado." msgid "Please select some product options first." msgstr "Selecione uma das opções do produto primeiro." -#: classes/Shipping_Package.php:151 -msgid "" -"Please select some product options before adding this product to your cart." -msgstr "Selecione uma das opções do produto antes de adicioná-lo ao carrinho." - -#: classes/Shortcode.php:91 +#: classes/Shortcode.php:106 msgid "The server took too long to respond. Please try again." msgstr "O servidor demorou demais para responder. Tente novamente." -#: classes/Shortcode.php:92 +#: classes/Shortcode.php:107 msgid "An unexpected error occurred. Please refresh the page and try again." msgstr "Ocorreu um erro inesperado. Recarregue a página e tente novamente." @@ -333,7 +341,7 @@ msgstr "" msgid "Make a review" msgstr "Faça uma avaliação" -#: templates/shipping-simulator-form.php:17 +#: templates/shipping-simulator-form.php:15 msgid "Calculate shipping" msgstr "Calcular frete" @@ -341,6 +349,12 @@ msgstr "Calcular frete" msgid "Avaliable shipping options" msgstr "Opções de frete disponíveis" +#~ msgid "" +#~ "Please select some product options before adding this product to your " +#~ "cart." +#~ msgstr "" +#~ "Selecione uma das opções do produto antes de adicioná-lo ao carrinho." + #~ msgid "Missing dependencies for %s:" #~ msgstr "Está faltando algumas dependências do %s:" diff --git a/languages/wc-shipping-simulator.pot b/languages/wc-shipping-simulator.pot index 3a965b1..3b6a727 100644 --- a/languages/wc-shipping-simulator.pot +++ b/languages/wc-shipping-simulator.pot @@ -2,14 +2,14 @@ # This file is distributed under the GPLv3. msgid "" msgstr "" -"Project-Id-Version: Shipping Simulator for WooCommerce 2.2.2\n" +"Project-Id-Version: Shipping Simulator for WooCommerce 2.3.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shipping-simulator-for-woocommerce\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-08-14T10:23:45-03:00\n" +"POT-Creation-Date: 2023-09-19T16:16:41-03:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.6.0\n" "X-Domain: wc-shipping-simulator\n" @@ -48,7 +48,8 @@ msgstr "" #: classes/Admin/inc/settings_fields.php:20 #: classes/Admin/inc/settings_fields.php:32 -#: classes/Admin/inc/settings_fields.php:96 +#: classes/Admin/inc/settings_fields.php:40 +#: classes/Admin/inc/settings_fields.php:104 msgid "Enable" msgstr "" @@ -66,86 +67,94 @@ msgid "Disable this option to allow customers simulate shipping rates even when msgstr "" #: classes/Admin/inc/settings_fields.php:39 -msgid "Update customer address" +msgid "Display full address" msgstr "" #: classes/Admin/inc/settings_fields.php:41 +msgid "When this option is activated, the street, neighborhood and city will be displayed in the shipping simulator." +msgstr "" + +#: classes/Admin/inc/settings_fields.php:47 +msgid "Update customer address" +msgstr "" + +#: classes/Admin/inc/settings_fields.php:49 msgid "Don't update" msgstr "" -#: classes/Admin/inc/settings_fields.php:42 +#: classes/Admin/inc/settings_fields.php:50 msgid "Update only shipping address" msgstr "" -#: classes/Admin/inc/settings_fields.php:43 +#: classes/Admin/inc/settings_fields.php:51 msgid "Update billing and shipping address" msgstr "" -#: classes/Admin/inc/settings_fields.php:45 +#: classes/Admin/inc/settings_fields.php:53 msgid "The customer address can be updated when a shipping simulation returns shipping options." msgstr "" -#: classes/Admin/inc/settings_fields.php:51 +#: classes/Admin/inc/settings_fields.php:59 msgid "Title" msgstr "" -#: classes/Admin/inc/settings_fields.php:52 +#: classes/Admin/inc/settings_fields.php:60 msgid "Text that appears before the simulator fields." msgstr "" -#: classes/Admin/inc/settings_fields.php:53 +#: classes/Admin/inc/settings_fields.php:61 msgid "Check shipping cost and delivery time:" msgstr "" -#: classes/Admin/inc/settings_fields.php:58 +#: classes/Admin/inc/settings_fields.php:66 msgid "Input placeholder" msgstr "" -#: classes/Admin/inc/settings_fields.php:59 +#: classes/Admin/inc/settings_fields.php:67 msgid "Text that appears when the postcode field is empty." msgstr "" -#: classes/Admin/inc/settings_fields.php:60 +#: classes/Admin/inc/settings_fields.php:68 msgid "Type your postcode" msgstr "" -#: classes/Admin/inc/settings_fields.php:65 +#: classes/Admin/inc/settings_fields.php:73 msgid "Button Text" msgstr "" -#: classes/Admin/inc/settings_fields.php:66 +#: classes/Admin/inc/settings_fields.php:74 msgid "Text that appears on the shipping simulator button." msgstr "" -#: classes/Admin/inc/settings_fields.php:67 +#: classes/Admin/inc/settings_fields.php:75 msgid "Apply" msgstr "" -#: classes/Admin/inc/settings_fields.php:72 +#: classes/Admin/inc/settings_fields.php:80 msgid "Text after results." msgstr "" -#: classes/Admin/inc/settings_fields.php:73 +#: classes/Admin/inc/settings_fields.php:81 msgid "Delivery times start from the confirmation of payment." msgstr "" -#: classes/Admin/inc/settings_fields.php:79 +#: classes/Admin/inc/settings_fields.php:87 msgid "Text when there are no results." msgstr "" -#: classes/Admin/inc/settings_fields.php:80 +#: classes/Admin/inc/settings_fields.php:88 msgid "Unfortunately at this moment this product cannot be delivered to the specified region." msgstr "" -#: classes/Admin/inc/settings_fields.php:90 +#: classes/Admin/inc/settings_fields.php:98 msgid "Debug" msgstr "" -#: classes/Admin/inc/settings_fields.php:95 +#: classes/Admin/inc/settings_fields.php:103 msgid "Debug mode" msgstr "" -#: classes/Admin/inc/settings_fields.php:97 +#: classes/Admin/inc/settings_fields.php:105 msgid "Enable debug mode to log your shipping simulations and display helpful informations in product page." msgstr "" @@ -158,11 +167,11 @@ msgstr "" msgid "Donate" msgstr "" -#: classes/Admin/Settings.php:59 +#: classes/Admin/Settings.php:62 msgid "Shipping simulator" msgstr "" -#: classes/Admin/Settings.php:75 +#: classes/Admin/Settings.php:78 msgid "Settings" msgstr "" @@ -215,7 +224,7 @@ msgid "This box not appears for your customers." msgstr "" #. translators: %d: days to delivery -#: classes/Helpers.php:76 +#: classes/Helpers.php:81 msgid "Delivery within %d working day" msgid_plural "Delivery within %d working days" msgstr[0] "" diff --git a/loader.php b/loader.php index 2699616..439977b 100644 --- a/loader.php +++ b/loader.php @@ -9,7 +9,7 @@ Admin\Plugin_Meta::class, Admin\Notices::class, Integration\Brazil::instance(), - Integration\Correios::instance(), + Integration\Autofill_Brazilian_Addresses::instance(), Integration\Free_Shipping::instance(), Integration\Melhor_Envio::instance(), Integration\Estimating_Delivery::instance(), diff --git a/main.php b/main.php index 4a813bb..81ad509 100644 --- a/main.php +++ b/main.php @@ -3,7 +3,7 @@ Plugin Name: Shipping Simulator for WooCommerce Plugin URI: https://github.com/luizbills/shipping-simulator-for-woocommerce Description: Allows your customers to calculate the shipping rates on the product page -Version: 2.2.2 +Version: 2.3.0 Requires at least: 4.9 Requires PHP: 7.4 Author: Luiz Bills