Plugin Directory

Changeset 2825700


Ignore:
Timestamp:
11/29/2022 08:33:29 AM (3 years ago)
Author:
RistoNiinemets
Message:

Add version 1.6.1

Location:
estonian-shipping-methods-for-woocommerce
Files:
82 added
12 edited

Legend:

Unmodified
Added
Removed
  • estonian-shipping-methods-for-woocommerce/trunk/estonian-shipping-methods-for-woocommerce.php

    r2337311 r2825700  
    44 * Plugin URI: https://github.com/KonektOU/estonian-shipping-methods-for-woocommerce
    55 * Description: Extends WooCommerce with most commonly used Estonian shipping methods.
    6  * Version: 1.5.8.2
     6 * Version: 1.6.1
    77 * Author: Konekt OÜ
    88 * Author URI: https://www.konekt.ee
     
    1111 * Text Domain: wc-estonian-shipping-methods
    1212 * Domain Path: /languages
    13  * WC requires at least: 2.6
    14  * WC tested up to: 4.3
     13 * WC requires at least: 3.3
     14 * WC tested up to: 7.1
     15 *
     16 * @package Estonian_Shipping_Methods_For_WooCommerce
    1517 */
    1618
     
    3133
    3234/**
    33  * @class    Estonian_Shipping_Methods_For_WooCommerce
     35 * Main class.
     36 *
    3437 * @category Plugin
    3538 * @package  Estonian_Shipping_Methods_For_WooCommerce
     
    5962        'WC_Estonian_Shipping_Method_Omniva_Parcel_Machines_LT' => false,
    6063
    61         // Omniva Post Offices
     64        // Omniva Post Offices.
    6265        'WC_Estonian_Shipping_Method_Omniva_Post_Offices_EE' => false,
    6366
     
    8992        }
    9093
    91         // Load functionality, translations
     94        // Load functionality, translations.
    9295        $this->includes();
    9396        $this->load_translations();
    9497
    95         // Shipping
     98        // Shipping.
    9699        add_action( 'woocommerce_shipping_init', array( $this, 'shipping_init' ) );
    97100
    98         // Add shipping methods
     101        // Add shipping methods.
    99102        add_filter( 'woocommerce_shipping_methods', array( $this, 'register_shipping_methods' ) );
    100103
    101         // Allow WC template file search in this plugin
     104        // Allow WC template file search in this plugin.
    102105        add_filter( 'woocommerce_locate_template', array( $this, 'locate_template' ), 20, 3 );
    103106        add_filter( 'woocommerce_locate_core_template', array( $this, 'locate_template' ), 20, 3 );
    104107
    105         add_action( 'woocommerce_view_order', array( $this, 'load_shipping_method' ), 1, 1 );
    106         add_action( 'woocommerce_email', array( $this, 'load_shipping_method' ), 1, 1 );
     108        $this->add_terminals_hooks();
    107109    }
    108110
     
    113115     */
    114116    public function includes() {
    115         // Compatibility helpers
     117        // Compatibility helpers.
    116118        require_once WC_ESTONIAN_SHIPPING_METHODS_INCLUDES_PATH . '/compatibility-helpers.php';
    117119
    118         // Abstract classes
     120        // Abstract classes.
    119121        require_once WC_ESTONIAN_SHIPPING_METHODS_INCLUDES_PATH . '/abstracts/class-wc-estonian-shipping-method.php';
    120122        require_once WC_ESTONIAN_SHIPPING_METHODS_INCLUDES_PATH . '/abstracts/class-wc-estonian-shipping-method-terminals.php';
     
    123125        require_once WC_ESTONIAN_SHIPPING_METHODS_INCLUDES_PATH . '/abstracts/class-wc-estonian-shipping-method-dpd-shops.php';
    124126
    125         // Methods
     127        // Methods.
    126128        require_once WC_ESTONIAN_SHIPPING_METHODS_INCLUDES_PATH . '/methods/class-wc-estonian-shipping-method-smartpost-estonia.php';
    127129        require_once WC_ESTONIAN_SHIPPING_METHODS_INCLUDES_PATH . '/methods/class-wc-estonian-shipping-method-smartpost-finland.php';
     
    142144
    143145    /**
    144      * Force loading the shipping method on, for example, "view order" page,
    145      * otherwise selected terminal will not be shown
    146      *
    147      * @param  integer $order_id Order ID
    148      * @return void
    149      */
    150     public function load_shipping_method( $order_id ) {
    151         WC()->shipping();
     146     * Add hooks even when shipping might not be inited. Adds compatibility with lots of plugins.
     147     *
     148     * @return void
     149     */
     150    public function add_terminals_hooks() {
     151        foreach ( $this->methods as $method_id => $method ) {
     152            if ( is_subclass_of( $method_id, 'WC_Estonian_Shipping_Method_Terminals' ) ) {
     153                $method = new $method_id();
     154                $method->add_terminals_hooks();
     155            }
     156        }
    152157    }
    153158
     
    185190
    186191        load_textdomain( $domain, WP_LANG_DIR . '/estonian-shipping-methods-for-woocommerce/' . $domain . '-' . $locale . '.mo' );
    187         load_plugin_textdomain( $domain, '', dirname( plugin_basename( WC_ESTONIAN_SHIPPING_METHODS_MAIN_FILE ) ) . '/languages/' );
     192        load_plugin_textdomain( $domain, false, dirname( plugin_basename( WC_ESTONIAN_SHIPPING_METHODS_MAIN_FILE ) ) . '/languages/' );
    188193    }
    189194
     
    195200     */
    196201    public function register_shipping_methods( $methods ) {
    197         // Add methods
     202        // Add methods.
    198203        foreach ( $this->methods as $method_id => $method ) {
    199204            $methods[ $method_id ] = $method;
  • estonian-shipping-methods-for-woocommerce/trunk/includes/abstracts/class-wc-estonian-shipping-method-dpd-shops.php

    r1948507 r2825700  
    1717     * @var string
    1818     */
    19     public $terminals_url = 'ftp://ftp.dpd.ee/parcelshop/psexport_latest.csv';
     19    public $terminals_url = 'ftp://ftp:@ftp.dpdbaltics.com/PickupParcelShopData.json';
    2020
    2121    /**
     
    2525        $this->terminals_template = 'dpd';
    2626
    27         // Checkout phone numbe validation
     27        // Checkout phone numbe validation.
    2828        add_action( 'woocommerce_after_checkout_validation', array( $this, 'validate_customer_phone_number' ), 10, 1 );
    2929
    30         // Construct parent
     30        // Construct parent.
    3131        parent::__construct();
    3232    }
    3333
    3434    /**
    35      * Fetch the terminals from remote URL
     35     * Fetch the terminals from remote URL.
     36     *
     37     * @param false|string $filter_country Country to be filtered.
     38     * @param integer      $filter_type    Additional filter. Not used for this method.
     39     *
     40     * @return array Terminals.
    3641     */
    3742    public function get_terminals( $filter_country = false, $filter_type = 0 ) {
    38         // Fetch terminals from cache
     43        // Fetch terminals from cache.
    3944        $cached_terminals = $this->get_terminals_cache();
    4045
    41         if( $cached_terminals !== null ) {
     46        if ( null !== $cached_terminals ) {
    4247            return $cached_terminals;
    4348        }
    4449
    45         $filter_country    = $filter_country ? $filter_country : $this->get_shipping_country();
    46         $locations         = array();
     50        $filter_country = $filter_country ? $filter_country : $this->get_shipping_country();
     51        $locations      = array();
    4752
    48         // Fetch
     53        // Fetch terminals.
    4954        $terminals_request = $this->request_remote_url( $this->terminals_url );
    5055
    51         if( $terminals_request['success'] === true ) {
    52             foreach( str_getcsv( $terminals_request['data'], "\n" ) as $row_data ) {
    53                 $data = str_getcsv( $row_data, '|' );
     56        if ( true === $terminals_request['success'] ) {
     57            $terminals = json_decode( $terminals_request['data'] );
    5458
    55                 $shop_location_id = $data[22];
    56                 $shop_country     = substr( $shop_location_id, 0, 2 );
    57 
    58                 if( $filter_country != $shop_country ) {
     59            foreach ( $terminals as $data ) {
     60                if ( $filter_country !== $data->countryCode ) {
    5961                    continue;
    6062                }
    6163
    62                 $locations[]      = (object) array(
    63                     'place_id'   => $shop_location_id,
    64                     'zipcode'    => $data[4],
    65                     'name'       => utf8_encode( $data[2] ),
    66                     'address'    => utf8_encode( $data[3] ),
    67                     'city'       => utf8_encode( $data[5] )
     64                $locations[] = (object) array(
     65                    'place_id' => $data->parcelShopId,
     66                    'zipcode'  => $data->zipCode,
     67                    'name'     => $data->companyName,
     68                    'address'  => sprintf( '%s, %s', $data->street, $data->city ),
     69                    'city'     => $data->city,
    6870                );
    6971            }
    7072        }
    7173
    72         // Save cache
     74        // Save terminals to cache.
    7375        $this->save_terminals_cache( $locations );
    7476
  • estonian-shipping-methods-for-woocommerce/trunk/includes/abstracts/class-wc-estonian-shipping-method-terminals.php

    r2337311 r2825700  
    3636     * @return void
    3737     */
    38     function __construct() {
    39         // Add terminal selection dropdown and save it
    40         add_action( 'woocommerce_review_order_after_shipping',                 array( $this, 'review_order_after_shipping' ) );
    41         add_action( 'woocommerce_checkout_update_order_meta',                  array( $this, 'checkout_save_order_terminal_id_meta' ), 10, 2 );
    42         add_action( 'woocommerce_checkout_update_order_review',                array( $this, 'checkout_save_session_terminal_id' ), 10, 1 );
    43 
    44         // Show selected terminal in order and emails
    45         add_action( 'woocommerce_order_details_after_customer_details',        array( $this, 'show_selected_terminal' ), 10, 1 );
    46         add_action( 'woocommerce_email_customer_details',                      array( $this, 'show_selected_terminal' ), 15, 1 );
    47 
    48         // WooCommerce PDF Invoices & Packing Slips
    49         add_action( 'wpo_wcpdf_after_order_data',                              array( $this, 'wpo_wcpdf_show_selected_terminal' ), 10, 2 );
     38    public function __construct() {
     39        // Meta and input field name.
     40        $this->field_name = apply_filters( 'wc_shipping_' . $this->id . '_terminals_field_name', 'wc_shipping_' . $this->id . '_terminal' );
     41
     42        // i18n.
     43        $this->i18n_selected_terminal = esc_html__( 'Chosen terminal', 'wc-estonian-shipping-methods' );
     44
     45        // Construct parent.
     46        parent::__construct();
     47
     48        // Add/merge form fields.
     49        $this->add_form_fields();
     50    }
     51
     52    /**
     53     * Add hooks even when shipping might not be inited. Adds compatibility with lots of plugins.
     54     *
     55     * @return void
     56     */
     57    public function add_terminals_hooks() {
     58        // Show selected terminal in order and emails.
     59        add_action( 'woocommerce_order_details_after_customer_details', array( $this, 'show_selected_terminal' ), 10, 1 );
     60        add_action( 'woocommerce_email_customer_details', array( $this, 'show_selected_terminal' ), 15, 1 );
     61
     62        // WooCommerce PDF Invoices & Packing Slips.
     63        add_action( 'wpo_wcpdf_after_order_data', array( $this, 'wpo_wcpdf_show_selected_terminal' ), 10, 2 );
    5064
    5165        // Custom locations.
     
    5367        add_filter( 'wc_estonian_shipping_method_order_terminal_name', array( $this, 'add_order_terminal_name' ), 10, 2 );
    5468
     69        // Show selected terminal in admin order review
     70        // and since WC 3.3.0 in order preview.
     71        add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'show_selected_terminal' ), 20 );
     72        add_filter( 'woocommerce_admin_order_preview_get_order_details', array( $this, 'show_selected_terminal_in_order_preview' ), 20, 2 );
     73
     74        // Add terminal selection dropdown and save it.
     75        add_action( 'woocommerce_review_order_after_shipping', array( $this, 'review_order_after_shipping' ) );
     76        add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'checkout_save_order_terminal_id_meta' ), 10, 2 );
     77        add_action( 'woocommerce_checkout_update_order_review', array( $this, 'checkout_save_session_terminal_id' ), 10, 1 );
     78
    5579        // Checkout validation.
    56         add_action( 'woocommerce_after_checkout_validation',                   array( $this, 'validate_user_selected_terminal' ), 10, 1 );
    57 
    58         // Show selected terminal in admin order review
    59         // and since WC 3.3.0 in order preview
    60         if ( is_admin() ) {
    61             add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'show_selected_terminal' ), 20 );
    62             add_filter( 'woocommerce_admin_order_preview_get_order_details', array( $this, 'show_selected_terminal_in_order_preview' ), 20, 2 );
    63         }
    64 
    65         // Meta and input field name.
    66         $this->field_name = apply_filters( 'wc_shipping_' . $this->id . '_terminals_field_name', 'wc_shipping_' . $this->id . '_terminal' );
    67 
    68         // i18n.
    69         $this->i18n_selected_terminal = esc_html__( 'Chosen terminal', 'wc-estonian-shipping-methods' );
    70 
    71         // Construct parent.
    72         parent::__construct();
    73 
    74         // Add/merge form fields.
    75         $this->add_form_fields();
    76     }
    77 
    78     function add_form_fields() {
     80        add_action( 'woocommerce_after_checkout_validation', array( $this, 'validate_user_selected_terminal' ), 10, 1 );
     81    }
     82
     83    public function add_form_fields() {
    7984        $this->form_fields = array_merge( $this->form_fields, array(
    8085                'terminals_format' => array(
  • estonian-shipping-methods-for-woocommerce/trunk/includes/abstracts/class-wc-estonian-shipping-method.php

    r1953050 r2825700  
    111111        $cart_total_cost    = WC()->cart->get_displayed_subtotal();
    112112
    113         if ( ( method_exists( WC()->cart, 'display_prices_including_tax' ) && WC()->cart->display_prices_including_tax() ) || WC()->cart->tax_display_cart ) {
     113        if ( WC()->cart->display_prices_including_tax() ) {
    114114            $cart_total_cost = round( $cart_total_cost - ( WC()->cart->get_discount_total() + WC()->cart->get_discount_tax() ), wc_get_price_decimals() );
    115115        } else {
  • estonian-shipping-methods-for-woocommerce/trunk/includes/compatibility-helpers.php

    r1813248 r2825700  
    8282    }
    8383}
     84
     85/**
     86 * Get HTML element class name from theme.
     87 *
     88 * @since 1.6
     89 *
     90 * @param string $element HTML element name.
     91 *
     92 * @return string HTML class name.
     93 */
     94function wc_esm_get_element_class_name( $element ) {
     95    $class_name = '';
     96
     97    if ( function_exists( 'wc_wp_theme_get_element_class_name' ) ) {
     98        $class_name = wc_wp_theme_get_element_class_name( $element );
     99    }
     100
     101    return apply_filters( 'wc_estonian_shipping_methods_element_class_name', $class_name, $element );
     102}
  • estonian-shipping-methods-for-woocommerce/trunk/readme.txt

    r2337311 r2825700  
    33Tags: WooCommerce, shipping method, Estonia, smartpost, dpd, pakiautomaat, courier, omniva
    44Requires at least: 4.1
    5 Tested up to: 5.4.2
    6 Stable tag: 1.5.8.2
     5Tested up to: 6.1.1
     6Stable tag: 1.6.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5151
    5252== Changelog ==
     53
     54= 1.6.0 =
     55* Relocate terminal methods hooks for compatibility with other plugins
     56* Add version tag to templates, clean up templates
     57* Removed use of deprecated WC property
     58
     59= 1.5.9 =
     60* Change DPD terminals source URL
    5361
    5462= 1.5.8 =
  • estonian-shipping-methods-for-woocommerce/trunk/woocommerce/checkout/form-shipping-collect-net.php

    r1813248 r2825700  
    1 <tr class="wc_shipping_collectnet wc-esm-method--collect-net">
    2     <th><label for="<?php echo esc_attr( $field_id ) ?>"><?php esc_html_e( 'Choose packrobot', 'wc-estonian-shipping-methods' ) ?></label></th>
     1<?php
     2/**
     3 * Collect.net checkout dropdown template
     4 *
     5 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping-collect-net.php.
     6 *
     7 * HOWEVER, on occasion WooCommerce will need to update template files and you
     8 * (the theme developer) will need to copy the new files to your theme to
     9 * maintain compatibility. We try to do this as little as possible, but it does
     10 * happen. When this occurs the version of the template file will be bumped and
     11 * the readme will list any important changes.
     12 *
     13 * @see     https://docs.woocommerce.com/document/template-structure/
     14 * @package Estonian_Shipping_Methods_For_WooCommerce
     15 * @version 7.1.0
     16 */
     17
     18defined( 'ABSPATH' ) || exit;
     19?>
     20
     21<tr class="wc_shipping_collectnet wc-esm-method wc-esm-method--collect-net">
     22    <th><label for="<?php echo esc_attr( $field_id ); ?>"><?php esc_html_e( 'Choose packrobot', 'wc-estonian-shipping-methods' ); ?></label></th>
    323    <td>
    4         <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $field_id ) ?>">
    5             <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose packrobot -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ) ?></option>
    6         <?php foreach( $terminals as $group_name => $locations ) : ?>
    7             <optgroup label="<?php echo $group_name ?>">
    8                 <?php foreach( $locations as $location ) : ?>
    9                 <option value="<?php echo esc_html( $location->place_id ) ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ) ?></option>
    10                 <?php endforeach; ?>
    11             </optgroup>
    12         <?php endforeach; ?>
     24        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_id ); ?>" class="<?php echo esc_attr( wc_esm_get_element_class_name( 'select' ) ); ?>">
     25            <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose packrobot -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ); ?></option>
     26
     27            <?php foreach ( $terminals as $group_name => $locations ) : ?>
     28                <optgroup label="<?php echo esc_attr( $group_name ); ?>">
     29                    <?php foreach ( $locations as $location ) : ?>
     30                        <option value="<?php echo esc_attr( $location->place_id ); ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ); ?></option>
     31                    <?php endforeach; ?>
     32                </optgroup>
     33            <?php endforeach; ?>
    1334        </select>
    1435    </td>
  • estonian-shipping-methods-for-woocommerce/trunk/woocommerce/checkout/form-shipping-dpd.php

    r1831316 r2825700  
    1 <tr class="wc_shipping_dpd wc-esm-method--dpd">
    2     <th><label for="<?php echo esc_attr( $field_id ) ?>"><?php esc_html_e( 'Choose terminal', 'wc-estonian-shipping-methods' ) ?></label></th>
     1<?php
     2/**
     3 * DPD checkout dropdown template
     4 *
     5 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping-dpd.php.
     6 *
     7 * HOWEVER, on occasion WooCommerce will need to update template files and you
     8 * (the theme developer) will need to copy the new files to your theme to
     9 * maintain compatibility. We try to do this as little as possible, but it does
     10 * happen. When this occurs the version of the template file will be bumped and
     11 * the readme will list any important changes.
     12 *
     13 * @see     https://docs.woocommerce.com/document/template-structure/
     14 * @package Estonian_Shipping_Methods_For_WooCommerce
     15 * @version 7.1.0
     16 */
     17
     18defined( 'ABSPATH' ) || exit;
     19?>
     20
     21<tr class="wc_shipping_dpd wc-esm-method wc-esm-method--dpd">
     22    <th><label for="<?php echo esc_attr( $field_id ); ?>"><?php esc_html_e( 'Choose terminal', 'wc-estonian-shipping-methods' ); ?></label></th>
    323    <td>
    4         <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $field_id ) ?>">
    5             <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose terminal -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ) ?></option>
    6         <?php foreach( $terminals as $group_name => $locations ) : ?>
    7             <optgroup label="<?php echo $group_name ?>">
    8                 <?php foreach( $locations as $location ) : ?>
    9                 <option value="<?php echo esc_html( $location->place_id ) ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ) ?></option>
    10                 <?php endforeach; ?>
    11             </optgroup>
    12         <?php endforeach; ?>
     24        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_id ); ?>" class="<?php echo esc_attr( wc_esm_get_element_class_name( 'select' ) ); ?>">
     25            <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose terminal -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ); ?></option>
     26
     27            <?php foreach ( $terminals as $group_name => $locations ) : ?>
     28                <optgroup label="<?php echo esc_attr( $group_name ); ?>">
     29                    <?php foreach ( $locations as $location ) : ?>
     30                        <option value="<?php echo esc_attr( $location->place_id ); ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ); ?></option>
     31                    <?php endforeach; ?>
     32                </optgroup>
     33            <?php endforeach; ?>
    1334        </select>
    1435    </td>
  • estonian-shipping-methods-for-woocommerce/trunk/woocommerce/checkout/form-shipping-omniva-postoffice.php

    r2097833 r2825700  
    1 <tr class="wc_shipping_omniva">
    2     <th><label for="<?php echo $field_id ?>"><?php _e( 'Choose post office', 'wc-estonian-shipping-methods' ) ?></label></th>
     1<?php
     2/**
     3 * Omniva postoffice dropdown template
     4 *
     5 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping-omniva-postoffice.php.
     6 *
     7 * HOWEVER, on occasion WooCommerce will need to update template files and you
     8 * (the theme developer) will need to copy the new files to your theme to
     9 * maintain compatibility. We try to do this as little as possible, but it does
     10 * happen. When this occurs the version of the template file will be bumped and
     11 * the readme will list any important changes.
     12 *
     13 * @see     https://docs.woocommerce.com/document/template-structure/
     14 * @package Estonian_Shipping_Methods_For_WooCommerce
     15 * @version 7.1.0
     16 */
     17
     18defined( 'ABSPATH' ) || exit;
     19?>
     20
     21<tr class="wc_shipping_omniva wc-esm-method wc-esm-method--omniva-postoffice">
     22<th><label for="<?php echo esc_attr( $field_id ); ?>"><?php esc_html_e( 'Choose post office', 'wc-estonian-shipping-methods' ); ?></label></th>
    323    <td>
    4         <select name="<?php echo $field_name ?>" id="<?php echo $field_id ?>">
    5             <option value="" <?php selected( $selected, '' ); ?>><?php _ex( '- Choose post office -', 'empty value label for post office', 'wc-estonian-shipping-methods' ) ?></option>
    6         <?php foreach( $terminals as $group_name => $locations ) : ?>
    7             <optgroup label="<?php echo $group_name ?>">
    8                 <?php foreach( $locations as $location ) : ?>
    9                 <option value="<?php echo $location->place_id ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo $location->name ?></option>
    10                 <?php endforeach; ?>
    11             </optgroup>
    12         <?php endforeach; ?>
     24        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_id ); ?>" class="<?php echo esc_attr( wc_esm_get_element_class_name( 'select' ) ); ?>">
     25            <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose post office -', 'empty value label for post office', 'wc-estonian-shipping-methods' ); ?></option>
     26
     27            <?php foreach ( $terminals as $group_name => $locations ) : ?>
     28                <optgroup label="<?php echo esc_attr( $group_name ); ?>">
     29                    <?php foreach ( $locations as $location ) : ?>
     30                        <option value="<?php echo esc_attr( $location->place_id ); ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ); ?></option>
     31                    <?php endforeach; ?>
     32                </optgroup>
     33            <?php endforeach; ?>
    1334        </select>
    1435    </td>
  • estonian-shipping-methods-for-woocommerce/trunk/woocommerce/checkout/form-shipping-omniva.php

    r1831316 r2825700  
    1 <tr class="wc_shipping_omniva wc-esm-method--omniva">
    2     <th><label for="<?php echo esc_attr( $field_id ) ?>"><?php esc_html_e( 'Choose terminal', 'wc-estonian-shipping-methods' ) ?></label></th>
     1<?php
     2/**
     3 * Omniva dropdown template
     4 *
     5 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping-omniva.php.
     6 *
     7 * HOWEVER, on occasion WooCommerce will need to update template files and you
     8 * (the theme developer) will need to copy the new files to your theme to
     9 * maintain compatibility. We try to do this as little as possible, but it does
     10 * happen. When this occurs the version of the template file will be bumped and
     11 * the readme will list any important changes.
     12 *
     13 * @see     https://docs.woocommerce.com/document/template-structure/
     14 * @package Estonian_Shipping_Methods_For_WooCommerce
     15 * @version 7.1.0
     16 */
     17
     18defined( 'ABSPATH' ) || exit;
     19?>
     20
     21<tr class="wc_shipping_omniva wc-esm-method wc-esm-method--omniva">
     22    <th><label for="<?php echo esc_attr( $field_id ); ?>"><?php esc_html_e( 'Choose terminal', 'wc-estonian-shipping-methods' ); ?></label></th>
    323    <td>
    4         <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $field_id ) ?>">
    5             <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose terminal -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ) ?></option>
    6         <?php foreach( $terminals as $group_name => $locations ) : ?>
    7             <optgroup label="<?php echo $group_name ?>">
    8                 <?php foreach( $locations as $location ) : ?>
    9                 <option value="<?php echo esc_html( $location->place_id ) ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ) ?></option>
    10                 <?php endforeach; ?>
    11             </optgroup>
    12         <?php endforeach; ?>
     24        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_id ); ?>" class="<?php echo esc_attr( wc_esm_get_element_class_name( 'select' ) ); ?>">
     25            <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose terminal -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ); ?></option>
     26
     27            <?php foreach ( $terminals as $group_name => $locations ) : ?>
     28                <optgroup label="<?php echo esc_attr( $group_name ); ?>">
     29                    <?php foreach ( $locations as $location ) : ?>
     30                        <option value="<?php echo esc_attr( $location->place_id ); ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ); ?></option>
     31                    <?php endforeach; ?>
     32                </optgroup>
     33            <?php endforeach; ?>
    1334        </select>
    1435    </td>
  • estonian-shipping-methods-for-woocommerce/trunk/woocommerce/checkout/form-shipping-smartpost-courier.php

    r1813248 r2825700  
    1 <tr class="wc_shipping_smartpost wc-esm-method--smartpost-courier">
    2     <th><label for="<?php echo esc_attr( $field_id ) ?>"><?php esc_html_e( 'Choose timewindow', 'wc-estonian-shipping-methods' ) ?></label></th>
     1<?php
     2/**
     3 * Smartpost courier dropdown template
     4 *
     5 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping-smartpost-courier.php.
     6 *
     7 * HOWEVER, on occasion WooCommerce will need to update template files and you
     8 * (the theme developer) will need to copy the new files to your theme to
     9 * maintain compatibility. We try to do this as little as possible, but it does
     10 * happen. When this occurs the version of the template file will be bumped and
     11 * the readme will list any important changes.
     12 *
     13 * @see     https://docs.woocommerce.com/document/template-structure/
     14 * @package Estonian_Shipping_Methods_For_WooCommerce
     15 * @version 7.1.0
     16 */
     17
     18defined( 'ABSPATH' ) || exit;
     19?>
     20
     21<tr class="wc_shipping_smartpost wc-esm-method wc-esm-method--smartpost-courier">
     22    <th><label for="<?php echo esc_attr( $field_id ); ?>"><?php esc_html_e( 'Choose timewindow', 'wc-estonian-shipping-methods' ); ?></label></th>
    323    <td>
    4         <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $field_id ) ?>">
    5             <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose timewindow -', 'empty value label for courier', 'wc-estonian-shipping-methods' ) ?></option>
    6         <?php foreach( $windows as $value => $window ) : ?>
    7             <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $selected, $value ); ?>><?php echo esc_html( $window ) ?></option>
    8         <?php endforeach; ?>
     24        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_id ); ?>" class="<?php echo esc_attr( wc_esm_get_element_class_name( 'select' ) ); ?>">
     25            <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose timewindow -', 'empty value label for courier', 'wc-estonian-shipping-methods' ); ?></option>
     26
     27            <?php foreach ( $windows as $value => $window ) : ?>
     28                <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $selected, $value ); ?>><?php echo esc_html( $window ); ?></option>
     29            <?php endforeach; ?>
    930        </select>
    1031    </td>
  • estonian-shipping-methods-for-woocommerce/trunk/woocommerce/checkout/form-shipping-smartpost.php

    r1831316 r2825700  
     1<?php
     2/**
     3 * Smartpost terminals dropdown template
     4 *
     5 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-shipping-smartpost.php.
     6 *
     7 * HOWEVER, on occasion WooCommerce will need to update template files and you
     8 * (the theme developer) will need to copy the new files to your theme to
     9 * maintain compatibility. We try to do this as little as possible, but it does
     10 * happen. When this occurs the version of the template file will be bumped and
     11 * the readme will list any important changes.
     12 *
     13 * @see     https://docs.woocommerce.com/document/template-structure/
     14 * @package Estonian_Shipping_Methods_For_WooCommerce
     15 * @version 7.1.0
     16 */
     17
     18defined( 'ABSPATH' ) || exit;
     19?>
     20
    121<tr class="wc_shipping_smartpost wc-esm-method--smartpost">
    2     <th><label for="<?php echo esc_attr( $field_id ) ?>"><?php esc_html_e( 'Choose terminal', 'wc-estonian-shipping-methods' ) ?></label></th>
     22    <th><label for="<?php echo esc_attr( $field_id ); ?>"><?php esc_html_e( 'Choose terminal', 'wc-estonian-shipping-methods' ); ?></label></th>
    323    <td>
    4         <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $field_id ) ?>">
    5             <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose terminal -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ) ?></option>
    6         <?php foreach( $terminals as $group_name => $locations ) : ?>
    7             <optgroup label="<?php echo $group_name ?>">
    8                 <?php foreach( $locations as $location ) : ?>
    9                 <option value="<?php echo esc_html( $location->place_id ) ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ) ?></option>
    10                 <?php endforeach; ?>
    11             </optgroup>
    12         <?php endforeach; ?>
     24        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_id ); ?>" class="<?php echo esc_attr( wc_esm_get_element_class_name( 'select' ) ); ?>">
     25            <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html_x( '- Choose terminal -', 'empty value label for terminals', 'wc-estonian-shipping-methods' ); ?></option>
     26
     27            <?php foreach ( $terminals as $group_name => $locations ) : ?>
     28                <optgroup label="<?php echo esc_attr( $group_name ); ?>">
     29                    <?php foreach ( $locations as $location ) : ?>
     30                        <option value="<?php echo esc_attr( $location->place_id ); ?>" <?php selected( $selected, $location->place_id ); ?>><?php echo esc_html( $location->name ); ?></option>
     31                    <?php endforeach; ?>
     32                </optgroup>
     33            <?php endforeach; ?>
    1334        </select>
    1435    </td>
Note: See TracChangeset for help on using the changeset viewer.