Example #1
0
	/** @see WP_Widget::widget */
	function widget($args, $instance) {
		$cache = wp_cache_get('widget_recent_products', 'widget');

		if ( !is_array($cache) ) $cache = array();

		if ( isset($cache[$args['widget_id']]) ) {
			echo $cache[$args['widget_id']];
			return;
		}

		ob_start();
		extract($args);
		
		$title = apply_filters('widget_title', empty($instance['title']) ? __('New Products', 'jigoshop') : $instance['title'], $instance, $this->id_base);
		if ( !$number = (int) $instance['number'] )
			$number = 10;
		else if ( $number < 1 )
			$number = 1;
		else if ( $number > 15 )
			$number = 15;

    $show_variations = $instance['show_variations'] ? '1' : '0';

    $args = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'product');

    if($show_variations=='0'){
      $args['meta_query'] = array(
			  array(
				  'key' => 'visibility',
				  'value' => array('catalog', 'visible'),
				  'compare' => 'IN'
			  )
		  );
		  $args['parent'] = '0';
    }

		$r = new WP_Query($args);
		
		if ($r->have_posts()) :
?>
		<?php echo $before_widget; ?>
		<?php if ( $title ) echo $before_title . $title . $after_title; ?>
		<ul class="product_list_widget">
		<?php  while ($r->have_posts()) : $r->the_post(); $_product = &new jigoshop_product(get_the_ID()); ?>
		<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>">
			<?php if (has_post_thumbnail()) the_post_thumbnail('shop_tiny'); else echo '<img src="'.jigoshop::plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'px" height="'.jigoshop::get_var('shop_tiny_h').'px" />'; ?>
			<?php if ( get_the_title() ) the_title(); else the_ID(); ?>
		</a> <?php echo $_product->get_price_html(); ?></li>
		<?php endwhile; ?>
		</ul>
		<?php echo $after_widget; ?>
<?php
		// Reset the global $the_post as this query will have stomped on it
		//wp_reset_postdata();

		endif;

		if (isset($args['widget_id']) && isset($cache[$args['widget_id']])) $cache[$args['widget_id']] = ob_get_flush();
		wp_cache_set('widget_recent_products', $cache, 'widget');
	}
Example #2
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     if (is_cart()) {
         return;
     }
     extract($args);
     if (!empty($instance['title'])) {
         $title = $instance['title'];
     } else {
         $title = __('Cart', 'jigoshop');
     }
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo '<ul class="cart_list">';
     if (sizeof(jigoshop_cart::$cart_contents) > 0) {
         foreach (jigoshop_cart::$cart_contents as $item_id => $values) {
             $_product = $values['data'];
             if ($_product->exists() && $values['quantity'] > 0) {
                 echo '<li><a href="' . get_permalink($item_id) . '">';
                 if (has_post_thumbnail($item_id)) {
                     echo get_the_post_thumbnail($item_id, 'shop_tiny');
                 } else {
                     echo '<img src="' . jigoshop::plugin_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . jigoshop::get_var('shop_tiny_w') . '" height="' . jigoshop::get_var('shop_tiny_h') . '" />';
                 }
                 echo apply_filters('jigoshop_cart_widget_product_title', $_product->get_title(), $_product) . '</a> ' . $values['quantity'] . ' &times; ' . jigoshop_price($_product->get_price()) . '</li>';
             }
         }
     } else {
         echo '<li class="empty">' . __('No products in the cart.', 'jigoshop') . '</li>';
     }
     echo '</ul>';
     if (sizeof(jigoshop_cart::$cart_contents) > 0) {
         echo '<p class="total"><strong>';
         if (get_option('js_prices_include_tax') == 'yes') {
             _e('Total', 'jigoshop');
         } else {
             _e('Subtotal', 'jigoshop');
         }
         echo ':</strong> ' . jigoshop_cart::get_cart_total();
         echo '</p>';
         do_action('jigoshop_widget_shopping_cart_before_buttons');
         echo '<p class="buttons"><a href="' . jigoshop_cart::get_cart_url() . '" class="button">' . __('View Cart &rarr;', 'jigoshop') . '</a> <a href="' . jigoshop_cart::get_checkout_url() . '" class="button checkout">' . __('Checkout &rarr;', 'jigoshop') . '</a></p>';
     }
     echo $after_widget;
 }
Example #3
0
	/** @see WP_Widget::widget */
	function widget($args, $instance) {
		$cache = wp_cache_get('widget_featured_products', 'widget');

		if ( !is_array($cache) ) $cache = array();

		if ( isset($cache[$args['widget_id']]) ) {
			echo $cache[$args['widget_id']];
			return;
		}

		ob_start();
		extract($args);

		$title = apply_filters('widget_title', empty($instance['title']) ? __('Featured Products', 'jigoshop') : $instance['title'], $instance, $this->id_base);
		if ( !$number = (int) $instance['number'] )
			$number = 10;
		else if ( $number < 1 )
			$number = 1;
		else if ( $number > 15 )
			$number = 15;

		$featured_posts = get_posts(array('numberposts' => $number, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'featured', 'meta_value' => 'yes' ));
		if ($featured_posts) :
?>
		<?php echo $before_widget; ?>
		<?php if ( $title ) echo $before_title . $title . $after_title; ?>
		<ul class="product_list_widget">
		<?php foreach ($featured_posts as $r) : $_product = &new jigoshop_product( $r->ID ); ?>
		
		<li><a href="<?php echo get_permalink( $r->ID ) ?>" title="<?php echo esc_attr($r->post_title ? $r->post_title : $r->ID); ?>">
			<?php if (has_post_thumbnail( $r->ID )) echo get_the_post_thumbnail($r->ID, 'shop_tiny'); else echo '<img src="'.jigoshop::plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'px" height="'.jigoshop::get_var('shop_tiny_h').'px" />'; ?>
			<?php if ( $r->post_title ) echo $r->post_title; else echo $r->ID; ?>
		</a> <?php echo $_product->get_price_html(); ?></li>
		
		<?php endforeach; ?>
		</ul>
		<?php echo $after_widget; ?>
<?php

		endif;

		$cache[$args['widget_id']] = ob_get_flush();
		wp_cache_set('widget_featured_products', $cache, 'widget');
	}
Example #4
0
 function jigoshop_get_product_thumbnail($size = 'shop_small', $placeholder_width = 0, $placeholder_height = 0)
 {
     global $post;
     if (!$placeholder_width) {
         $placeholder_width = jigoshop::get_var('shop_small_w');
     }
     if (!$placeholder_height) {
         $placeholder_height = jigoshop::get_var('shop_small_h');
     }
     if (has_post_thumbnail()) {
         return get_the_post_thumbnail($post->ID, $size);
     } else {
         return '<img class="scale-with-grid" src="' . jigoshop::plugin_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . $placeholder_width . '" height="' . $placeholder_height . '" />';
     }
 }
Example #5
0
function jigoshop_init() {
	
	jigoshop_post_type();
	
	// Image sizes
	add_image_size( 'shop_tiny', jigoshop::get_var('shop_tiny_w'), jigoshop::get_var('shop_tiny_h'), 'true' );
	add_image_size( 'shop_thumbnail', jigoshop::get_var('shop_thumbnail_w'), jigoshop::get_var('shop_thumbnail_h'), 'true' );
	add_image_size( 'shop_small', jigoshop::get_var('shop_small_w'), jigoshop::get_var('shop_small_h'), 'true' );
	add_image_size( 'shop_large', jigoshop::get_var('shop_large_w'), jigoshop::get_var('shop_large_h'), 'true' );

	// Include template functions here so they are pluggable by themes
	include_once( 'jigoshop_template_functions.php' );
	
	@ob_start();
	
	add_role('customer', 'Customer', array(
	    'read' => true,
	    'edit_posts' => false,
	    'delete_posts' => false
	));

	$css = file_exists(get_stylesheet_directory() . '/jigoshop/style.css') ? get_stylesheet_directory_uri() . '/jigoshop/style.css' : jigoshop::plugin_url() . '/assets/css/frontend.css';
    if (JIGOSHOP_USE_CSS) wp_register_style('jigoshop_frontend_styles', $css );
    
    wp_register_style('jigoshop_fancybox_styles', jigoshop::plugin_url() . '/assets/css/fancybox.css');
    wp_register_style('jqueryui_styles', jigoshop::plugin_url() . '/assets/css/ui.css');
    wp_register_script( 'fancybox', jigoshop::plugin_url() . '/assets/js/jquery.fancybox-1.3.4.pack.js', 'jquery', '1.0' );
    wp_register_script( 'blockui', jigoshop::plugin_url() . '/assets/js/blockui.js', 'jquery', '1.0' );
    wp_register_script( 'cookie', jigoshop::plugin_url() . '/assets/js/cookie.js', 'jquery', '1.0' );
    wp_register_script( 'scrollto', jigoshop::plugin_url() . '/assets/js/scrollto.js', 'jquery', 'jquery', '1.0' );
    wp_register_script( 'jigoshop_script', jigoshop::plugin_url() . '/assets/js/script.js.php', 'jquery', '1.0' );
    wp_register_script( 'jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js', 'jquery', '1.0' );
    wp_register_script( 'jquery.placeholder', jigoshop::plugin_url() . '/assets/js/jquery.placeholder.js', 'jquery', '1.0' );
    
    if (is_admin()) :
    
    	wp_register_style('jigoshop_admin_styles', jigoshop::plugin_url() . '/assets/css/admin.css');
   		wp_register_style('jigoshop_admin_datepicker_styles', jigoshop::plugin_url() . '/assets/css/datepicker.css');
    	wp_enqueue_style('jigoshop_admin_styles');
    	wp_enqueue_style('jigoshop_admin_datepicker_styles');
    	
    	wp_register_script( 'flot', jigoshop::plugin_url() . '/assets/js/jquery.flot.min.js' );
    	wp_enqueue_script('flot');
    	wp_enqueue_script('blockui');
    	wp_enqueue_script('cookie');
    	
    else :
    
    	wp_enqueue_style('jigoshop_frontend_styles');
    	wp_enqueue_style('jigoshop_fancybox_styles');
    	wp_enqueue_style('jqueryui_styles');
    	wp_enqueue_script('jquery');
    	wp_enqueue_script('jqueryui');
    	wp_enqueue_script('fancybox');
    	wp_enqueue_script('blockui');
    	wp_enqueue_script('cookie');
    	wp_enqueue_script('scrollto');
    	wp_enqueue_script('jigoshop_script');
    	wp_enqueue_script('jquery.placeholder');
    	
    endif;
}
Example #6
0
function jigoshop_get_product_thumbnail($size = 'shop_small', $placeholder_width = 0, $placeholder_height = 0)
{
    global $post;
    if (!$placeholder_width) {
        $placeholder_width = jigoshop::get_var('shop_small_w');
    }
    if (!$placeholder_height) {
        $placeholder_height = jigoshop::get_var('shop_small_h');
    }
    if (has_post_thumbnail()) {
        $thumb = get_the_post_thumbnail($post->ID, $size);
    } else {
        $thumb = '';
    }
    if (empty($thumb)) {
        $thumb = '<img src="' . jigoshop::plugin_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . $placeholder_width . '" height="' . $placeholder_height . '" />';
    }
    return $thumb;
}
Example #7
0
/**
 * System info
 * 
 * Shows the system info panel which contains version data and debug info
 *
 * @since 		1.0
 * @usedby 		jigoshop_settings()
 */
function jigoshop_system_info()
{
    ?>
	<div class="wrap jigoshop">
		<div class="icon32 icon32-jigoshop-debug" id="icon-jigoshop"><br/></div>
	    <h2><?php 
    _e('System Information', 'jigoshop');
    ?>
</h2>
	    <p>Use the information below when submitting technical support requests via the Jigoshop community / premium <a href="http://jigoshop.com/forums/" title="Jigoshop Support Forums" target="_blank">support forums</a>.</p>
		<div id="tabs-wrap">
			<ul class="tabs">
				<li><a href="#versions"><?php 
    _e('Environment', 'jigoshop');
    ?>
</a></li>
				<li><a href="#debugging"><?php 
    _e('Debugging', 'jigoshop');
    ?>
</a></li>
			</ul>
			<div id="versions" class="panel">
				<table class="widefat fixed" style="width:850px;">
		            <thead>		            
		            	<tr>
		                    <th scope="col" width="200px"><?php 
    _e('Software Versions', 'jigoshop');
    ?>
</th>
		                    <th scope="col">&nbsp;</th>
		                </tr>
		           	</thead>
		           	<tbody>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('Jigoshop Version', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    echo jigoshop::get_var('version');
    ?>
</td>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('WordPress Version', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    if (is_multisite()) {
        echo 'WPMU';
    } else {
        echo 'WP';
    }
    ?>
 <?php 
    echo bloginfo('version');
    ?>
</td>
		                </tr>
		            </tbody>
		            <thead>
		                <tr>
		                    <td scope="col" width="200px"><?php 
    _e('Server', 'jigoshop');
    ?>
</td>
		                    <td scope="col"><?php 
    echo defined('PHP_OS') ? (string) PHP_OS : 'N/A';
    ?>
</td>
		                </tr>
		            </thead>
		           	<tbody>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('PHP Version', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    if (function_exists('phpversion')) {
        echo phpversion();
    }
    ?>
</td>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('Server Software', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    echo $_SERVER['SERVER_SOFTWARE'];
    ?>
</td>
		                </tr>
		        	</tbody>
		        </table>
			</div>
			<div id="debugging" class="panel">
				<table class="widefat fixed" style="width:850px;">
		            <tbody>
		            	<tr>
		                    <th scope="col" width="200px"><?php 
    _e('Debug Information', 'jigoshop');
    ?>
</th>
		                    <th scope="col">&nbsp;</th>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('UPLOAD_MAX_FILESIZE', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    if (function_exists('phpversion')) {
        echo jigoshop_let_to_num(ini_get('upload_max_filesize')) / (1024 * 1024) . "MB";
    }
    ?>
</td>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('POST_MAX_SIZE', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    if (function_exists('phpversion')) {
        echo jigoshop_let_to_num(ini_get('post_max_size')) / (1024 * 1024) . "MB";
    }
    ?>
</td>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('WordPress Memory Limit', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    echo jigoshop_let_to_num(WP_MEMORY_LIMIT) / (1024 * 1024) . "MB";
    ?>
</td>
		                </tr>
		                 <tr>
		                    <td class="titledesc"><?php 
    _e('WP_DEBUG', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    echo WP_DEBUG === true ? __('On', 'jigoshop') : __('Off', 'jigoshop');
    ?>
</td>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('DISPLAY_ERRORS', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    echo ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A';
    ?>
</td>
		                </tr>
		                <tr>
		                    <td class="titledesc"><?php 
    _e('FSOCKOPEN', 'jigoshop');
    ?>
</td>
		                    <td class="forminp"><?php 
    if (function_exists('fsockopen')) {
        echo '<span style="color:green">' . __('Your server supports fsockopen.', 'jigoshop') . '</span>';
    } else {
        echo '<span style="color:red">' . __('Your server does not support fsockopen.', 'jigoshop') . '</span>';
    }
    ?>
</td>
		                </tr>
		        	</tbody>
		        </table>
			</div>
		</div> 
    </div>
    <script type="text/javascript">
	jQuery(function() {
	    // Tabs
		jQuery('ul.tabs').show();
		jQuery('ul.tabs li:first').addClass('active');
		jQuery('div.panel:not(div.panel:first)').hide();
		jQuery('ul.tabs a').click(function(){
			jQuery('ul.tabs li').removeClass('active');
			jQuery(this).parent().addClass('active');
			jQuery('div.panel').hide();
			jQuery( jQuery(this).attr('href') ).show();
			return false;
		});
	});
	</script>
	<?php 
}
Example #8
0
function jigoshop_cart( $atts ) {
	
	$errors = array();
	
	// Process Discount Codes
	if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && jigoshop::verify_nonce('cart')) :
	
		$coupon_code = stripslashes(trim($_POST['coupon_code']));
		jigoshop_cart::add_discount($coupon_code);

	// Remove from cart
	elseif ( isset($_GET['remove_item']) && $_GET['remove_item'] > 0  && jigoshop::verify_nonce('cart', '_GET')) :
	
		jigoshop_cart::set_quantity( $_GET['remove_item'], 0 );
		
		jigoshop::add_message( __('Cart updated.', 'jigoshop') );
	
	// Update Cart
	elseif (isset($_POST['update_cart']) && $_POST['update_cart']  && jigoshop::verify_nonce('cart')) :
		
		$cart_totals = $_POST['cart'];
		
		if (sizeof(jigoshop_cart::$cart_contents)>0) : 
			foreach (jigoshop_cart::$cart_contents as $item_id => $values) :
				
				if (isset($cart_totals[$item_id]['qty'])) jigoshop_cart::set_quantity( $item_id, $cart_totals[$item_id]['qty'] );
				
			endforeach;
		endif;
		
		jigoshop::add_message( __('Cart updated.', 'jigoshop') );
	
	// Update Shipping
	elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && jigoshop::verify_nonce('cart')) :

		unset($_SESSION['_chosen_method_id']);
		$country 	= $_POST['calc_shipping_country'];
		$state 	= $_POST['calc_shipping_state'];
		
		$postcode 	= $_POST['calc_shipping_postcode'];
		
		if ($postcode && !jigoshop_validation::is_postcode( $postcode, $country )) : 
			jigoshop::add_error( __('Please enter a valid postcode/ZIP.','jigoshop') ); 
			$postcode = '';
		elseif ($postcode) :
			$postcode = jigoshop_validation::format_postcode( $postcode, $country );
		endif;
		
		if ($country) :
		
			// Update customer location
			jigoshop_customer::set_location( $country, $state, $postcode );
			jigoshop_customer::set_shipping_location( $country, $state, $postcode );
			
			// Re-calc price
			jigoshop_cart::calculate_totals();
			
			jigoshop::add_message(  __('Shipping costs updated.', 'jigoshop') );
		
		else :
		
			jigoshop_customer::set_shipping_location( '', '', '' );
			
			jigoshop::add_message(  __('Shipping costs updated.', 'jigoshop') );
			
		endif;
			
	endif;
	
	$result = jigoshop_cart::check_cart_item_stock();
	if (is_wp_error($result)) :
		jigoshop::add_error( $result->get_error_message() );
	endif;
	
	jigoshop::show_messages();
	
	if (sizeof(jigoshop_cart::$cart_contents)==0) :
		echo '<p>'.__('Your cart is empty.', 'jigoshop').'</p>';
		return;
	endif;
	
	?>
	<form action="<?php echo jigoshop_cart::get_cart_url(); ?>" method="post">
	<table class="shop_table cart" cellspacing="0">
		<thead>
			<tr>
				<th class="product-remove"></th>
				<th class="product-thumbnail"></th>
				<th class="product-name"><span class="nobr"><?php _e('Product Name', 'jigoshop'); ?></span></th>
				<th class="product-price"><span class="nobr"><?php _e('Unit Price', 'jigoshop'); ?></span></th>
				<th class="product-quantity"><?php _e('Quantity', 'jigoshop'); ?></th>
				<th class="product-subtotal"><?php _e('Price', 'jigoshop'); ?></th>
			</tr>
		</thead>
		<tbody>
			<?php
			if (sizeof(jigoshop_cart::$cart_contents)>0) : 
				foreach (jigoshop_cart::$cart_contents as $item_id => $values) :
					$_product = $values['data'];
					if ($_product->exists() && $values['quantity']>0) :
						echo '
							<tr>
								<td class="product-remove"><a href="'.jigoshop_cart::get_remove_url($item_id).'" class="remove" title="Remove this item">&times;</a></td>
								<td class="product-thumbnail"><a href="'.get_permalink($item_id).'">';
						
						if (has_post_thumbnail($item_id)) echo get_the_post_thumbnail($item_id, 'shop_tiny'); 
						else echo '<img src="'.jigoshop::plugin_url(). '/assets/images/placeholder.png" alt="Placeholder" width="'.jigoshop::get_var('shop_tiny_w').'" height="'.jigoshop::get_var('shop_tiny_h').'" />'; 
							
						echo '	</a></td>
								<td class="product-name"><a href="'.get_permalink($item_id).'">' . apply_filters('jigoshop_cart_product_title', $_product->get_title(), $_product) . '</a></td>
								<td class="product-price">'.jigoshop_price($_product->get_price()).'</td>
								<td class="product-quantity"><div class="quantity"><input name="cart['.$item_id.'][qty]" value="'.$values['quantity'].'" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div></td>
								<td class="product-subtotal">'.jigoshop_price($_product->get_price()*$values['quantity']).'</td>
							</tr>';
					endif;
				endforeach; 
			endif;
			
			do_action( 'jigoshop_shop_table_cart' );
			?>
			<tr>
				<td colspan="6" class="actions">
					<div class="coupon">
						<label for="coupon_code"><?php _e('Coupon', 'jigoshop'); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'jigoshop'); ?>" />
					</div>
					<?php jigoshop::nonce_field('cart') ?>
					<input type="submit" class="button" name="update_cart" value="<?php _e('Update Shopping Cart', 'jigoshop'); ?>" /> <a href="<?php echo jigoshop_cart::get_checkout_url(); ?>" class="checkout-button button-alt"><?php _e('Proceed to Checkout &rarr;', 'jigoshop'); ?></a>
				</td>
			</tr>
		</tbody>
	</table>
	</form>
	<div class="cart-collaterals">
		
		<?php do_action('cart-collaterals'); ?>

		<div class="cart_totals">
		<?php
		// Hide totals if customer has set location and there are no methods going there
		$available_methods = jigoshop_shipping::get_available_shipping_methods();
		if ($available_methods || !jigoshop_customer::get_shipping_country() || !jigoshop_shipping::$enabled ) : 
			?>
			<h2><?php _e('Cart Totals', 'jigoshop'); ?></h2>
			<table cellspacing="0" cellpadding="0">
				<tbody>
					<tr>
						<th><?php _e('Subtotal', 'jigoshop'); ?></th>
						<td><?php echo jigoshop_cart::get_cart_subtotal(); ?></td>
					</tr>
					
					<?php if (jigoshop_cart::get_cart_shipping_total()) : ?><tr>
						<th><?php _e('Shipping', 'jigoshop'); ?> <small><?php echo jigoshop_countries::shipping_to_prefix().' '.jigoshop_countries::$countries[ jigoshop_customer::get_shipping_country() ]; ?></small></th>
						<td><?php echo jigoshop_cart::get_cart_shipping_total(); ?> <small><?php echo jigoshop_cart::get_cart_shipping_title(); ?></small></td>
					</tr><?php endif; ?>
					<?php if (jigoshop_cart::get_cart_tax()) : ?><tr>
						<th><?php _e('Tax', 'jigoshop'); ?> <?php if (jigoshop_customer::is_customer_outside_base()) : ?><small><?php echo sprintf(__('estimated for %s', 'jigoshop'), jigoshop_countries::estimated_for_prefix() . jigoshop_countries::$countries[ jigoshop_countries::get_base_country() ] ); ?></small><?php endif; ?></th>
						<td><?php 
							echo jigoshop_cart::get_cart_tax(); 
						?></td>
					</tr><?php endif; ?>
					
					<?php if (jigoshop_cart::get_total_discount()) : ?><tr class="discount">
						<th><?php _e('Discount', 'jigoshop'); ?></th>
						<td>-<?php echo jigoshop_cart::get_total_discount(); ?></td>
					</tr><?php endif; ?>
					<tr>
						<th><strong><?php _e('Total', 'jigoshop'); ?></strong></th>
						<td><strong><?php echo jigoshop_cart::get_total(); ?></strong></td>
					</tr>
				</tbody>
			</table>

			<?php
			else :
				echo '<p>'.__('Sorry, it seems that there are no available shipping methods to your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'jigoshop').'</p>';
			endif;
		?>
		</div>
		
		<?php jigoshop_shipping_calculator(); ?>
		
	</div>
	<?php		
}
Example #9
0
function my_cart($atts)
{
    $errors = array();
    unset(jigoshop_session::instance()->selected_rate_id);
    // Process Discount Codes
    if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && jigoshop::verify_nonce('cart')) {
        $coupon_code = stripslashes(trim($_POST['coupon_code']));
        jigoshop_cart::add_discount($coupon_code);
        // Update Shipping
    } elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && jigoshop::verify_nonce('cart')) {
        unset(jigoshop_session::instance()->chosen_shipping_method_id);
        $country = $_POST['calc_shipping_country'];
        $state = $_POST['calc_shipping_state'];
        $postcode = $_POST['calc_shipping_postcode'];
        if ($postcode && !jigoshop_validation::is_postcode($postcode, $country)) {
            jigoshop::add_error(__('Please enter a valid postcode/ZIP.', 'jigoshop'));
            $postcode = '';
        } elseif ($postcode) {
            $postcode = jigoshop_validation::format_postcode($postcode, $country);
        }
        if ($country) {
            // Update customer location
            jigoshop_customer::set_location($country, $state, $postcode);
            jigoshop_customer::set_shipping_location($country, $state, $postcode);
            jigoshop::add_message(__('Shipping costs updated.', 'jigoshop'));
        } else {
            jigoshop_customer::set_shipping_location('', '', '');
            jigoshop::add_message(__('Shipping costs updated.', 'jigoshop'));
        }
    } elseif (isset($_POST['shipping_rates'])) {
        $rates_params = explode(":", $_POST['shipping_rates']);
        $available_methods = jigoshop_shipping::get_available_shipping_methods();
        $shipping_method = $available_methods[$rates_params[0]];
        if ($rates_params[1] != NULL) {
            jigoshop_session::instance()->selected_rate_id = $rates_params[1];
        }
        $shipping_method->choose();
        // choses the method selected by user.
    }
    // Re-Calc prices. This needs to happen every time the cart page is loaded and after checking post results. It will happen twice for coupon.
    jigoshop_cart::calculate_totals();
    $result = jigoshop_cart::check_cart_item_stock();
    if (is_wp_error($result)) {
        jigoshop::add_error($result->get_error_message());
    }
    jigoshop::show_messages();
    if (sizeof(jigoshop_cart::$cart_contents) == 0) {
        echo '<p>' . __('Your cart is empty.', 'jigoshop') . '</p>';
        ?>
<p><a href="<?php 
        echo esc_url(jigoshop_cart::get_shop_url());
        ?>
" class="button"><?php 
        _e('&larr; Return to Shop', 'jigoshop');
        ?>
</a></p><?php 
        return;
    }
    ?>
    <form action="<?php 
    echo esc_url(jigoshop_cart::get_cart_url());
    ?>
" method="post">
        <table class="shop_table cart" cellspacing="0" id="shop-cart">
            <thead>
                <tr>
                    <th class="product-remove">Remove</th>
                    <th class="product-thumbnail"></th>
                    <th class="product-name"><span class="nobr"><?php 
    _e('Product Name', 'jigoshop');
    ?>
</span></th>
                    <th class="product-price"><span class="nobr"><?php 
    _e('Unit Price', 'jigoshop');
    ?>
</span></th>
                    <th class="product-quantity"><?php 
    _e('Quantity', 'jigoshop');
    ?>
</th>
                    <th class="product-subtotal"><?php 
    _e('Price', 'jigoshop');
    ?>
</th>
                </tr>
                <?php 
    do_action('jigoshop_shop_table_cart_head');
    ?>
            </thead>
            <tbody>
                <?php 
    if (sizeof(jigoshop_cart::$cart_contents) > 0) {
        foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) {
            $_product = $values['data'];
            if ($_product->exists() && $values['quantity'] > 0) {
                $additional_description = jigoshop_cart::get_item_data($values);
                ?>
                            <tr>
                                <td class="product-remove"><a href="<?php 
                echo esc_url(jigoshop_cart::get_remove_url($cart_item_key));
                ?>
" class="remove" title="<?php 
                echo esc_attr(__('Remove this item.', 'jigoshop'));
                ?>
">&times;</a></td>
                                <td class="product-thumbnail"><a href="<?php 
                echo esc_url(apply_filters('jigoshop_product_url_display_in_cart', get_permalink($values['product_id']), $cart_item_key));
                ?>
">
                                    <?php 
                if ($values['variation_id'] && has_post_thumbnail($values['variation_id'])) {
                    echo get_the_post_thumbnail($values['variation_id'], 'shop_tiny');
                } else {
                    if (has_post_thumbnail($values['product_id'])) {
                        echo get_the_post_thumbnail($values['product_id'], 'shop_tiny');
                    } else {
                        echo '<img src="' . jigoshop::assets_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . jigoshop::get_var('shop_tiny_w') . '" height="' . jigoshop::get_var('shop_tiny_h') . '" />';
                    }
                }
                ?>
</a>
                                </td>

                                <td class="product-name">
                                    <a href="<?php 
                echo esc_url(apply_filters('jigoshop_product_url_display_in_cart', get_permalink($values['product_id']), $cart_item_key));
                ?>
"><?php 
                echo apply_filters('jigoshop_cart_product_title', $_product->get_title(), $_product);
                ?>
</a>
                                    <?php 
                echo $additional_description;
                ?>
                                    <?php 
                if (!empty($values['variation_id'])) {
                    $product_id = $values['variation_id'];
                } else {
                    $product_id = $values['product_id'];
                }
                $custom_products = (array) jigoshop_session::instance()->customized_products;
                $custom = isset($custom_products[$product_id]) ? $custom_products[$product_id] : '';
                if (!empty($custom_products[$product_id])) {
                    ?>
											<dl class="customization">
												<dt class="customized_product_label"><?php 
                    echo apply_filters('jigoshop_customized_product_label', __('Personal: ', 'jigoshop'));
                    ?>
</dt>
												<dd class="customized_product"><?php 
                    echo esc_textarea($custom);
                    ?>
</dd>
											</dl>
											<?php 
                }
                ?>
                                </td>
                                <td class="product-price"><span class="m-label">Unit price:</span><?php 
                echo jigoshop_price($_product->get_price());
                ?>
</td>
                                <td class="product-quantity">
                                    <span class="m-label">Quantity:</span>
                                     <div class="quantity"><input name="cart[<?php 
                echo $cart_item_key;
                ?>
][qty]" value="<?php 
                echo esc_attr($values['quantity']);
                ?>
" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
                                </td>
                                <td class="product-subtotal"><span class="m-label">Price:</span><?php 
                echo jigoshop_price($_product->get_price() * $values['quantity']);
                ?>
</td>
                            </tr>
                            <?php 
            }
        }
    }
    do_action('jigoshop_shop_table_cart_body');
    ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="6" class="actions">

                        <?php 
    $coupons = JS_Coupons::get_coupons();
    if (!empty($coupons)) {
        ?>
                            <div class="coupon">
                                <label for="coupon_code"><?php 
        _e('Coupon', 'jigoshop');
        ?>
:</label> <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" />
                                <input type="submit" class="button" name="apply_coupon" value="<?php 
        _e('Apply Coupon', 'jigoshop');
        ?>
" />
                            </div>
                        <?php 
    }
    ?>

                        <?php 
    jigoshop::nonce_field('cart');
    ?>
                        <input type="submit" class="button" name="update_cart" value="<?php 
    _e('Update Shopping Cart', 'jigoshop');
    ?>
" /> <a href="<?php 
    echo esc_url(jigoshop_cart::get_checkout_url());
    ?>
" class="checkout-button button-alt"><?php 
    _e('Proceed to Checkout &rarr;', 'jigoshop');
    ?>
</a>
                    </td>
                </tr>
                <?php 
    if (count(jigoshop_cart::$applied_coupons)) {
        ?>
                    <tr>
                        <td colspan="6" class="applied-coupons">
                            <div>
                                <span class="applied-coupons-label"><?php 
        _e('Applied Coupons: ', 'jigoshop');
        ?>
</span>
								<?php 
        foreach (jigoshop_cart::$applied_coupons as $code) {
            ?>
                                <a href="?unset_coupon=<?php 
            echo $code;
            ?>
" id="<?php 
            echo $code;
            ?>
" class="applied-coupons-values"><?php 
            echo $code;
            ?>
									<span class="close">&times;</span>
								</a>
								<?php 
        }
        ?>
                            </div>
                        </td>
                    </tr>
                    <?php 
    }
    do_action('jigoshop_shop_table_cart_foot');
    ?>
            </tfoot>
            <?php 
    do_action('jigoshop_shop_table_cart');
    ?>
        </table>
    </form>
    <div class="cart-collaterals">

        <?php 
    do_action('cart-collaterals');
    ?>

        <div class="cart_totals">
            <?php 
    // Hide totals if customer has set location and there are no methods going there
    $available_methods = jigoshop_shipping::get_available_shipping_methods();
    $jigoshop_options = Jigoshop_Base::get_options();
    if ($available_methods || !jigoshop_customer::get_shipping_country() || !jigoshop_shipping::is_enabled()) {
        ?>
                <h2><?php 
        _e('Cart Totals', 'jigoshop');
        ?>
</h2>

                <div class="cart_totals_table">
                    <table cellspacing="0" cellpadding="0">
                        <tbody>

                            <tr>
							   <?php 
        $price_label = jigoshop_cart::show_retail_price() ? __('Retail Price', 'jigoshop') : __('Subtotal', 'jigoshop');
        ?>

								<th class="cart-row-subtotal-title"><?php 
        echo $price_label;
        ?>
</th>
                                <td class="cart-row-subtotal"><?php 
        echo jigoshop_cart::get_cart_subtotal();
        ?>
</td>
                            </tr>

                            <?php 
        if (jigoshop_cart::get_cart_shipping_total()) {
            ?>
							<tr>
                                <th class="cart-row-shipping-title"><?php 
            _e('Shipping', 'jigoshop');
            ?>
 <small><?php 
            echo jigoshop_countries::shipping_to_prefix() . ' ' . __(jigoshop_countries::$countries[jigoshop_customer::get_shipping_country()], 'jigoshop');
            ?>
</small></th>
                                <td class="cart-row-shipping"><?php 
            echo jigoshop_cart::get_cart_shipping_total();
            ?>
 <small><?php 
            echo jigoshop_cart::get_cart_shipping_title();
            ?>
</small></td>
                            </tr>
                            <?php 
        }
        ?>

                            <?php 
        if (jigoshop_cart::show_retail_price()) {
            ?>
                                <tr>
                                    <th class="cart-row-subtotal-title"><?php 
            _e('Subtotal', 'jigoshop');
            ?>
</th>
                                    <td class="cart-row-subtotal"><?php 
            echo jigoshop_cart::get_cart_subtotal(true, true);
            ?>
</td>
                                </tr>
                            <?php 
        }
        ?>

                            <?php 
        if (jigoshop_cart::tax_after_coupon()) {
            ?>
                                <tr class="discount">
                                    <th class="cart-row-discount-title"><?php 
            _e('Discount', 'jigoshop');
            ?>
</th>
									<td class="cart-row-discount">-<?php 
            echo jigoshop_cart::get_total_discount();
            ?>
</td>
                                </tr>
                            <?php 
        }
        ?>

                            <?php 
        if (Jigoshop_Base::get_options()->get_option('jigoshop_calc_taxes') == 'yes') {
            foreach (jigoshop_cart::get_applied_tax_classes() as $tax_class) {
                if (jigoshop_cart::get_tax_for_display($tax_class)) {
                    ?>
                                        <tr>
                                            <th class="cart-row-tax-title"><?php 
                    echo jigoshop_cart::get_tax_for_display($tax_class);
                    ?>
</th>
                                            <td class="cart-row-tax"><?php 
                    echo jigoshop_cart::get_tax_amount($tax_class);
                    ?>
</td>
                                        </tr>
                                    <?php 
                }
            }
        }
        ?>

							<?php 
        if (!jigoshop_cart::tax_after_coupon() && jigoshop_cart::get_total_discount()) {
            ?>
							<tr class="discount">
								<th class="cart-row-discount-title"><?php 
            _e('Discount', 'jigoshop');
            ?>
</th>
								<td class="cart-row-discount">-<?php 
            echo jigoshop_cart::get_total_discount();
            ?>
</td>
							</tr>
							<?php 
        }
        ?>

							<tr>
								<th class="cart-row-total-title"><strong><?php 
        _e('Total', 'jigoshop');
        ?>
</strong></th>
								<td class="cart-row-total"><strong><?php 
        echo jigoshop_cart::get_total();
        ?>
</strong></td>
							</tr>

						</tbody>
					</table>
				</div>
			<?php 
    } else {
        echo '<p>' . __(jigoshop_shipping::get_shipping_error_message(), 'jigoshop') . '</p>';
    }
    ?>
		</div>

		<?php 
    jigoshop_shipping_calculator();
    ?>

	</div>
	<?php 
}
Example #10
0
            ?>
">&times;</a>
						</td>
						<td class="product-thumbnail">
							<a href="<?php 
            echo esc_url(apply_filters('jigoshop_product_url_display_in_cart', get_permalink($values['product_id']), $cart_item_key));
            ?>
">
								<?php 
            if ($values['variation_id'] && jigoshop_cart_has_post_thumbnail($cart_item_key, $values['variation_id'])) {
                echo jigoshop_cart_get_post_thumbnail($cart_item_key, $values['variation_id'], 'shop_tiny');
            } else {
                if (jigoshop_cart_has_post_thumbnail($cart_item_key, $values['product_id'])) {
                    echo jigoshop_cart_get_post_thumbnail($cart_item_key, $values['product_id'], 'shop_tiny');
                } else {
                    echo '<img src="' . JIGOSHOP_URL . '/assets/images/placeholder.png" alt="Placeholder" width="' . jigoshop::get_var('shop_tiny_w') . '" height="' . jigoshop::get_var('shop_tiny_h') . '" />';
                }
            }
            ?>
</a>
						</td>
						<td class="product-name">
							<a href="<?php 
            echo esc_url(apply_filters('jigoshop_product_url_display_in_cart', get_permalink($values['product_id']), $cart_item_key));
            ?>
">
								<?php 
            echo apply_filters('jigoshop_cart_product_title', $product->get_title(), $product);
            ?>
							</a>
							<?php