Plugin Directory

Changeset 3415749


Ignore:
Timestamp:
12/09/2025 07:38:24 PM (2 months ago)
Author:
shipo
Message:

Checkout improvments

Location:
shipo/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • shipo/trunk/assets/js/checkout.js

    r3410852 r3415749  
    66        var cityValue = $(this).val();
    77        var elementId = $(this).attr('id');
     8        var prefix = elementId.split('_')[0] + '_' + elementId.split('_')[1];
     9
     10        $('#' + elementId + '_id').val('');
     11        $('#' + prefix + '_street').val('');
     12        $('#' + prefix + '_street_id').val('');
     13        $('#' + prefix + '_street_suggestions').html('');
     14        $('#' + elementId.split('_')[0] + '_postcode').val('');
    815
    916        clearMapElements();
     
    3744                                    label: suggestionsResponse[key]['name'],
    3845                                    value: suggestionsResponse[key]['name'],
    39                                     coord: suggestionsResponse[key]['coord']
     46                                    coord: suggestionsResponse[key]['coord'],
     47                                    zipcode: suggestionsResponse[key]['zipcode']
    4048                                });
    4149                            });
     
    4452                        if (suggestions.length > 0 && suggestions[0].coord) {
    4553                            suggestions.forEach(function(suggestion) {
    46                                 $('#' + elementId + '_suggestions ul').append('<li data-coord="' + suggestion.coord['lat'] + ',' + suggestion.coord['lng'] + '" data-city-id="' + suggestion.id + '">' + suggestion.value + '</li>');
     54                                $('#' + elementId + '_suggestions ul').append('<li data-coord="' + suggestion.coord['lat'] + ',' + suggestion.coord['lng'] + '" data-city-id="' + suggestion.id + '" data-zipcode="' + suggestion.zipcode + '">' + suggestion.value + '</li>');
    4755                            });
    4856                        } else {
     
    5058                        }
    5159                    } else {
    52                         console.log(response.data.message);
    5360                        $('#' + elementId + '_suggestion ul').append('<li>' + response.data.message + '</li>');
    5461                    }
     
    8895        var prefix = elementId.split('_')[0] + '_' + elementId.split('_')[1];
    8996
     97        $('#' + prefix + '_street').val('');
     98        $('#' + prefix + '_street_id').val('');
     99        $('#' + prefix + '_street_suggestions').html('');
     100
    90101        var selectedAddress = $(this).text();
    91102        var coordAddress = $(this).data('coord');
    92103        var cityId = $(this).data('city-id');
     104        var zipcode = $(this).data('zipcode');
    93105        var cityName = $(this).text();
    94106        $('#' + prefix + '_city').val(selectedAddress);
     
    96108        $('input[name="' + prefix + '_coord"]').val(coordAddress);
    97109        $('input[name="' + prefix + '_city_id"]').val(cityId);
    98         $('input[name="' + prefix + '_postcode"]').val('');
    99         $('input[name="' + elementId.split('_')[0] + '_postcode"]').val('');
     110        $('input[name="' + prefix + '_postcode"]').val(zipcode);
     111        $('input[name="' + elementId.split('_')[0] + '_postcode"]').val(zipcode);
    100112
    101113        toggleViewSector(prefix, cityName);
     
    131143        var newElementId = elementIdParts.join('_');
    132144        var cityValue = $('#' + newElementId + '_city').val();
     145
     146        $('#' + elementId + '_id').val('');
     147        $('#' + elementIdParts[0] + '_postcode').val('');
    133148
    134149        if (streetValue.length >= 3) {
     
    193208        $('input[name="' + prefix + '_street_id"]').val(streetId);
    194209
    195         $(document.body).trigger('update_checkout');
     210        // $(document.body).trigger('update_checkout');
    196211    });
    197212
  • shipo/trunk/includes/class-shipo-checkout.php

    r3404077 r3415749  
    484484       
    485485        if (empty($_POST['billing_shipo_street'])) {
    486             wc_add_notice(__('Seletează o stradă validă din.', 'shipo'), 'error');
     486            wc_add_notice(__('Selecteaza strada.', 'shipo'), 'error');
    487487        }
    488488
     
    496496       
    497497        if (empty($_POST['shipping_shipo_street'])) {
    498             wc_add_notice(__('Seletează o stradă validă din.', 'shipo'), 'error');
     498            wc_add_notice(__('Selecteaza strada.', 'shipo'), 'error');
    499499        }
    500500
     
    611611        if (isset($_POST['ship_to_different_address']) && isset($_POST['shipping_shipo_city_id']) && empty($_POST['shipping_shipo_city_id'])) {
    612612            wc_add_notice('<a href="#shipping_shipo_city">' . __('Selectează un oraș valid din listă', 'shipo') . '</a>', 'error');
    613         }
    614        
    615         if (isset($_POST['billing_shipo_street_id']) && empty($_POST['billing_shipo_street_id'])) {
    616             wc_add_notice('<a href="#billing_shipo_street">' . __('Selectează o stradă validă din listă.', 'shipo') . '</a>', 'error');
    617         }
    618 
    619         if (isset($_POST['ship_to_different_address']) && isset($_POST['shipping_shipo_street_id']) && empty($_POST['shipping_shipo_street_id'])) {
    620             wc_add_notice('<a href="#shipping_shipo_street">' . __('Selectează o stradă validă din listă.', 'shipo') . '</a>', 'error');
    621613        }
    622614
  • shipo/trunk/includes/class-shipo-wc-shipping.php

    r3410852 r3415749  
    151151        // Try multiple sources for Shipo data
    152152        $shipo_city = '';
    153         $shipo_street = '';
    154153       
    155154        // 1. Try data from current session
    156155        if(WC()->customer) {
    157156            $shipo_city = WC()->customer->get_meta('shipping_shipo_city');
    158             $shipo_street = WC()->customer->get_meta('shipping_shipo_street');
    159157           
    160             if(empty($shipo_city) && empty($shipo_street)) {
     158            if(empty($shipo_city)) {
    161159                $shipo_city = WC()->customer->get_meta('billing_shipo_city');
    162                 $shipo_street = WC()->customer->get_meta('billing_shipo_street');
    163160            }
    164161        }
     
    195192                $shipo_city = sanitize_text_field(wp_unslash($_POST['shipping_shipo_city']));
    196193            }
    197             if(empty($shipo_street) && isset($_POST['shipping_shipo_street'])) {
    198                 $shipo_street = sanitize_text_field(wp_unslash($_POST['shipping_shipo_street']));
    199             }
    200194        }
    201195       
     
    204198            $shipo_city = $package['destination']['city'];
    205199        }
    206         if(empty($shipo_street) && isset($package['destination']['address_1'])) {
    207             $shipo_street = $package['destination']['address_1'];
    208         }
     200       
    209201        // 4. Try data from session
    210202        if(empty($shipo_city) && WC()->session && WC()->session->get('shipo_city')) {
    211203            $shipo_city = WC()->session->get('shipo_city');
    212204        }
    213         if(empty($shipo_street) && WC()->session && WC()->session->get('shipo_street')) {
    214             $shipo_street = WC()->session->get('shipo_street');
    215         }
     205       
    216206        if (!empty($shipo_city)) {
    217207            $package['destination']['shipo_city'] = sanitize_text_field($shipo_city);
    218208            $package['destination']['city'] = sanitize_text_field($shipo_city);
    219         }
    220         if (!empty($shipo_street)) {
    221             $package['destination']['address'] = sanitize_text_field($shipo_street);
    222             $package['destination']['shipo_address'] = sanitize_text_field($shipo_street);
    223             $package['destination']['address_1'] = sanitize_text_field($shipo_street);
    224209        }
    225210
  • shipo/trunk/readme.txt

    r3410852 r3415749  
    44Requires at least: 4.7
    55Tested up to: 6.9
    6 Stable tag: 1.3
     6Stable tag: 1.4
    77Requires PHP: 8.0
    88License: GPLv2 or later
     
    5454
    5555Showing all lockers
     56
     57= 1.4 =
     58
     59Checkout page improvements:
     60- Allows users to manually enter a street name in the free text field if the street is not found in the suggestions dropdown list
  • shipo/trunk/shipo.php

    r3410852 r3415749  
    33 * Plugin Name: Shipo
    44 * Description: Shipo connects your webshop with top couriers instantly, no contract. Ship to address or locker, pay only when parcels are delivered.
    5  * Version: 1.3
     5 * Version: 1.4
    66 * Author: Shipo
    77 * Author URI: https://shipo.ro
     
    1616
    1717// Define plugin constants
    18 define('SHIPO_PLUGIN_VERSION', '1.3.0');
     18define('SHIPO_PLUGIN_VERSION', '1.4.0');
    1919define('SHIPO_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2020define('SHIPO_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.