Skip to content

Commit

Permalink
Actualiziación update_order_meta para aceptar array de valores.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseconti committed Apr 12, 2024
1 parent ed9889a commit 09e3a42
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions classes/class-wc-gateway-redsys-global-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,22 @@ public function get_order_meta( $order_id, $key, $single = true ) {
/**
* Copyright: (C) 2013 - 2021 José Conti
*/
public function update_order_meta( $post_id, $meta_key, $meta_value ) {
$this->debug( 'Función update_order_meta' );
$this->debug( '$post_id: ' . $post_id );
$this->debug( '$meta_key: ' . $meta_key );
$this->debug( '$meta_value: ' . $meta_value );

public function update_order_meta( $post_id, $meta_key_array, $meta_value = false ) {
if ( ! is_array( $meta_key_array ) ) {
$meta_keys = array( $meta_key_array => $meta_value );
} else {
$meta_keys = $meta_key_array;
}
$order_id = $this->get_order_meta( $post_id, 'post_id', true );
$this->debug( '$order_id $this->get_order_meta: ' . $order_id );
if ( $order_id ) {
$post_id = $order_id;
$this->debug( '$post_id = $order_id' );
$order = wc_get_order( $post_id );
} else {
$order = wc_get_order( $post_id );
$this->debug( '$order = wc_get_order( $post_id )' );
}
$this->debug( 'update_meta_data' );
$this->debug( '$meta_key: ' . $meta_key );
$this->debug( '$meta_value: ' . $meta_value );
$order->update_meta_data( $meta_key, $meta_value );
foreach ( $meta_keys as $meta_key => $meta_value ) {
$order->update_meta_data( $meta_key, $meta_value );
}
$order->save();
}
/**
Expand Down

0 comments on commit 09e3a42

Please sign in to comment.