Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimativa de Entrega nos Métodos Carta e Impresso #70

Merged
merged 3 commits into from Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 36 additions & 8 deletions includes/abstracts/abstract-wc-correios-shipping-carta.php
Expand Up @@ -33,13 +33,15 @@ public function __construct( $instance_id = 0 ) {
$this->init_form_fields();

// Define user set variables.
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->shipping_class = $this->get_option( 'shipping_class' );
$this->fee = $this->get_option( 'fee' );
$this->receipt_notice = $this->get_option( 'receipt_notice' );
$this->own_hands = $this->get_option( 'own_hands' );
$this->debug = $this->get_option( 'debug' );
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->shipping_class = $this->get_option( 'shipping_class' );
$this->show_delivery_time = $this->get_option( 'show_delivery_time' );
$this->additional_time = $this->get_option( 'additional_time' );
$this->fee = $this->get_option( 'fee' );
$this->receipt_notice = $this->get_option( 'receipt_notice' );
$this->own_hands = $this->get_option( 'own_hands' );
$this->debug = $this->get_option( 'debug' );

// Active logs.
if ( 'yes' === $this->debug ) {
Expand Down Expand Up @@ -100,6 +102,22 @@ public function init_form_fields() {
'class' => 'wc-enhanced-select',
'options' => $this->get_shipping_classes_options(),
),
'show_delivery_time' => array(
'title' => __( 'Delivery Time', 'woocommerce-correios' ),
'type' => 'checkbox',
'label' => __( 'Show estimated delivery time', 'woocommerce-correios' ),
'description' => __( 'Display the estimated delivery time in working days.', 'woocommerce-correios' ),
'desc_tip' => true,
'default' => 'no',
),
'additional_time' => array(
'title' => __( 'Delivery Days', 'woocommerce-correios' ),
'type' => 'text',
'description' => __( 'Working days to the estimated delivery.', 'woocommerce-correios' ),
'desc_tip' => true,
'default' => '0',
'placeholder' => '0',
),
'fee' => array(
'title' => __( 'Handling Fee', 'woocommerce-correios' ),
'type' => 'price',
Expand Down Expand Up @@ -164,6 +182,16 @@ protected function get_shipping_cost( $package ) {
return 0;
}

/**
* Get shpping time.
*
* @param array $package Shipping package.
* @return int
*/
protected function get_shipping_time( $package ) {
return 0;
}

/**
* Get package weight.
*
Expand Down Expand Up @@ -226,7 +254,7 @@ public function calculate_shipping( $package = array() ) {
// Create the rate and apply filters.
$rate = apply_filters( 'woocommerce_correios_' . $this->id . '_rate', array(
'id' => $this->id . $this->instance_id,
'label' => $this->title,
'label' => $this->get_shipping_method_label( (int) $this->get_shipping_time( $package ), $package ),
'cost' => $cost + $fee,
), $this->instance_id, $package );

Expand Down
34 changes: 26 additions & 8 deletions includes/abstracts/abstract-wc-correios-shipping-impresso.php
Expand Up @@ -85,14 +85,16 @@ public function __construct( $instance_id = 0 ) {
$this->init_form_fields();

// Define user set variables.
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->shipping_class = $this->get_option( 'shipping_class' );
$this->registry_type = $this->get_option( 'registry_type' );
$this->fee = $this->get_option( 'fee' );
$this->receipt_notice = $this->get_option( 'receipt_notice' );
$this->own_hands = $this->get_option( 'own_hands' );
$this->debug = $this->get_option( 'debug' );
$this->enabled = $this->get_option( 'enabled' );
$this->title = $this->get_option( 'title' );
$this->shipping_class = $this->get_option( 'shipping_class' );
$this->registry_type = $this->get_option( 'registry_type' );
$this->show_delivery_time = $this->get_option( 'show_delivery_time' );
$this->additional_time = $this->get_option( 'additional_time' );
$this->fee = $this->get_option( 'fee' );
$this->receipt_notice = $this->get_option( 'receipt_notice' );
$this->own_hands = $this->get_option( 'own_hands' );
$this->debug = $this->get_option( 'debug' );

// Active logs.
if ( 'yes' === $this->debug ) {
Expand Down Expand Up @@ -149,6 +151,22 @@ public function init_form_fields() {
),
'default' => 'RM',
),
'show_delivery_time' => array(
'title' => __( 'Delivery Time', 'woocommerce-correios' ),
'type' => 'checkbox',
'label' => __( 'Show estimated delivery time', 'woocommerce-correios' ),
'description' => __( 'Display the estimated delivery time in working days.', 'woocommerce-correios' ),
'desc_tip' => true,
'default' => 'no',
),
'additional_time' => array(
'title' => __( 'Delivery Days', 'woocommerce-correios' ),
'type' => 'text',
'description' => __( 'Working days to the estimated delivery.', 'woocommerce-correios' ),
'desc_tip' => true,
'default' => '0',
'placeholder' => '0',
),
'fee' => array(
'title' => __( 'Handling Fee', 'woocommerce-correios' ),
'type' => 'price',
Expand Down
10 changes: 10 additions & 0 deletions languages/woocommerce-correios.pot
Expand Up @@ -262,6 +262,16 @@ msgstr ""
msgid "Additional working days to the estimated delivery."
msgstr ""

#: includes/abstracts/abstract-wc-correios-shipping-carta.php:114
#: includes/abstracts/abstract-wc-correios-shipping-impresso.php:163
msgid "Delivery Days"
msgstr ""

#: includes/abstracts/abstract-wc-correios-shipping-carta.php:116
#: includes/abstracts/abstract-wc-correios-shipping-impresso.php:165
msgid "Working days to the estimated delivery."
msgstr ""

#: includes/abstracts/abstract-wc-correios-shipping.php:162
msgid "Declare Value for Insurance"
msgstr ""
Expand Down