Skip to content

Commit

Permalink
Created new abstract method for international shipping
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Dec 6, 2015
1 parent e633ada commit 6cdae0e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 7 deletions.
49 changes: 49 additions & 0 deletions includes/abstracts/abstract-wc-correios-international-shipping.php
@@ -0,0 +1,49 @@
<?php
/**
* Abstract Correios international shipping method.
*
* @package WooCommerce_Correios/Abstracts
* @since 3.0.0
* @version 3.0.0
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Default Correios international shipping method abstract class.
*
* This is a abstract method with default options for all methods.
*/
abstract class WC_Correios_International_Shipping extends WC_Correios_Shipping {

/**
* Get shipping method title.
*
* @return string
*/
public function get_method_title() {
return sprintf( __( '%s is a international shipping method from Correios, the brazilian most used delivery company.', 'woocommerce-correios' ), $this->method_title );
}

/**
* Get shipping rate.
*
* @param array $package Order package.
*
* @return SimpleXMLElement
*/
protected function get_rate( $package ) {

}

/**
* Calculates the shipping rate.
*
* @param array $package Order package.
*/
public function calculate_shipping( $package = array() ) {

}
}
9 changes: 9 additions & 0 deletions includes/abstracts/abstract-wc-correios-shipping.php
Expand Up @@ -119,6 +119,15 @@ public function init_form_fields() {
);
}

/**
* Get shipping method title.
*
* @return string
*/
public function get_method_title() {
return sprintf( __( '%s is a shipping method from Correios, the brazilian most used delivery company.', 'woocommerce-correios' ), $this->method_title );
}

/**
* Correios options page.
*/
Expand Down
Expand Up @@ -17,7 +17,7 @@
<h3><?php echo esc_html( $this->method_title ); ?></h3>

<p>
<?php echo esc_html( sprintf( __( '%s is a shipping method from Correios, the brazilian most used delivery company.', 'woocommerce-correios' ), $this->method_title ) ); ?>
<?php echo esc_html( $this->get_method_title() ); ?>

<?php if ( ! empty( $this->more_link ) ) : ?>
<a href="<?php echo esc_url( $this->more_link ); ?>"><?php echo esc_html( sprintf( __( 'More about %s.', 'woocommerce-correios' ), $this->method_title ) ); ?></a>
Expand Down
Expand Up @@ -14,13 +14,13 @@
/**
* Leve Internacional shipping method class.
*/
class WC_Correios_Shipping_Leve_Internacional extends WC_Correios_Shipping {
class WC_Correios_Shipping_Leve_Internacional extends WC_Correios_International_Shipping {

/**
* Initialize Leve Internacional.
*/
public function __construct() {
$this->id = 'correios_esedex';
$this->id = 'correios_leve_internacional';
$this->method_title = __( 'Leve Internacional', 'woocommerce-correios' );
$this->more_link = '';

Expand Down
Expand Up @@ -14,13 +14,13 @@
/**
* Mercadoria Econômica shipping method class.
*/
class WC_Correios_Shipping_Mercadoria_Economica extends WC_Correios_Shipping {
class WC_Correios_Shipping_Mercadoria_Economica extends WC_Correios_International_Shipping {

/**
* Initialize Mercadoria Econômica.
*/
public function __construct() {
$this->id = 'correios_esedex';
$this->id = 'correios_mercadoria_economica';
$this->method_title = __( 'Mercadoria Econ&ocirc;mica', 'woocommerce-correios' );
$this->more_link = '';

Expand Down
Expand Up @@ -14,13 +14,13 @@
/**
* Mercadoria Expressa shipping method class.
*/
class WC_Correios_Shipping_Mercadoria_Expressa extends WC_Correios_Shipping {
class WC_Correios_Shipping_Mercadoria_Expressa extends WC_Correios_International_Shipping {

/**
* Initialize Mercadoria Expressa.
*/
public function __construct() {
$this->id = 'correios_esedex';
$this->id = 'correios_mercadoria_expressa';
$this->method_title = __( 'Mercadoria Expressa', 'woocommerce-correios' );
$this->more_link = '';

Expand Down
1 change: 1 addition & 0 deletions woocommerce-correios.php
Expand Up @@ -103,6 +103,7 @@ private function includes() {

// Shipping methods.
include_once 'includes/abstracts/abstract-wc-correios-shipping.php';
include_once 'includes/abstracts/abstract-wc-correios-international-shipping.php';
foreach ( glob( plugin_dir_path( __FILE__ ) . 'includes/shipping/*.php' ) as $filename ) {
include_once $filename;
}
Expand Down

0 comments on commit 6cdae0e

Please sign in to comment.