Fix conflict

This commit is contained in:
Mike Jolley 2015-04-14 11:27:30 +01:00
commit d133d35e27
1 changed files with 9 additions and 0 deletions

View File

@ -372,6 +372,11 @@ class WC_API_Orders extends WC_API_Resource {
* @return array
*/
public function create_order( $data ) {
global $wpdb;
$data = isset( $data['order'] ) ? $data['order'] : array();
$wpdb->query( 'START TRANSACTION' );
try {
if ( ! isset( $data['order'] ) ) {
@ -482,10 +487,14 @@ class WC_API_Orders extends WC_API_Resource {
do_action( 'woocommerce_api_create_order', $order->id, $data, $this );
$wpdb->query( 'COMMIT' );
return $this->get_order( $order->id );
} catch ( WC_API_Exception $e ) {
$wpdb->query( 'ROLLBACK' );
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
}