Changeset 3110987
- Timestamp:
- 07/02/2024 08:49:51 AM (21 months ago)
- Location:
- fuvar-hu-api/trunk
- Files:
-
- 4 edited
-
fuvarhu.php (modified) (2 diffs)
-
inc/shipping_method.php (modified) (11 diffs)
-
inc/variables.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
fuvar-hu-api/trunk/fuvarhu.php
r3051155 r3110987 2 2 3 3 /* 4 Plugin Name: Fuvar.HU Api5 Plugin URI: https:// uzlet.fuvar.hu6 description: Fuvar.hu B2B Rendszer api7 Version: 1.4.3.14 Plugin Name: Fuvar.HU Szállítási módok 5 Plugin URI: https://app.fuvar.hu 6 description: Bővítmény segítségével hozzáadhatod a fuvar.hu által kínált szolgáltatásokat a webshopodhoz 7 Version: 2 8 8 Author: Fuvar.hu 9 9 License: GPL2 … … 14 14 include('inc/error_handler.php'); 15 15 include('inc/variables.php'); 16 include('inc/settings.php');17 16 include('inc/product.php'); 18 include('inc/single_action.php');19 include('inc/group_action.php');20 include('inc/export.php');21 17 include('inc/shipping_method.php'); 22 23 function fuvarhu_message_sender(){24 25 if (isset($_GET["fuvar_message_sender"]) && !empty(sanitize_text_field($_GET['fuvar_message_sender']))){26 27 $message = sanitize_text_field($_GET['fuvar_message_sender']);28 29 switch ($message["type"]) {30 case 'updated':31 $fuvar_sender_message ='<div class="updated notice"><p>'.$message["message"].'</p></div>';32 break;33 34 case 'error':35 $fuvar_sender_message = '<div class="error notice"><p>'.$message["message"].'</p></div>';36 break;37 38 default:39 $fuvar_sender_message = '<div class="update-nag notice"><p>'.$message["message"].'</p></div>';40 break;41 }42 43 echo $fuvar_sender_message;44 }45 46 if(isset($_GET["download_meta_hash"]) && !empty(sanitize_text_field($_GET["download_meta_hash"]))){47 echo'<div class="error notice"><p>CSV exportálás sikertelen! Kérlek ellenörizd a beállításokat.</p></div>';48 fuvarhu_exportOrdersToCsv(sanitize_text_field($_GET["download_meta_hash"]));49 }50 }51 52 add_action( 'admin_notices', 'fuvarhu_message_sender');53 54 function fuvarhu_register_awaiting_shipment_order_status() {55 register_post_status( 'wc-awaiting-shipment', array(56 'label' => 'Átadva a fuvar.hu-nak',57 'public' => true,58 'exclude_from_search' => false,59 'show_in_admin_all_list' => true,60 'show_in_admin_status_list' => true,61 'label_count' => _n_noop( 'Átadva a fuvar.hu-nak', 'Átadva a fuvar.hu-nak' )62 ) );63 }64 add_action( 'init', 'fuvarhu_register_awaiting_shipment_order_status' );65 66 function fuvarhu_add_awaiting_shipment_to_order_statuses( $order_statuses ) {67 68 $new_order_statuses = array();69 70 // add new order status after processing71 foreach ( $order_statuses as $key => $status ) {72 73 $new_order_statuses[ $key ] = $status;74 75 if ( 'wc-processing' === $key ) {76 $new_order_statuses['wc-awaiting-shipment'] = 'Átadva a fuvar.hu-nak';77 }78 }79 80 return $new_order_statuses;81 }82 add_filter( 'wc_order_statuses', 'fuvarhu_add_awaiting_shipment_to_order_statuses' );83 84 85 18 } 86 19 -
fuvar-hu-api/trunk/inc/shipping_method.php
r3051056 r3110987 3 3 add_filter( 'woocommerce_shipping_methods', 'fuvarhu_registerfuvarhu_method' ); 4 4 function fuvarhu_registerfuvarhu_method( $methods ) { 5 $methods[ 'fuvarhu_hazhozdpd' ] = 'WC_Shipping_fuvarhu_HAZ_DPD';6 5 $methods[ 'fuvarhu_hazhoz' ] = 'WC_Shipping_fuvarhu_HAZ'; 6 $methods[ 'fuvarhu_hazhoz_dpd' ] = 'WC_Shipping_fuvarhu_HAZ_DPD'; 7 7 $methods[ 'fuvarhu_pop' ] = 'WC_Shipping_fuvarhu_POP'; 8 8 $methods[ 'fuvarhu_pos' ] = 'WC_Shipping_fuvarhu_POS'; 9 9 $methods[ 'fuvarhu_csp' ] = 'WC_Shipping_fuvarhu_CSP'; 10 $methods[ 'fuvarhu_aut_dpd' ] = 'WC_Shipping_fuvarhu_AUT_DPD'; 11 $methods[ 'fuvarhu_aut_pck' ] = 'WC_Shipping_fuvarhu_AUT_PCK'; 12 10 13 return $methods; 11 14 } … … 21 24 22 25 if( $value = $order->get_meta( '_store_pickup_data' ) ) { 23 echo'<p><strong>' . __( ' MPL Pont megnevezése', "woocommerce" ) . ':<br></strong> '.$value.'</p>';26 echo'<p><strong>' . __( 'Átvételi pont', "woocommerce" ) . ':<br></strong> '.$value.'</p>'; 24 27 } 25 28 echo'</div>'; … … 35 38 if( $key == 'order_status' ){ 36 39 $reordered_columns['fuvarhu-shipping'] = __( 'Szállítási mód','fuvarhu'); 37 $reordered_columns['fuvarhu-mpl-point'] = __( ' MPLPont','fuvarhu');40 $reordered_columns['fuvarhu-mpl-point'] = __( 'Átvételi Pont','fuvarhu'); 38 41 } 39 42 } … … 156 159 } 157 160 161 if(!class_exists("WC_Shipping_fuvarhu_AUT_DPD")){ 162 class WC_Shipping_fuvarhu_AUT_DPD extends WC_Shipping_Method { 163 public function __construct( $instance_id = 0 ) { 164 $this->id = 'fuvarhu_aut_dpd'; 165 $this->instance_id = absint( $instance_id ); 166 $this->method_title = __( 'Fuvar.hu - Automata & Csomagpont (DPD)' ); 167 $this->method_description = __( 'DPD Automata & Csomagpont a Fuvar.hu szerződött partnere által' ); 168 $this->supports = array( 169 'shipping-zones', 170 'instance-settings', 171 ); 172 $this->instance_form_fields = array( 173 'enabled' => array( 174 'title' => __( 'Engedélyezve' ), 175 'type' => 'checkbox', 176 'label' => __( 'Szállítási mód engedélyezése' ), 177 'default' => 'yes', 178 ), 179 'shipping_fee' => array( 180 'title' => __( 'Szállítás összege' ), 181 'type' => 'number', 182 'description' => __( 'A vevőre terhelt szállítási díj' ), 183 'default' => __( '0' ), 184 'desc_tip' => true 185 ) 186 ); 187 $this->enabled = $this->get_option( 'enabled' ); 188 $this->title = 'Automata & Csomagpont (DPD)'; 189 190 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); 191 } 192 193 public function calculate_shipping( $package = array() ) { 194 $this->add_rate( array( 195 'id' => $this->id . $this->instance_id, 196 'label' => $this->title, 197 'cost' => $this->get_option('shipping_fee'), 198 ) ); 199 } 200 } 201 } 202 203 if(!class_exists("WC_Shipping_fuvarhu_AUT_PCK")){ 204 class WC_Shipping_fuvarhu_AUT_PCK extends WC_Shipping_Method { 205 public function __construct( $instance_id = 0 ) { 206 $this->id = 'fuvarhu_aut_pck'; 207 $this->instance_id = absint( $instance_id ); 208 $this->method_title = __( 'Fuvar.hu - Automata & Csomagpont (Packeta)' ); 209 $this->method_description = __( 'Packeta Automata & Csomagpont a Fuvar.hu szerződött partnere által' ); 210 $this->supports = array( 211 'shipping-zones', 212 'instance-settings', 213 ); 214 $this->instance_form_fields = array( 215 'enabled' => array( 216 'title' => __( 'Engedélyezve' ), 217 'type' => 'checkbox', 218 'label' => __( 'Szállítási mód engedélyezése' ), 219 'default' => 'yes', 220 ), 221 'shipping_fee' => array( 222 'title' => __( 'Szállítás összege' ), 223 'type' => 'number', 224 'description' => __( 'A vevőre terhelt szállítási díj' ), 225 'default' => __( '0' ), 226 'desc_tip' => true 227 ) 228 ); 229 $this->enabled = $this->get_option( 'enabled' ); 230 $this->title = 'Automata & Csomagpont (Packeta)'; 231 232 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); 233 } 234 235 public function calculate_shipping( $package = array() ) { 236 $this->add_rate( array( 237 'id' => $this->id . $this->instance_id, 238 'label' => $this->title, 239 'cost' => $this->get_option('shipping_fee'), 240 ) ); 241 } 242 } 243 } 244 158 245 159 246 if(!class_exists("WC_Shipping_fuvarhu_POP")){ … … 184 271 ); 185 272 $this->enabled = $this->get_option( 'enabled' ); 186 $this->title = ' MPL PostaPontra (MOL, Coop) a Fuvarral';273 $this->title = 'PostaPont (MOL, Coop)'; 187 274 188 275 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); … … 226 313 ); 227 314 $this->enabled = $this->get_option( 'enabled' ); 228 $this->title = 'Postára kézbesítés a Fuvarral';315 $this->title = 'Postára kézbesítés (MPL)'; 229 316 230 317 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); … … 268 355 ); 269 356 $this->enabled = $this->get_option( 'enabled' ); 270 $this->title = ' MPL Csomagautomatába a Fuvarral';357 $this->title = 'Automata (MPL)'; 271 358 272 359 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); … … 289 376 function fuvarhu_store_pickup_field_update_order_meta( $order_id ) { 290 377 if ( isset($_POST['pickup_store']) && !empty(sanitize_text_field($_POST['pickup_store'])) ){ 291 $store_pickup = "<h3> Felvételi pont:</h3><br>".sanitize_text_field($_POST['pickup_store']);378 $store_pickup = "<h3>Átvételi pont:</h3><br>".sanitize_text_field($_POST['pickup_store']); 292 379 $order = wc_get_order( $order_id ); 293 380 $order->update_meta_data( '_store_pickup_data', sanitize_text_field($_POST['pickup_store']) ); … … 316 403 } 317 404 318 if($selected != "haz" && ($selected == "pos" || $selected == "csp" || $selected = "pop")){ 405 if(strpos($chosen_method_id,"fuvarhu_aut_dpd") !== false){ 406 $selected = "aut"; 407 } 408 409 if(strpos($chosen_method_id,"fuvarhu_aut_pck") !== false){ 410 $selected = "aut"; 411 } 412 413 if($selected != "haz" && ($selected == "pos" || $selected == "csp" || $selected = "pop" || $selected = "aut")){ 319 414 if(!isset($_POST['pickup_store']) || empty($_POST['pickup_store'])){ 320 415 wc_add_notice( __( 'Kérlek, válassz kézbesítési pontot!' ), 'error' ); … … 327 422 function fuvarhu_pickup_store_custom_field( $method, $index ) { 328 423 329 if( is_cart() || !in_array($method->method_id, ["fuvarhu_csp","fuvarhu_pop","fuvarhu_pos" ]) )424 if( is_cart() || !in_array($method->method_id, ["fuvarhu_csp","fuvarhu_pop","fuvarhu_pos","fuvarhu_aut_dpd","fuvarhu_aut_pck"]) ) 330 425 return; 331 426 … … 335 430 $options = []; 336 431 $selected = ""; 432 $provider = ""; 433 $show_for = ""; 337 434 338 435 if(strpos($chosen_method_id,"fuvarhu_csp") !== false){ 339 436 $selected = "csp"; 437 $provider = "mpl"; 438 $show_for = "fuvarhu_csp"; 340 439 } 341 440 342 441 if(strpos($chosen_method_id,"fuvarhu_pop") !== false){ 343 442 $selected = "pop"; 443 $provider = "mpl"; 444 $show_for = "fuvarhu_pop"; 344 445 } 345 446 346 447 if(strpos($chosen_method_id,"fuvarhu_pos") !== false){ 347 448 $selected = "pos"; 348 } 349 350 if($method->method_id != "fuvarhu_".$selected){ 449 $provider = "mpl"; 450 $show_for = "fuvarhu_pos"; 451 } 452 453 if(strpos($chosen_method_id,"fuvarhu_aut_dpd") !== false){ 454 $selected = "aut"; 455 $provider = "dpd"; 456 $show_for = "fuvarhu_aut_dpd"; 457 } 458 459 if(strpos($chosen_method_id,"fuvarhu_aut_pck") !== false){ 460 $selected = "aut"; 461 $provider = "pck"; 462 $show_for = "fuvarhu_aut_pck"; 463 } 464 465 if($method->method_id != $show_for){ 351 466 return; 352 467 } 353 468 354 $response = wp_remote_get("https://uzlet.fuvar.hu/dev/export/mplpoints?type=".$selected); 469 $response = wp_remote_post("https://backend.fuvar.hu/graphql/public/",[ 470 'headers' => [ 471 'Accept: application/json', 472 'Content-Type: application/json' 473 ], 474 'body' => ['query' => 'query getMplPoints($type: String! $search: String $provider: String) {collectorpoints(limit: 0, page: 1, type: $type, search: $search, provider: $provider) {data {id point_id title zip city address}}}', 'variables' => [ 475 'type' => $selected, 476 'search' => '', 477 'provider' => $provider 478 ]] 479 ]); 480 481 $pointserror = '<div class="wrapper-pickup_store" style="margin-top:8px; margin-bottom:16px">A pontok lekérése során hiba lépett fel kérlek próbáld meg késöbb</div><input type="hidden" value="" name="pickup_store">'; 482 355 483 if(wp_remote_retrieve_response_code($response) != 200){ 356 echo '<div class="wrapper-pickup_store" style="margin-top:8px; margin-bottom:16px">Sajnos a pontok betöltése sikertelen volt.</div><input type="hidden" value="" name="pickup_store">'; 484 echo $pointserror; 485 return; 357 486 }else{ 358 487 $mpl_points = wp_remote_retrieve_body( $response ); 359 488 $points = json_decode($mpl_points,true); 489 490 if(!isset($points['data']) || !isset($points['data']['collectorpoints']) || !isset($points['data']['collectorpoints']['data'])){ 491 echo $pointserror; 492 return; 493 } 494 495 $points = $points['data']['collectorpoints']['data']; 496 360 497 foreach ($points as $key => $value) { 361 498 $options[$value["title"]] = $value["city"]." - ".$value["title"]." (".$value["address"].")"; -
fuvar-hu-api/trunk/inc/variables.php
r2596076 r3110987 13 13 ]); 14 14 15 define('fuvarhu_plugin_setting_maps_api_key', 'fuvarhu_plugin_setting_maps_api_key');16 17 15 define('fuvarhu_plugin_other_setting_weight_measure', 'fuvarhu_plugin_other_setting_weight_measure'); 18 16 -
fuvar-hu-api/trunk/readme.txt
r3051155 r3110987 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 A bővítmény segítségével a Fuvar.hu rendeléskezelő felületén használt struktúrában töltheted le a megrendeléseidet.11 A mővítmény segítségével hozzáadhatod a fuvar.hu által kínált szolgáltatásokat a webshopodhoz. 12 12 13 13 == Description == 14 14 15 A bővítmény segítségével a Fuvar.hu rendeléskezelő felületén használt struktúrában töltheted le a megrendeléseidet, melyeket aztán egyszerűen feltölthetsz a felületre.A Plugin működéséhez szükséged van egy Fuvar.hu üzleti fiókra. Ha még nem rendelkezel ilyennel, itt tudsz regisztrálni:15 Bővítmény segítségével hozzáadhatod a fuvar.hu által kínált szolgáltatásokat a webshopodhoz .A Plugin működéséhez szükséged van egy Fuvar.hu üzleti fiókra. Ha még nem rendelkezel ilyennel, itt tudsz regisztrálni: 16 16 https://fuvar.hu/business 17 17
Note: See TracChangeset
for help on using the changeset viewer.