Changeset 3145874
- Timestamp:
- 09/03/2024 10:28:56 AM (17 months ago)
- Location:
- revolut-gateway-for-woocommerce/trunk
- Files:
-
- 4 edited
-
gateway-revolut.php (modified) (2 diffs)
-
includes/abstract/class-wc-payment-gateway-revolut.php (modified) (5 diffs)
-
includes/traits/wc-revolut-helper-trait.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
revolut-gateway-for-woocommerce/trunk/gateway-revolut.php
r3143027 r3145874 7 7 * Author URI: https://www.revolut.com/business/online-payments 8 8 * Text Domain: revolut-gateway-for-woocommerce 9 * Version: 4.17. 19 * Version: 4.17.2 10 10 * Requires at least: 4.4 11 11 * Tested up to: 6.5.4 … … 16 16 defined( 'ABSPATH' ) || exit; 17 17 define( 'REVOLUT_PATH', plugin_dir_path( __FILE__ ) ); 18 define( 'WC_GATEWAY_REVOLUT_VERSION', '4.17. 1' );18 define( 'WC_GATEWAY_REVOLUT_VERSION', '4.17.2' ); 19 19 define( 'WC_GATEWAY_PUBLIC_KEY_ENDPOINT', '/public-key/latest' ); 20 20 define( 'WC_GATEWAY_REVPAY_INDEX', 'USE_REVOLUT_PAY_2_0' ); -
revolut-gateway-for-woocommerce/trunk/includes/abstract/class-wc-payment-gateway-revolut.php
r3142952 r3145874 92 92 add_action( 'add_option_woocommerce_revolut_settings', array( $this, 'request_available_payment_methods_and_brand_logos' ) ); 93 93 add_action( 'update_option_woocommerce_revolut_settings', array( $this, 'request_available_payment_methods_and_brand_logos' ) ); 94 add_action( 'added_post_meta', array( $this, 'save_shipments_information' ), 10, 4 ); 95 add_action( 'added_order_meta', array( $this, 'save_shipments_information' ), 10, 4 ); 96 add_action( 'updated_post_meta', array( $this, 'save_shipments_information' ), 10, 4 ); 97 add_action( 'updated_order_meta', array( $this, 'save_shipments_information' ), 10, 4 ); 94 add_action( 'woocommerce_update_order', array( $this, 'save_shipments_information' ), 10, 1 ); 98 95 } 99 96 … … 110 107 $shipments = array( 111 108 array( 112 'tracking_number' => $tracking_item['tracking_number'],113 'shipping_company ' => $tracking_item['tracking_provider'],109 'tracking_number' => $tracking_item['tracking_number'], 110 'shipping_company_name' => $tracking_item['tracking_provider'], 114 111 ), 115 112 ); … … 124 121 * Fires immediately after updating metadata. 125 122 * 126 * @param int $meta_id ID of updated metadata entry. 127 * @param int $order_id Order Object ID. 128 * @param string $meta_key Metadata key. 129 * @param mixed $meta_value Metadata value. 130 */ 131 public function save_shipments_information( $meta_id, $order_id = 0, $meta_key = '', $meta_value = '' ) { 123 * @param int $order_id Order Object ID. 124 */ 125 public function save_shipments_information( $order_id = 0 ) { 132 126 try { 133 if ( ! $order_id || ( strpos( $meta_key, 'tracking_code' ) === false && strpos( $meta_key, 'tracking_number' ) === false && strpos( $meta_key, 'tracking_provider' ) === false ) ) {134 return;135 }136 137 127 $wc_order = wc_get_order( $order_id ); 138 128 $revolut_order_id = $wc_order->get_meta( 'revolut_payment_order_id', true ); … … 143 133 } 144 134 145 if ( strpos( $meta_key, 'tracking_number' ) !== false ) { 146 $shipping_company = $this->get_order_meta_by_partial_key( $wc_order, 'shipping_company' ); 147 $tracking_number = $meta_value; 148 } 149 150 if ( strpos( $meta_key, 'tracking_code' ) !== false ) { 151 $shipping_company = $this->get_order_meta_by_partial_key( $wc_order, 'shipping_company' ); 152 $tracking_number = $meta_value; 153 } 154 155 if ( strpos( $meta_key, 'tracking_provider' ) !== false ) { 156 $shipping_company = $meta_value; 157 $tracking_number = $this->get_order_meta_by_partial_key( $wc_order, 'tracking_number' ); 158 } 135 $shipping_company = $this->get_order_meta_by_partial_key( $wc_order, array( 'shipping_company', 'shipping_provider', 'tracking_provider' ) ); 136 $tracking_number = $this->get_order_meta_by_partial_key( $wc_order, array( 'tracking_number', 'tracking_code' ) ); 159 137 160 138 if ( empty( $shipping_company ) || empty( $tracking_number ) ) { … … 166 144 $shipping['shipments'] = array( 167 145 array( 168 'tracking_number' => $tracking_number,169 'shipping_company ' => $shipping_company,146 'tracking_number' => $tracking_number, 147 'shipping_company_name' => $shipping_company, 170 148 ), 171 149 ); 172 150 173 $this->api_client->patch( "/orders/$revolut_order_id", $shipping, false, true ); 151 $order_details = array( 'shipping' => $shipping ); 152 153 $this->api_client->patch( "/orders/$revolut_order_id", $order_details, false, true ); 174 154 175 155 $wc_order->update_meta_data( 'is_rev_shipments_info_saved', true ); -
revolut-gateway-for-woocommerce/trunk/includes/traits/wc-revolut-helper-trait.php
r3143027 r3145874 170 170 */ 171 171 public function collect_order_shipping_info( $order ) { 172 $shipping_address = $order->get_address( 'shipping' ); 172 $shipping_address = $order->get_address( 'shipping' ); 173 $billing_phone_number = preg_replace( '/[^0-9]/', '', $order->get_billing_phone() ); 173 174 174 175 $shipping = array( … … 184 185 'name' => $shipping_address['first_name'] . ' ' . $shipping_address['last_name'], 185 186 'email' => $order->get_billing_email(), 186 'phone' => $order->get_billing_phone(),187 'phone' => empty( $billing_phone_number ) ? null : $billing_phone_number, 187 188 ), 188 189 ); … … 215 216 $product_url = get_permalink( $product_id ); 216 217 $image_urls = $this->get_product_images( $product ); 218 219 if ( ! empty( $description ) && strlen( $description ) > 1024 ) { 220 $description = substr( $description, 0, 1024 ); 221 } 217 222 218 223 $line_items[] = array( … … 1108 1113 * 1109 1114 * @param object $order WC Order object. 1110 * @param string $meta_key ketof meta data.1111 */ 1112 public function get_order_meta_by_partial_key( $order, $meta _key) {1115 * @param array $metakey_list key of meta data. 1116 */ 1117 public function get_order_meta_by_partial_key( $order, $metakey_list ) { 1113 1118 foreach ( $order->get_meta_data() as $meta ) { 1114 if ( strpos( $meta->key, $meta_key ) !== false ) { 1115 return $meta->value; 1119 foreach ( $metakey_list as $meta_key ) { 1120 if ( strpos( $meta->key, $meta_key ) !== false ) { 1121 return $meta->value; 1122 } 1116 1123 } 1117 1124 } -
revolut-gateway-for-woocommerce/trunk/readme.txt
r3143027 r3145874 4 4 Requires at least: 4.4 5 5 Tested up to: 6.5 6 Stable tag: 4.17. 16 Stable tag: 4.17.2 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 99 99 100 100 == Changelog == 101 = 4.17.2 = 102 * Added logic for collecting line items & proof of shipping 103 101 104 = 4.17.1 = 102 105 * Fixed Woo Blocks order processing
Note: See TracChangeset
for help on using the changeset viewer.