Skip to content

Instantly share code, notes, and snippets.

@stompweb
Created September 27, 2016 15:57
Show Gist options
  • Save stompweb/8653d2ff8375cc651563b934117b2b51 to your computer and use it in GitHub Desktop.
Save stompweb/8653d2ff8375cc651563b934117b2b51 to your computer and use it in GitHub Desktop.
Order Classs
<?php
class Order {
public $_order;
public function __construct( $order_id ) {
if ( empty( $order_id ) ) {
throw new Exception( '$order_id empty' );
}
$this->_order = $this->get( $order_id );
}
function get( $order_id ) {
global $wpdb;
$table_name = $wpdb->base_prefix . 'orders';
$orders = $wpdb->get_row( "SELECT * FROM $table_name WHERE order_id = " . $order_id, ARRAY_A );
return $order;
}
function get_total() {
return $this->_order['total'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment