Changeset 3021703
- Timestamp:
- 01/15/2024 04:20:37 AM (2 years ago)
- Location:
- redbox-pickup
- Files:
-
- 17 added
- 3 edited
-
tags/1.33/admin (added)
-
tags/1.33/admin/config.php (added)
-
tags/1.33/admin/new_method.php (added)
-
tags/1.33/css (added)
-
tags/1.33/css/front.css (added)
-
tags/1.33/front (added)
-
tags/1.33/front/front.php (added)
-
tags/1.33/images (added)
-
tags/1.33/images/marker_counter.svg (added)
-
tags/1.33/images/marker_counter_locker.svg (added)
-
tags/1.33/images/marker_locked.svg (added)
-
tags/1.33/images/marker_locker.svg (added)
-
tags/1.33/images/marker_selected.svg (added)
-
tags/1.33/js (added)
-
tags/1.33/js/front.js (added)
-
tags/1.33/readme.txt (added)
-
tags/1.33/redbox.php (added)
-
trunk/front/front.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/redbox.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
redbox-pickup/trunk/front/front.php
r2994949 r3021703 40 40 'name' => $item->get_name(), 41 41 'quantity' => $item->get_quantity(), 42 'total ' => $item->get_total(),42 'totalPrice' => $item->get_total(), 43 43 'currency' => $order->get_currency() 44 44 ]; 45 $note = 'items ' . json_encode($item->get_data()); 46 $order->add_order_note( $note ); 45 47 } 46 48 return $products; … … 175 177 "cod_currency" => "", 176 178 "shipping_price" => $priceData['shipping_total'], 177 "shipping_ currency" => $order->get_currency(),179 "shipping_price_currency" => $order->get_currency(), 178 180 "items" => $this->redbox_get_product($order), 179 181 "from_platform" => "woo_commerce" … … 185 187 $dataShipment['cod_currency'] = $priceData['curency']; 186 188 } else { 187 if ($order->is_paid()) { 188 $dataShipment['cod_amount'] = 0; 189 $dataShipment['cod_currency'] = $priceData['curency']; 190 } else { 191 $dataShipment['cod_amount'] = 10; 192 $dataShipment['cod_currency'] = "USD"; 193 } 189 $dataShipment['cod_amount'] = 0; 190 $dataShipment['cod_currency'] = $priceData['curency']; 194 191 } 195 192 if ($this->redbox_validate_body_create_shipment($dataShipment)) { … … 218 215 219 216 private function redbox_validate_body_update_shipment($dataShipment = []){ 220 if (isset($dataShipment["point_id"]) && !empty($dataShipment["point_id"]) && 221 isset($dataShipment["customer_phone"]) && !empty($dataShipment["customer_phone"]) 222 ) { 217 if (isset($dataShipment["customer_phone"]) && !empty($dataShipment["customer_phone"])) { 223 218 return true; 224 219 } else { … … 227 222 } 228 223 229 function redbox_update_shipment( $post_id ) { 230 if (isset($_POST[ 'post_type' ]) && 'shop_order' == $_POST[ 'post_type' ]) { 231 $order = wc_get_order( $post_id ); 232 $orderKey = $order->get_order_key(); 233 $orderNumber = $order->get_order_number(); 234 235 $customerData = $this->redbox_get_data_customer($order); 236 $priceData = $this->redbox_get_other_info($order); 237 238 $dataShipment = [ 239 "reference" => $post_id, 240 "point_id" => get_post_meta( $order_id, '_redbox_point_id', true ), 241 "customer_name" => $customerData['name'], 242 "customer_phone" => $customerData['phone'], 243 "customer_email" => $customerData['email'], 244 "customer_address" => $customerData['adddress'], 245 "cod_amount" => "", 246 "cod_currency" => "", 247 "shipping_price" => $priceData['shipping_total'], 248 "shipping_currency" => $order->get_currency(), 249 "items" => $this->redbox_get_product($order), 250 "status" => $order->get_status() 251 ]; 252 if ($order->get_payment_method() == "cod") { 253 $dataShipment['cod_amount'] = $priceData['order_total']; 254 $dataShipment['cod_currency'] = $priceData['curency']; 255 } else { 256 $dataShipment['cod_amount'] = 0; 257 $dataShipment['cod_currency'] = $priceData['curency']; 258 } 259 if ($this->redbox_validate_body_update_shipment($dataShipment)) { 260 $urlQuery = REDBOX_URL_UPDATE_SHIPMENT; 261 $options = array( 262 'headers' => array( 263 'Authorization' => 'Bearer ' . $this->redboxKey 264 ), 265 'body' => $dataShipment, 266 'timeout' => 60 267 ); 268 $response = wp_remote_post($urlQuery, $options); 269 } 270 } 224 function redbox_update_shipment( $order_id, $order ) { 225 if ( is_admin() ) { 226 $orderKey = $order->get_order_key(); 227 $orderNumber = $order->get_order_number(); 228 229 $customerData = $this->redbox_get_data_customer($order); 230 $priceData = $this->redbox_get_other_info($order); 231 $current_user = wp_get_current_user(); 232 233 $dataShipment = [ 234 "reference" => $order_id, 235 "point_id" => get_post_meta( $order_id, '_redbox_point_id', true ), 236 "customer_name" => $customerData['name'], 237 "customer_phone" => $customerData['phone'], 238 "customer_email" => $customerData['email'], 239 "customer_address" => $customerData['adddress'], 240 "cod_amount" => "", 241 "cod_currency" => "", 242 "shipping_price" => $priceData['shipping_total'], 243 "shipping_price_currency" => $order->get_currency(), 244 "items" => $this->redbox_get_product($order), 245 "status" => $order->get_status(), 246 "action_by" => $current_user ? $current_user->user_login : "business_admin" 247 ]; 248 if ($order->get_payment_method() == "cod") { 249 $dataShipment['cod_amount'] = $priceData['order_total']; 250 $dataShipment['cod_currency'] = $priceData['curency']; 251 } else { 252 $dataShipment['cod_amount'] = 0; 253 $dataShipment['cod_currency'] = $priceData['curency']; 254 } 255 if ($this->redbox_validate_body_update_shipment($dataShipment)) { 256 $urlQuery = REDBOX_URL_UPDATE_SHIPMENT; 257 $options = array( 258 'headers' => array( 259 'Authorization' => 'Bearer ' . $this->redboxKey 260 ), 261 'body' => $dataShipment, 262 'timeout' => 60 263 ); 264 $response = wp_remote_post($urlQuery, $options); 265 } 266 } 271 267 } 272 268 … … 358 354 add_action( 'woocommerce_view_order', array($this, 'redbox_show_redbox_point_when_create_order_success') ); 359 355 add_action('woocommerce_checkout_process', array($this, 'redbox_validate_with_redbox_pickup')); 360 add_action( ' save_post', array($this, 'redbox_update_shipment'));356 add_action( 'woocommerce_update_order', array($this, 'redbox_update_shipment'), 10, 2); 361 357 add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this, 'redbox_add_button_print_label')); 362 358 add_filter( 'woocommerce_package_rates', array($this, 'bbloomer_woocommerce_tiered_shipping'), 10, 2 ); -
redbox-pickup/trunk/readme.txt
r2994949 r3021703 5 5 Requires at least: 3.3 6 6 Tested up to: 5.5.1 7 Stable tag: 1.3 37 Stable tag: 1.34 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 = 1.33 = 75 75 Fix shipping method 76 = 1.34 = 77 Fix update information, api create-v2 76 78 77 79 -
redbox-pickup/trunk/redbox.php
r2994949 r3021703 4 4 * Description: This plugin allows customers pickup package at RedBox Locker. 5 5 * Plugin URI: https://woocommerce.com/ 6 * Version: 1.3 36 * Version: 1.34 7 7 * Author: RedBox 8 8 * Author URI: https://redboxsa.com … … 40 40 } 41 41 if (!defined('REDBOX_URL_CREATE_SHIPMENT')) { 42 define('REDBOX_URL_CREATE_SHIPMENT', REDBOX_BASE_URL . "/create-shipment- for-store");42 define('REDBOX_URL_CREATE_SHIPMENT', REDBOX_BASE_URL . "/create-shipment-v2"); 43 43 } 44 44 if (!defined('REDBOX_URL_UPDATE_SHIPMENT')) {
Note: See TracChangeset
for help on using the changeset viewer.