/**
  * Adds actions and filters
  *
  * @access public
  * @return void
  */
 public static function init()
 {
     if (self::isActive()) {
         //get plugin instance
         self::$woocommerce = $GLOBALS['woocommerce'];
         //add authors support
         add_action('init', array(__CLASS__, 'addPosts'), 999);
         //update actions
         add_action('wp', array(__CLASS__, 'update'), 3);
         //order actions
         add_action('woocommerce_checkout_update_order_meta', array(__CLASS__, 'addOrder'), 999);
         add_filter('woocommerce_paypal_ap_payment_args', array(__CLASS__, 'splitOrder'), 10, 2);
         add_action('woocommerce_order_status_changed', array(__CLASS__, 'updateOrder'));
         //add checkout fields
         add_action('init', array(__CLASS__, 'addFields'), 999);
         //add custom columns
         add_filter('manage_edit-shop_order_columns', array(__CLASS__, 'addColumns'), 15);
         //enqueue scripts
         add_action('wp_enqueue_scripts', array(__CLASS__, 'addScripts'));
         //update cart actions
         add_filter('add_to_cart_fragments', array(__CLASS__, 'filterCart'));
         add_action('woocommerce_add_to_cart', array(__CLASS__, 'addCart'), 10, 1);
         add_action('woocommerce_cart_item_restored', array(__CLASS__, 'addCart'), 10, 1);
         add_action('woocommerce_thankyou', array(__CLASS__, 'removeCart'), 10);
         add_action('woocommerce_cart_item_removed', array(__CLASS__, 'removeCart'), 10);
         add_action('woocommerce_before_cart_item_quantity_zero', array(__CLASS__, 'removeCart'), 10);
         //shipping actions
         add_filter('woocommerce_package_rates', array(__CLASS__, 'updateShipping'), 100, 2);
         //set products limit
         add_filter('loop_shop_per_page', array(__CLASS__, 'updateProductsLimit'), 20);
         add_filter('woocommerce_output_related_products_args', array(__CLASS__, 'updateRelatedLimit'));
         add_action('woocommerce_after_single_product_summary', array(__CLASS__, 'updateUpsellLimit'), 15);
         //get product reviews
         add_filter('woocommerce_product_review_list_args', array(__CLASS__, 'getReviews'));
         //remove actions
         remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
         remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10);
         remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
         remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
         remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);
         remove_action('woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15);
         remove_action('woocommerce_before_shop_loop', 'wc_print_notices', 10);
         //add actions
         add_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 10);
         add_action('woocommerce_single_product_summary', 'comments_template', 60);
     }
 }
Example #2
0
 /**
  * Gets user
  *
  * @access public
  * @param int $ID
  * @param bool $extended
  * @return array
  */
 public static function getUser($ID, $extended = false)
 {
     $data = get_userdata($ID);
     if ($data != false) {
         $user['login'] = $data->user_login;
         $user['email'] = $data->user_email;
         $user['date'] = $data->user_registered;
     }
     $user['ID'] = $ID;
     $user['profile'] = self::getProfile($ID);
     $user['settings'] = self::getSettings($ID);
     $user['shop'] = self::getShop($ID);
     $user['favorites'] = array_reverse(ThemexCore::getUserRelations($ID, 0, 'product'));
     $user['shops'] = ThemexCore::getUserRelations($ID, 0, 'shop');
     $user['updates'] = ThemexWoo::getRelations($user['shops']);
     $user['clicks'] = intval(ThemexCore::getUserMeta($ID, 'clicks'));
     $user['profit'] = round(floatval(ThemexCore::getUserMeta($ID, 'profit')), 2);
     $user['balance'] = round(floatval(ThemexCore::getUserMeta($ID, 'balance')), 2);
     if ($extended) {
         $user['links'] = self::getLinks($ID, array('shops' => !ThemexCore::checkOption('shop_multiple'), 'shop' => themex_status($user['shop']) == 'publish', 'referrals' => !ThemexCore::checkOption('shop_referrals'), 'woocommerce' => ThemexWoo::isActive(), 'address' => !ThemexCore::checkOption('profile_address'), 'links' => !ThemexCore::checkOption('profile_links'), 'shipping' => !ThemexCore::checkOption('shop_shipping') && ThemexWoo::isShipping()));
     }
     return $user;
 }
</th>
				<th><?php 
            _e('Status', 'makery');
            ?>
</th>
				<th><?php 
            _e('Total', 'makery');
            ?>
</th>
				<th>&nbsp;</th>
			</tr>
		</thead>
		<tbody>
			<?php 
            foreach (ThemexShop::$data['orders'] as $ID) {
                $order = ThemexWoo::getOrder($ID);
                ?>
			<tr>
				<td>
					<a href="<?php 
                echo ThemexCore::getURL('shop-order', $order['ID']);
                ?>
">
						<?php 
                echo $order['number'];
                ?>
					</a>
				</td>
				<td>
					<time datetime="<?php 
                echo date('Y-m-d', strtotime($order['date']));
								</div>
								<div class="fourcol column">
									<div class="field-wrap">
										<input type="text" name="variation_regular_prices[]" value="<?php 
                        echo ThemexWoo::formatPrice($variation->_regular_price);
                        ?>
" placeholder="<?php 
                        _e('Regular Price', 'makery');
                        ?>
" />
									</div>
								</div>
								<div class="fourcol column last">
									<div class="field-wrap">
										<input type="text" name="variation_sale_prices[]" value="<?php 
                        echo ThemexWoo::formatPrice($variation->_sale_price);
                        ?>
" placeholder="<?php 
                        _e('Sale Price', 'makery');
                        ?>
" />
									</div>
								</div>
								<input type="hidden" name="variation_ids[]" value="<?php 
                        echo $variation->ID;
                        ?>
" />
							</div>
						</td>
					</tr>
					<?php 
Example #5
0
 /**
  * Uncompletes order
  *
  * @access public
  * @param int $ID
  * @return void
  */
 public static function uncompleteOrder($ID)
 {
     $relations = ThemexWoo::getRelatedPost($ID, array('course_product', 'plan_product'));
     if (!empty($relations)) {
         foreach ($relations as $related) {
             if ($related->post_type == 'course') {
                 ThemexCourse::removeUser($related->ID, $related->post_author, true);
             } else {
                 if ($related->post_type == 'plan') {
                     ThemexCourse::unsubscribeUser($related->ID, $related->post_author, true);
                 }
             }
         }
     }
 }
*/
get_header();
get_sidebar('profile-left');
?>
<div class="column fivecol">
	<div class="element-title indented">
		<h1><?php 
_e('My Address', 'makery');
?>
</h1>
	</div>
	<?php 
ThemexInterface::renderTemplateContent('profile-address');
?>
	<?php 
if (!ThemexWoo::isActive() || ThemexCore::checkOption('profile_address')) {
    ?>
	<span class="secondary"><?php 
    _e('There are no fields in this form.', 'makery');
    ?>
</span>
	<?php 
} else {
    ?>
	<form action="" method="POST" class="site-form">
		<div class="message">
			<?php 
    ThemexInterface::renderMessages(themex_value('success', $_POST, false));
    ?>
		</div>
		<table class="profile-fields">
									<div class="field-wrap">
										<input type="text" name="option_values[]" value="<?php 
                        echo $option['value'];
                        ?>
" placeholder="<?php 
                        _e('Options (comma separated)', 'makery');
                        ?>
" />
									</div>
								</div>
							</div>
						</td>
					</tr>
					<?php 
                    }
                    $variations = ThemexWoo::getVariations(ThemexWoo::$data['product']['ID']);
                    ?>
					<tr class="trigger-type-physical">
						<th><?php 
                    _e('Variations', 'makery');
                    ?>
</th>
						<td>
							<div class="element-options" id="variation">
								<?php 
                    foreach ($variations as $index => $variation) {
                        ?>
								<div class="option">
									<a href="#<?php 
                        echo $variation->ID;
                        ?>
    if (!ThemexCore::checkOption('shop_multiple') && ThemexShop::$data['status'] == 'publish') {
        ?>
				<tr>
					<th><?php 
        _e('Current Rate', 'makery');
        ?>
</th>				
					<td><?php 
        echo ThemexShop::filterRate(ThemexShop::$data['ID'], ThemexShop::$data['rate']);
        ?>
%</td>
				</tr>
				<?php 
    }
    $methods = array_flip(ThemexCore::getOption('withdrawal_methods', array('paypal', 'skrill', 'swift')));
    $gateways = ThemexWoo::getPaymentMethods();
    if (count($gateways) > 1 || !isset($gateways['paypal-adaptive-payments'])) {
        foreach (ThemexCore::$components['forms']['withdrawal'] as $name => $field) {
            if (is_array(reset($field))) {
                if (isset($methods[$name])) {
                    foreach ($field as $key => $child) {
                        ?>
								<tr class="trigger-method-<?php 
                        echo $name;
                        ?>
">
									<th><?php 
                        echo $child['label'];
                        ?>
</th>
									<td>
Example #9
0
<div class="course-rating rating-form">
	<div data-score="<?php 
echo round(ThemexCourse::$data['rating']);
?>
" <?php 
if (ThemexCourse::isRated()) {
    ?>
data-readonly="true"<?php 
}
?>
></div>
	<?php 
if (!ThemexCourse::isRated() && !ThemexWoo::isCheckout()) {
    ?>
	<form class="ajax-form hidden" action="<?php 
    echo AJAX_URL;
    ?>
" method="POST">
		<input type="hidden" name="course_rating" class="rating" value="" />
		<input type="hidden" name="course_id" value="<?php 
    echo ThemexCourse::$data['ID'];
    ?>
" />		
		<input type="hidden" name="course_action" value="update_rating" />
		<input type="hidden" name="nonce" class="nonce" value="<?php 
    echo wp_create_nonce(THEMEX_PREFIX . 'nonce');
    ?>
" />
		<input type="hidden" name="action" class="action" value="<?php 
    echo THEMEX_PREFIX;
    ?>
*/
get_header();
get_sidebar('profile-left');
?>
<div class="column fivecol">
	<div class="element-title indented">
		<h1><?php 
_e('Shop Membership', 'makery');
?>
</h1>
	</div>
	<?php 
ThemexInterface::renderTemplateContent('shop-membership');
?>
	<?php 
if (!ThemexWoo::isActive() || !ThemexCore::checkOption('membership_free')) {
    ?>
	<span class="secondary"><?php 
    _e('This shop does not exist.', 'makery');
    ?>
</span>
	<?php 
} else {
    $membership = ThemexUser::getMembership(ThemexUser::$data['current']['ID']);
    ?>
	<table class="profile-fields">
		<tbody>
			<tr>
				<th><?php 
    _e('Membership', 'makery');
    ?>
					<th><?php 
    _e('Total Profit', 'makery');
    ?>
</th>
					<td><?php 
    echo ThemexWoo::getPrice(ThemexUser::$data['current']['profit']);
    ?>
</td>
				</tr>
				<tr>
					<th><?php 
    _e('Current Balance', 'makery');
    ?>
</th>
					<td><?php 
    echo ThemexWoo::getPrice(ThemexUser::$data['current']['balance']);
    ?>
</td>
				</tr>
				<?php 
    if (!ThemexCore::checkOption('shop_multiple') && ThemexShop::$data['status'] == 'publish') {
        ?>
				<tr>
					<th><?php 
        _e('Current Rate', 'makery');
        ?>
</th>				
					<td><?php 
        echo ThemexShop::$data['rate'];
        ?>
%</td>
</th>
					<td>
						<?php 
            echo ThemexInterface::renderOption(array('id' => 'local_delivery_countries[]', 'type' => 'select', 'options' => ThemexWoo::getShippingCountries(), 'value' => themex_array('countries', $shipping['local_delivery']), 'wrap' => false, 'attributes' => array('class' => 'element-chosen', 'multiple' => 'multiple', 'data-placeholder' => __('Select Options', 'makery'))));
            ?>
					</td>
				</tr>
				<tr>
					<th><?php 
            _e('Cost', 'makery');
            ?>
</th>
					<td>
						<div class="field-wrap">
							<input type="text" name="local_delivery_cost" value="<?php 
            echo ThemexWoo::formatPrice(themex_value('cost', $shipping['local_delivery'], '0'));
            ?>
" />
						</div>
					</td>
				</tr>
			</tbody>
		</table>
		<?php 
        }
        ?>
		<a href="#" class="element-button element-submit primary"><?php 
        _e('Save Changes', 'makery');
        ?>
</a>
		<input type="hidden" name="shop_id" value="<?php 
Example #13
0
		<div class="plan-price product-price">
			<?php 
    echo $price;
    ?>
		</div>
		<?php 
}
?>
		
		<div class="plan-description">
			<?php 
the_content();
?>
		</div>
		<?php 
if (!ThemexWoo::isCheckout()) {
    ?>
		<footer class="plan-footer">
			<form action="<?php 
    echo themex_url(true, ThemexCore::getURL('register'));
    ?>
" method="POST">				
				<a href="#" class="element-button submit-button <?php 
    if ($post->menu_order != 1) {
        ?>
secondary<?php 
    }
    ?>
"><?php 
    _e('Subscribe Now', 'academy');
    ?>
Example #14
0
        ?>
				</ul>										
			</div>
		</footer>
		<?php 
    }
    ?>
	</div>
	<?php 
} else {
    ?>
	<div class="profile-preview sidebar-widget">
		<div class="profile-image">
			<?php 
    if (get_query_var('shop-product') && !ThemexCore::checkOption('shop_multiple')) {
        ThemexWoo::$data['product'] = ThemexWoo::getProduct(get_query_var('shop-product'));
        ?>
				<div class="image-wrap">
					<?php 
        echo ThemexCore::getImage(themex_value('ID', ThemexWoo::$data['product']), 200, THEME_URI . 'images/product.png');
        ?>
				</div>
				<?php 
        if (!empty(ThemexWoo::$data['product'])) {
            ?>
				<div class="profile-upload">
					<form action="" enctype="multipart/form-data" method="POST">
						<label for="product_thumb" class="element-button square" title="<?php 
            _e('Upload Image', 'makery');
            ?>
">
 /**
  * Gets membership period
  *
  * @access public
  * @param int $membership
  * @return string
  */
 public static function getPeriod($membership)
 {
     $price = '';
     $product = intval(ThemexCore::getPostMeta($membership, 'product'));
     if (!empty($product)) {
         $period = intval(ThemexCore::getPostMeta($membership, 'period'));
         $price = ThemexWoo::getPeriod($product, $period);
     }
     return $price;
 }
Example #16
0
			<!-- /header -->
			<div class="site-toolbar container">
				<nav class="header-menu element-menu left">
					<?php 
wp_nav_menu(array('theme_location' => 'main_menu', 'container_class' => 'menu'));
?>
				</nav>
				<div class="select-menu element-select redirect medium">
					<span></span>
					<?php 
ThemexInterface::renderDropdownMenu('main_menu');
?>
				</div>
				<!-- /menu -->
				<?php 
if (ThemexWoo::isActive()) {
    ?>
				<div class="header-cart right">
					<a href="<?php 
    echo ThemexWoo::$woocommerce->cart->get_cart_url();
    ?>
" class="cart-amount">
						<span class="fa fa-shopping-cart"></span>
						<?php 
    echo ThemexWoo::$woocommerce->cart->get_cart_total();
    ?>
					</a>
					<div class="cart-quantity"><?php 
    echo ThemexWoo::$woocommerce->cart->cart_contents_count;
    ?>
</div>
Example #17
0
<?php

/*
@version 3.0.0
*/
if (!defined('ABSPATH')) {
    exit;
}
global $woocommerce;
$product = reset($woocommerce->cart->get_cart());
$related = ThemexWoo::getRelatedPost($product['product_id'], array('course_product', 'plan_product'), true);
if (!empty($related)) {
    $get_checkout_url = apply_filters('woocommerce_get_checkout_url', $woocommerce->cart->get_checkout_url());
    wc_print_notices();
    do_action('woocommerce_before_checkout_form', $checkout);
    $query = new WP_Query(array('post__in' => array($related->ID), 'post_type' => $related->post_type));
    ?>
<form name="checkout" method="post" class="checkout course-checkout" action="<?php 
    echo esc_url($get_checkout_url);
    ?>
">
	<div class="threecol column">
		<?php 
    $query->the_post();
    if ($related->post_type == 'course') {
        get_template_part('content', 'course-grid');
    } else {
        get_template_part('content', 'plan');
    }
    ?>
	</div>
		<tr>
			<th><?php 
    _e('Customer Note', 'makery');
    ?>
</th>
			<td>
				<?php 
    echo nl2br(esc_html($order->post->post_excerpt));
    ?>
			</td>
		</tr>		
		<?php 
}
?>
		<?php 
$note = ThemexWoo::getNote($order->id);
if (!empty($note)) {
    ?>
		<tr>
			<th><?php 
    _e('Order Note', 'makery');
    ?>
</th>
			<td>
				<?php 
    echo nl2br(esc_html($note));
    ?>
			</td>
		</tr>		
		<?php 
}
 /**
  * Updates shop rating
  *
  * @access public
  * @param int $ID
  * @return void
  */
 public static function updateRating($ID)
 {
     $rating = get_comment_meta($ID, 'rating', true);
     if (!empty($rating)) {
         $comment = get_comment($ID);
         $user = get_post_field('post_author', $comment->comment_post_ID);
         $shop = ThemexUser::getShop($user);
         $rating = ThemexWoo::getRating($user);
         ThemexCore::updatePostMeta($shop, 'rating', $rating['rating']);
         ThemexCore::updatePostMeta($shop, 'ratings', $rating['ratings']);
     }
 }
Example #20
0
<?php

/*
Template Name: Shop Order
*/
get_header();
get_sidebar('profile-left');
$order = ThemexWoo::getOrder(get_query_var('shop-order'));
?>
<div class="column fivecol">
	<div class="element-title indented">
		<h1><?php 
_e('Edit Order', 'makery');
?>
</h1>
	</div>
	<?php 
ThemexInterface::renderTemplateContent('shop-order');
?>
	<?php 
if (ThemexCore::checkOption('shop_multiple')) {
    ?>
	<span class="secondary"><?php 
    _e('This shop does not exist.', 'makery');
    ?>
</span>
	<?php 
} else {
    if (empty($order) || $order['author'] != ThemexUser::$data['current']['ID']) {
        ?>
	<span class="secondary"><?php 
</th>
				<th><?php 
            _e('Stock', 'makery');
            ?>
</th>
				<th><?php 
            _e('Price', 'makery');
            ?>
</th>
				<th>&nbsp;</th>
			</tr>
		</thead>
		<tbody>
			<?php 
            foreach (ThemexShop::$data['products'] as $ID) {
                $product = ThemexWoo::getProduct($ID);
                ?>
			<tr>
				<td>
					<a href="<?php 
                echo ThemexCore::getURL('shop-product', $product['ID']);
                ?>
" <?php 
                if ($product['status'] == 'draft') {
                    ?>
class="secondary"<?php 
                }
                ?>
>
						<?php 
                if (empty($product['title'])) {
Example #22
0
<?php

get_header();
?>
<div class="woocommerce">
	<?php 
$woocommerce_loop['single'] = true;
$woocommerce_loop['columns'] = 4;
$products = array_merge(ThemexShop::$data['products'], array(0));
$limit = intval(themex_value('limit', $_GET, ThemexCore::getOption('products_per_page', 9)));
$order = ThemexWoo::getSorting();
query_posts(array('post_type' => 'product', 'post_status' => 'publish', 'paged' => themex_paged(), 'posts_per_page' => $limit, 'post__in' => $products, 'orderby' => $order['orderby'], 'order' => $order['order'], 'meta_key' => $order['meta_key']));
$layout = 'full';
$shop = $post->ID;
ThemexWoo::getTemplate('archive-product.php');
?>
</div>
<?php 
get_footer();
Example #23
0
/*
@version 2.3.0
*/
if (!defined('ABSPATH')) {
    exit;
}
$cart = ThemexWoo::getCart();
wc_print_notices();
do_action('woocommerce_before_cart');
?>
<div id="content">
	<div class="eightcol column">
		<?php 
if (!empty($cart)) {
    $title = get_the_title(ThemexUser::getShop(ThemexWoo::getUser()));
    ?>
		<div class="element-title indented">
			<h2><?php 
    echo __('Order from', 'woocommerce') . ' ' . $title;
    ?>
</h2>
		</div>
		<?php 
}
?>
		<form action="<?php 
echo esc_url(WC()->cart->get_cart_url());
?>
" method="POST">
			<?php 
Example #24
0
 /**
  * Adds course member
  *
  * @access public
  * @param int $ID
  * @param bool $private
  * @return void
  */
 public static function addUser($ID, $user, $private = false)
 {
     self::refresh($ID);
     $redirect = get_permalink($ID);
     if ($user != 0 || self::$data['status'] == 'premium' && self::$data['product'] != 0) {
         if (!self::isMember($user)) {
             if ($private || self::$data['status'] == 'free' || self::$data['status'] == 'premium' && self::$data['product'] == 0) {
                 ThemexCore::addUserRelation($user, $ID, 'course', current_time('timestamp'));
                 self::$data['users'][] = $user;
                 $number = count(self::$data['users']);
                 ThemexCore::updatePostMeta($ID, 'course_popularity', $number);
                 $message = ThemexCore::getOption('email_course');
                 if (!empty($message)) {
                     $data = get_userdata($user);
                     $keywords = array('username' => $data->user_login, 'title' => get_the_title($ID), 'link' => $redirect);
                     themex_mail($data->user_email, __('Course Membership', 'academy'), themex_keywords($message, $keywords));
                 }
                 if (!$private) {
                     wp_redirect($redirect);
                     exit;
                 }
             } else {
                 if (self::$data['status'] == 'premium') {
                     ThemexWoo::addProduct(self::$data['product']);
                 }
             }
         } else {
             if (!$private) {
                 wp_redirect($redirect);
                 exit;
             }
         }
     }
 }
				<tr> 
					<td><?php 
            _e('All Classes', 'makery');
            ?>
</td>
					<td>
						<div class="field-wrap">
							<input type="text" name="flat_rate_default_cost" value="<?php 
            echo themex_value('default_cost', $shipping['flat_rate'], '0');
            ?>
" />
						</div>
					</td>
				</tr>
				<?php 
            $classes = ThemexWoo::getShippingClasses();
            $costs = themex_array('costs', $shipping['flat_rate']);
            foreach ($classes as $index => $class) {
                ?>
				<tr> 
					<td><?php 
                echo $class->name;
                ?>
</td>
					<td>
						<div class="field-wrap">
							<input type="text" name="flat_rate_cost[<?php 
                echo $index;
                ?>
]" value="<?php 
                echo themex_value($class->slug, $costs, '0');