Changeset 3059826
- Timestamp:
- 03/27/2024 01:27:39 PM (2 years ago)
- Location:
- hfd-epost-integration/trunk
- Files:
-
- 9 edited
-
class/Admin.php (modified) (1 diff)
-
class/App.php (modified) (2 diffs)
-
class/Helper/Hfd/Api.php (modified) (1 diff)
-
class/Helper/Spot.php (modified) (2 diffs)
-
css/style.css (modified) (1 diff)
-
hfd-woocommerce-epost.php (modified) (2 diffs)
-
js/map.js (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
-
templates/cart/footer.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hfd-epost-integration/trunk/class/Admin.php
r3011172 r3059826 75 75 'headers' => array( 76 76 'Authorization' => 'Bearer '.$authToken 77 ) 77 ), 78 'sslverify' => false 78 79 ); 79 80 $response_run = wp_remote_get( $cancel_shipment_url, $args ); -
hfd-epost-integration/trunk/class/App.php
r3026812 r3059826 211 211 'headers' => array( 212 212 'Authorization' => 'Bearer '.$authToken 213 ) 213 ), 214 'sslverify' => false 214 215 ); 215 216 $printLabelUrl = str_replace( "{RAND}", $epost_ship_number, $printLabelUrl ); … … 457 458 public function renderPickupMap() 458 459 { 459 $template = Container::create('Hfd\Woocommerce\Template'); 460 echo $template->fetchView('cart/footer.php'); 460 if( function_exists( 'is_cart' ) && function_exists( 'is_checkout' ) && ( is_cart() || is_checkout() ) ){ 461 $template = Container::create('Hfd\Woocommerce\Template'); 462 echo $template->fetchView('cart/footer.php'); 463 } 461 464 } 462 465 -
hfd-epost-integration/trunk/class/Helper/Hfd/Api.php
r2811095 r3059826 116 116 $args = array( 117 117 'timeout' => 15, 118 'user-agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13' 118 'user-agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13', 119 'sslverify' => false 119 120 ); 120 121 // add bearer token into request -
hfd-epost-integration/trunk/class/Helper/Spot.php
r2766592 r3059826 25 25 $args = array( 26 26 'timeout' => 15, 27 'sslverify' => false 27 28 ); 28 29 … … 62 63 $args = array( 63 64 'timeout' => 15, 65 'sslverify' => false 64 66 ); 65 67 $response = wp_remote_get( $this->getServiceUrl( $city ), $args ); -
hfd-epost-integration/trunk/css/style.css
r2766592 r3059826 235 235 } 236 236 237 .gm-style .gm-style-iw{ 238 padding: 0 !important; 239 } 240 .gm-style .gm-style-iw-d{ 241 overflow: auto !important; 242 } 243 237 244 @media only screen and (max-width: 767px){ 238 245 #legend { -
hfd-epost-integration/trunk/hfd-woocommerce-epost.php
r3026812 r3059826 2 2 /* 3 3 Plugin Name: HFD ePost Integration 4 Requires Plugins: woocommerce 4 5 Plugin URI: 5 6 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. 87 Version: 1.9 7 8 Author: HFD 8 9 Author URI: https://www.hfd.co.il … … 11 12 */ 12 13 13 //if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option( 'active_plugins')))) { 14 // return; 15 //} 14 //return if woocommerce not installed 15 if( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){ 16 return; 17 } 16 18 17 19 define( 'HFD_EPOST_PATH', dirname( __FILE__ ) ); -
hfd-epost-integration/trunk/js/map.js
r2889280 r3059826 4 4 infoWindows: {}, 5 5 markers: {}, 6 current_spot: null, 6 7 7 8 init: function () { 8 9 var _this = this; 9 $j(document).on('click', '.close-infoBox', function (event) {10 _this.closeInfobox();11 event.preventDefault();12 }.bind(this));13 14 10 $j( "body" ).on( 'click', '.selectspot', function (e) { 15 11 e.preventDefault(); 16 12 var spotId = $j(this).data('shopid'); 17 _this.selectSpot( _this.markers[spotId].json);13 _this.selectSpot(); 18 14 }); 19 15 20 16 var searchInput = $j('#pac-input'); 21 17 $j(window).trigger('resize'); 22 18 23 19 this.drawMap(); 24 20 }, 25 21 26 drawMap: function(){ 22 drawMap: async function(){ 23 const { AdvancedMarkerElement } = await google.maps.importLibrary("marker"); 24 //const { AutocompleteService } = await google.maps.importLibrary("places"); 25 27 26 this.map = new google.maps.Map(document.getElementById('israelpost-map'), { 28 27 center: {lat: 32.063940, lng: 34.837801}, 29 zoom: 12 28 zoom: 12, 29 mapId: 'hfd19integration' 30 30 }); 31 31 var map = this.map; … … 36 36 this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(searchContainer); 37 37 38 var autocomplete = new google.maps.places.Autocomplete(input);39 autocomplete.bindTo('bounds', this.map);38 //const autocomplete = new AutocompleteService(); 39 //autocomplete.bindTo('bounds', this.map); 40 40 41 var marker = new google.maps.Marker({41 const amarker = new AdvancedMarkerElement({ 42 42 map: map, 43 anchorPoint: new google.maps.Point(0, -29)44 43 }); 45 44 46 autocomplete.addListener('place_changed', function () {47 marker.setVisible(false);45 /* autocomplete.addListener('place_changed', function () { 46 amarker.setVisible(false); 48 47 var place = autocomplete.getPlace(); 49 48 … … 59 58 map.setZoom(17); // Why 17? Because it looks good. 60 59 } 61 marker.setIcon(({60 amarker.setIcon(({ 62 61 url: place.icon, 63 62 size: new google.maps.Size(71, 71), … … 66 65 scaledSize: new google.maps.Size(35, 35) 67 66 })); 68 marker.setPosition(place.geometry.location);69 marker.setVisible(true);70 }); 67 amarker.setPosition(place.geometry.location); 68 amarker.setVisible(true); 69 }); */ 71 70 }, 72 73 pinMarkers: function (spots) { 71 buildContent: function( spot ){ 72 var icon = IsraelPostCommon.getConfig('redDotPath'); 73 if (spot.type == 'חנות') { 74 var icon = IsraelPostCommon.getConfig('grnDotPath'); 75 } 76 77 const content = document.createElement("div"); 78 content.classList.add("infoBox"); 79 content.innerHTML = '<div class="details">' + 80 '<h3>' + spot.name + '</h3>' + 81 '<p>' + spot.street + ' ' + spot.house + 82 '<br />' + spot.city + 83 '<br />' + spot.remarks + 84 '</p><ul class="hours">' + this.generateHours(spot) + '</ul>' + 85 '<a href="#" data-shopid="' + spot.n_code + '" class="selectspot">' + Translator.translate('Select') + ' ' + spot.type + ' »</a></div>'; 86 87 return content; 88 }, 89 90 pinMarkers: async function (spots) { 91 const { AdvancedMarkerElement } = await google.maps.importLibrary("marker"); 92 const { Map, InfoWindow } = await google.maps.importLibrary("maps"); 93 74 94 spots = spots || {}; 75 95 var _this = this, 76 96 infoboxOptions, 77 97 spot; 78 98 99 var info_window = null; 100 79 101 //loop trough shops 80 102 for (i in spots) { 81 103 spot = spots[i]; 82 infoboxOptions = { 83 content: '<div><a href="#" class="close close-infoBox"></a>' + 84 '<h3>' + spot.name + '</h3>' + 85 '<p>' + spot.street + ' ' + spot.house + 86 '<br />' + spot.city + 87 '<br />' + spot.remarks + 88 '</p><ul class="hours">' + _this.generateHours(spot) + '</ul>' + 89 '<a href="#" data-shopid="' + spot.n_code + '" class="selectspot">' + Translator.translate('Select') + ' ' + spot.type + ' »</a></div>', 90 disableAutoPan: false, 91 maxWidth: 0, 92 pixelOffset: new google.maps.Size(0, -10), 93 zIndex: null, 94 boxStyle: { 95 width: "235px" 96 }, 97 closeBoxURL: "", 98 infoBoxClearance: new google.maps.Size(20, 20), 99 isHidden: false, 100 pane: "floatPane", 101 enableEventPropagation: true 102 }; 103 this.infoWindows[spot.n_code] = new InfoBox(infoboxOptions); 104 104 105 105 var icon = IsraelPostCommon.getConfig('redDotPath'); 106 106 if (spot.type == 'חנות') { 107 107 var icon = IsraelPostCommon.getConfig('grnDotPath'); 108 108 } 109 110 const hfdImg = document.createElement("img"); 111 hfdImg.src = icon; 112 109 113 //google maps marker 110 this.markers[spot.n_code] = new google.maps.Marker({114 const marker = new AdvancedMarkerElement({ 111 115 position: new google.maps.LatLng(spot.latitude, spot.longitude), 112 116 map: this.map, 113 icon: icon, 114 shape: null, 115 zIndex: 1, 116 json: spot 117 content: hfdImg, 118 zIndex: null, 117 119 }); 118 google.maps.event.addListener(this.markers[spot.n_code], 'click', (function (marker) { 119 return function () { 120 _this.clickSpot(marker.json.n_code); 121 }.bind(this) 122 }.bind(this))(this.markers[spot.n_code])); 120 121 marker.spot = spot; 122 marker.addListener("click", ({domEvent, latLng}) => { 123 if( info_window ){ 124 info_window.close(); 125 } 126 // Create an info window to share between markers. 127 info_window = new InfoWindow({ 128 content: this.buildContent( marker.spot ), 129 }); 130 this.current_spot = marker.spot; 131 //infoWindow.setContent( marker.content ); 132 info_window.open({ 133 anchor: marker, 134 }); 135 }); 123 136 } 124 137 … … 130 143 clickSpot: function (spotid) { 131 144 //move map to center of this marker 132 this.map.panTo(this.markers[spotid].getPosition());145 // this.map.panTo(this.markers[spotid].getPosition()); 133 146 //open the infobubble 134 147 if (this.activeInfo != null) { … … 145 158 }, 146 159 147 selectSpot: function (spot) { 160 selectSpot: function () { 161 var spot = this.current_spot; 148 162 var html = this.spotTemplate = '<strong>' + Translator.translate('Branch name') + ':</strong> '+ spot.name +' <br/>' 149 163 + '<strong>' + Translator.translate('Branch address') + ':</strong> '+ spot.street +' '+ spot.house +', '+ spot.city +' <br/>' -
hfd-epost-integration/trunk/readme.txt
r3026812 r3059826 4 4 Donate link: 5 5 Requires at least: 4.0 6 Tested up to: 6. 47 Stable tag: 1. 86 Tested up to: 6.5 7 Stable tag: 1.9 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later -
hfd-epost-integration/trunk/templates/cart/footer.php
r3021501 r3059826 12 12 $setting = \Hfd\Woocommerce\Container::get( 'Hfd\Woocommerce\Setting' ); 13 13 $layout = $setting->get( 'betanet_epost_layout' ); 14 ?> 15 <?phpif( $layout == 'map' ): ?>14 15 if( $layout == 'map' ): ?> 16 16 <div id="israelpost-modal" style="display: none"> 17 17 <div id="israelpost-autocompelete"> … … 30 30 <div id="israelpost-map" style="width: 100%; max-width: 750px; height: 450px;"></div> 31 31 </div> 32 <script> 33 var apiKey = '<?php echo $setting->getGoogleApiKey(); ?>'; 34 (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src='https://maps.googleapis.com/maps/api/js?'+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({ 35 key: apiKey, 36 v: "quarterly", 37 }); 38 </script> 32 39 <?php 33 wp_enqueue_script( 'hfd-gscript', '//maps.googleapis.com/maps/api/js?v=3.37&libraries=places&language=he&key='.$setting->getGoogleApiKey() );34 wp_enqueue_script( 'hfd-gmaps', $this->getSkinUrl( 'js/infobox.js' ) );35 40 wp_enqueue_script( 'hfd-common-js', $this->getSkinUrl( 'js/common.js' ) ); 36 wp_enqueue_script( 'hfd-gmap-js', $this->getSkinUrl( 'js/map.js' ) );41 wp_enqueue_script( 'hfd-gmap-js', $this->getSkinUrl( 'js/map.js' ), array(), time() ); 37 42 wp_enqueue_script( 'hfd-pickup-post', $this->getSkinUrl( 'js/pickup-post.js' ) ); 38 43 wp_enqueue_script( 'hfd-checkout-js', $this->getSkinUrl( 'js/checkout.js' ) ); … … 66 71 var mainBlock = jQuery('#israelpost-additional'); 67 72 if( mainBlock.parent().find( 'input.shipping_method' ).is(':checked') ){ 68 /* if( !hfdObj ){69 IsraelPostCommon.init({70 saveSpotInfoUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php' ) ); ?>',71 getSpotsUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php?action=get_spots' ) ); ?>',72 redDotPath: '<?php echo esc_html( $this->getSkinUrl( 'images/red-dot.png' ) ); ?>',73 grnDotPath: '<?php echo esc_html( $this->getSkinUrl( '/images/grn-dot.png' ) ); ?>'74 });75 IsraelPost.showPickerPopup(e);76 //hfdObj = true;77 } */78 //console.log( hfdObj );79 73 mainBlock.show(); 80 74 }else{ … … 91 85 var spotId = $j(this).data('shopid'); 92 86 //console.log( IsraelPostMap.markers ); 93 spot = IsraelPostMap. markers[spotId].json;87 spot = IsraelPostMap.current_spot; 94 88 95 89 var html = this.spotTemplate = '<strong>' + Translator.translate('Branch name') + ':</strong> '+ spot.name +' <br/>'
Note: See TracChangeset
for help on using the changeset viewer.