Changeset 2515504
- Timestamp:
- 04/15/2021 09:41:51 AM (5 years ago)
- Location:
- redbox-pickup
- Files:
-
- 3 edited
- 6 copied
-
tags/1.4 (copied) (copied from redbox-pickup/trunk)
-
tags/1.4/css/front.css (copied) (copied from redbox-pickup/trunk/css/front.css)
-
tags/1.4/front/front.php (copied) (copied from redbox-pickup/trunk/front/front.php) (4 diffs)
-
tags/1.4/js/front.js (copied) (copied from redbox-pickup/trunk/js/front.js)
-
tags/1.4/readme.txt (copied) (copied from redbox-pickup/trunk/readme.txt) (3 diffs)
-
tags/1.4/redbox.php (copied) (copied from redbox-pickup/trunk/redbox.php) (1 diff)
-
trunk/front/front.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/redbox.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
redbox-pickup/tags/1.4/front/front.php
r2491692 r2515504 122 122 } 123 123 124 function redbox_create_shipment( $order_id ) { 125 if ( ! $order_id ) 126 return; 127 128 if( ! get_post_meta( $order_id, '_thankyou_action_done', true ) ) { 129 $order = wc_get_order( $order_id ); 130 $orderKey = $order->get_order_key(); 131 $orderNumber = $order->get_order_number(); 132 133 $customerData = $this->redbox_get_data_customer($order); 134 $priceData = $this->redbox_get_other_info($order); 135 136 $dataShipment = [ 137 "store_url" => get_home_url(), 138 "reference" => $order_id, 139 "point_id" => $order->get_meta( '_redbox_point_id' ), 140 "customer_name" => $customerData['name'], 141 "customer_phone" => $customerData['phone'], 142 "customer_email" => $customerData['email'], 143 "customer_address" => $customerData['adddress'], 144 "cod_amount" => "", 145 "cod_currency" => "", 146 "shipping_price" => $priceData['shipping_total'], 147 "shipping_currency" => $order->get_currency(), 148 "items" => $this->redbox_get_product($order), 149 "from_platform" => "woo_commerce" 150 ]; 151 if ($order->get_payment_method() == "cod") { 152 $dataShipment['cod_amount'] = $priceData['order_total']; 153 $dataShipment['cod_currency'] = $priceData['curency']; 154 } else { 155 $dataShipment['cod_amount'] = 0; 156 $dataShipment['cod_currency'] = $priceData['curency']; 157 } 158 if ($this->redbox_validate_body_create_shipment($dataShipment)) { 159 $urlQuery = REDBOX_URL_CREATE_SHIPMENT; 160 $options = array( 161 'headers' => array( 162 'Authorization' => 'Bearer ' . $this->redboxKey 163 ), 164 'body' => $dataShipment 165 ); 166 $response = wp_remote_post($urlQuery, $options); 167 $body = json_decode( wp_remote_retrieve_body( $response ), true ); 168 if ($body['success']) { 169 $note = 'RedBox tracking number: ' . $body['tracking_number']; 170 $order->add_order_note( $note ); 171 $order->update_meta_data( 'redbox_shipment_url_shipping_label', $body['url_shipping_label'] ); 172 } else { 173 $note = 'RedBox error: ' . $body['msg']; 174 $order->add_order_note( $note ); 175 } 124 function redbox_create_shipment( $order_id, $posted_data, $order ) { 125 if (!$order) return; 126 $orderKey = $order->get_order_key(); 127 $orderNumber = $order->get_order_number(); 128 129 $customerData = $this->redbox_get_data_customer($order); 130 $priceData = $this->redbox_get_other_info($order); 131 132 $dataShipment = [ 133 "store_url" => get_home_url(), 134 "reference" => $order_id, 135 "point_id" => $order->get_meta( '_redbox_point_id' ), 136 "customer_name" => $customerData['name'], 137 "customer_phone" => $customerData['phone'], 138 "customer_email" => $customerData['email'], 139 "customer_address" => $customerData['adddress'], 140 "cod_amount" => "", 141 "cod_currency" => "", 142 "shipping_price" => $priceData['shipping_total'], 143 "shipping_currency" => $order->get_currency(), 144 "items" => $this->redbox_get_product($order), 145 "from_platform" => "woo_commerce" 146 ]; 147 if ($order->get_payment_method() == "cod") { 148 $dataShipment['cod_amount'] = $priceData['order_total']; 149 $dataShipment['cod_currency'] = $priceData['curency']; 150 } else { 151 $dataShipment['cod_amount'] = 0; 152 $dataShipment['cod_currency'] = $priceData['curency']; 153 } 154 if ($this->redbox_validate_body_create_shipment($dataShipment)) { 155 $urlQuery = REDBOX_URL_CREATE_SHIPMENT; 156 $options = array( 157 'headers' => array( 158 'Authorization' => 'Bearer ' . $this->redboxKey 159 ), 160 'body' => $dataShipment 161 ); 162 $response = wp_remote_post($urlQuery, $options); 163 $body = json_decode( wp_remote_retrieve_body( $response ), true ); 164 if ($body['success']) { 165 $note = 'RedBox tracking number: ' . $body['tracking_number']; 166 $order->add_order_note( $note ); 167 $order->update_meta_data( 'redbox_shipment_url_shipping_label', $body['url_shipping_label'] ); 168 } else { 169 $note = 'RedBox error: ' . $body['msg']; 170 $order->add_order_note( $note ); 176 171 } 177 178 $order->update_meta_data( '_thankyou_action_done', true ); 179 $order->save(); 180 } 172 } 173 174 $order->save(); 181 175 } 182 176 … … 195 189 196 190 function redbox_update_shipment( $post_id ) { 197 if ( 'shop_order' == $_POST[ 'post_type' ]) {191 if (isset($_POST[ 'post_type' ]) && 'shop_order' == $_POST[ 'post_type' ]) { 198 192 $order = wc_get_order( $post_id ); 199 193 $orderKey = $order->get_order_key(); … … 267 261 } 268 262 269 function redbox_show_redbox_point_in_admin_order_detail( $order ) {263 function redbox_show_redbox_point_in_admin_order_detail( $order ) { 270 264 $order_id = $order->get_id(); 271 265 if (get_post_meta( $order_id, '_redbox_point', true )) { … … 301 295 add_action('wp_ajax_getlispoint', array( $this, 'redbox_get_list_point' )); 302 296 add_action('wp_ajax_nopriv_getlispoint', array( $this, 'redbox_get_list_point' )); 303 add_action('woocommerce_ thankyou', array( $this, 'redbox_create_shipment' ));297 add_action('woocommerce_checkout_order_processed', array( $this, 'redbox_create_shipment' ), 10, 3); 304 298 add_action( 'woocommerce_after_checkout_billing_form', array($this, 'redbox_add_point_field') ); 305 299 306 300 307 301 add_action( 'woocommerce_checkout_update_order_meta', array($this, 'redbox_save_redbox_point_when_create_order') ); 308 //add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this, 'redbox_show_redbox_point_in_admin_order_detail'));309 add_action( 'woocommerce_ thankyou', array($this, 'redbox_show_redbox_point_when_create_order_success') );302 add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this, 'redbox_show_redbox_point_in_admin_order_detail')); 303 add_action( 'woocommerce_checkout_order_processed', array($this, 'redbox_show_redbox_point_when_create_order_success') ); 310 304 add_action( 'woocommerce_view_order', array($this, 'redbox_show_redbox_point_when_create_order_success') ); 311 305 add_action('woocommerce_checkout_process', array($this, 'redbox_validate_with_redbox_pickup')); -
redbox-pickup/tags/1.4/readme.txt
r2493015 r2515504 5 5 Requires at least: 3.3 6 6 Tested up to: 5.5.1 7 Stable tag: 1. 37 Stable tag: 1.4 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 37 37 = 1.3 = 38 38 Bound map when search address or click my location 39 = 1.4 = 40 Enhance hook to complete order 39 41 40 42 … … 44 46 = 1.3 = 45 47 Bound map when search address or click my location 48 = 1.4 = 49 Enhance hook to complete order 46 50 47 51 -
redbox-pickup/tags/1.4/redbox.php
r2493015 r2515504 4 4 * Description: This plugin allows customers pickup package at RedBox Locker. 5 5 * Plugin URI: https://woocommerce.com/ 6 * Version: 1. 36 * Version: 1.4 7 7 * Author: RedBox 8 8 * Author URI: https://redboxsa.com -
redbox-pickup/trunk/front/front.php
r2491692 r2515504 122 122 } 123 123 124 function redbox_create_shipment( $order_id ) { 125 if ( ! $order_id ) 126 return; 127 128 if( ! get_post_meta( $order_id, '_thankyou_action_done', true ) ) { 129 $order = wc_get_order( $order_id ); 130 $orderKey = $order->get_order_key(); 131 $orderNumber = $order->get_order_number(); 132 133 $customerData = $this->redbox_get_data_customer($order); 134 $priceData = $this->redbox_get_other_info($order); 135 136 $dataShipment = [ 137 "store_url" => get_home_url(), 138 "reference" => $order_id, 139 "point_id" => $order->get_meta( '_redbox_point_id' ), 140 "customer_name" => $customerData['name'], 141 "customer_phone" => $customerData['phone'], 142 "customer_email" => $customerData['email'], 143 "customer_address" => $customerData['adddress'], 144 "cod_amount" => "", 145 "cod_currency" => "", 146 "shipping_price" => $priceData['shipping_total'], 147 "shipping_currency" => $order->get_currency(), 148 "items" => $this->redbox_get_product($order), 149 "from_platform" => "woo_commerce" 150 ]; 151 if ($order->get_payment_method() == "cod") { 152 $dataShipment['cod_amount'] = $priceData['order_total']; 153 $dataShipment['cod_currency'] = $priceData['curency']; 154 } else { 155 $dataShipment['cod_amount'] = 0; 156 $dataShipment['cod_currency'] = $priceData['curency']; 157 } 158 if ($this->redbox_validate_body_create_shipment($dataShipment)) { 159 $urlQuery = REDBOX_URL_CREATE_SHIPMENT; 160 $options = array( 161 'headers' => array( 162 'Authorization' => 'Bearer ' . $this->redboxKey 163 ), 164 'body' => $dataShipment 165 ); 166 $response = wp_remote_post($urlQuery, $options); 167 $body = json_decode( wp_remote_retrieve_body( $response ), true ); 168 if ($body['success']) { 169 $note = 'RedBox tracking number: ' . $body['tracking_number']; 170 $order->add_order_note( $note ); 171 $order->update_meta_data( 'redbox_shipment_url_shipping_label', $body['url_shipping_label'] ); 172 } else { 173 $note = 'RedBox error: ' . $body['msg']; 174 $order->add_order_note( $note ); 175 } 124 function redbox_create_shipment( $order_id, $posted_data, $order ) { 125 if (!$order) return; 126 $orderKey = $order->get_order_key(); 127 $orderNumber = $order->get_order_number(); 128 129 $customerData = $this->redbox_get_data_customer($order); 130 $priceData = $this->redbox_get_other_info($order); 131 132 $dataShipment = [ 133 "store_url" => get_home_url(), 134 "reference" => $order_id, 135 "point_id" => $order->get_meta( '_redbox_point_id' ), 136 "customer_name" => $customerData['name'], 137 "customer_phone" => $customerData['phone'], 138 "customer_email" => $customerData['email'], 139 "customer_address" => $customerData['adddress'], 140 "cod_amount" => "", 141 "cod_currency" => "", 142 "shipping_price" => $priceData['shipping_total'], 143 "shipping_currency" => $order->get_currency(), 144 "items" => $this->redbox_get_product($order), 145 "from_platform" => "woo_commerce" 146 ]; 147 if ($order->get_payment_method() == "cod") { 148 $dataShipment['cod_amount'] = $priceData['order_total']; 149 $dataShipment['cod_currency'] = $priceData['curency']; 150 } else { 151 $dataShipment['cod_amount'] = 0; 152 $dataShipment['cod_currency'] = $priceData['curency']; 153 } 154 if ($this->redbox_validate_body_create_shipment($dataShipment)) { 155 $urlQuery = REDBOX_URL_CREATE_SHIPMENT; 156 $options = array( 157 'headers' => array( 158 'Authorization' => 'Bearer ' . $this->redboxKey 159 ), 160 'body' => $dataShipment 161 ); 162 $response = wp_remote_post($urlQuery, $options); 163 $body = json_decode( wp_remote_retrieve_body( $response ), true ); 164 if ($body['success']) { 165 $note = 'RedBox tracking number: ' . $body['tracking_number']; 166 $order->add_order_note( $note ); 167 $order->update_meta_data( 'redbox_shipment_url_shipping_label', $body['url_shipping_label'] ); 168 } else { 169 $note = 'RedBox error: ' . $body['msg']; 170 $order->add_order_note( $note ); 176 171 } 177 178 $order->update_meta_data( '_thankyou_action_done', true ); 179 $order->save(); 180 } 172 } 173 174 $order->save(); 181 175 } 182 176 … … 195 189 196 190 function redbox_update_shipment( $post_id ) { 197 if ( 'shop_order' == $_POST[ 'post_type' ]) {191 if (isset($_POST[ 'post_type' ]) && 'shop_order' == $_POST[ 'post_type' ]) { 198 192 $order = wc_get_order( $post_id ); 199 193 $orderKey = $order->get_order_key(); … … 267 261 } 268 262 269 function redbox_show_redbox_point_in_admin_order_detail( $order ) {263 function redbox_show_redbox_point_in_admin_order_detail( $order ) { 270 264 $order_id = $order->get_id(); 271 265 if (get_post_meta( $order_id, '_redbox_point', true )) { … … 301 295 add_action('wp_ajax_getlispoint', array( $this, 'redbox_get_list_point' )); 302 296 add_action('wp_ajax_nopriv_getlispoint', array( $this, 'redbox_get_list_point' )); 303 add_action('woocommerce_ thankyou', array( $this, 'redbox_create_shipment' ));297 add_action('woocommerce_checkout_order_processed', array( $this, 'redbox_create_shipment' ), 10, 3); 304 298 add_action( 'woocommerce_after_checkout_billing_form', array($this, 'redbox_add_point_field') ); 305 299 306 300 307 301 add_action( 'woocommerce_checkout_update_order_meta', array($this, 'redbox_save_redbox_point_when_create_order') ); 308 //add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this, 'redbox_show_redbox_point_in_admin_order_detail'));309 add_action( 'woocommerce_ thankyou', array($this, 'redbox_show_redbox_point_when_create_order_success') );302 add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this, 'redbox_show_redbox_point_in_admin_order_detail')); 303 add_action( 'woocommerce_checkout_order_processed', array($this, 'redbox_show_redbox_point_when_create_order_success') ); 310 304 add_action( 'woocommerce_view_order', array($this, 'redbox_show_redbox_point_when_create_order_success') ); 311 305 add_action('woocommerce_checkout_process', array($this, 'redbox_validate_with_redbox_pickup')); -
redbox-pickup/trunk/readme.txt
r2493015 r2515504 5 5 Requires at least: 3.3 6 6 Tested up to: 5.5.1 7 Stable tag: 1. 37 Stable tag: 1.4 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 37 37 = 1.3 = 38 38 Bound map when search address or click my location 39 = 1.4 = 40 Enhance hook to complete order 39 41 40 42 … … 44 46 = 1.3 = 45 47 Bound map when search address or click my location 48 = 1.4 = 49 Enhance hook to complete order 46 50 47 51 -
redbox-pickup/trunk/redbox.php
r2493015 r2515504 4 4 * Description: This plugin allows customers pickup package at RedBox Locker. 5 5 * Plugin URI: https://woocommerce.com/ 6 * Version: 1. 36 * Version: 1.4 7 7 * Author: RedBox 8 8 * Author URI: https://redboxsa.com
Note: See TracChangeset
for help on using the changeset viewer.