Plugin Directory

Changeset 3718397


Ignore:
Timestamp:
09/29/2026 06:45:58 AM (4 weeks ago)
Author:
matejpodstrelenec
Message:

2.0.1

Location:
slovenska-posta-epodaci-harok
Files:
32 added
5 edited

Legend:

Unmodified
Added
Removed
  • slovenska-posta-epodaci-harok/trunk/includes/Posta_ShippingClass.php

    r3640073 r3718397  
    7777                            'type' => 'number',
    7878                            'custom_attributes' => array( 'step' => 'any', 'min' => '0' ),
    79                             'description' => __( 'Doprava zdarma od sumy.', 'spirit-eph' ),
     79                            'description' => __( 'Doprava zdarma od sumy. Ak pole necháte prázdne, doprava zdarma je vypnutá.', 'spirit-eph' ),
    8080                            'default' => 50
     81                        ),
     82                        'free_shipping_label' => array(
     83                            'title' => __( 'Text pri doprave zdarma', 'spirit-eph' ),
     84                            'type' => 'text',
     85                            'description' => __( 'Text zobrazený za názvom dopravy, ak je doprava zdarma (napr. "Slovenská pošta - doprava zadarmo"). Ak pole necháte prázdne, text sa nezobrazí.', 'spirit-eph' ),
     86                            'default' => __( 'doprava zadarmo', 'spirit-eph' )
    8187                        )
    8288
    … …  
    95101                   
    96102                    // We will add the cost, rate and logics in here
    97                     $cost = (double) $this->get_option( 'standard_cost' );
    98                     $free_shipping = (double) $this->get_option( 'free_shipping' );
     103                    $cost = (float) $this->get_option( 'standard_cost' );
     104                    $free_shipping = $this->get_option( 'free_shipping' );
    99105
    100                     //If total higher than 20, activate free shipping
    101                     if ($free_shipping <= $package['cart_subtotal']) {
     106                    // Empty threshold means free shipping is disabled
     107                    if ( $free_shipping !== '' && (float) $free_shipping <= $package['cart_subtotal'] ) {
    102108                        $cost = 0.00;
     109                    }
     110
     111                    $label = $this->title;
     112                    $free_shipping_label = trim( $this->get_option( 'free_shipping_label' ) );
     113
     114                    if ( $cost <= 0 && $free_shipping_label !== '' ) {
     115                        $label .= ' - ' . $free_shipping_label;
    103116                    }
    104117
    105118                    $rate = array(
    106119                        'id' => $this->id,
    107                         'label' => $this->title,
     120                        'label' => $label,
    108121                        'cost' => $cost
    109122                    );
  • slovenska-posta-epodaci-harok/trunk/includes/pickup-widget.php

    r3640073 r3718397  
    3535                ),
    3636        ) );
     37}
     38
     39/*
     40 * Resolve the pickup widget shipmentType ('b', 'ex', 'zb') from the default parcel
     41 * type configured for the chosen Pošta shipping instance, so the widget only lists
     42 * points that accept that parcel type.
     43 */
     44function tsseph_get_pickup_shipment_type() {
     45        $shipment_types = array( 'b' => 'b', 'ek' => 'ex', 'zb' => 'zb' );
     46
     47        if ( ! WC()->session || ! WC()->shipping() ) return 'b';
     48
     49        $chosen   = WC()->session->get( 'chosen_shipping_methods', array() );
     50        $packages = WC()->shipping()->get_packages();
     51
     52        foreach ( $chosen as $package_key => $rate_id ) {
     53                if ( strpos( $rate_id, 'tssph_sk_posta' ) !== 0 ) continue;
     54                if ( empty( $packages[ $package_key ]['rates'][ $rate_id ] ) ) continue;
     55
     56                $instance_id = $packages[ $package_key ]['rates'][ $rate_id ]->get_instance_id();
     57                $eph_method  = tsseph_resolve_eph_method( $instance_id, 'tssph_sk_posta', get_option( 'tsseph_options' ) );
     58                $druh        = tsseph_posta_api_get_druh_zasielky( tsseph_get_druh_zasielky( $eph_method ) );
     59
     60                return isset( $shipment_types[ $druh['code'] ] ) ? $shipment_types[ $druh['code'] ] : 'b';
     61        }
     62
     63        return 'b';
    3764}
    3865
    … …  
    5784                <th><?php esc_html_e( 'Odberné miesto', 'spirit-eph' ); ?></th>
    5885                <td>
    59                         <button type="button" id="tsseph-pickup-btn" class="button wp-element-button">
     86                        <button type="button" id="tsseph-pickup-btn" class="button wp-element-button" data-shipment-type="<?php echo esc_attr( tsseph_get_pickup_shipment_type() ); ?>">
    6087                                <?php echo esc_html( $btn_label ); ?>
    6188                        </button>
  • slovenska-posta-epodaci-harok/trunk/js/tsseph-pickup-widget.js

    r3640073 r3718397  
    4848                        $( '#tsseph-pickup-label' ).html( address );
    4949                        $( '#tsseph-pickup-btn' ).text( tsseph_pickup.i18n.change_point );
    50                         $( '.tsseph-pickup-address-row' ).show();
     50                        // Keep the selection in session, but only show the address while Pošta is the chosen method
     51                        $( '.tsseph-pickup-address-row' ).toggle( isPostaSelected() );
    5152                } else {
    5253                        $( '#tsseph-pickup-label' ).html( '' );
    … …  
    107108                slposta.PickupWidget.open( {
    108109                        branchKinds:  [ 'office', 'bbox', 'point' ],
    109                         shipmentType: 'b',
     110                        shipmentType: $( '#tsseph-pickup-btn' ).data( 'shipment-type' ) || 'b',
    110111                        callback: function ( pickupPoint ) {
    111112                                // Widget closed without selecting
  • slovenska-posta-epodaci-harok/trunk/readme.txt

    r3642268 r3718397  
    66Tested up to: 7.0
    77Requires PHP: 5.2.4
    8 Stable tag: 2.0.0
     8Stable tag: 2.0.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5656 
    5757== Changelog ==
     58
     59= 2.0.1 =
     60* BalíkoBOX: adresa odberného miesta sa skryje pri zmene na iný spôsob dopravy
     61* Text "doprava zadarmo" za názvom dopravy Slovenská pošta (nastaviteľný v shipping zóne)
     62* Prázdne pole "Doprava zdarma" vypína dopravu zdarma
     63* Widget odberných miest zohľadňuje nastavený druh zásielky (Balík / Expres kuriér / Zmluvný balík)
    5864
    5965= 2.0.0 =
  • slovenska-posta-epodaci-harok/trunk/slovenska-posta-epodaci-harok.php

    r3640073 r3718397  
    44Plugin URI:  https://www.matejpodstrelenec.sk
    55Description: Plugin pre generovanie podacieho hárku určeného na import do webovej aplikácie slovenskej pošty.
    6 Version:     2.0.0
     6Version:     2.0.1
    77Author: Matej Podstrelenec
    88Author URI: https://www.matejpodstrelenec.sk/en/
    … …  
    3232
    3333define('SPIRIT_EPH_PLUGIN_PATH', plugin_dir_path( __FILE__));
    34 define('SPIRIT_EPH_VERSION', '2.0.0' );
     34define('SPIRIT_EPH_VERSION', '2.0.1' );
    3535
    3636include (SPIRIT_EPH_PLUGIN_PATH . "includes/functions.php");
Note: See TracChangeset for help on using the changeset viewer.