Created
December 16, 2016 10:25
-
-
Save slobich/9f3cde167ed609d3a471720bd6717455 to your computer and use it in GitHub Desktop.
matej
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !$data["status"]["errors"] ) { | |
unset( $data["status"] ); | |
$response = $this->get_response( $this->base_url . "Order", "post", json_encode( $data ), "application/json" ); | |
if (is_wp_error($response)) { | |
if ( !array_key_exists( "messages", $data["status"] ) ) { | |
$data["status"]["messages"] = "Greška u komunikaciji s 3i API-em."; | |
} | |
update_post_meta( $order_id, "_sf_sync_status", "failed" ); | |
update_post_meta( $order_id, "_sf_sync_error_message", esc_attr( $data["status"]["messages"] ) ); | |
} else { | |
$body = json_decode( json_decode( $response["body"] ) ); | |
// var_dump( $body ); | |
if ( $body->status == "1" ) { | |
// update_field( "successful_sync", true, $order_id ); | |
update_post_meta( $order_id, "_sf_sync_status", "successful" ); | |
} else { | |
// update_field( "error_message", esc_attr( $body->errorMessage ), $order_id ); | |
update_post_meta( $order_id, "_sf_sync_status", "failed" ); | |
update_post_meta( $order_id, "_sf_sync_error_message", esc_attr( $body->errorMessage ) ); | |
} | |
} | |
} else { | |
if ( !array_key_exists( "messages", $data["status"] ) ) { | |
$data["status"]["messages"] = "Greška u komunikaciji s 3i API-em."; | |
} | |
// update_field( "error_message", esc_attr( $data["status"]["messages"] ), $order_id ); | |
update_post_meta( $order_id, "_sf_sync_status", "failed" ); | |
update_post_meta( $order_id, "_sf_sync_error_message", esc_attr( $data["status"]["messages"] ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment