Changeset 2415872
- Timestamp:
- 11/10/2020 02:27:26 PM (5 years ago)
- Location:
- posturinn
- Files:
-
- 14 edited
- 1 copied
-
tags/1.0.8 (copied) (copied from posturinn/trunk)
-
tags/1.0.8/inc/admin.php (modified) (5 diffs)
-
tags/1.0.8/inc/functions.php (modified) (1 diff)
-
tags/1.0.8/languages/postis-is_IS.mo (modified) (previous)
-
tags/1.0.8/languages/postis-is_IS.po (modified) (4 diffs)
-
tags/1.0.8/languages/postis.pot (modified) (1 diff)
-
tags/1.0.8/readme.txt (modified) (2 diffs)
-
tags/1.0.8/wc-posturinn-shipping-api.php (modified) (3 diffs)
-
trunk/inc/admin.php (modified) (5 diffs)
-
trunk/inc/functions.php (modified) (1 diff)
-
trunk/languages/postis-is_IS.mo (modified) (previous)
-
trunk/languages/postis-is_IS.po (modified) (4 diffs)
-
trunk/languages/postis.pot (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wc-posturinn-shipping-api.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
posturinn/tags/1.0.8/inc/admin.php
r2396143 r2415872 313 313 314 314 }else{ 315 // if (substr($customer_phone, 0, 1) === '6' || substr($customer_phone, 0, 1) === '7' || substr($customer_phone, 0, 1) === '8') { 316 317 // } else { 318 // $customer_phone = ''; 319 // } 315 if ($shipping_service == 'DPP' OR $shipping_service == 'DPH') { 316 if (substr($customer_phone, 0, 1) === '6' || substr($customer_phone, 0, 1) === '7' || substr($customer_phone, 0, 1) === '8') { 317 // phoneNumber is valid 318 } else { 319 $valid_phonenumber = ''; 320 } 321 } 320 322 $recipeint = array( 'name' => $shipping_customerName, 321 323 'addressLine1' => $shipping_address1, … … 454 456 if ($automatic_printing == 'yes') { 455 457 $print_response = wp_remote_post( $print_query, $print_headers ); 456 // postis_pa($print_response); 457 } 458 459 $print_response_code = wp_remote_retrieve_response_code( $print_response ); 460 461 if ($print_response_code == 204 ) { 462 update_post_meta( $order_id, 'postis_is_shipment_printed', 'printed' ); 463 }else{ 464 update_post_meta( $order_id, 'postis_is_shipment_printed', 'not_printed' ); 465 } 466 } 467 468 // postis_pa($print_response_code); exit; 458 469 459 470 … … 572 583 573 584 if ($shipment_status == true && $get_shipment_meta != '') { 574 echo '<a class="button button-primary" href="'.esc_url($pdf_url).'" target="'.esc_attr($open_pdf_status).'">'. __("Get PDF", "postis").'</a>'; 585 586 $print_status = get_post_meta( $order_id, 'postis_is_shipment_printed', true ); 587 588 if ($print_status == 'printed') { 589 $tooltip = __('Shipment Printed', 'postis'); 590 $icon = '<span data-tip="'.esc_attr($tooltip).'" class="tips dashicons dashicons-yes" style="color:#00ff00;margin-top: 4px;"></span>'; 591 }else{ 592 $icon = ''; 593 } 594 595 echo '<a class="button button-primary" href="'.esc_url($pdf_url).'" target="'.esc_attr($open_pdf_status).'">'. __("Get PDF", "postis"). $icon .'</a>'; 575 596 }else{ 576 597 echo '--'; … … 581 602 582 603 583 function postis_get_shipment_data($order_id, $shipmet_key){584 585 $shipment_meta = get_post_meta($order_id, 'postis_shipment_meta', true );604 // function postis_get_shipment_data($order_id, $shipmet_key){ 605 606 // $shipment_meta = get_post_meta($order_id, 'postis_shipment_meta', true ); 586 607 587 $postval = isset($shipment_meta[$shipmet_key]) ? $shipment_meta[$shipmet_key] : '';588 589 return $postval;590 }608 // $postval = isset($shipment_meta[$shipmet_key]) ? $shipment_meta[$shipmet_key] : ''; 609 610 // return $postval; 611 // } 591 612 592 613 add_action( 'woocommerce_product_options_shipping', 'postis_product_custom_field' ); … … 626 647 update_post_meta($post_id, 'descriptionOfContents', sanitize_text_field($descContents)); 627 648 } 649 650 add_filter( 'bulk_actions-edit-shop_order', 'postis_order_bulk_action_option', 20, 1 ); 651 function postis_order_bulk_action_option( $actions ) { 652 $actions['create_shipment'] = __( 'CreateShipment', 'postis' ); 653 $actions['print_shipment'] = __( 'PrintShipments', 'postis' ); 654 return $actions; 655 } 656 657 add_filter( 'handle_bulk_actions-edit-shop_order', 'postis_bulk_action_process', 10, 3 ); 658 function postis_bulk_action_process( $redirect_to, $action, $post_ids ) { 659 // if ( $action !== 'create_shipment' || $action !== 'print_shipment') 660 // return $redirect_to; 661 662 $processed_ids = array(); 663 $recipeint = array(); 664 665 $postis_apikey = postis_get_settings( 'apikey' ); 666 $domain = $_SERVER['HTTP_HOST']; 667 $endpoint_url = postis_get_endpoints( 'create_shipment' ); 668 669 if ($action === 'create_shipment') { 670 671 foreach ( $post_ids as $post_id ) { 672 673 $order = wc_get_order( $post_id ); 674 $ship_methods = $order->get_shipping_methods(); 675 $shipping_customerName = $order->get_formatted_shipping_full_name(); 676 $shipping_address1 = $order->get_shipping_address_1(); 677 $shipping_postcode = $order->get_shipping_postcode(); 678 $country_code = $order->get_shipping_country(); 679 $city = $order->get_shipping_city(); 680 $customer_email = $order->get_billing_email(); 681 $customer_phone = $order->get_billing_phone(); 682 683 $shipping_service = get_post_meta( $post_id, 'postis_shipping_method', true ); 684 685 $recipeint = array( 'name' => $shipping_customerName, 686 'addressLine1' => $shipping_address1, 687 "postcode" => $shipping_postcode, 688 "countryCode" => $country_code, 689 "mobilePhone" => $customer_phone, 690 ); 691 692 $recipeint['email'] = $customer_email; 693 $options = array('deliveryServiceId' => $shipping_service); 694 $params = array( 695 'recipient' => $recipeint, 696 'options' => $options, 697 ); 698 699 $order_data = $order->get_data(); 700 701 $params = array_filter( $params ); 702 703 // postis_pa($params); exit; 704 705 // Set Header 706 $headers = array( 707 'headers' => array('Content-Type' => 'application/json; charset=utf-8', 'x-api-key'=>$postis_apikey,'domain_name'=> $domain), 708 'body' => json_encode($params), 709 'method' => 'POST', 710 'data_format' => 'body', 711 ); 712 713 // Run the query 714 $response = wp_remote_post( $endpoint_url, $headers ); 715 $get_shipment_meta = json_decode( $response['body'], true ); 716 717 718 // postis_pa($get_shipment_meta); exit; 719 720 if( $response['response']['code'] != 400 && $response['response']['code'] != 401 ) { 721 722 update_post_meta( $post_id, 'postis_shipment_meta', $get_shipment_meta ); 723 724 $ajax_response = array('status'=>'success', 'message'=> __('Shipment Created Successfully', 'postis')); 725 $res_msg = 'created'; 726 727 }else{ 728 $resp_message = sprintf( __("Shipment Not Created.\nServer Response: %s", "postis"), $get_shipment_meta['message'] ); 729 $res_msg = 'failed'; 730 731 if (strpos($get_shipment_meta['message'], 'Ekki var hægt að skrá sendingu (Addressee.Gsm') !== false) { 732 $ajax_response = array('status'=>'error', 'type'=>'phonenumber', 'message'=> $resp_message ); 733 } else { 734 $ajax_response = array('status'=>'error', 'type'=>'other', 'message'=> $resp_message ); 735 } 736 737 } 738 739 $processed_ids[] = $post_id; 740 } 741 }else if($action === 'print_shipment'){ 742 foreach ( $post_ids as $post_id ) { 743 744 $shipmentId = postis_get_shipment_data($post_id, 'shipmentId'); 745 746 $print_endpoint = postis_get_endpoints( 'print' ); 747 $print_params = array( 748 'shipmentId' => $shipmentId, 749 'outputFormat' => 'poststod' 750 ); 751 $print_params = array_filter( $print_params ); 752 753 754 // Query format parameters. 755 $print_query = add_query_arg( $print_params, $print_endpoint ); 756 757 // Set Header 758 $print_headers = array( 759 'headers' => array('x-api-key'=>$postis_apikey, 'domain_name'=> $domain), 760 //'body' => json_encode($print_params), 761 'method' => 'POST', 762 // 'data_format' => 'body', 763 ); 764 // postis_pa($print_headers); 765 766 // Run the query 767 $automatic_printing = postis_get_settings( 'pdf_print' ); 768 if ($automatic_printing == 'yes') { 769 $print_response = wp_remote_post( $print_query, $print_headers ); 770 771 $print_response_code = wp_remote_retrieve_response_code( $print_response ); 772 773 if ($print_response_code == 204 ) { 774 update_post_meta( $post_id, 'postis_is_shipment_printed', 'printed' ); 775 }else{ 776 update_post_meta( $post_id, 'postis_is_shipment_printed', 'not_printed' ); 777 } 778 779 // postis_pa($print_response); exit; 780 } 781 782 } 783 }else{ 784 return $redirect_to; 785 } 786 787 return $redirect_to = add_query_arg( array( 788 'processed_count' => count( $processed_ids ), 789 'status' => $res_msg, 790 ), $redirect_to ); 791 } 792 793 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { 794 795 // adds the coupon filtering dropdown to the orders page 796 add_action( 'restrict_manage_posts', 'filter_orders_by_coupon_used' ); 797 798 // makes coupons filterable 799 // add_filter( 'posts_join', 'add_order_items_join' ); 800 // add_filter( 'posts_where', 'add_filterable_where' ); 801 802 add_filter( 'request', 'filter_orders_by_payment_method_query' ); 803 } 804 805 function filter_orders_by_coupon_used() { 806 global $typenow; 807 808 if ( 'shop_order' === $typenow ) { 809 810 ?> 811 <select name="postis_shipment_print_status" id="postis_shipment_print_status"> 812 <option value=""><?php esc_html_e( 'Shipment Print Status', 'postis' ); ?></option> 813 <option value="printed"><?php esc_html_e( 'Printed', 'postis' ); ?></option> 814 <option value="not_printed"><?php esc_html_e( 'Not printed', 'postis' ); ?></option> 815 </select> 816 <?php 817 } 818 } 819 820 function filter_orders_by_payment_method_query( $vars ) { 821 global $typenow; 822 823 if ( 'shop_order' === $typenow && isset( $_GET['postis_shipment_print_status'] ) && ! empty( $_GET['postis_shipment_print_status'] ) ) { 824 825 $vars['meta_key'] = 'postis_is_shipment_printed'; 826 $vars['meta_value'] = wc_clean( $_GET['postis_shipment_print_status'] ); 827 } 828 829 return $vars; 830 } -
posturinn/tags/1.0.8/inc/functions.php
r2402610 r2415872 390 390 return apply_filters('postis_international_contents_fields',$options); 391 391 } 392 393 function postis_get_shipment_data($order_id, $shipmet_key){ 394 395 $shipment_meta = get_post_meta($order_id, 'postis_shipment_meta', true ); 396 397 $postval = isset($shipment_meta[$shipmet_key]) ? $shipment_meta[$shipmet_key] : ''; 398 399 return $postval; 400 } -
posturinn/tags/1.0.8/languages/postis-is_IS.po
r2334877 r2415872 3 3 "Project-Id-Version: Pósturinn's Shipping with WooCommerce\n" 4 4 "POT-Creation-Date: 2020-06-24 12:20+0000\n" 5 "PO-Revision-Date: 2020- 07-01 08:38+0000\n"5 "PO-Revision-Date: 2020-11-10 13:33+0000\n" 6 6 "Last-Translator: Aron Hallsson <[email protected]>\n" 7 7 "Language-Team: Aron Hallsson <[email protected]>\n" … … 11 11 "Content-Transfer-Encoding: 8bit\n" 12 12 "Plural-Forms: nplurals=2; plural=(n%10==1 && n%100!=11);\n" 13 "X-Generator: Poedit 2. 3.1\n"13 "X-Generator: Poedit 2.4.1\n" 14 14 "X-Poedit-Basepath: ..\n" 15 15 "X-Poedit-Flags-xgettext: --add-comments=translators:\n" … … 21 21 "X-Poedit-SearchPathExcluded-0: *.min.js\n" 22 22 23 #: inc/admin.php:813 24 msgid "Shipment Print Status" 25 msgstr "Prent staða" 26 27 #: inc/admin.php:814 28 msgid "Printed" 29 msgstr "Prentað" 30 31 #: inc/admin.php:815 32 msgid "Not printed" 33 msgstr "Ekki prentað" 34 35 #: inc/admin.class.php:534 36 msgid "Create Shipments" 37 msgstr "Búa til sendingarmiða" 38 39 #: inc/admin.class.php:535 40 msgid "Print Shipment PDF" 41 msgstr "Prenta sendingarmiða" 42 43 #: inc/admin.class.php:536 44 msgid "Mark as printed" 45 msgstr "Merkja sem prentað" 46 47 #: inc/admin.class.php:537 48 msgid "Mark as not printed" 49 msgstr "Merkja sem EKKI prentað" 50 51 52 #: inc/admin.class.php:685 53 msgid "Tarriff Number" 54 msgstr "Tollnúmer" 55 56 #: inc/admin.class.php:688 57 msgid "Tarriff Number. Needs to be 6 or 8 numbers" 58 msgstr "Tollnúmer. Þarf að vera 6 eða 8 tölustafir" 59 60 #: inc/admin.class.php:694 61 msgid "Description in english" 62 msgstr "Lýsing tollvöru á ensku" 63 64 #: inc/admin.class.php:697 65 msgid "This needs to be written in english!" 66 msgstr "Þetta þarf að vera skrifað á ensku!" 67 68 69 23 70 #: inc/postis.class.php:125 24 71 msgid "Use Shipping Price" … … 31 78 #: inc/postis.class.php:133 32 79 msgid "Include Woocommerce VAT" 33 msgstr "Reikna með Woocommerce VSK útreikning ."80 msgstr "Reikna með Woocommerce VSK útreikning" 34 81 35 82 #: inc/postis.class.php:137 -
posturinn/tags/1.0.8/languages/postis.pot
r2295413 r2415872 23 23 24 24 25 26 27 28 #: inc/admin.php:813 29 msgid "Shipment Print Status" 30 msgstr "" 31 32 #: inc/admin.php:814 33 msgid "Printed" 34 msgstr "" 35 36 #: inc/admin.php:815 37 msgid "Not printed" 38 msgstr "" 39 40 41 42 #: inc/admin.class.php:534 43 msgid "Create Shipments" 44 msgstr "" 45 46 #: inc/admin.class.php:535 47 msgid "Print Shipment PDF" 48 msgstr "" 49 50 #: inc/admin.class.php:536 51 msgid "Mark as printed" 52 msgstr "" 53 54 #: inc/admin.class.php:537 55 msgid "Mark as not printed" 56 msgstr "" 57 58 59 60 61 62 #: inc/admin.class.php:685 63 msgid "Tarriff Number" 64 msgstr "" 65 66 #: inc/admin.class.php:688 67 msgid "Tarriff Number. Needs to be 6 or 8 numbers" 68 msgstr "" 69 70 #: inc/admin.class.php:694 71 msgid "Description in english" 72 msgstr "" 73 74 #: inc/admin.class.php:697 75 msgid "This needs to be written in english!" 76 msgstr "" 77 78 79 80 81 82 25 83 #: templates/shipment-options.php:58 26 84 msgid "Extra Options" -
posturinn/tags/1.0.8/readme.txt
r2402610 r2415872 3 3 Tags: shipping, posturinn, icelandic post shipping, shipping rates, woocommerce 4 4 Requires at least: 4.3 5 Tested up to: 5.5. 15 Tested up to: 5.5.3 6 6 Requires PHP: 5.6 7 7 Stable tag: trunk … … 26 26 27 27 == Changelog == 28 = 1.0.8 = 29 Add bulk actions for createShipment 30 Add bulk actions for printing shipments 31 Add bulk actions for marking shipments as printed or not printed 32 Add filter by printed or not printed 33 Add admin class 34 Fixed phoneNumber issue on DPP and DPH shipments 35 36 28 37 = 1.0.7 = 29 38 Add postbox sort by nearest postcode -
posturinn/tags/1.0.8/wc-posturinn-shipping-api.php
r2402610 r2415872 3 3 * Plugin Name: Pósturinn's Shipping with WooCommerce 4 4 * Description: This plugin is an WooCommerce extension to extend shipping method with Pósturinn's - Iceland 5 * Version: 1.0. 75 * Version: 1.0.8 6 6 * Author: Pósturinn 7 7 * Author URI: https://postur.is … … 34 34 include plugin_dir_path(__FILE__).'inc/functions.php'; 35 35 include plugin_dir_path(__FILE__).'inc/callbacks.php'; 36 include plugin_dir_path(__FILE__).'inc/admin.php'; 36 include plugin_dir_path(__FILE__).'inc/admin.class.php'; 37 // include plugin_dir_path(__FILE__).'inc/admin.php'; 37 38 include plugin_dir_path(__FILE__).'inc/checkout-fields.class.php'; 38 39 … … 131 132 $pdf->Output(); 132 133 } 134 135 function postis_merge_pdf_files($pdf_files, $pdf_path){ 136 $pdf_width = postis_get_settings( 'pdf_width' ); 137 $pdf_height = postis_get_settings( 'pdf_height' ); 138 $pdf_rotate = postis_get_settings( 'pdf_rotate' ); 139 $pdf_orientation = postis_get_settings( 'pdf_orientation' ); 140 $pdf_moveright = postis_get_settings( 'pdf_moveright' ); 141 $pdf_movedown = postis_get_settings( 'pdf_movedown' ); 142 $pdf_biggerbarcode = postis_get_settings( 'pdf_biggerbarcode' ); 143 $pdf_size = array($pdf_width, $pdf_height, 'Rotate' => $pdf_rotate); 144 145 $pdf = new FPDI(); 146 147 foreach ($pdf_files as $file) { 148 149 if (!empty($file)) { 150 151 $pageCount = $pdf->setSourceFile($file); 152 153 for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { 154 155 // import a page 156 $templateId = $pdf->importPage($pageNo); 157 158 $pdf->AddPage($pdf_orientation,$pdf_size); 159 160 $pdf->useTemplate($templateId, $pdf_moveright, $pdf_movedown, $pdf_biggerbarcode); 161 } 162 } 163 } 164 165 $pdf->Output($pdf_path,"F"); 166 } -
posturinn/trunk/inc/admin.php
r2396143 r2415872 313 313 314 314 }else{ 315 // if (substr($customer_phone, 0, 1) === '6' || substr($customer_phone, 0, 1) === '7' || substr($customer_phone, 0, 1) === '8') { 316 317 // } else { 318 // $customer_phone = ''; 319 // } 315 if ($shipping_service == 'DPP' OR $shipping_service == 'DPH') { 316 if (substr($customer_phone, 0, 1) === '6' || substr($customer_phone, 0, 1) === '7' || substr($customer_phone, 0, 1) === '8') { 317 // phoneNumber is valid 318 } else { 319 $valid_phonenumber = ''; 320 } 321 } 320 322 $recipeint = array( 'name' => $shipping_customerName, 321 323 'addressLine1' => $shipping_address1, … … 454 456 if ($automatic_printing == 'yes') { 455 457 $print_response = wp_remote_post( $print_query, $print_headers ); 456 // postis_pa($print_response); 457 } 458 459 $print_response_code = wp_remote_retrieve_response_code( $print_response ); 460 461 if ($print_response_code == 204 ) { 462 update_post_meta( $order_id, 'postis_is_shipment_printed', 'printed' ); 463 }else{ 464 update_post_meta( $order_id, 'postis_is_shipment_printed', 'not_printed' ); 465 } 466 } 467 468 // postis_pa($print_response_code); exit; 458 469 459 470 … … 572 583 573 584 if ($shipment_status == true && $get_shipment_meta != '') { 574 echo '<a class="button button-primary" href="'.esc_url($pdf_url).'" target="'.esc_attr($open_pdf_status).'">'. __("Get PDF", "postis").'</a>'; 585 586 $print_status = get_post_meta( $order_id, 'postis_is_shipment_printed', true ); 587 588 if ($print_status == 'printed') { 589 $tooltip = __('Shipment Printed', 'postis'); 590 $icon = '<span data-tip="'.esc_attr($tooltip).'" class="tips dashicons dashicons-yes" style="color:#00ff00;margin-top: 4px;"></span>'; 591 }else{ 592 $icon = ''; 593 } 594 595 echo '<a class="button button-primary" href="'.esc_url($pdf_url).'" target="'.esc_attr($open_pdf_status).'">'. __("Get PDF", "postis"). $icon .'</a>'; 575 596 }else{ 576 597 echo '--'; … … 581 602 582 603 583 function postis_get_shipment_data($order_id, $shipmet_key){584 585 $shipment_meta = get_post_meta($order_id, 'postis_shipment_meta', true );604 // function postis_get_shipment_data($order_id, $shipmet_key){ 605 606 // $shipment_meta = get_post_meta($order_id, 'postis_shipment_meta', true ); 586 607 587 $postval = isset($shipment_meta[$shipmet_key]) ? $shipment_meta[$shipmet_key] : '';588 589 return $postval;590 }608 // $postval = isset($shipment_meta[$shipmet_key]) ? $shipment_meta[$shipmet_key] : ''; 609 610 // return $postval; 611 // } 591 612 592 613 add_action( 'woocommerce_product_options_shipping', 'postis_product_custom_field' ); … … 626 647 update_post_meta($post_id, 'descriptionOfContents', sanitize_text_field($descContents)); 627 648 } 649 650 add_filter( 'bulk_actions-edit-shop_order', 'postis_order_bulk_action_option', 20, 1 ); 651 function postis_order_bulk_action_option( $actions ) { 652 $actions['create_shipment'] = __( 'CreateShipment', 'postis' ); 653 $actions['print_shipment'] = __( 'PrintShipments', 'postis' ); 654 return $actions; 655 } 656 657 add_filter( 'handle_bulk_actions-edit-shop_order', 'postis_bulk_action_process', 10, 3 ); 658 function postis_bulk_action_process( $redirect_to, $action, $post_ids ) { 659 // if ( $action !== 'create_shipment' || $action !== 'print_shipment') 660 // return $redirect_to; 661 662 $processed_ids = array(); 663 $recipeint = array(); 664 665 $postis_apikey = postis_get_settings( 'apikey' ); 666 $domain = $_SERVER['HTTP_HOST']; 667 $endpoint_url = postis_get_endpoints( 'create_shipment' ); 668 669 if ($action === 'create_shipment') { 670 671 foreach ( $post_ids as $post_id ) { 672 673 $order = wc_get_order( $post_id ); 674 $ship_methods = $order->get_shipping_methods(); 675 $shipping_customerName = $order->get_formatted_shipping_full_name(); 676 $shipping_address1 = $order->get_shipping_address_1(); 677 $shipping_postcode = $order->get_shipping_postcode(); 678 $country_code = $order->get_shipping_country(); 679 $city = $order->get_shipping_city(); 680 $customer_email = $order->get_billing_email(); 681 $customer_phone = $order->get_billing_phone(); 682 683 $shipping_service = get_post_meta( $post_id, 'postis_shipping_method', true ); 684 685 $recipeint = array( 'name' => $shipping_customerName, 686 'addressLine1' => $shipping_address1, 687 "postcode" => $shipping_postcode, 688 "countryCode" => $country_code, 689 "mobilePhone" => $customer_phone, 690 ); 691 692 $recipeint['email'] = $customer_email; 693 $options = array('deliveryServiceId' => $shipping_service); 694 $params = array( 695 'recipient' => $recipeint, 696 'options' => $options, 697 ); 698 699 $order_data = $order->get_data(); 700 701 $params = array_filter( $params ); 702 703 // postis_pa($params); exit; 704 705 // Set Header 706 $headers = array( 707 'headers' => array('Content-Type' => 'application/json; charset=utf-8', 'x-api-key'=>$postis_apikey,'domain_name'=> $domain), 708 'body' => json_encode($params), 709 'method' => 'POST', 710 'data_format' => 'body', 711 ); 712 713 // Run the query 714 $response = wp_remote_post( $endpoint_url, $headers ); 715 $get_shipment_meta = json_decode( $response['body'], true ); 716 717 718 // postis_pa($get_shipment_meta); exit; 719 720 if( $response['response']['code'] != 400 && $response['response']['code'] != 401 ) { 721 722 update_post_meta( $post_id, 'postis_shipment_meta', $get_shipment_meta ); 723 724 $ajax_response = array('status'=>'success', 'message'=> __('Shipment Created Successfully', 'postis')); 725 $res_msg = 'created'; 726 727 }else{ 728 $resp_message = sprintf( __("Shipment Not Created.\nServer Response: %s", "postis"), $get_shipment_meta['message'] ); 729 $res_msg = 'failed'; 730 731 if (strpos($get_shipment_meta['message'], 'Ekki var hægt að skrá sendingu (Addressee.Gsm') !== false) { 732 $ajax_response = array('status'=>'error', 'type'=>'phonenumber', 'message'=> $resp_message ); 733 } else { 734 $ajax_response = array('status'=>'error', 'type'=>'other', 'message'=> $resp_message ); 735 } 736 737 } 738 739 $processed_ids[] = $post_id; 740 } 741 }else if($action === 'print_shipment'){ 742 foreach ( $post_ids as $post_id ) { 743 744 $shipmentId = postis_get_shipment_data($post_id, 'shipmentId'); 745 746 $print_endpoint = postis_get_endpoints( 'print' ); 747 $print_params = array( 748 'shipmentId' => $shipmentId, 749 'outputFormat' => 'poststod' 750 ); 751 $print_params = array_filter( $print_params ); 752 753 754 // Query format parameters. 755 $print_query = add_query_arg( $print_params, $print_endpoint ); 756 757 // Set Header 758 $print_headers = array( 759 'headers' => array('x-api-key'=>$postis_apikey, 'domain_name'=> $domain), 760 //'body' => json_encode($print_params), 761 'method' => 'POST', 762 // 'data_format' => 'body', 763 ); 764 // postis_pa($print_headers); 765 766 // Run the query 767 $automatic_printing = postis_get_settings( 'pdf_print' ); 768 if ($automatic_printing == 'yes') { 769 $print_response = wp_remote_post( $print_query, $print_headers ); 770 771 $print_response_code = wp_remote_retrieve_response_code( $print_response ); 772 773 if ($print_response_code == 204 ) { 774 update_post_meta( $post_id, 'postis_is_shipment_printed', 'printed' ); 775 }else{ 776 update_post_meta( $post_id, 'postis_is_shipment_printed', 'not_printed' ); 777 } 778 779 // postis_pa($print_response); exit; 780 } 781 782 } 783 }else{ 784 return $redirect_to; 785 } 786 787 return $redirect_to = add_query_arg( array( 788 'processed_count' => count( $processed_ids ), 789 'status' => $res_msg, 790 ), $redirect_to ); 791 } 792 793 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { 794 795 // adds the coupon filtering dropdown to the orders page 796 add_action( 'restrict_manage_posts', 'filter_orders_by_coupon_used' ); 797 798 // makes coupons filterable 799 // add_filter( 'posts_join', 'add_order_items_join' ); 800 // add_filter( 'posts_where', 'add_filterable_where' ); 801 802 add_filter( 'request', 'filter_orders_by_payment_method_query' ); 803 } 804 805 function filter_orders_by_coupon_used() { 806 global $typenow; 807 808 if ( 'shop_order' === $typenow ) { 809 810 ?> 811 <select name="postis_shipment_print_status" id="postis_shipment_print_status"> 812 <option value=""><?php esc_html_e( 'Shipment Print Status', 'postis' ); ?></option> 813 <option value="printed"><?php esc_html_e( 'Printed', 'postis' ); ?></option> 814 <option value="not_printed"><?php esc_html_e( 'Not printed', 'postis' ); ?></option> 815 </select> 816 <?php 817 } 818 } 819 820 function filter_orders_by_payment_method_query( $vars ) { 821 global $typenow; 822 823 if ( 'shop_order' === $typenow && isset( $_GET['postis_shipment_print_status'] ) && ! empty( $_GET['postis_shipment_print_status'] ) ) { 824 825 $vars['meta_key'] = 'postis_is_shipment_printed'; 826 $vars['meta_value'] = wc_clean( $_GET['postis_shipment_print_status'] ); 827 } 828 829 return $vars; 830 } -
posturinn/trunk/inc/functions.php
r2402610 r2415872 390 390 return apply_filters('postis_international_contents_fields',$options); 391 391 } 392 393 function postis_get_shipment_data($order_id, $shipmet_key){ 394 395 $shipment_meta = get_post_meta($order_id, 'postis_shipment_meta', true ); 396 397 $postval = isset($shipment_meta[$shipmet_key]) ? $shipment_meta[$shipmet_key] : ''; 398 399 return $postval; 400 } -
posturinn/trunk/languages/postis-is_IS.po
r2334877 r2415872 3 3 "Project-Id-Version: Pósturinn's Shipping with WooCommerce\n" 4 4 "POT-Creation-Date: 2020-06-24 12:20+0000\n" 5 "PO-Revision-Date: 2020- 07-01 08:38+0000\n"5 "PO-Revision-Date: 2020-11-10 13:33+0000\n" 6 6 "Last-Translator: Aron Hallsson <[email protected]>\n" 7 7 "Language-Team: Aron Hallsson <[email protected]>\n" … … 11 11 "Content-Transfer-Encoding: 8bit\n" 12 12 "Plural-Forms: nplurals=2; plural=(n%10==1 && n%100!=11);\n" 13 "X-Generator: Poedit 2. 3.1\n"13 "X-Generator: Poedit 2.4.1\n" 14 14 "X-Poedit-Basepath: ..\n" 15 15 "X-Poedit-Flags-xgettext: --add-comments=translators:\n" … … 21 21 "X-Poedit-SearchPathExcluded-0: *.min.js\n" 22 22 23 #: inc/admin.php:813 24 msgid "Shipment Print Status" 25 msgstr "Prent staða" 26 27 #: inc/admin.php:814 28 msgid "Printed" 29 msgstr "Prentað" 30 31 #: inc/admin.php:815 32 msgid "Not printed" 33 msgstr "Ekki prentað" 34 35 #: inc/admin.class.php:534 36 msgid "Create Shipments" 37 msgstr "Búa til sendingarmiða" 38 39 #: inc/admin.class.php:535 40 msgid "Print Shipment PDF" 41 msgstr "Prenta sendingarmiða" 42 43 #: inc/admin.class.php:536 44 msgid "Mark as printed" 45 msgstr "Merkja sem prentað" 46 47 #: inc/admin.class.php:537 48 msgid "Mark as not printed" 49 msgstr "Merkja sem EKKI prentað" 50 51 52 #: inc/admin.class.php:685 53 msgid "Tarriff Number" 54 msgstr "Tollnúmer" 55 56 #: inc/admin.class.php:688 57 msgid "Tarriff Number. Needs to be 6 or 8 numbers" 58 msgstr "Tollnúmer. Þarf að vera 6 eða 8 tölustafir" 59 60 #: inc/admin.class.php:694 61 msgid "Description in english" 62 msgstr "Lýsing tollvöru á ensku" 63 64 #: inc/admin.class.php:697 65 msgid "This needs to be written in english!" 66 msgstr "Þetta þarf að vera skrifað á ensku!" 67 68 69 23 70 #: inc/postis.class.php:125 24 71 msgid "Use Shipping Price" … … 31 78 #: inc/postis.class.php:133 32 79 msgid "Include Woocommerce VAT" 33 msgstr "Reikna með Woocommerce VSK útreikning ."80 msgstr "Reikna með Woocommerce VSK útreikning" 34 81 35 82 #: inc/postis.class.php:137 -
posturinn/trunk/languages/postis.pot
r2295413 r2415872 23 23 24 24 25 26 27 28 #: inc/admin.php:813 29 msgid "Shipment Print Status" 30 msgstr "" 31 32 #: inc/admin.php:814 33 msgid "Printed" 34 msgstr "" 35 36 #: inc/admin.php:815 37 msgid "Not printed" 38 msgstr "" 39 40 41 42 #: inc/admin.class.php:534 43 msgid "Create Shipments" 44 msgstr "" 45 46 #: inc/admin.class.php:535 47 msgid "Print Shipment PDF" 48 msgstr "" 49 50 #: inc/admin.class.php:536 51 msgid "Mark as printed" 52 msgstr "" 53 54 #: inc/admin.class.php:537 55 msgid "Mark as not printed" 56 msgstr "" 57 58 59 60 61 62 #: inc/admin.class.php:685 63 msgid "Tarriff Number" 64 msgstr "" 65 66 #: inc/admin.class.php:688 67 msgid "Tarriff Number. Needs to be 6 or 8 numbers" 68 msgstr "" 69 70 #: inc/admin.class.php:694 71 msgid "Description in english" 72 msgstr "" 73 74 #: inc/admin.class.php:697 75 msgid "This needs to be written in english!" 76 msgstr "" 77 78 79 80 81 82 25 83 #: templates/shipment-options.php:58 26 84 msgid "Extra Options" -
posturinn/trunk/readme.txt
r2402610 r2415872 3 3 Tags: shipping, posturinn, icelandic post shipping, shipping rates, woocommerce 4 4 Requires at least: 4.3 5 Tested up to: 5.5. 15 Tested up to: 5.5.3 6 6 Requires PHP: 5.6 7 7 Stable tag: trunk … … 26 26 27 27 == Changelog == 28 = 1.0.8 = 29 Add bulk actions for createShipment 30 Add bulk actions for printing shipments 31 Add bulk actions for marking shipments as printed or not printed 32 Add filter by printed or not printed 33 Add admin class 34 Fixed phoneNumber issue on DPP and DPH shipments 35 36 28 37 = 1.0.7 = 29 38 Add postbox sort by nearest postcode -
posturinn/trunk/wc-posturinn-shipping-api.php
r2402610 r2415872 3 3 * Plugin Name: Pósturinn's Shipping with WooCommerce 4 4 * Description: This plugin is an WooCommerce extension to extend shipping method with Pósturinn's - Iceland 5 * Version: 1.0. 75 * Version: 1.0.8 6 6 * Author: Pósturinn 7 7 * Author URI: https://postur.is … … 34 34 include plugin_dir_path(__FILE__).'inc/functions.php'; 35 35 include plugin_dir_path(__FILE__).'inc/callbacks.php'; 36 include plugin_dir_path(__FILE__).'inc/admin.php'; 36 include plugin_dir_path(__FILE__).'inc/admin.class.php'; 37 // include plugin_dir_path(__FILE__).'inc/admin.php'; 37 38 include plugin_dir_path(__FILE__).'inc/checkout-fields.class.php'; 38 39 … … 131 132 $pdf->Output(); 132 133 } 134 135 function postis_merge_pdf_files($pdf_files, $pdf_path){ 136 $pdf_width = postis_get_settings( 'pdf_width' ); 137 $pdf_height = postis_get_settings( 'pdf_height' ); 138 $pdf_rotate = postis_get_settings( 'pdf_rotate' ); 139 $pdf_orientation = postis_get_settings( 'pdf_orientation' ); 140 $pdf_moveright = postis_get_settings( 'pdf_moveright' ); 141 $pdf_movedown = postis_get_settings( 'pdf_movedown' ); 142 $pdf_biggerbarcode = postis_get_settings( 'pdf_biggerbarcode' ); 143 $pdf_size = array($pdf_width, $pdf_height, 'Rotate' => $pdf_rotate); 144 145 $pdf = new FPDI(); 146 147 foreach ($pdf_files as $file) { 148 149 if (!empty($file)) { 150 151 $pageCount = $pdf->setSourceFile($file); 152 153 for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { 154 155 // import a page 156 $templateId = $pdf->importPage($pageNo); 157 158 $pdf->AddPage($pdf_orientation,$pdf_size); 159 160 $pdf->useTemplate($templateId, $pdf_moveright, $pdf_movedown, $pdf_biggerbarcode); 161 } 162 } 163 } 164 165 $pdf->Output($pdf_path,"F"); 166 }
Note: See TracChangeset
for help on using the changeset viewer.