2012-12-31 18:25:09 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce Shipping Rate Class
|
|
|
|
*
|
|
|
|
* Simple Class for storing rates.
|
|
|
|
*
|
|
|
|
* @class WC_Shipping_Rate
|
|
|
|
* @version 2.0.0
|
|
|
|
* @package WooCommerce/Classes/Shipping
|
2013-02-20 17:14:46 +00:00
|
|
|
* @category Class
|
2012-12-31 18:25:09 +00:00
|
|
|
* @author WooThemes
|
|
|
|
*/
|
|
|
|
|
2014-03-25 11:36:54 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
2012-12-31 18:25:09 +00:00
|
|
|
|
|
|
|
class WC_Shipping_Rate {
|
|
|
|
|
|
|
|
var $id = '';
|
|
|
|
var $label = '';
|
|
|
|
var $cost = 0;
|
|
|
|
var $taxes = array();
|
|
|
|
var $method_id = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* __construct function.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param mixed $id
|
|
|
|
* @param mixed $label
|
|
|
|
* @param mixed $cost
|
|
|
|
* @param mixed $taxes
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct( $id, $label, $cost, $taxes, $method_id ) {
|
|
|
|
$this->id = $id;
|
|
|
|
$this->label = $label;
|
|
|
|
$this->cost = $cost;
|
|
|
|
$this->taxes = $taxes ? $taxes : array();
|
|
|
|
$this->method_id = $method_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get_shipping_tax function.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function get_shipping_tax() {
|
|
|
|
$taxes = 0;
|
2014-03-25 11:36:54 +00:00
|
|
|
if ( $this->taxes && sizeof( $this->taxes ) > 0 && ! WC()->customer->is_vat_exempt() ) {
|
2012-12-31 18:25:09 +00:00
|
|
|
$taxes = array_sum( $this->taxes );
|
2014-03-25 11:36:54 +00:00
|
|
|
}
|
2014-09-26 08:35:59 +00:00
|
|
|
return apply_filters( 'woocommerce_get_shipping_tax', $taxes, $this );
|
2012-12-31 18:25:09 +00:00
|
|
|
}
|
2014-07-20 03:32:52 +00:00
|
|
|
}
|