/** * Display the simulator. * * @return string Simulator HTML. */ public static function simulator() { global $product; if (!is_product() || !self::$activated) { return; } if ($product->needs_shipping() && $product->is_in_stock() && in_array($product->product_type, array('simple', 'variable'))) { $options = get_option('woocommerce_correios_settings'); if ('variable' == $product->product_type) { $style = 'display: none'; $ids = array(); foreach ($product->get_available_variations() as $variation) { $_variation = get_product($variation['variation_id']); $ids[] = $_variation->needs_shipping() ? $_variation->variation_id : ''; } $ids = implode(',', array_filter($ids)); } else { $style = ''; $ids = $product->id; } if (isset($options['display_date']) && 'yes' == $options['display_date']) { $title = __('Shipping and delivery time', 'woocommerce-correios'); $description = __('Calculate the shipping and delivery time estimated to your region.', 'woocommerce-correios'); } else { $title = __('Shipping', 'woocommerce-correios'); $description = __('Calculate shipping estimated to your region.', 'woocommerce-correios'); } woocommerce_get_template('single-product/correios-simulator.php', array('product' => $product, 'style' => $style, 'ids' => $ids, 'title' => $title, 'description' => $description), '', WC_Correios::get_templates_path()); } }
/** * Return an instance of this class. * * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Initialize tracking template. */ public function __construct() { $this->id = 'correios_tracking'; $this->title = __('Correios Tracking Code', 'woocommerce-correios'); $this->enabled = 'yes'; $this->description = __('This email is sent when configured a tracking code within an order.', 'woocommerce-correios'); $this->heading = __('Your order has been sent', 'woocommerce-correios'); $this->subject = __('[{blogname}] Your order {order_number} has been sent by Correios', 'woocommerce-correios'); $this->message = __('Hi there. Your recent order on {blogname} has been sent by Correios.', 'woocommerce-correios') . PHP_EOL . PHP_EOL . __('To track your delivery, use the following the tracking code: {tracking_code}.', 'woocommerce-correios') . PHP_EOL . PHP_EOL . __('The delivery service is the responsibility of the Correios, but if you have any questions, please contact us.', 'woocommerce-correios'); $this->tracking_message = $this->get_option('tracking_message', $this->message); $this->template_html = 'emails/correios-tracking-code.php'; $this->template_plain = 'emails/plain/correios-tracking-code.php'; // Call parent constructor. parent::__construct(); $this->template_base = WC_Correios::get_templates_path(); }
/** * Initialize the Correios shipping method. * * @return void */ public function __construct() { $this->id = 'correios'; $this->method_title = __('Correios', 'woocommerce-correios'); $this->method_description = __('Correios is a brazilian delivery method.', 'woocommerce-correios'); // Load the form fields. $this->init_form_fields(); // Load the settings. $this->init_settings(); // Define user set variables. $this->enabled = $this->get_option('enabled'); $this->title = $this->get_option('title'); $this->declare_value = $this->get_option('declare_value'); $this->display_date = $this->get_option('display_date'); $this->additional_time = $this->get_option('additional_time'); $this->fee = $this->get_option('fee'); $this->zip_origin = $this->get_option('zip_origin'); $this->simulator = $this->get_option('simulator', 'no'); $this->tracking_history = $this->get_option('tracking_history', 'no'); $this->corporate_service = $this->get_option('corporate_service'); $this->login = $this->get_option('login'); $this->password = $this->get_option('password'); $this->service_pac = $this->get_option('service_pac'); $this->service_sedex = $this->get_option('service_sedex'); $this->service_sedex_10 = $this->get_option('service_sedex_10'); $this->service_sedex_hoje = $this->get_option('service_sedex_hoje'); $this->service_esedex = $this->get_option('service_esedex'); $this->minimum_height = $this->get_option('minimum_height'); $this->minimum_width = $this->get_option('minimum_width'); $this->minimum_length = $this->get_option('minimum_length'); $this->debug = $this->get_option('debug'); // Method variables. $this->availability = 'specific'; $this->countries = array('BR'); // Actions. add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options')); // Active logs. if ('yes' == $this->debug) { $this->log = WC_Correios::logger(); } }
/** * Correios options page. */ public function admin_options() { include WC_Correios::get_plugin_path() . 'includes/admin/views/html-admin-shipping-method-settings.php'; }
/** * Initialize the Connect class. * * @param string $debug Debug mode. */ public function __construct() { $this->id = 'correios'; $this->log = WC_Correios::logger(); }
<?php /** * Shipping methods admin settings. * * @package WooCommerce_Correios/Admin/Settings */ if (!defined('ABSPATH')) { exit; } $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script('wc-correios', plugins_url('assets/js/admin/integration' . $suffix . '.js', WC_Correios::get_main_file()), array('jquery'), WC_Correios::VERSION, true); ?> <h3><?php echo esc_html($this->method_title); ?> </h3> <p><?php echo esc_html($this->method_description); ?> </p> <?php include 'html-admin-help-message.php'; ?> <table class="form-table"> <?php $this->generate_settings_html();
/** * Display the order tracking code in order details and the tracking history. * * @param WC_Order $order_id Order data. */ public function view($order) { $events = false; $tracking_code = get_post_meta($order->id, 'correios_tracking', true); // Check if exist a tracking code for the order. if (!$tracking_code) { return; } // Get the shipping method options. $options = $this->get_method_options(); // Try to connect to Correios Webservices and get the tracking history. if (!empty($options['tracking_history']) && 'yes' == $options['tracking_history']) { $tracking = $this->get_tracking_history($tracking_code); $events = isset($tracking->objeto->evento) ? $tracking->objeto->evento : false; } // Display the right template for show the tracking code or tracking history. if ($events) { woocommerce_get_template('myaccount/tracking-history-table.php', array('events' => $events, 'code' => $tracking_code), '', WC_Correios::get_templates_path()); } else { woocommerce_get_template('myaccount/tracking-code.php', array('code' => $tracking_code), '', WC_Correios::get_templates_path()); } }