Files
piratepoet/lib/WooCommerce/Helper.php
2019-05-13 12:26:23 -04:00

54 lines
1.1 KiB
PHP

<?php
namespace MailPoet\WooCommerce;
use MailPoet\WP\Functions;
class Helper {
/** @var Functions */
private $wp;
function __construct(Functions $wp = null) {
if (!$wp) {
$wp = Functions::get();
}
$this->wp = $wp;
}
function isWooCommerceActive() {
return class_exists('WooCommerce');
}
function wcGetCustomerOrderCount($user_id) {
return wc_get_customer_order_count($user_id);
}
function wcGetOrder($order = false) {
return wc_get_order($order);
}
function wcPrice($price, array $args = array()) {
return wc_price($price, $args);
}
function wcGetProduct($the_product = false) {
return wc_get_product($the_product);
}
function getWoocommerceCurrency() {
return get_woocommerce_currency();
}
function getOrdersCount() {
$counts = $this->wp->wpCountPosts('shop_order');
return array_reduce((array)$counts, function($sum, $count_for_state) {
return $sum + (int)$count_for_state;
});
}
function getRawPrice($price, array $args = []) {
$html_price = $this->wcPrice($price, $args);
return html_entity_decode(strip_tags($html_price));
}
}