woocommerce/includes/class-wc-shipping-rate.php

74 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2014-11-17 16:30:15 +00:00
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
2015-11-03 13:31:20 +00:00
* WooCommerce Shipping Rate Class.
*
* Simple Class for storing rates.
*
* @class WC_Shipping_Rate
2014-11-17 16:30:15 +00:00
* @version 2.3.0
* @package WooCommerce/Classes/Shipping
2013-02-20 17:14:46 +00:00
* @category Class
* @author WooThemes
*/
2014-11-17 16:30:15 +00:00
class WC_Shipping_Rate {
2014-11-17 16:30:15 +00:00
/** @var string Rate ID. */
public $id = '';
2014-11-17 16:30:15 +00:00
/** @var string Label for the rate. */
public $label = '';
/** @var float Cost for the rate. */
public $cost = 0;
/** @var array Array of taxes for the rate. */
public $taxes = array();
2014-11-17 16:30:15 +00:00
/** @var string Label for the rate. */
public $method_id = '';
/**
2015-11-03 13:31:20 +00:00
* Constructor.
*
2014-11-17 16:30:15 +00:00
* @param string $id
* @param string $label
* @param float $cost
* @param array $taxes
* @param string $method_id
*/
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.
*
* @return array
*/
2014-11-17 16:30:15 +00:00
public function get_shipping_tax() {
$taxes = 0;
if ( $this->taxes && sizeof( $this->taxes ) > 0 && ! WC()->customer->is_vat_exempt() ) {
$taxes = array_sum( $this->taxes );
}
2014-09-26 08:35:59 +00:00
return apply_filters( 'woocommerce_get_shipping_tax', $taxes, $this );
}
/**
2015-11-03 13:31:20 +00:00
* Get label.
*
* @return string
*/
public function get_label() {
return apply_filters( 'woocommerce_shipping_rate_label', $this->label );
}
}