/** * @return delivery cost for the shipping method instance * @author Zasilkovna */ function getCosts(VirtueMartCart $cart, $method, $cart_prices) { //get actual display currency. in $cart->pricesCurrency its not updated immediately.. but if we dont use change currency, getUserStateFromRequest doesnt return anything.. so then use cart pricesCurrency $currency = CurrencyDisplay::getInstance(); $pricesCurrencyId = $currency->_app->getUserStateFromRequest('virtuemart_currency_id', 'virtuemart_currency_id', $currency->_vendorCurrency); if (empty($pricesCurrencyId)) { //this is pretty weird $pricesCurrencyId = $cart->pricesCurrency; } $pobocka = $this->getSelectedPobocka(); if (empty($pobocka)) { return 0; } require_once dirname(__FILE__) . DS . 'helper.php'; $pobockaObj = UlozenkaHelper::getDataPobocky($method, $pobocka); $parcel_price = 'parcelprice' . $pobocka; $dobierka_price = 'codprice' . $pobocka; $price = $method->pobocky->{$parcel_price}; if (!class_exists('ShopFunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $cid = ShopFunctions::getCurrencyIDByName("CZK"); /* Set free shipping */ $total = $cart->pricesUnformatted['billTotal']; if (!empty($cart->pricesUnformatted['salesPriceShipment'])) { $total -= (double) $cart->pricesUnformatted['salesPriceShipment']; } if (!empty($cart->pricesUnformatted['salesPricePayment'])) { $total -= (double) $cart->pricesUnformatted['salesPricePayment']; } if (!empty($pobockaObj->sk)) { $method->free_start_sk = (double) $method->free_start_sk; if (!empty($method->free_start_sk)) { if ($total >= $method->free_start_sk) { return 0; } } } else { if (!empty($pobockaObj->partner)) { if (!empty($method->free_start_partner)) { $fs = (double) $method->free_start_partner; if ($total >= $fs) { return 0; } } } else { if (!empty($method->free_start_ulozenka)) { $fs = (double) $method->free_start_ulozenka; if ($total >= $fs) { return 0; } } } } if (!empty($method->cod_payments)) { if (!empty($cart->virtuemart_paymentmethod_id)) { if (in_array($cart->virtuemart_paymentmethod_id, $method->cod_payments)) { if (!empty($method->pobocky->{$dobierka_price})) { $price += $method->pobocky->{$dobierka_price}; } } } } $orderWeight = $this->getOrderWeight($cart, $method->weight_unit); if (!empty($method->weight_stop)) { if ($orderWeight > $method->weight_stop) { $w = (double) $method->weight_stop; $times = $orderWeight / $w; $c = ceil($times); $price = $price * $c; } } return $price; }