You appear to be a bot. Output may be restricted
Description
Calculate shipping ratesNow supports multiple rates for different shipping methods which need to be identified in the countrygroup_title field for each defined rate.
Usage
OIK_Shipping_Pro::calculate_shipping( $package );
Parameters
- $package
- ( array ) optional –
Returns
voidSource
File name: oik-weightcountry-shipping-pro/class-oik-shipping-pro.phpLines:
1 to 31 of 31
function calculate_shipping( $package = array() ) { //bw_trace2(); $woocommerce = function_exists('WC') ? WC() : $GLOBALS['woocommerce']; $country_group = $this->get_countrygroup($package); $rates = $this->get_rates_by_countrygroup( $country_group ); //bw_trace2( $rates, "rates" ); $weight = $woocommerce->cart->cart_contents_weight; //bw_trace2( $weight, "cart contents weight" ); $picked_rates = $this->pick_rates_for_weight( $rates, $weight ); if ( count( $picked_rates ) ) { foreach ( $picked_rates as $key => $data ) { $final_rate = $data['rate']; if ( is_numeric( $final_rate ) ) { if ( $this->fee > 0 && $package['destination']['country'] ) { $final_rate += $this->fee; } $rate = array( 'id' => $this->id . $key , 'label' => $data['title'] , 'cost' => $final_rate , 'taxes' => '' , 'calc_tax' => 'per_order' ); $this->add_rate( $rate ); } else { add_filter( "woocommerce_cart_no_shipping_available_html", array( $this, 'no_shipping_available') ); } } } }View on GitHub