admin_url( 'admin-ajax.php' ), 'plugin_dir_url' => plugin_dir_url( __FILE__ ), 'rendelesi_azonosito' => __('Order ID:', 'allpacka' ), 'fuvarlevelszam' => __('Waybill number:', 'allpacka' ), 'ugyfelszolgalat_kuldi' => __('The waybill will be sent to you by the Allpacka.com Customer Service.', 'allpacka' ), 'megtekintes' => __('View', 'allpacka' ), 'nyomkovetes' => __('Tracking', 'allpacka' ), ); wp_localize_script( 'allpacka_admin_js', 'allpacka_adatok', $allpacka_adatok ); } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_action( 'wp_enqueue_scripts', 'allpacka_mask_js' ); function allpacka_mask_js() { wp_enqueue_script( 'allpacka_frontend_js', plugins_url('js/frontend.js', __FILE__) ); wp_enqueue_script( 'allpacka_mask1', plugins_url('js/inputmask.js', __FILE__), '', null, false ); wp_enqueue_script( 'allpacka_mask2', plugins_url('js/jquery.inputmask.js', __FILE__), '', null, false ); wp_enqueue_script( 'allpacka_mask3', plugins_url('js/inputmask.numeric.extensions.js', __FILE__), '', null, false ); } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_action( 'admin_enqueue_scripts', 'allpacka_admin_css' ); function allpacka_admin_css() { wp_enqueue_style( 'allpacka_admin_css', plugins_url('css/admin.css', __FILE__) ); } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ register_activation_hook( __FILE__, 'allpacka_mappa' ); function allpacka_mappa(){ $upload_dir = wp_upload_dir(); if (!is_dir( $upload_dir['basedir'].'/allpacka' )) { mkdir( $upload_dir['basedir'].'/allpacka', 0777, true ); } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_filter('manage_edit-shop_order_columns' , 'allpacka_order_column_title', 10); function allpacka_order_column_title( $columns ) { if( get_option( 'allpacka_allapot' ) == 'yes' ){ $columns['allpacka'] = 'Allpacka.com'; } return $columns; } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_action('manage_shop_order_posts_custom_column' , 'allpacka_order_column', 10, 2 ); function allpacka_order_column( $column_name, $order_id ) { if( get_option( 'allpacka_allapot' ) == 'yes' ){ switch ( $column_name ) { case 'allpacka' : allpacka_gombok( $order_id ); break; } } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_gombok( $order_id ){ $upload_dir = wp_upload_dir(); $allpacka_azonosito = get_post_meta( $order_id, '_allpacka_azonosito', true ); $allpacka_fuvarlevelszam = get_post_meta( $order_id, '_allpacka_fuvarlevelszam', true ); if( empty( $allpacka_azonosito ) && empty( $allpacka_fuvarlevelszam ) ){ echo ''.__( 'Place order', 'allpacka' ).''; } else if( !empty( $allpacka_azonosito ) && empty( $allpacka_fuvarlevelszam ) ){ echo '

'.__( 'Order ID:', 'allpacka' ).' '.$allpacka_azonosito.'

'; echo '


'.__( 'The waybill will be sent to you by the Allpacka.com Customer Service.', 'allpacka' ).'

'; } else if( !empty( $allpacka_azonosito ) && !empty( $allpacka_fuvarlevelszam ) ){ echo '

'.__( 'Order ID:', 'allpacka' ).' '.$allpacka_azonosito.'

'; echo '

'; echo ''.__( 'Waybill number:', 'allpacka' ).' '.$allpacka_fuvarlevelszam.''; if( file_exists( $upload_dir['basedir'].'/allpacka/waybill_'.$order_id.'_'.$allpacka_fuvarlevelszam.'.pdf' ) ){ echo ''; } if( $nyomkovetes_url = allpacka_nyomkovetes_url( $allpacka_fuvarlevelszam ) ){ echo ''; } echo '

'; } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_nyomkovetes_url( $allpacka_fuvarlevelszam ){ if( strlen( $allpacka_fuvarlevelszam ) == 11 && substr( $allpacka_fuvarlevelszam, 0, 3) == '002' ){ $nyelv_kod = allpacka_nyelv(); if( $nyelv_kod == 'RO' ){ return 'https://gls-group.eu/RO/ro/urmarire-colet?match='.$allpacka_fuvarlevelszam; } else{ return 'https://gls-group.eu/HU/en/parcel-tracking?match='.$allpacka_fuvarlevelszam; } } else if( strlen( $allpacka_fuvarlevelszam ) == 14 && substr( $allpacka_fuvarlevelszam, 0, 3) == '164' ){ $nyelv_kod = allpacka_nyelv(); if( $nyelv_kod == 'RO' ){ return 'https://tracking.dpd.de/parcelstatus?query='.$allpacka_fuvarlevelszam.'&locale=ro_RO'; } else{ return 'https://tracking.dpd.de/parcelstatus?query='.$allpacka_fuvarlevelszam.'&locale=en_HU'; } } else{ return false; } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_action("add_meta_boxes", "allpacka_order_meta_box"); function allpacka_order_meta_box(){ if( get_option( 'allpacka_allapot' ) == 'yes' ){ add_meta_box("allpacka_meta_box", '
Allpacka.com
', 'allpacka_order_meta_box_content', 'shop_order', 'side', 'high', null); } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_order_meta_box_content( $order ){ if( get_option( 'allpacka_allapot' ) == 'yes' ){ if( !empty( $order->ID ) ){ allpacka_gombok( $order->ID ); } } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_konvertalas( $string ){ if( $string == 'yes' ){ return 'true'; } else{ return 'false'; } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_nyelv(){ $locale = get_locale(); if( $locale && substr( $locale, 0, 2 ) == 'ro' ){ return 'RO'; } else if( $locale && substr( $locale, 0, 2 ) == 'en' ){ return 'EN'; } else{ return 'EN'; } } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_filter( 'woocommerce_settings_tabs_array', 'allpacka_add_settings_tab', 50 ); function allpacka_add_settings_tab( $settings_tabs ) { $settings_tabs['allpacka'] = 'Allpacka.com'; return $settings_tabs; } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_action( 'woocommerce_settings_tabs_allpacka', 'allpacka_settings_tab' ); function allpacka_settings_tab() { echo ''; woocommerce_admin_fields( allpacka_get_settings() ); echo '
'; } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'allpacka_action_links' ); function allpacka_action_links( $links ) { $links[] = ''.__( 'Settings', 'allpacka' ).''; return $links; } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ add_action( 'woocommerce_update_options_allpacka', 'allpacka_update_settings' ); function allpacka_update_settings() { woocommerce_update_options( allpacka_get_settings() ); } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_get_settings() { $settings = array( 'allpacka_section_1' => array( 'name' => __( 'General settings', 'allpacka' ), 'type' => 'title', ), 'allpacka_allapot' => array( 'title' => __( 'Enable / Disable', 'allpacka' ), 'type' => 'checkbox', 'default' => 'no', 'desc' => __( 'Enable Allpacka.com', 'allpacka' ), 'desc_tip' => true, 'id' => 'allpacka_allapot' ), 'allpacka_tesztkornyezet' => array( 'title' => __( 'Test environment', 'allpacka' ), 'type' => 'checkbox', 'default' => 'yes', 'desc' => __( 'Use test environment', 'allpacka' ), 'desc_tip' => true, 'id' => 'allpacka_tesztkornyezet' ), 'allpacka_debug' => array( 'title' => __( 'Debug mode', 'allpacka' ), 'type' => 'checkbox', 'default' => 'no', 'desc' => __( 'Show request sent to and response received from Allpacka.com.', 'allpacka' ), 'desc_tip' => true, 'id' => 'allpacka_debug' ), 'allpacka_section_1_end' => array( 'type' => 'sectionend' ), 'allpacka_section_2' => array( 'name' => __( 'Allpacka.com account details', 'allpacka' ), 'type' => 'title', 'desc' => '', ), 'allpacka_email' => array( 'name' => __( 'Email address', 'allpacka' ), 'type' => 'text', 'desc' => __( 'Email address used to register on Allpacka.com', 'allpacka' ), 'desc_tip' => true, 'id' => 'allpacka_email', 'placeholder' => __( 'something@something.com', 'allpacka' ), 'class' => 'input_width_30' ), 'allpacka_jelszo' => array( 'name' => __( 'Password', 'allpacka' ), 'type' => 'text', 'desc' => __( 'Password on Allpacka.com', 'allpacka' ), 'desc_tip' => true, 'id' => 'allpacka_jelszo', 'class' => 'input_width_30' ), 'allpacka_section_2_end' => array( 'type' => 'sectionend' ), 'allpacka_section_3' => array( 'name' => __( 'Allpacka.com terms and conditions', 'allpacka' ), 'type' => 'title', 'desc' => '', ), 'allpacka_tiltott_aru' => array( 'title' => __( 'I declare that my package does not contain any dangerous and/or forbidden item.', 'allpacka' ), 'type' => 'checkbox', 'default' => 'no', 'desc' => __( 'List of dangerous and/or forbidden items can be found on Allpacka.com:', 'allpacka' ).'https://allpacka.com/faq/prohibited-items/', 'desc_tip' => true, 'id' => 'allpacka_tiltott_aru' ), 'allpacka_aszf' => array( 'title' => __( "I've read and understood the Terms and Conditions of Allpacka.com.", 'allpacka' ), 'type' => 'checkbox', 'default' => 'no', 'desc' => __( 'Terms and Conditions can be found on Allpacka.com:', 'allpacka' ).' https://allpacka.com/terms-conditions-tc/', 'desc_tip' => true, 'id' => 'allpacka_aszf' ), 'allpacka_section_3_end' => array( 'type' => 'sectionend' ), 'allpacka_section_4' => array( 'name' => __( 'Collection details', 'allpacka' ), 'type' => 'title', 'desc' => __( 'If you already specified this default data on Allpacka.com, it is not mandatory to provide them here.', 'allpacka' ), ), 'allpacka_felado_neve' => array( 'name' => __( "Sender's name", 'allpacka' ), 'type' => 'text', 'id' => 'allpacka_felado_neve', 'placeholder' => __( 'John Doe', 'allpacka' ), 'class' => 'input_width_30' ), 'allpacka_felado_bank_neve' => array( 'name' => __( "Name of Sender's bank", 'allpacka' ), 'type' => 'text', 'id' => 'allpacka_felado_bank_neve', 'placeholder' => __( 'UniCredit', 'allpacka' ), 'class' => 'input_width_30' ), 'allpacka_felado_bankszamlaszama' => array( 'name' => __( 'Bank account number of sender', 'allpacka' ), 'type' => 'text', 'id' => 'allpacka_felado_bankszamlaszama', 'placeholder' => __( 'XX1234567890 or 12345678-12345678-12345678', 'allpacka' ), 'class' => 'input_width_30' ), 'allpacka_section_4_end' => array( 'type' => 'sectionend' ), ); return apply_filters( 'allpacka_settings', $settings ); } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ function allpacka_megrendeles() { if ( isset($_REQUEST) ) { $order_id = $_REQUEST['order_id']; $order = wc_get_order( $order_id ); $company = method_exists( $order, 'get_shipping_company' ) ? $order->get_shipping_company() : $order->shipping_company; $contact_first_name = method_exists( $order, 'get_shipping_first_name' ) ? $order->get_shipping_first_name() : $order->shipping_first_name; $contact_last_name = method_exists( $order, 'get_shipping_last_name' ) ? $order->get_shipping_last_name() : $order->shipping_last_name; if( !empty( $company ) ){ $nmCompanyOrPerson = $company; $nmContact = $contact_last_name.' '.$contact_first_name; } else{ $nmCompanyOrPerson = $contact_last_name.' '.$contact_first_name; $nmContact = $contact_last_name.' '.$contact_first_name; } $DESTINATIONADDRESS = array( 'nmCompanyOrPerson' => $nmCompanyOrPerson, 'nmContact' => $nmContact, 'cdCountry' => method_exists( $order, 'get_shipping_country' ) ? $order->get_shipping_country() : $order->shipping_country, 'txAddress' => method_exists( $order, 'get_shipping_address_1' ) ? $order->get_shipping_address_1() : $order->shipping_address_1, 'txAddressNumber' => '.', //$order->shipping_houseno, 'txPost' => method_exists( $order, 'get_shipping_postcode' ) ? $order->get_shipping_postcode() : $order->shipping_postcode, 'txCity' => method_exists( $order, 'get_shipping_city' ) ? $order->get_shipping_city() : $order->shipping_city, 'txPhoneContact' => method_exists( $order, 'get_billing_phone' ) ? $order->get_billing_phone() : $order->billing_phone, 'txEmailContact' => method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email, 'txInstruction' => (string)substr( ( method_exists( $order, 'get_customer_message' ) ? $order->get_customer_message() : $order->customer_message ), 0, 75 ) ); $payment_method = method_exists( $order, 'get_payment_method' ) ? $order->get_payment_method() : $order->payment_method; if( $payment_method == 'cod' ){ $PACKAGE = array( array( 'ctPackage' => '1', 'amContent' => (string)$order->get_total(), ) ); $cod = 'true'; } else{ $PACKAGE = array( array( 'ctPackage' => '1', ) ); $cod = 'false'; } $PACKAGES = array( 'PACKAGE' => $PACKAGE ); if( get_option( 'allpacka_felado_neve' ) != '' && get_option( 'allpacka_felado_bank_neve' ) != '' && get_option( 'allpacka_felado_bankszamlaszama' ) != '' ){ $ORDER = array( 'flCOD' => $cod, 'nmRecipientCOD' => get_option( 'allpacka_felado_neve' ), 'nmBankCOD' => get_option( 'allpacka_felado_bank_neve' ), 'txBankAccountNumberCOD' => get_option( 'allpacka_felado_bankszamlaszama' ), 'flNothingProhibited' => allpacka_konvertalas( get_option( 'allpacka_tiltott_aru' ) ), 'flAgreedToTermsAndConditions' => allpacka_konvertalas( get_option( 'allpacka_aszf' ) ), 'DESTINATIONADDRESS' => $DESTINATIONADDRESS, "PACKAGES" => $PACKAGES ); } else{ $ORDER = array( 'flCOD' => $cod, 'flNothingProhibited' => allpacka_konvertalas( get_option( 'allpacka_tiltott_aru' ) ), 'flAgreedToTermsAndConditions' => allpacka_konvertalas( get_option( 'allpacka_aszf' ) ), 'DESTINATIONADDRESS' => $DESTINATIONADDRESS, "PACKAGES" => $PACKAGES ); } $REQUEST = array( 'flDebug' => allpacka_konvertalas( get_option( 'allpacka_tesztkornyezet' ) ), 'cdLang' => allpacka_nyelv(), 'txEmail' => get_option( 'allpacka_email' ), 'txPassword' => get_option( 'allpacka_jelszo' ), 'ORDER' => $ORDER ); $JSON = array( 'REQUEST' => $REQUEST, ); $return = array(); if( get_option( 'allpacka_debug' ) == 'yes' ){ $return['request'] = '

'.__( 'Request sent to Allpacka.com:', 'allpacka' ).'

'.json_encode($JSON, JSON_PRETTY_PRINT).'
'; } $JSON = json_encode( $JSON ); $options = array( 'http' => array( 'method' => 'POST', 'content' => $JSON ) ); $url = 'https://allpacka.com/webservices/webshop2.ashx'; $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); if ($result == null) { $return['hiba'][] = ''.__( 'Error message from Allpacka.com:', 'allpacka' ).' '.'NULL response'; echo json_encode( $return ); die(); } if (json_decode( $result, true) == null) { $return['hiba'][] = ''.__( 'Error message from Allpacka.com:', 'allpacka' ).' '.$result; echo json_encode( $return ); die(); } $result = json_decode( $result, true); if( get_option( 'allpacka_debug' ) == 'yes' ){ $return['result'] = '

'.__( 'Response received from Allpacka.com:', 'allpacka' ).'

'.json_encode($result, JSON_PRETTY_PRINT).'
'; } if( get_option( 'allpacka_tesztkornyezet' ) == 'yes' ){ if( $result ){ if( $result['Messages'] ){ foreach( $result['Messages'] as $message ){ if( $message['Text'] != 'TEST: Quote added successfully' ){ $return['hiba'][] = ''.__( 'Error message from Allpacka.com:', 'allpacka' ).' '.$message['Text']; } } } if( !empty( $result['Order']['Labels'] ) && !empty( $result['Order']['WayBills'] ) ){ update_post_meta( $order_id, '_allpacka_azonosito', 'teszt_'.$order_id ); update_post_meta( $order_id, '_allpacka_fuvarlevelszam', $result['Order']['WayBills'][0] ); $return['azonosito'] = $result['Order']['ID']; $return['fuvarlevelszam'] = $result['Order']['WayBills'][0]; $minta_fuvarlevel = plugin_dir_url(__FILE__).'/pdf/minta_fuvarlevel.pdf'; $upload_dir = wp_upload_dir(); $fajlnev_dir = $upload_dir['basedir'].'/allpacka/waybill_'.$order_id.'_'.$result['Order']['WayBills'][0].'.pdf'; $fajlnev_url = $upload_dir['baseurl'].'/allpacka/waybill_'.$order_id.'_'.$result['Order']['WayBills'][0].'.pdf'; copy( $minta_fuvarlevel, $fajlnev_dir); $return['siker'] = __( 'Successful Allpacka.com order. Webshop order ID:', 'allpacka' ).' '.$order_id.'. '.__( 'Allpacka.com order ID:', 'allpacka' ).' '.$result['Order']['ID'].'. '.__( 'Fuvarlevélszám:', 'allpacka' ).' '.$result['Order']['WayBills'][0].'. '.__( 'The waybill contains fake data in test mode!', 'allpacka' ).''; $return['fajlnev_url'] = $fajlnev_url; $return['nyomkovetes_url'] = allpacka_nyomkovetes_url( $result['Order']['WayBills'][0] ); $order->add_order_note( sprintf( __( 'Successful Allpacka.com order. Allpacka.com order ID: %s. Waybill number: %s. The waybill contains fake data in test mode!', 'allpacka' ), $result['Order']['ID'], $result['Order']['WayBills'][0] ) ); } else{ $return['hiba'][] = ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'Unsuccesful Allpacka.com order.', 'allpacka' ).' '.__( 'Webshop order ID:', 'allpacka' ).' '.$order_id; $order->add_order_note( ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'Unsuccesful Allpacka.com order.', 'allpacka' ) ); } } else{ $return['hiba'][] = ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'No response received from Allpacka.com for the request.', 'allpacka' ) .' '. __('Password or email address probably wrong.', 'allpacka' ); $order->add_order_note( ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'No response received from Allpacka.com for the request.', 'allpacka' ) ); } } else{ if( $result ){ if( $result['Messages'] ){ foreach( $result['Messages'] as $message ){ $return['hiba'][] = ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.$message['Text']; } } if( $result['Order']['ID'] > 0 && empty( $result['Order']['Labels'] ) && empty( $result['Order']['WayBills'] ) ){ update_post_meta( $order_id, '_allpacka_azonosito', $result['Order']['ID'] ); update_post_meta( $order_id, '_allpacka_fuvarlevelszam', '' ); $return['azonosito'] = $result['Order']['ID']; $return['siker_2'] = __( 'Successful Allpacka.com order, but a label/waybill was not generated. The Customer Service of Allpacka.com corrects the mistake and sends you an email.', 'allpacka' ).' '.__('Webshop order ID:', 'allpacka' ).' '.$order_id.'. '.__( 'Allpacka.com order ID:', 'allpacka' ).' '.$result['Order']['ID'].'.'; $order->add_order_note( __( 'Successful Allpacka.com order, but a label/waybill was not generated. The Customer Service of Allpacka.com corrects the mistake and sends you an email.', 'allpacka' )); } // got idQuote, got waybill number, but no PDF else if( $result['Order']['ID'] > 0 && empty( $result['Order']['Labels'] ) && !empty( $result['Order']['WayBills'] ) ){ update_post_meta( $order_id, '_allpacka_azonosito', $result['Order']['ID'] ); update_post_meta( $order_id, '_allpacka_fuvarlevelszam', $result['Order']['WayBills'][0] ); $return['azonosito'] = $result['Order']['ID']; $return['fuvarlevelszam'] = $result['Order']['WayBills'][0]; $return['siker'] = __( 'Successful Allpacka.com order.', 'allpacka' ).' '.__( 'Webshop order ID:', 'allpacka' ).' '.$order_id.'. '. __( 'Allpacka.com order ID:', 'allpacka' ) . ' '.$result['Order']['ID'].'. '. __( 'Waybill number:', 'allpacka' ).' '.$result['Order']['WayBills'][0].'.'; $return['nyomkovetes_url'] = allpacka_nyomkovetes_url( $result['Order']['WayBills'][0] ); $order->add_order_note( sprintf( __( 'Successful Allpacka.com order. Allpacka.com order ID: %s. Waybill number: %s.', 'allpacka' ), $result['Order']['ID'], $result['Order']['WayBills'][0] ) ); } // got idQuote, got Waybill number, and got PDF else if( !empty( $result['Order']['Labels'] ) && !empty( $result['Order']['WayBills'] ) && $result['Order']['ID'] > 0 ){ $fuvarlevel = $result['Order']['Labels'][0]; if( !empty( $fuvarlevel ) ){ update_post_meta( $order_id, '_allpacka_azonosito', $result['Order']['ID'] ); update_post_meta( $order_id, '_allpacka_fuvarlevelszam', $result['Order']['WayBills'][0] ); $return['azonosito'] = $result['Order']['ID']; $return['fuvarlevelszam'] = $result['Order']['WayBills'][0]; $upload_dir = wp_upload_dir(); $fuvarlevel = base64_decode($fuvarlevel); $fajlnev_dir = $upload_dir['basedir'].'/allpacka/waybill_'.$order_id.'_'.$result['Order']['WayBills'][0].'.pdf'; $fajlnev_url = $upload_dir['baseurl'].'/allpacka/waybill_'.$order_id.'_'.$result['Order']['WayBills'][0].'.pdf'; file_put_contents( $fajlnev_dir, $fuvarlevel); $return['siker'] = __( 'Successful Allpacka.com order.', 'allpacka' ).' '.__( 'Webshop order ID:', 'allpacka' ).' '.$order_id.'. '. __( 'Allpacka.com order ID:', 'allpacka' ) . ' '.$result['Order']['ID'].'. '. __( 'Waybill number:', 'allpacka' ).' '.$result['Order']['WayBills'][0].'.'; $return['fajlnev_url'] = $fajlnev_url; $return['nyomkovetes_url'] = allpacka_nyomkovetes_url( $result['Order']['WayBills'][0] ); $order->add_order_note( sprintf( __( 'Successful Allpacka.com order. Allpacka.com order ID: %s. Waybill number: %s.', 'allpacka' ), $result['Order']['ID'], $result['Order']['WayBills'][0] ) ); } else{ $return['hiba'][] = ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'Unsuccesful Allpacka.com order.', 'allpacka' ).' '.__( 'Webshop order ID:', 'allpacka' ).' '.$order_id; $order->add_order_note( ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'Unsuccesful Allpacka.com order.', 'allpacka' ) ); } } else{ $return['hiba'][] = ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'Unsuccesful Allpacka.com order.', 'allpacka' ).' '.__( 'Webshop order ID:', 'allpacka' ).' '.$order_id; $order->add_order_note( ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'Unsuccesful Allpacka.com order.', 'allpacka' ) ); } } else{ $return['hiba'][] = ''.__( 'Allpacka.com error message:', 'allpacka' ).' ' . __( 'No response received from Allpacka.com for the ORDER request.', 'allpacka' ) . ' ' . __( 'Password or email address probably wrong.', 'allpacka' ); $order->add_order_note( ''.__( 'Allpacka.com error message:', 'allpacka' ).' '.__( 'No response received from Allpacka.com for the ORDER request.', 'allpacka' ) ); } } echo json_encode( $return ); } die(); } add_action( 'wp_ajax_allpacka_megrendeles', 'allpacka_megrendeles' ); add_action( 'wp_ajax_nopriv_allpacka_megrendeles', 'allpacka_megrendeles' ); /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ //add_filter( 'woocommerce_checkout_fields' , 'allpacka_add_field_and_reorder_fields' ); function allpacka_add_field_and_reorder_fields( $fields ) { $fields['billing']['billing_houseno'] = array( 'label' => __('House number', 'allpacka'), 'placeholder' => __('19/B', 'allpacka'), 'required' => true, 'class' => array('form-row-first'), 'clear' => false ); $fields['shipping']['shipping_houseno'] = array( 'label' => __('House number', 'allpacka'), 'placeholder' => __('19/B', 'allpacka'), 'required' => true, 'class' => array('form-row-first'), 'clear' => false ); return $fields; } /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************/ ?>