Changeset 2766855
- Timestamp:
- 08/05/2022 12:24:59 PM (4 years ago)
- Location:
- welco/trunk
- Files:
-
- 7 edited
-
Api.php (modified) (2 diffs)
-
assets/js/welco.js (modified) (1 diff)
-
assets/style.css (modified) (1 diff)
-
cron.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
welco-orders.php (modified) (10 diffs)
-
welco-woocommerce.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
welco/trunk/Api.php
r2565716 r2766855 111 111 $this->opts['http']['method'] = 'GET'; 112 112 $url = $this->url.$this->endpoints['getShipmentTrace'].$deliveryId; 113 114 113 return $this->request($url); 115 114 } … … 138 137 $this->opts['http']['content'] = json_encode($postdata); 139 138 $url = $this->url.$this->endpoints['linkTo'].$welkerId; 139 echo $url; 140 140 return $this->request($url); 141 141 } -
welco/trunk/assets/js/welco.js
r2747583 r2766855 2 2 $(document).ready(function () { 3 3 $("<div id=\"welcoContainer\" style=\"min-height:586px; width:100%;display:none\"></div>").insertBefore('#payment'); 4 if ($('ul#shipping_method li').length >= 1 && $('ul#shipping_method li input').val() == "welco") { 4 console.log($('ul#shipping_method li input:checked').val() ); 5 if ($('ul#shipping_method li').length >= 1 && $('ul#shipping_method li input:checked').val() == "welco") { 5 6 displayWelco(); 6 7 gestionPopup(); 7 } else { 8 } 9 10 $(document).on('change', '.shipping_method', function () { 11 console.log($('#shipping_method_0_welco:checked').length); 8 12 if ($('#shipping_method_0_welco:checked').length > 0) { 9 13 displayWelco(); 10 14 gestionPopup(); 11 } 12 $(document).on('change', '.shipping_method', function () { 13 if ($('#shipping_method_0_welco:checked').length > 0) { 14 displayWelco(); 15 gestionPopup(); 16 } else { 17 $("#welcoContainer").hide(); 18 $("#payment #place_order").removeAttr('disabled'); 19 } 20 }); 21 } 15 } else { 16 $("#welcoContainer").hide(); 17 $("#payment #place_order").removeAttr('disabled'); 18 } 19 }); 22 20 23 21 -
welco/trunk/assets/style.css
r2565716 r2766855 105 105 /*---------------*/ 106 106 107 #form-settings-welco div{ 108 margin: 2rem 0; 109 } 110 111 #form-settings-welco div label{ 112 display: block; 113 } 114 107 115 108 116 @media (min-width: 992px) { -
welco/trunk/cron.php
r2565716 r2766855 1 1 <?php 2 2 add_action('cron-welco',function (){ 3 $idShipping = welco_idShipping(); 4 $myFields = get_option('woocommerce_welco_'.$idShipping.'_settings'); 5 if($myFields['majAutoCron' === 'yes']){ 3 4 if(get_option("majAutoCron") === 'yes'){ 6 5 welco_getCommandesWelcoApi(); 7 6 } -
welco/trunk/readme.txt
r2747583 r2766855 4 4 Tags: Transporteur, colis, voisin, welco 5 5 Requires at least: 4.0 6 Tested up to: 5.7.27 Stable tag: 1. 0.18 Requires PHP: 5.46 Tested up to: 6.0.1 7 Stable tag: 1.1.0 8 Requires PHP: 7.4 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
welco/trunk/welco-orders.php
r2565716 r2766855 3 3 function welco_add_admin_page() { 4 4 add_menu_page( 5 ' Commandes welco', //Page Title6 ' Commandeswelco', //Menu Title5 'Welco', //Page Title 6 'welco', //Menu Title 7 7 'manage_options', //Capability 8 'commandes-welco', //Page slug 9 'welco_admin_page_html' //Callback to print html 8 'commandes-welco-parent', //Page slug 9 'welco_admin_parameters_page_html' //Callback to print html 10 ); 11 12 add_submenu_page( 13 'commandes-welco-parent', 14 'Commandes welco', 15 'Commandes welco', 16 'manage_options', 17 'commandes-welco', 18 'welco_admin_page_html' 10 19 ); 11 20 } … … 116 125 'on-hold' => 'En attente', 'pending'=> 'Attente paiement', 'completed' => 'Terminée', 'cancelled' => 'Annulée', 'refunded' => 'Remboursée', 'failed'=>'Échouée']; 117 126 $result = welco_wp_query(); 118 $idShipping = welco_idShipping();119 $myFields = get_option('woocommerce_welco_'.$idShipping.'_settings');120 127 121 128 … … 128 135 <th>Statut</th> 129 136 <th>Adresse de livraison</th> 137 <th>Type</th> 130 138 <th>Etiquette</th> 131 139 </tr> … … 141 149 <td><?php echo esc_html($order->get_billing_last_name()." ". $order->get_billing_first_name());?></td> 142 150 <td><?php echo esc_html($etatCommande[$order->get_status()]); ?></td> 143 <td><?php echo esc_html($shipper["welker_name"][0])?> <?php echo esc_html($shipper["welker_prenom"][0])?> <?php echo esc_html($shipper["welker_adresse"][0])?> <?php echo esc_html($shipper["welker_cp"][0])?> <?php echo esc_html($shipper["welker_ville"][0])?></td> 151 <?php if(get_post_meta(get_the_ID(), "welco_home")[0] == 1): // afficher la bonne adresse en fonction de domicile ou welker ?> 152 <td><?php echo esc_html($order->get_billing_first_name())?> <?php echo esc_html($order->get_billing_last_name())?> <?php echo esc_html($order->get_billing_address_1())?> <?php echo esc_html($order->get_billing_address_2())?> <?php echo esc_html($order->get_billing_postcode())?> <?php echo esc_html($order->get_billing_city())?></td> 153 <?php else: ?> 154 <td><?php echo esc_html($shipper["welker_name"][0])?> <?php echo esc_html($shipper["welker_prenom"][0])?> <?php echo esc_html($shipper["welker_adresse"][0])?> <?php echo esc_html($shipper["welker_cp"][0])?> <?php echo esc_html($shipper["welker_ville"][0])?></td> 155 <?php endif; ?> 156 157 <?php if(get_post_meta(get_the_ID(), "welco_home")[0] == 1): // afficher en fonction de si c'est welco ou home ?> 158 <td>Domicile</td> 159 <?php else: ?> 160 <td>Welker</td> 161 <?php endif; ?> 144 162 <!--<td><?php //$order->get_status() === $myFields["commandeEnAttenteWelco"]? '': '<a href="'.$urlImage.'" target="_blank"><img style="max-width : 100%;" src="'.$urlImage.'" alt=""></a>'; ?></td>--> 145 <td><?php if($order->get_status() != $myFields["commandeEnAttenteWelco"]){ ?>163 <td><?php if($order->get_status() != get_option("commandeEnAttenteWelco_welco")){ ?> 146 164 <a href="<?php echo esc_url($urlImage); ?>" target="_blank"><img style="max-width : 100%;" src="<?php echo esc_url($urlImage); ?>" alt=""></a> 147 165 <?php } ?> … … 153 171 } 154 172 function welco_getCommandesWelcoApi(){ 155 $zones = WC_Shipping_Zones::get_zones(); 156 foreach($zones as $zone){ 157 foreach($zone as $method){ 158 if(is_array($method)){ 159 foreach ($method as $m){ 160 if(is_a($m,'WC_Welco_Shipping_Method')){ 161 if($m->id == 'welco'){ 162 $idShipping = $m->get_instance_id(); 163 } 164 } 165 } 166 } 167 } 168 } 169 $shipper = get_option('woocommerce_welco_'.$idShipping.'_settings'); 170 $api = new ApiWelco(); 173 $api = new ApiWelco(); 171 174 $result = welco_wp_query(); 172 175 $path = __DIR__.'/../../uploads/welco/images/'; … … 174 177 mkdir("$path",0777,true) ; 175 178 } 176 while ( $result->have_posts() ) { 179 while ( $result->have_posts() ) { // parcours des commandes en gestion 177 180 $result->the_post(); 178 181 $order= new WC_Order(get_the_ID()); 182 $weight = 0; 183 foreach ($order->get_items() as $item){ // on calcule le poids de la commande 184 $weight += $item->get_product()->get_weight(); 185 } 179 186 $idCommande = get_the_ID(); 180 187 $delivery = get_post_meta( get_the_ID(), 'delivery', false ); 181 188 182 $dataApi = $api->getShipmentTrace($delivery[0]); 189 $dataApi = $api->getShipmentTrace($delivery[0]); // on va chercher l'étape de la commande dans l'API 183 190 if(isset($dataApi['lastStatus'])){ 184 if ($dataApi['lastStatus'] === 'SHIPPING_NOTCREATED' && get_post_status() === $shipper["commandeEnAttenteWelco"]){185 $order->update_status( $shipper["commandeStatutPretPourExpedition"]);191 if ($dataApi['lastStatus'] === 'SHIPPING_NOTCREATED' && get_post_status() === get_option("commandeEnAttenteWelco_welco")){ // si on a pas encore créé la commande dans l'API et qu'on a pas l'étiquette 192 $order->update_status(get_option("commandeStatusPretPourExpedition_welco")); 186 193 $resultEtiquette = $api->createShipment([ 187 'shipperName' => $shipper["title"] , 188 'shipperCountryIsoCode' => 'FR', 189 'shipperZipCode' => $shipper["cp"], 190 'shipperCity' => $shipper["ville"], 191 'shipperStreet' => $shipper["adresse"], 192 'shipperPhoneNumber' => $shipper["tel"], 193 'receiverCountryIsoCode' => 'FR', 194 'weight' => 0.1, 195 'reference' => get_the_ID(), 196 'deliveryId' => $delivery[0], 194 "deliveryId" => $delivery[0], 195 "ref" =>get_the_ID(), 196 "shipper"=> [ 197 "name" => get_bloginfo( "name"), 198 "phone" => get_option("tel_welco"), 199 "address" => [ 200 "streetName" => get_option("adresse_welco"), 201 "city" => get_option("ville_welco"), 202 "country" => "FR", 203 "primaryPostalCode" => get_option("cp_welco") 204 ] 205 ], 206 "package" => [ 207 "packageWeight" => $weight 208 ] 197 209 ]); 198 210 $imageName = $idCommande.'-'.$delivery[0].'.png'; 199 $uploads = wp_upload_dir(); 200 file_put_contents( $uploads["baseurl"].'/welco/images/'.$imageName, base64_decode($resultEtiquette['label'])); 201 //file_put_contents( __DIR__.'/../../uploads/welco/images/'.$imageName, base64_decode($resultEtiquette['label'])); 202 203 // var_dump($resultEtiquette);die; 204 update_post_meta($idCommande,'welker_name',sanitize_text_field($resultEtiquette['welker']['last_name'])); 205 update_post_meta($idCommande,'welker_prenom',sanitize_text_field($resultEtiquette['welker']['first_name'])); 206 update_post_meta($idCommande,'welker_ville',sanitize_text_field($resultEtiquette['welker']['city'])); 207 update_post_meta($idCommande,'welker_adresse',sanitize_text_field($resultEtiquette['welker']['street_name'])); 208 update_post_meta($idCommande,'welker_tel',sanitize_text_field($resultEtiquette['welker']['phone'])); 209 update_post_meta($idCommande,'welker_cp',sanitize_text_field($resultEtiquette['welker']['postal_code'])); 210 if(isset($resultEtiquette['welker']['mail'])) 211 update_post_meta($idCommande,'welker_mail',sanitize_text_field($resultEtiquette['welker']['mail'])); 212 } 213 if ($dataApi['lastStatus'] === 'SHIPPING_REQUESTED' && get_post_status() === $shipper["commandeEnAttenteWelco"]){ 214 $order->update_status($shipper["commandeStatutPretPourExpedition"]); 211 file_put_contents( $path.$imageName, base64_decode($resultEtiquette['label'])); // on sauvegarde l'étiquette 212 213 if(isset($resultEtiquette['welker'])){ 214 update_post_meta($idCommande,'welker_name',sanitize_text_field($resultEtiquette['welker']['last_name'])); 215 update_post_meta($idCommande,'welker_prenom',sanitize_text_field($resultEtiquette['welker']['first_name'])); 216 update_post_meta($idCommande,'welker_ville',sanitize_text_field($resultEtiquette['welker']['city'])); 217 update_post_meta($idCommande,'welker_adresse',sanitize_text_field($resultEtiquette['welker']['street_name'])); 218 update_post_meta($idCommande,'welker_tel',sanitize_text_field($resultEtiquette['welker']['phone'])); 219 update_post_meta($idCommande,'welker_cp',sanitize_text_field($resultEtiquette['welker']['postal_code'])); 220 if(isset($resultEtiquette['welker']['mail'])) 221 update_post_meta($idCommande,'welker_mail',sanitize_text_field($resultEtiquette['welker']['mail'])); 222 } 223 } 224 if ($dataApi['lastStatus'] === 'SHIPPING_REQUESTED' && get_post_status() === get_option("commandeStatusPretPourExpedition_welco")){ 225 $order->update_status(get_option("commandeStatutExpediee_welco")); 215 226 } 216 227 if ($dataApi['lastStatus'] === 'SHIPPING_DELIVERED'){ 217 $order->update_status( $shipper["commandeStatutLivree"]);228 $order->update_status(get_option("commandeStatutLivree_welco")); 218 229 } 219 230 } … … 227 238 die; 228 239 } 240 229 241 add_action('wp_ajax_update_welco', 'update_welco'); 230 242 add_action('wp_ajax_nopriv_update_welco', 'update_welco'); 231 243 function update_welco(){ 232 $post_id = sanitize_text_field($_POST['ids']);233 $idShipping = welco_idShipping(); 234 $shipper = get_option('woocommerce_welco_'.$idShipping.'_settings'); 235 236 foreach ($post_id as $id){237 $order= new WC_Order($id);238 if(("wc-".$order->get_status()) === $shipper["commandeStatutPretPourExpedition"])239 $order->update_status($shipper["commandeStatutExpediee"]);240 }244 $post_id = $_POST['ids']; 245 246 247 248 foreach ($post_id as $id) { 249 $order = new WC_Order($id); 250 if (("wc-" . $order->get_status()) === get_option("commandeStatusPretPourExpedition_welco")) 251 $order->update_status(get_option("commandeStatutExpediee_welco")); 252 } 241 253 welco_getCommandesWelcoWoocommerce(); 242 254 die; … … 244 256 function welco_wp_query(){ 245 257 246 $idShipping = welco_idShipping(); 247 $myFields = get_option('woocommerce_welco_'.$idShipping.'_settings'); 258 259 248 260 $args = [ 249 261 'post_type'=>'shop_order', 250 'post_status' => [ $myFields['commandeEnAttenteWelco'], $myFields['commandeStatutPretPourExpedition']],262 'post_status' => [get_option("commandeEnAttenteWelco_welco"), get_option("commandeStatusPretPourExpedition_welco")], 251 263 'posts_per_page' => '-1', 252 264 'meta_query'=>[ … … 255 267 'compare'=> '!=', 256 268 'value' => '' 257 ] 269 ], 258 270 ] 259 271 ]; 272 260 273 return new WP_Query( $args ); 261 274 } … … 278 291 return $idShipping; 279 292 } 293 294 function multiple_welco_idShipping($datas){ 295 $shipping = []; 296 $zones = WC_Shipping_Zones::get_zones(); 297 foreach($zones as $zone){ 298 foreach($zone as $method){ 299 if(is_array($method)){ 300 foreach ($method as $m){ 301 foreach ($datas as $data){ 302 if(is_a($m,$data["methode"])){ 303 if($m->id == $data["id"]){ 304 $shipping[] = $m->get_instance_id(); 305 } 306 } 307 } 308 } 309 } 310 } 311 } 312 return $shipping; 313 } -
welco/trunk/welco-woocommerce.php
r2747583 r2766855 3 3 Plugin Name: Welco 4 4 Description: Envoyez les colis à vos voisins pour ne jamais rater leur arrivé 5 Version: 1. 0.15 Version: 1.1.0 6 6 Author: Welco 7 7 Author URI: http://welco.io/ … … 9 9 10 10 11 require('class-wc-welco.php'); 11 require('class-wc-welco-home.php'); 12 require('class-wc-welco-welker.php'); 12 13 require_once('Api.php'); 13 14 require_once('welco-orders.php'); 14 15 require_once('cron.php'); 16 require_once(__DIR__."/template/admin-parameters.php"); 15 17 16 18 wp_localize_script('ajax_main', 'ajax_js', array( … … 25 27 function welco_action_checkout_order_processed( $order_id, $posted_data, $order ) { 26 28 session_start(); 27 if($_SESSION['welker_id'] != null){ 28 update_post_meta($order_id,'welker_name',sanitize_text_field($_SESSION['welker_name'])); 29 update_post_meta($order_id,'welker_prenom',sanitize_text_field($_SESSION['welker_prenom'])); 30 update_post_meta($order_id,'welker_ville',sanitize_text_field($_SESSION['welker_ville'])); 31 update_post_meta($order_id,'welker_mail',sanitize_text_field($_SESSION['welker_mail'])); 32 update_post_meta($order_id,'welker_adresse',sanitize_text_field($_SESSION['welker_adresse'])); 33 update_post_meta($order_id,'welker_tel', sanitize_text_field($_SESSION['welker_tel'])); 34 update_post_meta($order_id,'welker_cp',sanitize_text_field($_SESSION['welker_cp'])); 35 update_post_meta($order_id,'comment_etablishment',sanitize_text_field($_SESSION['comment_etablishment'])); 36 update_post_meta($order_id,'comment_firstname',sanitize_text_field($_SESSION['comment_firstname'])); 37 update_post_meta($order_id,'comment_lastname',sanitize_text_field($_SESSION['comment_lastname'])); 38 update_post_meta($order_id,'comment_phone',sanitize_text_field($_SESSION['comment_phone'])); 29 30 $shipping_method = @array_shift($order->get_shipping_methods()); 31 $shipping_method_id = $shipping_method['method_id']; 32 33 34 if($shipping_method_id != "welco" && $shipping_method_id != "welco-home"){ 35 return; 36 } 37 38 if($_SESSION['welker_id'] != null) { 39 update_post_meta($order_id, 'welker_id', sanitize_text_field($_SESSION['welker_id'])); 40 update_post_meta($order_id, 'welker_name', sanitize_text_field($_SESSION['welker_name'])); 41 update_post_meta($order_id, 'welker_prenom', sanitize_text_field($_SESSION['welker_prenom'])); 42 update_post_meta($order_id, 'welker_ville', sanitize_text_field($_SESSION['welker_ville'])); 43 update_post_meta($order_id, 'welker_mail', sanitize_text_field($_SESSION['welker_mail'])); 44 update_post_meta($order_id, 'welker_adresse', sanitize_text_field($_SESSION['welker_adresse'])); 45 update_post_meta($order_id, 'welker_tel', sanitize_text_field($_SESSION['welker_tel'])); 46 update_post_meta($order_id, 'welker_cp', sanitize_text_field($_SESSION['welker_cp'])); 47 update_post_meta($order_id, 'comment_etablishment', sanitize_text_field($_SESSION['comment_etablishment'])); 48 update_post_meta($order_id, 'comment_firstname', sanitize_text_field($_SESSION['comment_firstname'])); 49 update_post_meta($order_id, 'comment_lastname', sanitize_text_field($_SESSION['comment_lastname'])); 50 update_post_meta($order_id, 'comment_phone', sanitize_text_field($_SESSION['comment_phone'])); 39 51 $shippingDetail['comment']['etablishment'] = sanitize_text_field($_SESSION['comment_etablishment']); 40 52 $shippingDetail['comment']['firstname'] = sanitize_text_field($_SESSION['comment_firstname']); 41 53 $shippingDetail['comment']['lastname'] = sanitize_text_field($_SESSION['comment_lastname']); 42 54 $shippingDetail['comment']['phone'] = sanitize_text_field($_SESSION['comment_phone']); 43 $api = new ApiWelco(); 44 $postdata = [ 45 'email' => $order->get_billing_email(), 46 'phone' => $order->get_billing_phone(), 47 'ref' => $order_id, 48 'first_name' => $order->get_billing_first_name(), 49 'last_name' => $order->get_billing_last_name(), 50 'street_number' => '', 51 'street_name' => $order->get_billing_address_1(), 52 'additional_address' => $order->get_billing_address_2(), 53 'postal_code' => $order->get_billing_postcode(), 54 'city' => $order->get_billing_city(), 55 'data' => !empty($shippingDetail['comment']) ? $shippingDetail['comment'] : null, 56 ]; 57 58 $response = $api->linkTo($_SESSION['welker_id'], $postdata); 59 update_post_meta($order_id,'delivery',sanitize_text_field($response["delivery"])); 60 $zones = WC_Shipping_Zones::get_zones(); 61 foreach($zones as $zone){ 62 foreach($zone as $method){ 63 if(is_array($method)){ 64 foreach ($method as $m){ 65 if(is_a($m,'WC_Welco_Shipping_Method')){ 66 if($m->id == 'welco'){ 67 $idShipping = $m->get_instance_id(); 68 } 69 } 70 } 71 } 72 } 73 } 74 $my_fields = get_option('woocommerce_welco_'.$idShipping.'_settings'); 75 //var_dump($my_fields['commandeEnAttenteWelco']); 76 $order->update_status($my_fields['commandeEnAttenteWelco']); 77 //die; 78 } 55 }else{ 56 update_post_meta($order_id,'welco_home',true); 57 } 58 59 79 60 session_destroy(); 80 61 81 82 /*if (!$response || 'success' !== $response['result']) { 83 $this->sendSentryEvent('Unable to contact Welco service', ['post' => $postdata, 'predict' => $shippingDetail]); 84 62 } 63 64 add_action('woocommerce_order_status_processing', 'payment_complete_callback'); 65 function payment_complete_callback($order_id) 66 { 67 68 $order = wc_get_order($order_id); 69 70 $shipping_method = @array_shift($order->get_shipping_methods()); 71 $shipping_method_id = $shipping_method['method_id']; 72 73 74 if($shipping_method_id != "welco" && $shipping_method_id != "welco-home"){ 85 75 return; 86 }*/ 87 76 } 77 78 $weight = 0; 79 foreach ($order->get_items() as $item){ 80 $weight += $item->get_product()->get_weight(); 81 } 82 83 84 $api = new ApiWelco(); 85 86 $postdata = [ 87 "ref" => $order_id, 88 "shopper" => [ 89 "email" => $order->get_billing_email(), 90 "phone" => $order->get_billing_phone(), 91 "firstName" => $order->get_billing_first_name(), 92 "lastName" => $order->get_billing_last_name(), 93 "name" => $order->get_billing_first_name(), 94 "address" => [ 95 "streetNumber" => "", 96 "streetName" => $order->get_billing_address_1(), 97 "additionnalAddress" => $order->get_billing_address_2(), 98 "city" => $order->get_billing_city(), 99 "country" => "FR", 100 "primaryPostalCode" => $order->get_billing_postcode(), 101 ] 102 ], 103 "package" => [ 104 "packageWeight" => $weight, 105 ] 106 ]; 107 108 if(get_post_meta(get_the_ID(), "welco_home")[0] == 1) { 109 $response = $api->linkTo("", $postdata); 110 }else { 111 $response = $api->linkTo(get_post_meta($order_id, 'welker_id')[0], $postdata); 112 } 113 114 update_post_meta($order_id,'delivery',sanitize_text_field($response["delivery"])); 115 $order->update_status(get_option("commandeEnAttenteWelco_welco")); 116 welco_getCommandesWelcoApi(); 88 117 } 89 118 … … 116 145 add_action('wp_enqueue_scripts', 'welco_callback_for_setting_up_scripts'); 117 146 function welco_callback_for_setting_up_scripts() { 118 $zones = WC_Shipping_Zones::get_zones();119 foreach($zones as $zone){120 foreach($zone as $method){121 if(is_array($method)){122 foreach ($method as $m){123 if(is_a($m,'WC_Welco_Shipping_Method')){124 if($m->id == 'welco'){125 $idShipping = $m->get_instance_id();126 }127 }128 }129 }130 }131 }132 $my_fields = get_option('woocommerce_welco_'.$idShipping.'_settings');133 147 wp_register_style( 'namespace', plugins_url('/assets/style.css', __FILE__)); 134 148 wp_enqueue_style( 'namespace' ); 135 149 wp_enqueue_script( 'namespace', plugins_url('/assets/js/welco.js', __FILE__), array('jquery')); 136 wp_enqueue_script( '', $my_fields['welcowidgeturl'].'/widget.js',array(),false,true); 137 } 138 139 140 function head_welco(){ 141 $zones = WC_Shipping_Zones::get_zones(); 142 foreach($zones as $zone){ 143 foreach($zone as $method){ 144 if(is_array($method)){ 145 foreach ($method as $m){ 146 if(is_a($m,'WC_Welco_Shipping_Method')){ 147 if($m->id == 'welco'){ 148 $idShipping = $m->get_instance_id(); 149 } 150 } 151 } 152 } 153 } 154 } 155 $my_fields = get_option('woocommerce_welco_'.$idShipping.'_settings'); ?> 150 wp_enqueue_script( '', get_option("welcowidgeturl_welco").'/widget.js',array(),false,true); 151 } 152 153 154 function head_welco(){?> 156 155 <script type="text/javascript"> 157 var WnG_MapBoxToken = '<?php echo esc_js( $my_fields["mapboxkey"]);?>';158 var welcoToken = '<?php echo esc_js( $my_fields["welcokey"]);?>';156 var WnG_MapBoxToken = '<?php echo esc_js(get_option("mapboxkey_welco"));?>'; 157 var welcoToken = '<?php echo esc_js(get_option("welcokey_welco"));?>'; 159 158 var WnG_container = "welcoContainer"; 160 159 var WnG_delay = 2; … … 164 163 var welcoBaseDir = "<?php echo esc_url(plugins_url('welco-woocommerce'), __FILE__); ?>" 165 164 //var welcoCartId = "82"; 166 var WnG_merchantToken = "<?php echo esc_js( $my_fields["welcokey"]);?>";165 var WnG_merchantToken = "<?php echo esc_js(get_option("welcokey_welco"));?>"; 167 166 var WnG_startAddress = "Paris"; 168 167 var customer_first_name = ""; … … 183 182 function welco_my_custom_checkout_field_display_admin_order_meta( $order ){ 184 183 $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id; 185 echo '<p><strong>'.__('Nom voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_name', true ) . '</p>'; 186 echo '<p><strong>'.__('Prénom voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_prenom', true ) . '</p>'; 187 echo '<p><strong>'.__('Mail voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_mail', true ) . '</p>'; 188 echo '<p><strong>'.__('Tel voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_tel', true ) . '</p>'; 189 echo '<p><strong>'.__('Adresse voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_adresse', true ) . '</p>'; 190 echo '<p><strong>'.__('Ville voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_ville', true ) . '</p>'; 191 echo '<p><strong>'.__('Code postal voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_cp', true ) . '</p>'; 192 echo '<p><strong>'.__('Établissement voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_etablishment', true ) . '</p>'; 193 echo '<p><strong>'.__('Nom voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_firstname', true ) . '</p>'; 194 echo '<p><strong>'.__('Prénom voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_lastname', true ) . '</p>'; 195 echo '<p><strong>'.__('Tel voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_phone', true ) . '</p>'; 196 echo '<p><strong>'.__('delivery').':</strong> ' . get_post_meta( $order_id, 'delivery', true ) . '</p>'; 184 if(isset(get_post_meta($order_id, 'welker_id')[0])){ 185 echo '<p><strong>'.__('Nom voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_name', true ) . '</p>'; 186 echo '<p><strong>'.__('Prénom voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_prenom', true ) . '</p>'; 187 echo '<p><strong>'.__('Mail voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_mail', true ) . '</p>'; 188 echo '<p><strong>'.__('Tel voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_tel', true ) . '</p>'; 189 echo '<p><strong>'.__('Adresse voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_adresse', true ) . '</p>'; 190 echo '<p><strong>'.__('Ville voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_ville', true ) . '</p>'; 191 echo '<p><strong>'.__('Code postal voisin (Livraison Welco)').':</strong> ' . get_post_meta( $order_id, 'welker_cp', true ) . '</p>'; 192 echo '<p><strong>'.__('Établissement voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_etablishment', true ) . '</p>'; 193 echo '<p><strong>'.__('Nom voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_firstname', true ) . '</p>'; 194 echo '<p><strong>'.__('Prénom voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_lastname', true ) . '</p>'; 195 echo '<p><strong>'.__('Tel voisin (Livraison Welco - Voisin suggéré)').':</strong> ' . get_post_meta( $order_id, 'comment_phone', true ) . '</p>'; 196 } 197 198 $shipping_method = @array_shift($order->get_shipping_methods()); 199 $shipping_method_id = $shipping_method['method_id']; 200 201 if($shipping_method_id == "welco-home"){ 202 echo '<p><strong>'.__('delivery').':</strong> ' . get_post_meta( $order_id, 'delivery', true ) . '</p>'; 203 } 204 197 205 } 198 206 … … 252 260 if ($isUpdateNeeded) { 253 261 session_start(); 262 254 263 $_SESSION['welker_mail'] = $shippingDetail['mail']; 255 264 $_SESSION['welker_tel'] = $shippingDetail['gsm']; … … 262 271 $_SESSION['welker_id'] = $welkerId; 263 272 } 273 274 echo $welkerId; 275 276 264 277 return $result; 265 278 } 266 279 280 281 282 283 284 285 286 287 288 289 290 291 292
Note: See TracChangeset
for help on using the changeset viewer.