From e8851990316d1537a221da45806b23b505c1fafa Mon Sep 17 00:00:00 2001 From: timjackleus Date: Sun, 17 Dec 2023 14:09:13 +0100 Subject: [PATCH] fix: replace update_post_meta --- classes/class-ledyer-lco-gateway.php | 42 ++++++++++++++-------------- includes/lco-functions.php | 6 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php index 81b7627..2a3d5e7 100644 --- a/classes/class-ledyer-lco-gateway.php +++ b/classes/class-ledyer-lco-gateway.php @@ -279,39 +279,39 @@ public function process_payment_handler( $order_id ) { $company_name = ! empty( $customer_billing['companyName'] ) ? $customer_billing['companyName'] : ( ! empty( $customer_shipping['companyName'] ) ? $customer_shipping['companyName'] : '' ); // Set WC order transaction ID. - update_post_meta( $order_id, '_wc_ledyer_order_id', $ledyer_order['orderId'] ); + $order->update_meta_data( '_wc_ledyer_order_id', $ledyer_order['orderId'] ); - update_post_meta( $order_id, '_wc_ledyer_session_id', $ledyer_order['id'] ); + $order->update_meta_data( '_wc_ledyer_session_id', $ledyer_order['id'] ); - update_post_meta( $order_id, '_transaction_id', $ledyer_order['orderId'] ); + $order->update_meta_data( '_transaction_id', $ledyer_order['orderId'] ); - update_post_meta( $order_id, '_ledyer_company_id', $ledyer_order['customer']['companyId'] ); + $order->update_meta_data( '_ledyer_company_id', $ledyer_order['customer']['companyId'] ); - update_post_meta( $order_id, '_ledyer_company_name', $company_name ); + $order->update_meta_data( '_ledyer_company_name', $company_name ); $environment = $this->testmode ? 'sandbox' : 'production'; - update_post_meta( $order_id, '_wc_ledyer_environment', $environment ); + $order->update_meta_data( '_wc_ledyer_environment', $environment ); $ledyer_country = wc_get_base_location()['country']; - update_post_meta( $order_id, '_wc_ledyer_country', $ledyer_country ); + $order->update_meta_data( '_wc_ledyer_country', $ledyer_country ); // Set shipping meta if( isset( $ledyer_order['customer']['shippingAddress'] ) ) { - update_post_meta( $order_id, '_shipping_attention_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['attentionName'] ) ); - update_post_meta( $order_id, '_shipping_care_of', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['careOf'] ) ); + $order->update_meta_data( '_shipping_attention_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['attentionName'] ) ); + $order->update_meta_data( '_shipping_care_of', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['careOf'] ) ); } // Set order recipient meta if( isset( $ledyer_order['customer']['shippingAddress']['contact'] ) ) { - update_post_meta( $order_id, '_shipping_first_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["firstName"] ) ); - update_post_meta( $order_id, '_shipping_last_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["lastName"]) ); - update_post_meta( $order_id, '_shipping_phone', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["phone"] ) ); - update_post_meta( $order_id, '_shipping_email', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["email"]) ); + $order->update_meta_data( '_shipping_first_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["firstName"] ) ); + $order->update_meta_data( '_shipping_last_name', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["lastName"]) ); + $order->update_meta_data( '_shipping_phone', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["phone"] ) ); + $order->update_meta_data( '_shipping_email', sanitize_text_field( $ledyer_order['customer']['shippingAddress']['contact']["email"]) ); } // Set billing meta if( isset( $ledyer_order['customer']['billingAddress'] ) ) { - update_post_meta( $order_id, '_billing_attention_name', sanitize_text_field( $ledyer_order['customer']['billingAddress']['attentionName'] ) ); - update_post_meta( $order_id, '_billing_care_of', sanitize_text_field( $ledyer_order['customer']['billingAddress']['careOf'] ) ); + $order->update_meta_data( '_billing_attention_name', sanitize_text_field( $ledyer_order['customer']['billingAddress']['attentionName'] ) ); + $order->update_meta_data( '_billing_care_of', sanitize_text_field( $ledyer_order['customer']['billingAddress']['careOf'] ) ); } @@ -588,12 +588,12 @@ public function ledyer_order_shipping_fields( $order ) { } public function ledyer_order_save_custom_fields( $order_id ) { - update_post_meta( $order_id, '_billing_attention_name', sanitize_text_field( $_POST[ '_billing_attention_name' ] ) ); - update_post_meta( $order_id, '_billing_care_of', sanitize_text_field( $_POST[ '_billing_care_of' ] ) ); - update_post_meta( $order_id, '_shipping_attention_name', sanitize_text_field( $_POST[ '_shipping_attention_name' ] ) ); - update_post_meta( $order_id, '_shipping_care_of', sanitize_text_field( $_POST[ '_shipping_care_of' ] ) ); - update_post_meta( $order_id, '_shipping_phone', sanitize_text_field( $_POST[ '_shipping_phone' ] ) ); - update_post_meta( $order_id, '_shipping_email', sanitize_text_field( $_POST[ '_shipping_email' ] ) ); + $order->update_meta_data( '_billing_attention_name', sanitize_text_field( $_POST[ '_billing_attention_name' ] ) ); + $order->update_meta_data( '_billing_care_of', sanitize_text_field( $_POST[ '_billing_care_of' ] ) ); + $order->update_meta_data( '_shipping_attention_name', sanitize_text_field( $_POST[ '_shipping_attention_name' ] ) ); + $order->update_meta_data( '_shipping_care_of', sanitize_text_field( $_POST[ '_shipping_care_of' ] ) ); + $order->update_meta_data( '_shipping_phone', sanitize_text_field( $_POST[ '_shipping_phone' ] ) ); + $order->update_meta_data( '_shipping_email', sanitize_text_field( $_POST[ '_shipping_email' ] ) ); } /** diff --git a/includes/lco-functions.php b/includes/lco-functions.php index 495d714..a8018f9 100644 --- a/includes/lco-functions.php +++ b/includes/lco-functions.php @@ -215,8 +215,8 @@ function wc_ledyer_confirm_ledyer_order( $order_id ) { $ledyer_payment_provider = sanitize_text_field( $ledyer_payment_method['provider']); $ledyer_payment_type = sanitize_text_field( $ledyer_payment_method['type']); - update_post_meta( $order_id, 'ledyer_payment_type', $ledyer_payment_type ); - update_post_meta( $order_id, 'ledyer_payment_method', $ledyer_payment_provider ); + $order->update_meta_data( 'ledyer_payment_type', $ledyer_payment_type ); + $order->update_meta_data( 'ledyer_payment_method', $ledyer_payment_provider ); switch ( $ledyer_payment_type ) { case 'invoice': @@ -276,7 +276,7 @@ function wc_ledyer_confirm_ledyer_order( $order_id ) { } do_action( 'ledyer_process_payment', $order_id, $ledyer_order ); - update_post_meta( $order_id, '_ledyer_date_paid', gmdate( 'Y-m-d H:i:s' ) ); + $order->update_meta_data( '_ledyer_date_paid', gmdate( 'Y-m-d H:i:s' ) ); $response = ledyer()->api->acknowledge_order( $payment_id ); if( is_wp_error( $response ) ) {