Changeset 2884972
- Timestamp:
- 03/22/2023 01:22:56 PM (3 years ago)
- Location:
- hfd-epost-integration/trunk
- Files:
-
- 6 edited
-
class/App.php (modified) (2 diffs)
-
hfd-woocommerce-epost.php (modified) (1 diff)
-
js/epost-list.js (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
templates/cart/epost-additional.php (modified) (1 diff)
-
templates/cart/footer.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hfd-epost-integration/trunk/class/App.php
r2834354 r2884972 42 42 add_filter('woocommerce_order_shipping_to_display', array($this, 'emailPickupInfo'), 10, 2); 43 43 44 add_action( 'woocommerce_after_shipping_rate', array($this, 'renderAdditional'));44 add_action( 'woocommerce_after_shipping_rate', array($this, 'renderAdditional' ) ); 45 45 add_action('woocommerce_checkout_order_processed', array($this, 'convertPickupToOrder'), 10, 3); 46 46 add_action('woocommerce_new_order', array($this, 'convertPickupToOrderOptional'), 10, 2); … … 411 411 * @return void 412 412 */ 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' ){ 416 416 return; 417 417 } 418 418 419 /* @var \Hfd\Woocommerce\Shipping\Additional $additionalBLock */ 419 420 $additionalBLock = Container::create('Hfd\Woocommerce\Shipping\Additional'); -
hfd-epost-integration/trunk/hfd-woocommerce-epost.php
r2834354 r2884972 4 4 Plugin URI: 5 5 Description: 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. 46 Version: 1.5 7 7 Author: HFD 8 8 Author URI: https://www.hfd.co.il -
hfd-epost-integration/trunk/js/epost-list.js
r2766592 r2884972 3 3 config: {}, 4 4 spots: {}, 5 additonalBlock: null,5 additonalBlock: $j('#israelpost-additional'), 6 6 isLoading: false, 7 7 selectedCity: null, 8 8 9 9 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(); 19 19 }, 20 20 … … 23 23 this.shippingInput = this.additonalBlock.siblings('input.shipping_method'); 24 24 25 if (!this.shippingInput.length){25 if( !this.shippingInput.length ){ 26 26 return; 27 27 } 28 28 29 29 this.initCustomSelect(); 30 if (!this.shippingInput.is(':checked')){30 if( !this.shippingInput.is( ':checked' ) ){ 31 31 this.additonalBlock.hide(); 32 32 } … … 74 74 }, 75 75 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 } 104 105 }, 105 106 -
hfd-epost-integration/trunk/readme.txt
r2834354 r2884972 4 4 Donate link: 5 5 Requires at least: 4.0 6 Tested up to: 6. 17 Stable tag: 1. 46 Tested up to: 6.2 7 Stable tag: 1.5 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later -
hfd-epost-integration/trunk/templates/cart/epost-additional.php
r2768357 r2884972 21 21 </a> 22 22 </p> 23 <?php else: ?> 23 <?php else: 24 $helper = \Hfd\Woocommerce\Container::get( 'Hfd\Woocommerce\Helper\Spot' ); 25 ?> 24 26 <div class="spot-list-container"> 25 27 <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()"> 27 29 <option value=""><?php echo esc_html( __( 'Select city', 'hfd-integration' ) ); ?></option> 28 30 </select> -
hfd-epost-integration/trunk/templates/cart/footer.php
r2768357 r2884972 61 61 ?> 62 62 <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 }); 72 85 }); 73 86 </script>
Note: See TracChangeset
for help on using the changeset viewer.