/**
  * Display the simulator.
  *
  * @return string Simulator HTML.
  */
 public static function simulator()
 {
     global $product;
     if (!is_product() || !self::$activated) {
         return;
     }
     if ($product->needs_shipping() && $product->is_in_stock() && in_array($product->product_type, array('simple', 'variable'))) {
         $options = get_option('woocommerce_correios_settings');
         if ('variable' == $product->product_type) {
             $style = 'display: none';
             $ids = array();
             foreach ($product->get_available_variations() as $variation) {
                 $_variation = get_product($variation['variation_id']);
                 $ids[] = $_variation->needs_shipping() ? $_variation->variation_id : '';
             }
             $ids = implode(',', array_filter($ids));
         } else {
             $style = '';
             $ids = $product->id;
         }
         if (isset($options['display_date']) && 'yes' == $options['display_date']) {
             $title = __('Shipping and delivery time', 'woocommerce-correios');
             $description = __('Calculate the shipping and delivery time estimated to your region.', 'woocommerce-correios');
         } else {
             $title = __('Shipping', 'woocommerce-correios');
             $description = __('Calculate shipping estimated to your region.', 'woocommerce-correios');
         }
         woocommerce_get_template('single-product/correios-simulator.php', array('product' => $product, 'style' => $style, 'ids' => $ids, 'title' => $title, 'description' => $description), '', WC_Correios::get_templates_path());
     }
 }
function woocommerce_order_tracking($atts)
{
    global $woocommerce;
    $woocommerce->nocache();
    extract(shortcode_atts(array(), $atts));
    global $post;
    if ($_POST) {
        $woocommerce->verify_nonce('order_tracking');
        if (isset($_POST['orderid']) && $_POST['orderid']) {
            $order_id = $_POST['orderid'];
        } else {
            $order_id = 0;
        }
        if (isset($_POST['order_email']) && $_POST['order_email']) {
            $order_email = trim($_POST['order_email']);
        } else {
            $order_email = '';
        }
        $order = new WC_Order(apply_filters('woocommerce_shortcode_order_tracking_order_id', $order_id));
        if ($order->id && $order_email) {
            if (strtolower($order->billing_email) == strtolower($order_email)) {
                woocommerce_get_template('order/tracking.php', array('order' => $order));
                return;
            }
        }
        echo '<p>' . sprintf(__('Sorry, we could not find that order id in our database. <a href="%s">Want to retry?</a>', 'woocommerce'), get_permalink($post->ID)) . '</p>';
    } else {
        woocommerce_get_template('order/form-tracking.php');
    }
}
Exemple #3
0
 function woocommerce_template_loop_add_to_cart()
 {
     if (!is_user_logged_in()) {
         return;
     }
     woocommerce_get_template('loop/add-to-cart.php');
 }
 /**
  * Output the to pay block.
  *
  * @access public
  * @subpackage	Product
  * @return void
  * 
  */
 function woocommerce_auction_pay()
 {
     global $product;
     if ($product->product_type == 'auction') {
         woocommerce_get_template('single-product/pay.php');
     }
 }
 /**
  * Show a users bookings
  */
 public function my_bookings()
 {
     $bookings = WC_Bookings_Controller::get_bookings_for_user(get_current_user_id());
     if ($bookings) {
         woocommerce_get_template('myaccount/my-bookings.php', array('bookings' => $bookings), 'woocommerce-bookings/', WC_BOOKINGS_TEMPLATE_PATH);
     }
 }
/**
 * List all (or limited) product categories
 **/
function woocommerce_product_categories($atts)
{
    global $woocommerce_loop;
    extract(shortcode_atts(array('number' => null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1), $atts));
    if (isset($atts['ids'])) {
        $ids = explode(',', $atts['ids']);
        $ids = array_map('trim', $ids);
    } else {
        $ids = array();
    }
    $hide_empty = $hide_empty == true || $hide_empty == 1 ? 1 : 0;
    $args = array('number' => $number, 'orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids);
    $terms = get_terms('product_cat', $args);
    $woocommerce_loop['columns'] = $columns;
    ob_start();
    if ($product_categories) {
        echo '<ul class="products">';
        foreach ($product_categories as $category) {
            woocommerce_get_template('content-product_cat.php', array('category' => $category));
        }
        echo '</ul>';
    }
    wp_reset_query();
    return ob_get_clean();
}
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     // Check checkout is configured correctly
     if (current_user_can('manage_options')) {
         $pay_page_id = woocommerce_get_page_id('pay');
         $thanks_page_id = woocommerce_get_page_id('thanks');
         $pay_page = get_permalink($pay_page_id);
         $thanks_page = get_permalink($thanks_page_id);
         if (!$pay_page_id || !$thanks_page_id || empty($pay_page) || empty($thanks_page)) {
             $woocommerce->add_error(sprintf(__('WooCommerce Config Error: The checkout thanks/pay pages are missing - these pages are required for the checkout to function correctly. Please configure the pages <a href="%s">here</a>.', 'woocommerce'), admin_url('admin.php?page=woocommerce_settings&tab=pages')));
         }
     }
     // Show non-cart errors
     $woocommerce->show_messages();
     // Check cart has contents
     if (sizeof($woocommerce->cart->get_cart()) == 0) {
         return;
     }
     // Calc totals
     $woocommerce->cart->calculate_totals();
     // Check cart contents for errors
     do_action('woocommerce_check_cart_items');
     // Get checkout object
     $checkout = $woocommerce->checkout();
     if (empty($_POST) && $woocommerce->error_count() > 0) {
         woocommerce_get_template('checkout/cart-errors.php', array('checkout' => $checkout));
     } else {
         $non_js_checkout = !empty($_POST['woocommerce_checkout_update_totals']) ? true : false;
         if ($woocommerce->error_count() == 0 && $non_js_checkout) {
             $woocommerce->add_message(__('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce'));
         }
         woocommerce_get_template('checkout/form-checkout.php', array('checkout' => $checkout));
     }
 }
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     // Prevent cache
     $woocommerce->nocache();
     // Show non-cart errors
     $woocommerce->show_messages();
     // Check cart has contents
     if (sizeof($woocommerce->cart->get_cart()) == 0) {
         return;
     }
     // Calc totals
     $woocommerce->cart->calculate_totals();
     // Check cart contents for errors
     do_action('woocommerce_check_cart_items');
     // Get checkout object
     $checkout = $woocommerce->checkout();
     if (empty($_POST) && $woocommerce->error_count() > 0) {
         woocommerce_get_template('checkout/cart-errors.php', array('checkout' => $checkout));
     } else {
         $non_js_checkout = !empty($_POST['woocommerce_checkout_update_totals']) ? true : false;
         if ($woocommerce->error_count() == 0 && $non_js_checkout) {
             $woocommerce->add_message(__('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce'));
         }
         woocommerce_get_template('checkout/form-checkout.php', array('checkout' => $checkout));
     }
 }
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     $woocommerce->nocache();
     extract(shortcode_atts(array(), $atts));
     global $post;
     if (!empty($_REQUEST['orderid'])) {
         $woocommerce->verify_nonce('order_tracking');
         $order_id = empty($_REQUEST['orderid']) ? 0 : esc_attr($_REQUEST['orderid']);
         $order_email = empty($_REQUEST['order_email']) ? '' : esc_attr($_REQUEST['order_email']);
         if (!$order_id) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order ID', 'woocommerce') . '</p>';
         } elseif (!$order_email) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order email', 'woocommerce') . '</p>';
         } else {
             $order = new WC_Order(apply_filters('woocommerce_shortcode_order_tracking_order_id', $order_id));
             if ($order->id && $order_email) {
                 if (strtolower($order->billing_email) == strtolower($order_email)) {
                     do_action('woocommerce_track_order', $order->id);
                     woocommerce_get_template('order/tracking.php', array('order' => $order));
                     return;
                 }
             } else {
                 echo '<p class="woocommerce-error">' . sprintf(__('Sorry, we could not find that order id in our database.', 'woocommerce'), get_permalink($post->ID)) . '</p>';
             }
         }
     }
     woocommerce_get_template('order/form-tracking.php');
 }
/**
 * Outputs the order received page
 **/
function woocommerce_thankyou($atts)
{
    global $woocommerce;
    $woocommerce->nocache();
    $woocommerce->show_messages();
    $order = false;
    // Pay for order after checkout step
    if (isset($_GET['order'])) {
        $order_id = $_GET['order'];
    } else {
        $order_id = 0;
    }
    if (isset($_GET['key'])) {
        $order_key = $_GET['key'];
    } else {
        $order_key = '';
    }
    // Empty awaiting payment session
    unset($_SESSION['order_awaiting_payment']);
    if ($order_id > 0) {
        $order = new WC_Order($order_id);
        if ($order->order_key != $order_key) {
            unset($order);
        }
    }
    woocommerce_get_template('checkout/thankyou.php', array('order' => $order));
}
function woocommerce_order_tracking($atts)
{
    global $woocommerce, $order;
    extract(shortcode_atts(array(), $atts));
    global $post;
    if ($_POST) {
        $order =& new woocommerce_order();
        if (isset($_POST['orderid']) && $_POST['orderid'] > 0) {
            $order->id = (int) $_POST['orderid'];
        } else {
            $order->id = 0;
        }
        if (isset($_POST['order_email']) && $_POST['order_email']) {
            $order_email = trim($_POST['order_email']);
        } else {
            $order_email = '';
        }
        $woocommerce->verify_nonce('order_tracking');
        if ($order->id && $order_email && $order->get_order($order->id)) {
            if ($order->billing_email == $order_email) {
                woocommerce_get_template('order/tracking.php');
                return;
            }
        }
        echo '<p>' . sprintf(__('Sorry, we could not find that order id in our database. <a href="%s">Want to retry?</a>', 'woothemes'), get_permalink($post->ID)) . '</p>';
    } else {
        woocommerce_get_template('order/tracking-form.php');
    }
}
 /**
  * Add to cart for bookings
  */
 public function add_to_cart()
 {
     global $product;
     // Prepare form
     $booking_form = new WC_Booking_Form($product);
     // Get template
     woocommerce_get_template('single-product/add-to-cart/booking.php', array('booking_form' => $booking_form), 'woocommerce-bookings', WC_BOOKINGS_TEMPLATE_PATH);
 }
 /**
  * @since 1.1.0 of SA_WC_Compatibility
  */
 public static function wc_get_template($template_path)
 {
     if (self::is_wc_21()) {
         return wc_get_template($template_path);
     } else {
         return woocommerce_get_template($template_path);
     }
 }
 /**
  * Change product-thumbnails.php template
  * 
  * @access public
  * @return void
  * @since 1.0.0
  */
 public function show_product_thumbnails()
 {
     if (function_exists('wc_get_template')) {
         wc_get_template('single-product/product-thumbnails-magnifier.php', array(), '', YITH_WCMG_DIR . 'templates/');
     } else {
         woocommerce_get_template('single-product/product-thumbnails-magnifier.php', array(), '', YITH_WCMG_DIR . 'templates/');
     }
 }
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     if (!is_user_logged_in()) {
         return;
     }
     woocommerce_get_template('myaccount/form-change-password.php');
 }
 /**
  * Show my packages
  */
 public function my_packages()
 {
     if (($packages = wc_paid_listings_get_user_packages(get_current_user_id(), 'job_listing')) && is_array($packages) && sizeof($packages) > 0) {
         woocommerce_get_template('my-packages.php', array('packages' => $packages, 'type' => 'job_listing'), 'wc-paid-listings/', JOB_MANAGER_WCPL_TEMPLATE_PATH);
     }
     if (($packages = wc_paid_listings_get_user_packages(get_current_user_id(), 'resume')) && is_array($packages) && sizeof($packages) > 0) {
         woocommerce_get_template('my-packages.php', array('packages' => $packages, 'type' => 'resume'), 'wc-paid-listings/', JOB_MANAGER_WCPL_TEMPLATE_PATH);
     }
 }
 /**
  * Render the shortcode
  * @param  array $args     Shortcode paramters
  * @param  string $content Content between shortcode
  * @return string          HTML output
  */
 function render($args, $content = '')
 {
     global $woocommerce, $smof_data;
     $defaults = T4PCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'cat_slug' => '', 'number_posts' => 10, 'show_cats' => 'yes', 'show_price' => 'yes', 'show_buttons' => 'yes', 'picture_size' => 'fixed'), $args);
     extract($defaults);
     self::$args = $defaults;
     $html = '';
     $buttons = '';
     if (class_exists('Woocommerce')) {
         $number_posts = (int) $number_posts;
         $args = array('post_type' => 'product', 'posts_per_page' => $number_posts, 'meta_query' => array(array('key' => '_thumbnail_id', 'compare' => '!=', 'value' => null)));
         if ($cat_slug) {
             $cat_id = explode(',', $cat_slug);
             $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_id));
         }
         $css_class = 'simple-products-slider';
         if ($picture_size != 'fixed') {
             $css_class = 'simple-products-slider-variable';
         }
         $products = new WP_Query($args);
         $products_wrapper = $product = '';
         if ($products->have_posts()) {
             while ($products->have_posts()) {
                 $products->the_post();
                 $image = $price_tag = $terms = '';
                 if (has_post_thumbnail()) {
                     if ($smof_data['image_rollover']) {
                         $image = get_the_post_thumbnail(get_the_ID(), 'shop_catalog');
                     } else {
                         $image = sprintf('<a href="%s">%s</a>', get_permalink(get_the_ID()), get_the_post_thumbnail(get_the_ID(), 'shop_catalog'));
                     }
                     if ($show_cats == 'yes') {
                         $terms = get_the_term_list(get_the_ID(), 'product_cat', sprintf('<span %s>', T4PCore_Plugin::attributes('cats')), ', ', '</span>');
                     }
                     ob_start();
                     woocommerce_get_template('loop/price.php');
                     $price = ob_get_contents();
                     ob_end_clean();
                     if ($price && $show_price == 'yes') {
                         $price_tag = $price;
                     }
                     if ($show_buttons == 'yes') {
                         ob_start();
                         woocommerce_get_template('loop/add-to-cart.php');
                         $cart_button = ob_get_contents();
                         ob_end_clean();
                         $buttons = sprintf('<div %s>%s</div>', T4PCore_Plugin::attributes('product-buttons'), $cart_button, get_permalink());
                     }
                     $product .= sprintf('<li><div %s aria-haspopup="true">%s<div %s><div %s><h3><a href="%s">%s</a></h3><br />%s%s%s</div></div></div></li>', T4PCore_Plugin::attributes('woo-product-slider-shortcode-img-div'), $image, T4PCore_Plugin::attributes('image-extras'), T4PCore_Plugin::attributes('image-extras-content'), get_permalink(), get_the_title(), $terms, $price_tag, $buttons);
                 }
             }
             $products_wrapper = sprintf('<ul>%s</ul>', $product);
         }
         $html = sprintf('<div %s><div %s><div %s><div %s>%s</div><div %s><span %s></span><span %s></span></div></div></div><div class="t4p-clearfix"></div></div>', T4PCore_Plugin::attributes('woo-product-slider-shortcode'), T4PCore_Plugin::attributes($css_class . ' simple-products-slider'), T4PCore_Plugin::attributes('es-carousel-wrapper t4p-carousel-large'), T4PCore_Plugin::attributes('es-carousel'), $products_wrapper, T4PCore_Plugin::attributes('es-nav'), T4PCore_Plugin::attributes('es-nav-prev'), T4PCore_Plugin::attributes('es-nav-next'));
     }
     return $html;
 }
 /**
  * Output the variable product add to cart area.
  *
  * @access public
  * @since 1.0.0
  */
 function variable_add_to_cart()
 {
     global $product;
     // Enqueue variation scripts
     wp_enqueue_script('wc-add-to-cart-variation');
     $attributes = $product->get_variation_attributes();
     // Load the template
     woocommerce_get_template('single-product/add-to-cart/variable-wccl.php', array('available_variations' => $product->get_available_variations(), 'attributes' => $attributes, 'selected_attributes' => $product->get_variation_default_attributes(), 'attributes_types' => $this->get_variation_attributes_types($attributes)), '', YITH_WCCL_DIR . 'templates/');
 }
 function woocommerce_template_loop_add_to_cart()
 {
     global $product;
     if ($product->product_type == "variable") {
         woocommerce_variable_add_to_cart();
     } else {
         woocommerce_get_template('loop/add-to-cart.php');
     }
 }
    /**
     * Output the shortcode.
     *
     * @access public
     * @param array $atts
     * @return void
     */
    public static function output($atts)
    {
        global $woocommerce;
        $woocommerce->nocache();
        if (!is_user_logged_in()) {
            return;
        }
        extract(shortcode_atts(array('order_count' => 10), $atts));
        $user_id = get_current_user_id();
        $order_id = isset($_GET['order']) ? $_GET['order'] : 0;
        $order = new WC_Order($order_id);
        if ($order_id == 0) {
            woocommerce_get_template('myaccount/my-orders.php', array('order_count' => 'all' == $order_count ? -1 : $order_count));
            return;
        }
        if ($order->user_id != $user_id) {
            echo '<div class="woocommerce-error">' . __('Invalid order.', 'woocommerce') . ' <a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('My Account &rarr;', 'woocommerce') . '</a>' . '</div>';
            return;
        }
        $status = get_term_by('slug', $order->status, 'shop_order_status');
        echo '<p class="order-info">' . sprintf(__('Order <mark class="order-number">%s</mark> made on <mark class="order-date">%s</mark>', 'woocommerce'), $order->get_order_number(), date_i18n(get_option('date_format'), strtotime($order->order_date))) . '. ' . sprintf(__('Order status: <mark class="order-status">%s</mark>', 'woocommerce'), __($status->name, 'woocommerce')) . '.</p>';
        $notes = $order->get_customer_order_notes();
        if ($notes) {
            ?>
			<h2><?php 
            _e('Order Updates', 'woocommerce');
            ?>
</h2>
			<ol class="commentlist notes">
				<?php 
            foreach ($notes as $note) {
                ?>
				<li class="comment note">
					<div class="comment_container">
						<div class="comment-text">
							<p class="meta"><?php 
                echo date_i18n(__('l jS \\of F Y, h:ia', 'woocommerce'), strtotime($note->comment_date));
                ?>
</p>
							<div class="description">
								<?php 
                echo wpautop(wptexturize($note->comment_content));
                ?>
							</div>
			  				<div class="clear"></div>
			  			</div>
						<div class="clear"></div>
					</div>
				</li>
				<?php 
            }
            ?>
			</ol>
			<?php 
        }
        do_action('woocommerce_view_order', $order_id);
    }
 /**
  * Display saved cards
  */
 public function output()
 {
     if (!is_user_logged_in() || !($eway_cards = get_user_meta(get_current_user_id(), '_eway_token_cards', true))) {
         return;
     }
     if ($eway_cards) {
         woocommerce_get_template('saved-cards.php', array('cards' => $eway_cards), 'woocommerce-gateway-eway/', WC_EWAY_TEMPLATE_PATH);
     }
 }
function woocommerce_upsell_display($posts_per_page = 4, $columns = 4, $orderby = 'rand')
{
    $woo_product_layout = wpex_option('woo_product_layout', 'full-width');
    $posts_per_page = wpex_option('woocommerce_upsell_columns', '4');
    if (is_singular() && $woo_product_layout != 'full-width') {
        $posts_per_page = wpex_option('woocommerce_with_sidebar_upsell_columns', '3');
    }
    woocommerce_get_template('single-product/up-sells.php', array('posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'columns' => $columns));
}
 /**
  * Loads the my-software-activations.php template on the My Account page.
  *
  * @since 1.0
  * @return void
  */
 public function display_software_activations_template()
 {
     $user_id = get_current_user_id();
     $subscription_id = isset($_GET['id']) ? $_GET['id'] : '';
     $licences = $this->get_users_software_licences_with_activations($user_id, $subscription_id);
     if (!$licences) {
         return;
     }
     woocommerce_get_template('myaccount/my-software-activations.php', array('software_licences' => $licences), '', $this->plugin_dir_path . '/templates/');
 }
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     if (!is_user_logged_in()) {
         woocommerce_get_template('myaccount/form-login.php');
     } else {
         extract(shortcode_atts(array('order_count' => 5), $atts));
         woocommerce_get_template('myaccount/my-account.php', array('current_user' => get_user_by('id', get_current_user_id()), 'order_count' => 'all' == $order_count ? -1 : $order_count));
     }
 }
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     if (!is_user_logged_in()) {
         return;
     }
     $load_address = self::get_address_to_edit();
     $address = $woocommerce->countries->get_address_fields(get_user_meta(get_current_user_id(), $load_address . '_country', true), $load_address . '_');
     woocommerce_get_template('myaccount/form-edit-address.php', array('load_address' => $load_address, 'address' => apply_filters('woocommerce_address_to_edit', $address)));
 }
 /**
  * Output the cart shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     if (!defined('WOOCOMMERCE_CART')) {
         define('WOOCOMMERCE_CART', true);
     }
     // Add Discount
     if (!empty($_POST['apply_coupon'])) {
         if (!empty($_POST['coupon_code'])) {
             $woocommerce->cart->add_discount(sanitize_text_field($_POST['coupon_code']));
         } else {
             $woocommerce->add_error(WC_Coupon::get_generic_coupon_error(WC_Coupon::E_WC_COUPON_PLEASE_ENTER));
         }
         // Remove Coupon Codes
     } elseif (isset($_GET['remove_discounts'])) {
         $woocommerce->cart->remove_coupons($_GET['remove_discounts']);
         // Update Shipping
     } elseif (!empty($_POST['calc_shipping']) && $woocommerce->verify_nonce('cart')) {
         $validation = $woocommerce->validation();
         $woocommerce->shipping->reset_shipping();
         $woocommerce->customer->calculated_shipping(true);
         $country = woocommerce_clean($_POST['calc_shipping_country']);
         $state = woocommerce_clean($_POST['calc_shipping_state']);
         $postcode = apply_filters('woocommerce_shipping_calculator_enable_postcode', true) ? woocommerce_clean($_POST['calc_shipping_postcode']) : '';
         $city = apply_filters('woocommerce_shipping_calculator_enable_city', false) ? woocommerce_clean($_POST['calc_shipping_city']) : '';
         if ($postcode && !$validation->is_postcode($postcode, $country)) {
             $woocommerce->add_error(__('Please enter a valid postcode/ZIP.', 'woocommerce'));
             $postcode = '';
         } elseif ($postcode) {
             $postcode = $validation->format_postcode($postcode, $country);
         }
         if ($country) {
             // Update customer location
             $woocommerce->customer->set_location($country, $state, $postcode, $city);
             $woocommerce->customer->set_shipping_location($country, $state, $postcode, $city);
             $woocommerce->add_message(__('Shipping costs updated.', 'woocommerce'));
         } else {
             $woocommerce->customer->set_to_base();
             $woocommerce->customer->set_shipping_to_base();
             $woocommerce->add_message(__('Shipping costs updated.', 'woocommerce'));
         }
         do_action('woocommerce_calculated_shipping');
     }
     // Check cart items are valid
     do_action('woocommerce_check_cart_items');
     // Calc totals
     $woocommerce->cart->calculate_totals();
     if (sizeof($woocommerce->cart->get_cart()) == 0) {
         //woocommerce_get_template( 'cart/cart-empty.php' );
         woocommerce_get_template('checkout/form-checkout.php');
     } else {
         //woocommerce_get_template( 'cart/cart.php' );
         woocommerce_get_template('checkout/form-checkout.php');
     }
 }
 /**
  * Add notice to review order table
  *
  * @access public
  * @return HTML
  * @since 8.1.0
  */
 public function on_checkout()
 {
     global $woocommerce;
     $shipping_chosen = $woocommerce->session->get('chosen_shipping_methods');
     $message = array_key_exists('packing_kayu_text', $this->options) ? $this->options['packing_kayu_text'] : '';
     $label = array_key_exists('packing_kayu_label', $this->options) ? $this->options['packing_kayu_label'] : '';
     if (!empty($shipping_chosen[0])) {
         if (strpos($shipping_chosen[0], 'jne') !== false) {
             woocommerce_get_template('jne-packing-kayu.php', array('label' => $label, 'message_jne_packing_kayu' => $message), 'woocommerce-jne-exclusive', untrailingslashit(WC_JNE()->plugin_path()) . '/templates/checkout/');
         }
     }
 }
Exemple #28
0
/**
 * Output the cart shortcode.
 *
 * @access public
 * @param array $atts
 * @return void
 */
function woocommerce_cart($atts)
{
    global $woocommerce;
    $woocommerce->nocache();
    if (!defined('WOOCOMMERCE_CART')) {
        define('WOOCOMMERCE_CART', true);
    }
    // Add Discount
    if (!empty($_POST['apply_coupon'])) {
        if (!empty($_POST['coupon_code'])) {
            $woocommerce->cart->add_discount(stripslashes(trim($_POST['coupon_code'])));
        } else {
            $woocommerce->add_error(__('Please enter a coupon code.', 'woocommerce'));
        }
        // Remove Discount Codes
    } elseif (isset($_GET['remove_discounts'])) {
        $woocommerce->cart->remove_coupons($_GET['remove_discounts']);
        // Update Shipping
    } elseif (!empty($_POST['calc_shipping']) && $woocommerce->verify_nonce('cart')) {
        $validation = $woocommerce->validation();
        $_SESSION['calculated_shipping'] = true;
        unset($_SESSION['_chosen_shipping_method']);
        $country = $_POST['calc_shipping_country'];
        $state = $_POST['calc_shipping_state'];
        $postcode = $_POST['calc_shipping_postcode'];
        if ($postcode && !$validation->is_postcode($postcode, $country)) {
            $woocommerce->add_error(__('Please enter a valid postcode/ZIP.', 'woocommerce'));
            $postcode = '';
        } elseif ($postcode) {
            $postcode = $validation->format_postcode($postcode, $country);
        }
        if ($country) {
            // Update customer location
            $woocommerce->customer->set_location($country, $state, $postcode);
            $woocommerce->customer->set_shipping_location($country, $state, $postcode);
            $woocommerce->add_message(__('Shipping costs updated.', 'woocommerce'));
        } else {
            $woocommerce->customer->set_to_base();
            $woocommerce->customer->set_shipping_to_base();
            $woocommerce->add_message(__('Shipping costs updated.', 'woocommerce'));
        }
        do_action('woocommerce_calculated_shipping');
    }
    // Check cart items are valid
    do_action('woocommerce_check_cart_items');
    // Calc totals
    $woocommerce->cart->calculate_totals();
    if (sizeof($woocommerce->cart->get_cart()) == 0) {
        woocommerce_get_template('cart/empty.php');
    } else {
        woocommerce_get_template('cart/cart.php');
    }
}
 /**
  * Template function to render the template
  *
  * @since 1.0
  */
 function woocommerce_points_rewards_my_points()
 {
     global $wc_points_rewards;
     $points_balance = WC_Points_Rewards_Manager::get_users_points(get_current_user_id());
     $points_label = $wc_points_rewards->get_points_label($points_balance);
     $count = apply_filters('wc_points_rewards_my_account_points_events', 5, get_current_user_id());
     // get a set of points events, ordered newest to oldest
     $args = array('orderby' => array('field' => 'date', 'order' => 'DESC'), 'per_page' => $count, 'paged' => 0, 'user' => get_current_user_id());
     $events = WC_Points_Rewards_Points_Log::get_points_log_entries($args);
     // load the template
     woocommerce_get_template('myaccount/my-points.php', array('points_balance' => $points_balance, 'points_label' => $points_label, 'events' => $events), '', $wc_points_rewards->get_plugin_path() . '/templates/');
 }
Exemple #30
0
function product_thumbnail_with_cart()
{
    ?>
	
   <div class="product-thumb-wrap">
	   	<?php 
    echo woocommerce_get_product_thumbnail();
    ?>
	   	<?php 
    woocommerce_get_template('loop/add-to-cart.php');
    ?>
   	</div>
<?php 
}