/**
  * This function shows the WooCommerce cart notice if the user has
  * added the current course to cart. It does not show if the user is already taking
  * the course.
  *
  * @since 1.0.2
  * @return void;
  */
 public function sensei_woocommerce_in_cart_message()
 {
     global $post, $woocommerce;
     $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
     $user_course_status_id = WooThemes_Sensei_Utils::user_started_course($post->ID, get_current_user_id());
     if (0 < intval($wc_post_id) && !$user_course_status_id) {
         if (sensei_check_if_product_is_in_cart($wc_post_id)) {
             echo '<div class="sensei-message info">' . sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>');
         }
         // End If Statement
     }
     // End If Statement
 }
/**
 * sensei_simple_course_price function.
 *
 * @access public
 * @param mixed $post_id
 * @return void
 */
function sensei_simple_course_price($post_id)
{
    //WooCommerce Pricing
    if (Sensei_WC::is_woocommerce_active()) {
        $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true);
        if (0 < $wc_post_id) {
            // Get the product
            $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
            if (isset($product) && !empty($product) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart($wc_post_id)) {
                ?>
    	    		<span class="course-price"><?php 
                echo $product->get_price_html();
                ?>
</span>
    	    	<?php 
            }
            // End If Statement
        }
        // End If Statement
    }
    // End If Statement
}
Example #3
0
        $product = $woothemes_sensei->sensei_get_woocommerce_product_object($wc_post_id);
        if (!isset($product) || !is_object($product)) {
            exit;
        }
        if ($product->is_purchasable()) {
            // Check Product Availability
            $availability = $product->get_availability();
            if ($availability['availability']) {
                echo apply_filters('woocommerce_stock_html', '<p class="stock ' . $availability['class'] . '">' . $availability['availability'] . '</p>', $availability['availability']);
            }
            // End If Statement
            // Check for stock
            if ($product->is_in_stock()) {
                ?>
                <?php 
                if (!sensei_check_if_product_is_in_cart($wc_post_id)) {
                    ?>
                    <form action="<?php 
                    echo esc_url($product->add_to_cart_url());
                    ?>
" class="cart" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="product_id" value="<?php 
                    echo esc_attr($product->id);
                    ?>
" />
                        <input type="hidden" name="quantity" value="1" />
                        <?php 
                    if (isset($product->variation_id) && 0 < intval($product->variation_id)) {
                        ?>
                            <input type="hidden" name="variation_id" value="<?php 
                        echo $product->variation_id;