2011-08-09 15:16:18 +00:00
|
|
|
<?php
|
2011-08-10 17:11:11 +00:00
|
|
|
/**
|
|
|
|
* WooCommerce Shipping Method Class
|
|
|
|
*
|
|
|
|
* Extended by shipping methods to handle shipping calculations etc.
|
|
|
|
*
|
|
|
|
* @class woocommerce_shipping_method
|
|
|
|
* @package WooCommerce
|
|
|
|
* @category Shipping
|
|
|
|
* @author WooThemes
|
|
|
|
*/
|
|
|
|
class woocommerce_shipping_method {
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
var $id;
|
2011-09-05 11:56:26 +00:00
|
|
|
var $method_title;
|
2011-08-09 15:16:18 +00:00
|
|
|
var $title;
|
|
|
|
var $availability;
|
|
|
|
var $countries;
|
|
|
|
var $type;
|
|
|
|
var $fee = 0;
|
|
|
|
var $min_amount = null;
|
|
|
|
var $enabled = false;
|
|
|
|
var $shipping_total = 0;
|
|
|
|
var $shipping_tax = 0;
|
2011-09-02 14:42:04 +00:00
|
|
|
var $cost = 0; // Stores cost if theres only one
|
|
|
|
var $multiple_rates = false;
|
|
|
|
var $rates = array(); // When a method has more than one cost/choice it will be in this array of titles/costs
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
public function is_available() {
|
2011-09-06 11:11:22 +00:00
|
|
|
global $woocommerce;
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
if ($this->enabled=="no") return false;
|
|
|
|
|
2011-09-06 11:11:22 +00:00
|
|
|
if (isset($woocommerce->cart->cart_contents_total) && isset($this->min_amount) && $this->min_amount && $this->min_amount > $woocommerce->cart->cart_contents_total) return false;
|
2011-08-09 15:16:18 +00:00
|
|
|
|
|
|
|
$ship_to_countries = '';
|
|
|
|
|
|
|
|
if ($this->availability == 'specific') :
|
|
|
|
$ship_to_countries = $this->countries;
|
|
|
|
else :
|
2011-08-10 17:11:11 +00:00
|
|
|
if (get_option('woocommerce_allowed_countries')=='specific') :
|
|
|
|
$ship_to_countries = get_option('woocommerce_specific_allowed_countries');
|
2011-08-09 15:16:18 +00:00
|
|
|
endif;
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if (is_array($ship_to_countries)) :
|
2011-09-06 11:11:22 +00:00
|
|
|
if (!in_array($woocommerce->customer->get_shipping_country(), $ship_to_countries)) return false;
|
2011-08-09 15:16:18 +00:00
|
|
|
endif;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_fee( $fee, $total ) {
|
|
|
|
if (strstr($fee, '%')) :
|
|
|
|
return ($total/100) * str_replace('%', '', $fee);
|
|
|
|
else :
|
|
|
|
return $fee;
|
|
|
|
endif;
|
|
|
|
}
|
2011-09-02 14:42:04 +00:00
|
|
|
|
2011-08-09 15:16:18 +00:00
|
|
|
public function admin_options() {}
|
|
|
|
|
|
|
|
public function process_admin_options() {}
|
|
|
|
|
|
|
|
}
|