*/
class Astrk_Public
{
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of the plugin.
* @param string $version The version of this plugin.
*/
public function __construct($plugin_name, $version)
{
$this->plugin_name = $plugin_name;
$this->version = $version;
}
/**
* Register the JavaScript for the public-facing side of the site.
*
* @since 1.0.0
*/
public function enqueue_scripts()
{
function console_log($data)
{
$output = $data;
if (is_array($output))
$output = implode(',', $output);
echo "";
}
$options = get_option("astrk_options");
if (isset($options['uid']) && isset($options['token'])) {
global $woocommerce;
if (!empty($woocommerce->cart->applied_coupons)) {
if (!isset($_COOKIE['voucherCode'])) {
setcookie(
'voucherCode',
$woocommerce->cart->applied_coupons[0],
time() + 60 * 60 * 24 * 30, #cookie lasts for 30 days
'/',
$_SERVER['SERVER_NAME']
);
}
} else {
if (isset($_COOKIE['voucherCode'])) {
setcookie(
'voucherCode',
0,
time() - 3600,
'/',
$_SERVER['SERVER_NAME']
);
}
}
function adservice_is_woocommerce_activated()
{
return class_exists('woocommerce');
}
function adservice_get_last_order_id()
{
global $wpdb;
$statuses = array_keys(wc_get_order_statuses());
$statuses = implode("','", $statuses);
// Getting last Order ID (max value)
$results = $wpdb->get_col("
SELECT MAX(ID) FROM {$wpdb->prefix}posts
WHERE post_type LIKE 'shop_order'
AND post_status IN ('$statuses')
");
return reset($results);
}
add_action('wp_head', 'adservice_add_script_wp_header');
function adservice_add_script_wp_header()
{
?>
query_vars['order-received']);
$order = wc_get_order($order_id);
$order_data = $order->get_data();
echo "";
}
}
}
}
}
?>