id = 'flat_rate'; $this->enabled = get_option('woocommerce_flat_rate_enabled'); $this->title = get_option('woocommerce_flat_rate_title'); $this->availability = get_option('woocommerce_flat_rate_availability'); $this->countries = get_option('woocommerce_flat_rate_countries'); $this->type = get_option('woocommerce_flat_rate_type'); $this->tax_status = get_option('woocommerce_flat_rate_tax_status'); $this->cost = get_option('woocommerce_flat_rate_cost'); $this->fee = get_option('woocommerce_flat_rate_handling_fee'); add_action('woocommerce_update_options', array(&$this, 'process_admin_options')); add_option('woocommerce_flat_rate_availability', 'all'); add_option('woocommerce_flat_rate_title', 'Flat Rate'); add_option('woocommerce_flat_rate_tax_status', 'taxable'); } public function calculate_shipping() { $_tax = &new woocommerce_tax(); $this->shipping_total = 0; $this->shipping_tax = 0; if ($this->type=='order') : // Shipping for whole order $this->shipping_total = $this->cost + $this->get_fee( $this->fee, woocommerce_cart::$cart_contents_total ); if ( get_option('woocommerce_calc_taxes')=='yes' && $this->tax_status=='taxable' ) : $rate = $_tax->get_shipping_tax_rate(); if ($rate>0) : $tax_amount = $_tax->calc_shipping_tax( $this->shipping_total, $rate ); $this->shipping_tax = $this->shipping_tax + $tax_amount; endif; endif; else : // Shipping per item if (sizeof(woocommerce_cart::$cart_contents)>0) : foreach (woocommerce_cart::$cart_contents as $item_id => $values) : $_product = $values['data']; if ($_product->exists() && $values['quantity']>0) : $item_shipping_price = ($this->cost + $this->get_fee( $this->fee, $_product->get_price() )) * $values['quantity']; // Only count 'psysical' products if ($_product->is_type( 'simple' ) || $_product->is_type( 'variable' )) : $this->shipping_total = $this->shipping_total + $item_shipping_price; if ( $_product->is_shipping_taxable() && $this->tax_status=='taxable' ) : $rate = $_tax->get_shipping_tax_rate( $_product->data['tax_class'] ); if ($rate>0) : $tax_amount = $_tax->calc_shipping_tax( $item_shipping_price, $rate ); $this->shipping_tax = $this->shipping_tax + $tax_amount; endif; endif; endif; endif; endforeach; endif; endif; } public function admin_options() { ?>   : : : : : : : :