Plugin Directory

Changeset 2884972


Ignore:
Timestamp:
03/22/2023 01:22:56 PM (3 years ago)
Author:
hfdepost
Message:

Bug fixes

Location:
hfd-epost-integration/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • hfd-epost-integration/trunk/class/App.php

    r2834354 r2884972  
    4242        add_filter('woocommerce_order_shipping_to_display', array($this, 'emailPickupInfo'), 10, 2);
    4343
    44         add_action('woocommerce_after_shipping_rate', array($this, 'renderAdditional'));
     44        add_action( 'woocommerce_after_shipping_rate', array($this, 'renderAdditional' ) );
    4545        add_action('woocommerce_checkout_order_processed', array($this, 'convertPickupToOrder'), 10, 3);
    4646        add_action('woocommerce_new_order', array($this, 'convertPickupToOrderOptional'), 10, 2);
     
    411411     * @return void
    412412     */
    413     public function renderAdditional($method)
    414     {
    415         if ($method->get_method_id() != 'betanet_epost') {
     413    public function renderAdditional( $method )
     414    {
     415        if( $method->get_method_id() != 'betanet_epost' ){
    416416            return;
    417417        }
     418               
    418419        /* @var \Hfd\Woocommerce\Shipping\Additional $additionalBLock */
    419420        $additionalBLock = Container::create('Hfd\Woocommerce\Shipping\Additional');
  • hfd-epost-integration/trunk/hfd-woocommerce-epost.php

    r2834354 r2884972  
    44Plugin URI:
    55Description: Add shipping method of ePost, allowing the user on the checkout, to select the pickup location point from a google map popup. Also allows to synch the order to HFD API after the order is created.
    6 Version: 1.4
     6Version: 1.5
    77Author: HFD
    88Author URI: https://www.hfd.co.il
  • hfd-epost-integration/trunk/js/epost-list.js

    r2766592 r2884972  
    33    config: {},
    44    spots: {},
    5     additonalBlock: null,
     5    additonalBlock: $j('#israelpost-additional'),
    66    isLoading: false,
    77    selectedCity: null,
    88
    99    init: function (config) {
    10       config = config || {};
    11       this.config = config;
    12       this.initAdditional();
    13       this.initAjaxEvent();
    14       this.initValidation();
    15       this.renderCities()
    16       this.observeCityChange()
    17       this.observeSpotChange()
    18       this.observeShippingCity();
     10        config = config || {};
     11        this.config = config;
     12        this.initAdditional();
     13        this.initAjaxEvent();
     14        this.initValidation();
     15        this.renderCities();
     16        this.observeCityChange();
     17        this.observeSpotChange();
     18        this.observeShippingCity();
    1919    },
    2020
     
    2323      this.shippingInput = this.additonalBlock.siblings('input.shipping_method');
    2424
    25       if (!this.shippingInput.length) {
     25      if( !this.shippingInput.length ){
    2626        return;
    2727      }
    2828
    2929      this.initCustomSelect();
    30       if (!this.shippingInput.is(':checked')) {
     30      if( !this.shippingInput.is( ':checked' ) ){
    3131        this.additonalBlock.hide();
    3232      }
     
    7474    },
    7575
    76     renderCities: function () {
    77       var cities = this.config.cities
    78       if (cities.length) {
    79         var select = this.additonalBlock.find('#city-list'),
    80           selected = this.selectedCity || select.data('selected')
    81         if (select.length) {
    82           var i, city, option
    83           for (i in cities) {
    84             city = cities[i];
    85             //city = city.replace( /\(/g, " )" );
    86             var nth = 0;
    87             city = city.replace(/\)/g, function (match, i, original) {
    88                 nth++;
    89                 return (nth === 1) ? "(" : match;
    90             });
    91             var nnth = 0;
    92             city = city.replace(/\(/g, function (match, i, original) {
    93                 nnth++;
    94                 return (nnth === 2) ? ")" : match;
    95             });
    96             option = $j('<option>', { value: city, text: city } )
    97             if( selected && selected === city ){
    98               option.attr('selected', 'selected');
    99             }
    100             select.append(option)
    101           }
    102         }
    103       }
     76    renderCities: function(){
     77        var cities = this.config.cities;
     78        if( cities.length ){
     79            var select = this.additonalBlock.find( '#city-list' ),
     80            selected = this.selectedCity || select.data( 'selected' );
     81            if( select.length ){
     82                var i, city, option;
     83                var options = '';
     84                for( i in cities ){
     85                    city = cities[i];
     86                    //city = city.replace( /\(/g, " )" );
     87                    var nth = 0;
     88                    city = city.replace(/\)/g, function (match, i, original) {
     89                        nth++;
     90                        return (nth === 1) ? "(" : match;
     91                    });
     92                    var nnth = 0;
     93                    city = city.replace(/\(/g, function (match, i, original) {
     94                        nnth++;
     95                        return (nnth === 2) ? ")" : match;
     96                    });
     97                    option = $j( '<option>', { value: city, text: city } );
     98                    if( selected && selected === city ){
     99                        option.attr('selected', 'selected');
     100                    }
     101                    select.append( option );
     102                }
     103            }
     104        }
    104105    },
    105106
  • hfd-epost-integration/trunk/readme.txt

    r2834354 r2884972  
    44Donate link:
    55Requires at least: 4.0
    6 Tested up to: 6.1
    7 Stable tag: 1.4
     6Tested up to: 6.2
     7Stable tag: 1.5
    88Requires PHP: 5.4
    99License: GPLv2 or later
  • hfd-epost-integration/trunk/templates/cart/epost-additional.php

    r2768357 r2884972  
    2121            </a>
    2222        </p>
    23     <?php else: ?>
     23    <?php else:
     24        $helper = \Hfd\Woocommerce\Container::get( 'Hfd\Woocommerce\Helper\Spot' );
     25    ?>
    2426        <div class="spot-list-container">
    2527            <div class="field">
    26                 <select id="city-list" <?php if ($spotInfo) : ?>data-selected="<?php echo esc_attr( $spotInfo['city'] ); ?>" <?php endif; ?>>
     28                <select id="city-list" <?php if ($spotInfo) : ?>data-selected="<?php echo esc_attr( $spotInfo['city'] ); ?>" <?php endif; ?> onload="loadEpost()">
    2729                    <option value=""><?php echo esc_html( __( 'Select city', 'hfd-integration' ) ); ?></option>
    2830                </select>
  • hfd-epost-integration/trunk/templates/cart/footer.php

    r2768357 r2884972  
    6161    ?>
    6262    <script type="text/javascript">
    63         document.addEventListener("DOMContentLoaded", function() {
    64             Translator.add( 'Select a collection point','<?php esc_html_e( 'Select a collection point', 'hfd-integration' ); ?>');
    65             Translator.add( 'Select pickup point','<?php esc_html_e( 'Select pickup point', 'hfd-integration' ); ?>');
    66             Translator.add( 'There is no pickup point','<?php esc_html_e( 'There is no pickup point', 'hfd-integration' ); ?>');
    67             EpostList.init({
    68                 saveSpotInfoUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php' ) ); ?>',
    69                 getSpotsUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php?action=get_spots' ) ); ?>',
    70                 cities: <?php echo json_encode( $helper->getCities() ); ?>
    71             });
     63        document.addEventListener( "DOMContentLoaded", function(){
     64            Translator.add( 'Select a collection point','<?php esc_html_e( 'Select a collection point', 'hfd-integration' ); ?>');
     65            Translator.add( 'Select pickup point','<?php esc_html_e( 'Select pickup point', 'hfd-integration' ); ?>');
     66            Translator.add( 'There is no pickup point','<?php esc_html_e( 'There is no pickup point', 'hfd-integration' ); ?>');
     67                       
     68            var cityLoaded = false;
     69            jQuery( "body" ).on( "updated_checkout", function(){
     70                var mainBlock = jQuery('#israelpost-additional');
     71                if( mainBlock.siblings( 'input.shipping_method' ).is(':checked') ){
     72                    if( !cityLoaded || mainBlock.find( '#city-list' ).find( 'option' ).length == 1 ){
     73                        EpostList.init({
     74                            saveSpotInfoUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php' ) ); ?>',
     75                            getSpotsUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php?action=get_spots' ) ); ?>',
     76                            cities: <?php echo json_encode( $helper->getCities() ); ?>
     77                        });
     78                        cityLoaded = true;
     79                    }
     80                    mainBlock.show();
     81                }else{
     82                    mainBlock.hide();
     83                }
     84            });
    7285        });
    7386    </script>
Note: See TracChangeset for help on using the changeset viewer.