/**
  * Validate the checkout
  */
 public function validate_checkout()
 {
     if (jigoshop_cart::is_empty()) {
         jigoshop::add_error(sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage &rarr;</a>', 'jigoshop'), home_url()));
     }
     // Process Discount Codes
     if (!empty($_POST['coupon_code'])) {
         $coupon = sanitize_title($_POST['coupon_code']);
         jigoshop_cart::add_discount($coupon);
     }
     foreach (jigoshop_cart::get_coupons() as $coupon) {
         jigoshop_cart::is_valid_coupon($coupon);
     }
     // Checkout fields
     $this->posted['shipping_method'] = '';
     $this->posted['shipping_service'] = '';
     if (isset($_POST['shipping_method'])) {
         $shipping_method = jigowatt_clean($_POST['shipping_method']);
         $shipping_data = explode(':', $shipping_method);
         $this->posted['shipping_method'] = $shipping_data[0];
         $this->posted['shipping_service'] = $shipping_data[1];
     }
     $this->posted['shiptobilling'] = isset($_POST['shiptobilling']) ? jigowatt_clean($_POST['shiptobilling']) : '';
     $this->posted['payment_method'] = isset($_POST['payment_method']) ? jigowatt_clean($_POST['payment_method']) : '';
     $this->posted['order_comments'] = isset($_POST['order_comments']) ? jigowatt_clean($_POST['order_comments']) : '';
     $this->posted['terms'] = isset($_POST['terms']) ? jigowatt_clean($_POST['terms']) : '';
     $this->posted['create_account'] = isset($_POST['create_account']) ? jigowatt_clean($_POST['create_account']) : '';
     $this->posted['account_username'] = isset($_POST['account_username']) ? jigowatt_clean($_POST['account_username']) : '';
     $this->posted['account_password'] = isset($_POST['account_password']) ? jigowatt_clean($_POST['account_password']) : '';
     $this->posted['account_password_2'] = isset($_POST['account_password_2']) ? jigowatt_clean($_POST['account_password_2']) : '';
     if (jigoshop_cart::get_total(false) == 0) {
         $this->posted['payment_method'] = 'no_payment';
     }
     // establish customer billing and shipping locations
     if (jigoshop_cart::ship_to_billing_address_only()) {
         $this->posted['shiptobilling'] = 'true';
     }
     $country = isset($_POST['billing_country']) ? jigowatt_clean($_POST['billing_country']) : '';
     $state = isset($_POST['billing_state']) ? jigowatt_clean($_POST['billing_state']) : '';
     $allowed_countries = Jigoshop_Base::get_options()->get('jigoshop_allowed_countries');
     if ($allowed_countries === 'specific') {
         $specific_countries = Jigoshop_Base::get_options()->get('jigoshop_specific_allowed_countries');
         if (!in_array($country, $specific_countries)) {
             jigoshop::add_error(__('Invalid billing country.', 'jigoshop'));
             return;
         }
     }
     if (jigoshop_countries::country_has_states($country)) {
         $states = jigoshop_countries::get_states($country);
         if (!in_array($state, array_keys($states))) {
             jigoshop::add_error(__('Invalid billing state.', 'jigoshop'));
             return;
         }
     }
     $postcode = isset($_POST['billing_postcode']) ? jigowatt_clean($_POST['billing_postcode']) : '';
     $ship_to_billing = Jigoshop_Base::get_options()->get('jigoshop_ship_to_billing_address_only') == 'yes';
     jigoshop_customer::set_location($country, $state, $postcode);
     if (Jigoshop_Base::get_options()->get('jigoshop_calc_shipping') == 'yes') {
         if ($ship_to_billing || !empty($_POST['shiptobilling'])) {
             jigoshop_customer::set_shipping_location($country, $state, $postcode);
         } else {
             $country = isset($_POST['shipping_country']) ? jigowatt_clean($_POST['shipping_country']) : '';
             $state = isset($_POST['shipping_state']) ? jigowatt_clean($_POST['shipping_state']) : '';
             $postcode = isset($_POST['shipping_postcode']) ? jigowatt_clean($_POST['shipping_postcode']) : '';
             if ($allowed_countries === 'specific') {
                 $specific_countries = Jigoshop_Base::get_options()->get('jigoshop_specific_allowed_countries');
                 if (!in_array($country, $specific_countries)) {
                     jigoshop::add_error(__('Invalid shipping country.', 'jigoshop'));
                     return;
                 }
             }
             if (jigoshop_countries::country_has_states($country)) {
                 $states = jigoshop_countries::get_states($country);
                 if (!in_array($state, array_keys($states))) {
                     jigoshop::add_error(__('Invalid shipping state.', 'jigoshop'));
                     return;
                 }
             }
             jigoshop_customer::set_shipping_location($country, $state, $postcode);
         }
     }
     // Billing Information
     foreach ($this->billing_fields as $field) {
         $field = apply_filters('jigoshop_billing_field', $field);
         $this->posted[$field['name']] = isset($_POST[$field['name']]) ? jigowatt_clean($_POST[$field['name']]) : '';
         // Format
         if (isset($field['format'])) {
             switch ($field['format']) {
                 case 'postcode':
                     $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']]));
                     break;
             }
         }
         // Required
         if ($field['name'] == 'billing_state' && jigoshop_customer::has_valid_shipping_state()) {
             $field['required'] = false;
         }
         if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) {
             jigoshop::add_error($field['label'] . __(' (billing) is a required field.', 'jigoshop'));
         }
         if ($field['name'] == 'billing_euvatno') {
             $vatno = isset($this->posted['billing_euvatno']) ? $this->posted['billing_euvatno'] : '';
             $vatno = str_replace(' ', '', $vatno);
             $country = jigoshop_tax::get_customer_country();
             // strip any country code from the beginning of the number
             if (strpos($vatno, $country) === 0) {
                 $vatno = substr($vatno, strlen($country));
             }
             if ($vatno != '') {
                 $url = 'http://isvat.appspot.com/' . $country . '/' . $vatno . '/';
                 $httpRequest = curl_init();
                 curl_setopt($httpRequest, CURLOPT_FAILONERROR, true);
                 curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($httpRequest, CURLOPT_HEADER, false);
                 curl_setopt($httpRequest, CURLOPT_URL, $url);
                 $result = curl_exec($httpRequest);
                 curl_close($httpRequest);
                 if ($result === 'false') {
                     jigoshop_log('EU VAT validation error with URL: ' . $url);
                     jigoshop::add_error($field['label'] . __(' (billing) is not a valid VAT Number.  Leave it blank to disable VAT validation. (VAT may be charged depending on your location)', 'jigoshop'));
                 } else {
                     $this->valid_euvatno = jigoshop_countries::get_base_country() != jigoshop_tax::get_customer_country() && jigoshop_countries::is_eu_country(jigoshop_tax::get_customer_country());
                 }
             }
         }
         // Validation
         if (isset($field['validate']) && !empty($this->posted[$field['name']])) {
             switch ($field['validate']) {
                 case 'phone':
                     if (!jigoshop_validation::is_phone($this->posted[$field['name']])) {
                         jigoshop::add_error($field['label'] . __(' (billing) is not a valid number.', 'jigoshop'));
                     }
                     break;
                 case 'email':
                     if (!jigoshop_validation::is_email($this->posted[$field['name']])) {
                         jigoshop::add_error($field['label'] . __(' (billing) is not a valid email address.', 'jigoshop'));
                     }
                     break;
                 case 'postcode':
                     if (!jigoshop_validation::is_postcode($this->posted[$field['name']], $_POST['billing_country'])) {
                         jigoshop::add_error($field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'jigoshop'));
                     } else {
                         $this->posted[$field['name']] = jigoshop_validation::format_postcode($this->posted[$field['name']], $_POST['billing_country']);
                     }
                     break;
             }
         }
     }
     // Shipping Information
     if (jigoshop_shipping::is_enabled() && !jigoshop_cart::ship_to_billing_address_only() && empty($this->posted['shiptobilling'])) {
         foreach ($this->shipping_fields as $field) {
             $field = apply_filters('jigoshop_shipping_field', $field);
             if (isset($_POST[$field['name']])) {
                 $this->posted[$field['name']] = jigowatt_clean($_POST[$field['name']]);
             } else {
                 $this->posted[$field['name']] = '';
             }
             // Format
             if (isset($field['format'])) {
                 switch ($field['format']) {
                     case 'postcode':
                         $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']]));
                         break;
                 }
             }
             // Required
             if ($field['name'] == 'shipping_state' && jigoshop_customer::has_valid_shipping_state()) {
                 $field['required'] = false;
             }
             if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) {
                 jigoshop::add_error($field['label'] . __(' (shipping) is a required field.', 'jigoshop'));
             }
             // Validation
             if (isset($field['validate']) && !empty($this->posted[$field['name']])) {
                 switch ($field['validate']) {
                     case 'postcode':
                         if (!jigoshop_validation::is_postcode($this->posted[$field['name']], $country)) {
                             jigoshop::add_error($field['label'] . __(' (shipping) is not a valid postcode/ZIP.', 'jigoshop'));
                         } else {
                             $this->posted[$field['name']] = jigoshop_validation::format_postcode($this->posted[$field['name']], $country);
                         }
                         break;
                 }
             }
         }
     }
     if ($this->must_register && empty($this->posted['create_account'])) {
         jigoshop::add_error(__('Sorry, you must agree to creating an account', 'jigoshop'));
     }
     if ($this->must_register || empty($user_id) && $this->posted['create_account']) {
         if (!$this->show_signup) {
             jigoshop::add_error(__('Sorry, the shop owner has disabled guest purchases.', 'jigoshop'));
         }
         if (empty($this->posted['account_username'])) {
             jigoshop::add_error(__('Please enter an account username.', 'jigoshop'));
         }
         if (empty($this->posted['account_password'])) {
             jigoshop::add_error(__('Please enter an account password.', 'jigoshop'));
         }
         if ($this->posted['account_password_2'] !== $this->posted['account_password']) {
             jigoshop::add_error(__('Passwords do not match.', 'jigoshop'));
         }
         // Check the username
         if (!validate_username($this->posted['account_username'])) {
             jigoshop::add_error(__('Invalid email/username.', 'jigoshop'));
         } elseif (username_exists($this->posted['account_username'])) {
             jigoshop::add_error(__('An account is already registered with that username. Please choose another.', 'jigoshop'));
         }
         // Check the e-mail address
         if (email_exists($this->posted['billing_email'])) {
             jigoshop::add_error(__('An account is already registered with your email address. Please login.', 'jigoshop'));
         }
     }
     // Terms
     if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && jigoshop_get_page_id('terms') > 0) {
         jigoshop::add_error(__('You must accept our Terms &amp; Conditions.', 'jigoshop'));
     }
     if (jigoshop_cart::needs_shipping()) {
         // Shipping Method
         $available_methods = jigoshop_shipping::get_available_shipping_methods();
         if (!isset($available_methods[$this->posted['shipping_method']])) {
             jigoshop::add_error(__('Invalid shipping method.', 'jigoshop'));
         }
     }
 }
 /**
  * Is customer shipping outside base, but within the same country? This is
  * used to determine how to apply taxes. Also, it no country is set, assume
  * shipping is going to base country.
  */
 public static function is_customer_outside_base($shippable)
 {
     $outside = false;
     $country = $shippable ? self::get_shipping_country() : self::get_country();
     // if no country is set, then assume customer is from the shop base
     if ($country) {
         $shop_country = jigoshop_countries::get_base_country();
         // check if it's a country with states.
         if (jigoshop_countries::country_has_states($country)) {
             $shop_state = jigoshop_countries::get_base_state();
             // taxes only apply if the customer is shipping in the same country. If the customer is
             // shipping outside of the shop country, then taxes do not apply.
             if ($shop_country === $country && $shop_state !== ($shippable ? self::get_shipping_state() : self::get_state())) {
                 $outside = true;
             }
         } else {
             if (jigoshop_countries::is_eu_country($shop_country) && $shop_country != $country) {
                 // if both base country and shipping country are in the EU, then outside country base is true
                 $outside = jigoshop_countries::is_eu_country($country);
             }
         }
     }
     return $outside;
 }
Esempio n. 3
0
	/**
	 * Get the tax rate based on the country and state
	 *
	 * @param   object	Tax Class
	 * @return  mixed		
	 */
	function get_shipping_tax_rate( $tax_class = '' ) {
		
		if (defined('JIGOSHOP_CHECKOUT') && JIGOSHOP_CHECKOUT) :
			$country 	= jigoshop_customer::get_country();
			$state 		= jigoshop_customer::get_state();
		else :
			$country 	= jigoshop_countries::get_base_country();
			$state 		= jigoshop_countries::get_base_state();
		endif;
		
		// If we are here then shipping is taxable - work it out
		
		if ($tax_class) :
			
			// This will be per item shipping
			$rate = $this->find_rate( $country, $state, $tax_class );
			
			if (isset($rate['shipping']) && $rate['shipping']=='yes') :
				return $rate['rate'];
			else :
				// Get standard rate
				$rate = $this->find_rate( $country, $state );
				if (isset($rate['shipping']) && $rate['shipping']=='yes') return $rate['rate'];
			endif;
			
		else :
			
			// This will be per order shipping - loop through the order and find the highest tax class rate
			
			$found_rates = array();
			$found_shipping_rates = array();
			
			// Loop cart and find the highest tax band
			if (sizeof(jigoshop_cart::$cart_contents)>0) : foreach (jigoshop_cart::$cart_contents as $item) :
				
				if ($item['data']->data['tax_class']) :
					
					$found_rate = $this->find_rate( $country, $state, $item['data']->data['tax_class'] );
					
					$found_rates[] = $found_rate['rate'];
					
					if (isset($found_rate['shipping']) && $found_rate['shipping']=='yes') $found_shipping_rates[] = $found_rate['rate'];
					
				endif;
				
			endforeach; endif;
			
			if (sizeof($found_rates) > 0 && sizeof($found_shipping_rates) > 0) :
				
				rsort($found_rates);
				rsort($found_shipping_rates);
				
				if ($found_rates[0] == $found_shipping_rates[0]) :
					return $found_shipping_rates[0];
				else :
					// Use standard rate
					$rate = $this->find_rate( $country, $state );
					if (isset($rate['shipping']) && $rate['shipping']=='yes') return $rate['rate'];
				endif;
				
			else :
				// Use standard rate
				$rate = $this->find_rate( $country, $state );	
				if (isset($rate['shipping']) && $rate['shipping']=='yes') return $rate['rate'];
			endif;
			
		endif;

		return 0; // return false
	}
Esempio n. 4
0
 /**
  * Get the shop's taxation rate using find_rate()
  *
  * @param string $tax_class is the tax class (not object)
  * @param bool $rate_only
  * @return int
  */
 public function get_shop_base_rate($tax_class = '*', $rate_only = true)
 {
     $country = jigoshop_countries::get_base_country();
     $state = jigoshop_countries::get_base_state();
     $state = $state && jigoshop_countries::country_has_states($country) ? $state : '*';
     $rate = $this->find_rate($country, $state, $tax_class);
     return $rate_only ? $rate['rate'] : $rate;
 }
Esempio n. 5
0
 public function __construct($id)
 {
     $this->id = $id;
     $meta = get_user_meta($id);
     if (isset($meta['billing_first_name'])) {
         $this->billing_first_name = $meta['billing_first_name'][0];
     }
     if (isset($meta['billing_last_name'])) {
         $this->billing_last_name = $meta['billing_last_name'][0];
     }
     if (isset($meta['billing_company'])) {
         $this->billing_company = $meta['billing_company'][0];
     }
     if (isset($meta['billing_euvatno'])) {
         $this->billing_euvatno = $meta['billing_euvatno'][0];
     }
     if (isset($meta['billing_address_1'])) {
         $this->billing_address_1 = $meta['billing_address_1'][0];
     }
     if (isset($meta['billing_address_2'])) {
         $this->billing_address_2 = $meta['billing_address_2'][0];
     }
     if (isset($meta['billing_city'])) {
         $this->billing_city = $meta['billing_city'][0];
     }
     if (isset($meta['billing_state'])) {
         $this->billing_state = $meta['billing_state'][0];
     }
     if (isset($meta['billing_postcode'])) {
         $this->billing_postcode = $meta['billing_postcode'][0];
     }
     if (isset($meta['billing_country'])) {
         $country = $meta['billing_country'][0];
         $country = jigoshop_countries::has_country($country) ? $country : jigoshop_countries::get_base_country();
         $this->billing_country = $country;
     }
     if (isset($meta['billing_email'])) {
         $this->billing_email = $meta['billing_email'][0];
     }
     if (isset($meta['billing_first_name'])) {
         $this->billing_phone = $meta['billing_phone'][0];
     }
     if (isset($meta['shipping_first_name'])) {
         $this->shipping_first_name = $meta['shipping_first_name'][0];
     }
     if (isset($meta['shipping_last_name'])) {
         $this->shipping_last_name = $meta['shipping_last_name'][0];
     }
     if (isset($meta['shipping_company'])) {
         $this->shipping_company = $meta['shipping_company'][0];
     }
     if (isset($meta['shipping_address_1'])) {
         $this->shipping_address_1 = $meta['shipping_address_1'][0];
     }
     if (isset($meta['shipping_address_2'])) {
         $this->shipping_address_2 = $meta['shipping_address_2'][0];
     }
     if (isset($meta['shipping_city'])) {
         $this->shipping_city = $meta['shipping_city'][0];
     }
     if (isset($meta['shipping_state'])) {
         $this->shipping_state = $meta['shipping_state'][0];
     }
     if (isset($meta['shipping_postcode'])) {
         $this->shipping_postcode = $meta['shipping_postcode'][0];
     }
     if (isset($meta['shipping_country'])) {
         $country = $meta['shipping_country'][0];
         $country = jigoshop_countries::has_country($country) ? $country : jigoshop_countries::get_base_country();
         $this->shipping_country = $country;
     }
 }
Esempio n. 6
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		
}
Esempio n. 7
0
 /**
  *  Admin Notices for conditions under which FuturePay is available on a Shop
  */
 public function futurepay_notices()
 {
     if ($this->enabled == 'no') {
         return;
     }
     if (!in_array(Jigoshop_Base::get_options()->get('jigoshop_currency'), $this->allowed_currency)) {
         echo '<div class="error"><p>' . sprintf(__('The FuturePay gateway accepts payments in currencies of %s.  Your current currency is %s.  FuturePay won\'t work until you change the Jigoshop currency to an accepted one.  FuturePay is currently disabled on the Payment Gateways settings tab.', 'jigoshop'), implode(', ', $this->allowed_currency), Jigoshop_Base::get_options()->get('jigoshop_currency')) . '</p></div>';
         Jigoshop_Base::get_options()->set('jigoshop_futurepay_enabled', 'no');
     }
     if (!in_array($this->shop_base_country, $this->merchant_countries)) {
         $country_list = array();
         foreach ($this->merchant_countries as $this_country) {
             $country_list[] = jigoshop_countries::get_country($this_country);
         }
         echo '<div class="error"><p>' . sprintf(__('The FuturePay gateway is available to merchants from: %s.  Your country is: %s.  FuturePay won\'t work until you change the Jigoshop Shop Base country to an accepted one.  FuturePay is currently disabled on the Payment Gateways settings tab.', 'jigoshop'), implode(', ', $country_list), jigoshop_countries::get_base_country()) . '</p></div>';
         Jigoshop_Base::get_options()->set('jigoshop_futurepay_enabled', 'no');
     }
 }