File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Order.php.tar
www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/optinmonster/OMAPI/WooCommerce/Order.php 0000644 00000007755 15154774131 0030052 0 ustar 00 var <?php
/**
* WooCommerce Order class.
*
* @since 2.13.8
*
* @package OMAPI
* @author Justin Sternberg
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WooCommerce Order class.
*
* @since 2.13.8
*/
class OMAPI_WooCommerce_Order {
/**
* Holds instances of this order object.
*
* @since 2.13.8
*
* @var OMAPI_WooCommerce_Order[]
*/
protected static $instances = array();
/**
* Holds the ID of the order.
*
* @since 2.13.8
*
* @var string
*/
protected $id;
/**
* Holds the order object.
*
* @since 2.13.8
*
* @var WC_Order
*/
protected $order;
/**
* Get instance of the OMAPI_WooCommerce_Order and cache it.
*
* @since 2.13.8
*
* @param string $id The order ID.
* @param boolean $cached Whether to use the cached instance or not.
*
* @return self
*/
public static function get( $id = '', $cached = true ) {
if ( empty( $id ) ) {
return new self( $id );
}
if ( $id instanceof WC_Order || $id instanceof WC_Abstract_Order ) {
$order = $id;
$id = (int) $order->get_id();
if ( ! isset( self::$instances[ $id ] ) ) {
new self( $id );
}
self::$instances[ $id ]->set_order( $order );
} elseif ( ! empty( $id->ID ) ) {
$id = (int) $id->ID;
} else {
$id = (int) $id;
}
if ( ! $cached || ! isset( self::$instances[ $id ] ) ) {
$me = new self( $id );
$me->fetch_and_set_order();
}
return self::$instances[ $id ];
}
/**
* Class constructor.
*
* @since 2.13.8
*
* @param string $id The order ID.
*/
protected function __construct( $id = '' ) {
// If no data has been passed, don't setup anything. Maybe we are in test or create mode?
if ( empty( $id ) ) {
return;
}
// Prepare properties.
$this->id = $id;
self::$instances[ $id ] = $this;
}
/**
* Fetches the order object and sets it.
*
* @since 2.13.8
*
* @return self
*/
protected function fetch_and_set_order() {
$this->set_order( wc_get_order( $this->id ) );
return $this;
}
/**
* Sets the order object.
*
* @since 2.13.8
*
* @param WC_Order $order The order object.
*
* @return self
*/
protected function set_order( $order ) {
$this->order = $order;
return $this;
}
/**
* Checks if the order exists/is valid.
*
* @since 2.13.8
*
* @return boolean
*/
public function is() {
if ( empty( $this->order ) ) {
return false;
}
$id = $this->order->get_id();
return ! empty( $id );
}
/**
* Gets order meta, use HPOS API when possible.
*
* @since 2.13.8
*
* @param string $key Meta Key.
* @param bool $single return first found meta with key, or all with $key.
* @param string $context What the value is for. Valid values are view and edit.
* @return mixed
*/
public function get_meta( $key = '', $single = true, $context = 'edit' ) {
return ! empty( $this->order ) && method_exists( $this->order, 'get_meta' )
? $this->order->get_meta( $key, $single, $context )
: get_post_meta( $this->id, $key, $single );
}
/**
* Updates order meta, use HPOS API when possible.
*
* If using HPOS, can pass $save = false to not save the order (for bulk updates).
*
* @since 2.13.8
*
* @param string $key The meta key.
* @param mixed $value The meta value.
* @param bool $save Whether to save the order after meta update (if using HPOS).
*
* @return boolean
*/
public function update_meta_data( $key, $value, $save = true ) {
if ( ! empty( $this->order ) && method_exists( $this->order, 'update_meta_data' ) ) {
$this->order->update_meta_data( $key, $value );
return $save ? $this->order->save() : false;
}
return update_post_meta( $this->id, $key, $value );
}
/**
* Proxy calls to the order object.
*
* @since 2.13.8
*
* @param string $method The method name.
* @param array $args The method arguments.
*
* @return mixed
*/
public function __call( $method, $args ) {
return $this->order
? call_user_func_array( array( $this->order, $method ), $args )
: null;
}
}
www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/woocommerce/src/Admin/Overrides/Order.php 0000644 00000007123 15155122130 0030275 0 ustar 00 var <?php
/**
* WC Admin Order
*
* WC Admin Order class that adds some functionality on top of general WooCommerce WC_Order.
*/
namespace Automattic\WooCommerce\Admin\Overrides;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore as CustomersDataStore;
use Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore as OrdersStatsDataStore;
/**
* WC_Order subclass.
*/
class Order extends \WC_Order {
/**
* Order traits.
*/
use OrderTraits;
/**
* Holds refund amounts and quantities for the order.
*
* @var void|array
*/
protected $refunded_line_items;
/**
* Caches the customer ID.
*
* @var int
*/
public $customer_id = null;
/**
* Get only core class data in array format.
*
* @return array
*/
public function get_data_without_line_items() {
return array_merge(
array(
'id' => $this->get_id(),
),
$this->data,
array(
'number' => $this->get_order_number(),
'meta_data' => $this->get_meta_data(),
)
);
}
/**
* Get order line item data by type.
*
* @param string $type Order line item type.
* @return array|bool Array of line items on success, boolean false on failure.
*/
public function get_line_item_data( $type ) {
$type_to_items = array(
'line_items' => 'line_item',
'tax_lines' => 'tax',
'shipping_lines' => 'shipping',
'fee_lines' => 'fee',
'coupon_lines' => 'coupon',
);
if ( isset( $type_to_items[ $type ] ) ) {
return $this->get_items( $type_to_items[ $type ] );
}
return false;
}
/**
* Add filter(s) required to hook this class to substitute WC_Order.
*/
public static function add_filters() {
add_filter( 'woocommerce_order_class', array( __CLASS__, 'order_class_name' ), 10, 3 );
}
/**
* Filter function to swap class WC_Order for this one in cases when it's suitable.
*
* @param string $classname Name of the class to be created.
* @param string $order_type Type of order object to be created.
* @param number $order_id Order id to create.
*
* @return string
*/
public static function order_class_name( $classname, $order_type, $order_id ) {
// @todo - Only substitute class when necessary (during sync).
if ( 'WC_Order' === $classname ) {
return '\Automattic\WooCommerce\Admin\Overrides\Order';
} else {
return $classname;
}
}
/**
* Get the customer ID used for reports in the customer lookup table.
*
* @return int
*/
public function get_report_customer_id() {
if ( is_null( $this->customer_id ) ) {
$this->customer_id = CustomersDataStore::get_or_create_customer_from_order( $this );
}
return $this->customer_id;
}
/**
* Returns true if the customer has made an earlier order.
*
* @return bool
*/
public function is_returning_customer() {
return OrdersStatsDataStore::is_returning_customer( $this, $this->get_report_customer_id() );
}
/**
* Get the customer's first name.
*/
public function get_customer_first_name() {
if ( $this->get_user_id() ) {
return get_user_meta( $this->get_user_id(), 'first_name', true );
}
if ( '' !== $this->get_billing_first_name( 'edit' ) ) {
return $this->get_billing_first_name( 'edit' );
} else {
return $this->get_shipping_first_name( 'edit' );
}
}
/**
* Get the customer's last name.
*/
public function get_customer_last_name() {
if ( $this->get_user_id() ) {
return get_user_meta( $this->get_user_id(), 'last_name', true );
}
if ( '' !== $this->get_billing_last_name( 'edit' ) ) {
return $this->get_billing_last_name( 'edit' );
} else {
return $this->get_shipping_last_name( 'edit' );
}
}
}
httpdocs/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Routes/V1/Order.php0000644 00000004136 15157430254 0036164 0 ustar 00 var/www/vhosts/uyarreklam.com.tr <?php
namespace Automattic\WooCommerce\StoreApi\Routes\V1;
use Automattic\WooCommerce\StoreApi\SchemaController;
use Automattic\WooCommerce\StoreApi\Schemas\v1\AbstractSchema;
use Automattic\WooCommerce\StoreApi\Utilities\OrderController;
use Automattic\WooCommerce\StoreApi\Exceptions\RouteException;
use Automattic\WooCommerce\StoreApi\Utilities\OrderAuthorizationTrait;
/**
* Order class.
*/
class Order extends AbstractRoute {
use OrderAuthorizationTrait;
/**
* The route identifier.
*
* @var string
*/
const IDENTIFIER = 'order';
/**
* The schema item identifier.
*
* @var string
*/
const SCHEMA_TYPE = 'order';
/**
* Order controller class instance.
*
* @var OrderController
*/
protected $order_controller;
/**
* Constructor.
*
* @param SchemaController $schema_controller Schema Controller instance.
* @param AbstractSchema $schema Schema class for this route.
*/
public function __construct( SchemaController $schema_controller, AbstractSchema $schema ) {
parent::__construct( $schema_controller, $schema );
$this->order_controller = new OrderController();
}
/**
* Get the path of this REST route.
*
* @return string
*/
public function get_path() {
return '/order/(?P<id>[\d]+)';
}
/**
* Get method arguments for this REST route.
*
* @return array An array of endpoints.
*/
public function get_args() {
return [
[
'methods' => \WP_REST_Server::READABLE,
'callback' => [ $this, 'get_response' ],
'permission_callback' => [ $this, 'is_authorized' ],
'args' => [
'context' => $this->get_context_param( [ 'default' => 'view' ] ),
],
],
'schema' => [ $this->schema, 'get_public_item_schema' ],
];
}
/**
* Handle the request and return a valid response for this endpoint.
*
* @param \WP_REST_Request $request Request object.
* @return \WP_REST_Response
*/
protected function get_route_response( \WP_REST_Request $request ) {
$order_id = absint( $request['id'] );
return rest_ensure_response( $this->schema->get_item_response( wc_get_order( $order_id ) ) );
}
}