Skip to content

Commit

Permalink
fix: replace update_post_meta
Browse files Browse the repository at this point in the history
  • Loading branch information
timjackleus committed Dec 17, 2023
1 parent 8a1673d commit e885199
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
42 changes: 21 additions & 21 deletions classes/class-ledyer-lco-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) );
}


Expand Down Expand Up @@ -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' ] ) );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions includes/lco-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit e885199

Please sign in to comment.